source: titan/libeplayer3/playback/playback.c @ 42422

Last change on this file since 42422 was 42422, checked in by obi, 6 years ago

libeplayer3 v42 test

File size: 25.6 KB
Line 
1/*
2 * GPL
3 * duckbox 2010
4 */
5
6/* ***************************** */
7/* Includes                      */
8/* ***************************** */
9
10#include <stdlib.h>
11#include <string.h>
12#include <unistd.h>
13#include <sys/stat.h>
14#include <fcntl.h>
15#include <sys/socket.h>
16#include <netdb.h>
17#include <sys/types.h>
18#include <dirent.h>
19#include <errno.h>
20#include <poll.h>
21#include <stdint.h>
22
23#include "playback.h"
24#include "common.h"
25#include "misc.h"
26
27/* ***************************** */
28/* Makros/Constants              */
29/* ***************************** */
30// SULGE DEBUG
31//#define SAM_WITH_DEBUG
32
33#ifdef SAM_WITH_DEBUG
34#define PLAYBACK_DEBUG
35#else
36#define PLAYBACK_SILENT
37#endif
38
39static short debug_level = 20;
40
41#ifdef PLAYBACK_DEBUG
42#define playback_printf(level, fmt, x...) do { \
43if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0)
44#else
45#define playback_printf(level, fmt, x...)
46#endif
47
48#ifndef PLAYBACK_SILENT
49#define playback_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0)
50#else
51#define playback_err(fmt, x...)
52#endif
53
54#define cERR_PLAYBACK_NO_ERROR      0
55#define cERR_PLAYBACK_ERROR        -1
56
57#define cMaxSpeed_ff   128 /* fixme: revise */
58#define cMaxSpeed_fr   -320 /* fixme: revise */
59
60#define MAX_PLAYBACK_DIE_NOW_CALLBACKS 10
61
62/* ***************************** */
63/* Varaibles                     */
64/* ***************************** */
65
66/* ***************************** */
67/* Prototypes                    */
68/* ***************************** */
69extern void set_pause_timeout(uint8_t pause);
70static int32_t PlaybackTerminate(Context_t  *context);
71
72static int8_t dieNow = 0;
73static PlaybackDieNowCallback playbackDieNowCallbacks[MAX_PLAYBACK_DIE_NOW_CALLBACKS] = {NULL};
74
75/* ***************************** */
76/* MISC Functions                */
77/* ***************************** */
78int8_t PlaybackDieNow(int8_t val)
79{
80    if(val && dieNow == 0)
81    {
82        uint32_t i = 0;
83        dieNow = 1;
84        while (i < MAX_PLAYBACK_DIE_NOW_CALLBACKS)
85        {
86            if (playbackDieNowCallbacks[i] == NULL)
87            {
88                break;
89            }
90            playbackDieNowCallbacks[i]();
91            i += 1;
92        }
93    }
94    return dieNow;
95}
96
97bool PlaybackDieNowRegisterCallback(PlaybackDieNowCallback callback)
98{
99    bool ret = false;
100    if (callback)
101    {
102        uint32_t i = 0;
103        while (i < MAX_PLAYBACK_DIE_NOW_CALLBACKS)
104        {
105            if (playbackDieNowCallbacks[i] == callback)
106            {
107                ret = true;
108                break;
109            }
110           
111            if (playbackDieNowCallbacks[i] == NULL)
112            {
113                playbackDieNowCallbacks[i] = callback;
114                ret = true;
115                break;
116            }
117            i += 1;
118        }
119    }
120    return ret;
121}
122
123/* ***************************** */
124/* Functions                     */
125/* ***************************** */
126
127static int PlaybackStop(Context_t  *context);
128
129static int PlaybackOpen(Context_t  *context, PlayFiles_t *pFiles)
130{
131    if (context->playback->isPlaying)
132    {
133        PlaybackStop(context);
134    }
135   
136    char *uri = pFiles->szFirstFile;
137   
138    playback_printf(10, "URI=%s\n", uri);
139
140    if (context->playback->isPlaying)
141    { // shouldn't happen
142        playback_err("playback already running\n");
143        return cERR_PLAYBACK_ERROR;
144    }
145
146    char * extension = NULL;
147
148    context->playback->uri = strdup(uri);
149
150    context->playback->isFile = 0;
151    context->playback->isHttp = 0;
152
153    if (!strncmp("file://", uri, 7) || !strncmp("myts://", uri, 7))
154    {
155        context->playback->isFile = 1;
156        if (!strncmp("myts://", uri, 7))
157        {
158            memcpy(context->playback->uri, "file", 4);
159            context->playback->noprobe = 1;
160        }
161        else
162        {
163            context->playback->noprobe = 0;
164        }
165
166        extension = getExtension(context->playback->uri+7);
167        if(!extension)
168        {
169            playback_err("Wrong extension (%s)\n", context->playback->uri+7);
170            return cERR_PLAYBACK_ERROR;
171        }
172    }
173    else if (strstr(uri, "://"))
174    {
175        context->playback->isHttp = 1;
176        extension = "mp3";
177        if (!strncmp("mms://", uri, 6))
178        {
179            // mms is in reality called rtsp, and ffmpeg expects this
180            char * tUri = (char*)malloc(strlen(uri) + 2);
181            strncpy(tUri+1, uri, strlen(uri)+1);
182            strncpy(tUri, "rtsp", 4);
183            free(context->playback->uri);
184            context->playback->uri = tUri;
185        }
186    }
187    else
188    {
189        playback_err("Unknown stream (%s)\n", uri);
190        return cERR_PLAYBACK_ERROR;
191    }
192
193    pFiles->szFirstFile = context->playback->uri;
194    if ((context->container->Command(context, CONTAINER_ADD, extension) < 0)
195        ||  (!context->container->selectedContainer)
196        ||  (context->container->selectedContainer->Command(context, CONTAINER_INIT, pFiles) < 0))
197    {
198        playback_err("CONTAINER_ADD failed\n");
199        return cERR_PLAYBACK_ERROR;
200    }
201
202    playback_printf(10, "exiting with value 0\n");
203
204    return cERR_PLAYBACK_NO_ERROR;
205}
206
207static int PlaybackClose(Context_t  *context)
208{
209    int ret = cERR_PLAYBACK_NO_ERROR;
210
211    playback_printf(10, "\n");
212
213    if (context->container->Command(context, CONTAINER_DEL, NULL) < 0)
214    {
215        playback_err("container delete failed\n");
216    }
217
218    context->manager->audio->Command(context, MANAGER_DEL, NULL);
219    context->manager->video->Command(context, MANAGER_DEL, NULL);
220
221    context->playback->isPaused     = 0;
222    context->playback->isPlaying    = 0;
223    context->playback->isForwarding = 0;
224    context->playback->BackWard     = 0;
225    context->playback->SlowMotion   = 0;
226    context->playback->Speed        = 0;
227    if(context->playback->uri)
228    {
229        free(context->playback->uri);
230        context->playback->uri = NULL;
231    }
232
233    playback_printf(10, "exiting with value %d\n", ret);
234
235    return ret;
236}
237
238static int PlaybackPlay(Context_t  *context)
239{
240    pthread_attr_t attr;
241    int ret = cERR_PLAYBACK_NO_ERROR;
242
243    playback_printf(10, "\n");
244
245    if (!context->playback->isPlaying)
246    {
247        context->playback->AVSync = 1;
248        context->output->Command(context, OUTPUT_AVSYNC, NULL);
249
250        context->playback->isCreationPhase = 1; // allows the created thread to go into wait mode
251        ret = context->output->Command(context, OUTPUT_PLAY, NULL);
252
253        if (ret != 0)
254        {
255            playback_err("OUTPUT_PLAY failed!\n");
256            playback_err("clearing isCreationPhase!\n");
257            context->playback->isCreationPhase = 0;     // allow thread to go into next state
258            context->playback->isPlaying       = 0;
259            context->playback->isPaused        = 0;
260            context->playback->isForwarding    = 0;
261            context->playback->BackWard        = 0;
262            context->playback->SlowMotion      = 0;
263            context->playback->Speed           = 0;
264            context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL);
265        }
266        else
267        {
268            context->playback->isPlaying    = 1;
269            context->playback->isPaused     = 0;
270            context->playback->isForwarding = 0;
271            context->playback->BackWard     = 0;
272            context->playback->SlowMotion   = 0;
273            context->playback->Speed        = 1;
274
275            playback_printf(10, "clearing isCreationPhase!\n");
276
277            context->playback->isCreationPhase = 0;     // allow thread to go into next state
278
279            ret = context->container->selectedContainer->Command(context, CONTAINER_PLAY, NULL);
280            if (ret != 0) {
281                playback_err("CONTAINER_PLAY failed!\n");
282            }
283
284        }
285    }
286    else
287    {
288        playback_err("playback already running\n");
289        ret = cERR_PLAYBACK_ERROR;
290    }
291
292    playback_printf(10, "exiting with value %d\n", ret);
293
294    return ret;
295}
296
297static int PlaybackPause(Context_t  *context)
298{
299    int ret = cERR_PLAYBACK_NO_ERROR;
300
301    playback_printf(10, "\n");
302
303    if (context->playback->isPlaying && !context->playback->isPaused)
304    {
305        set_pause_timeout(1);
306//obi     
307        if(context->playback->SlowMotion)
308             context->output->Command(context, OUTPUT_CLEAR, NULL);        context->output->Command(context, OUTPUT_PAUSE, NULL);
309//obi (end)
310
311        context->output->Command(context, OUTPUT_PAUSE, NULL);
312
313        context->playback->isPaused     = 1;
314        //context->playback->isPlaying  = 1;
315        context->playback->isForwarding = 0;
316        context->playback->BackWard     = 0;
317        context->playback->SlowMotion   = 0;
318        context->playback->Speed        = 1;
319    }
320    else
321    {
322        playback_err("playback not playing or already in pause mode\n");
323        ret = cERR_PLAYBACK_ERROR;
324    }
325
326    playback_printf(10, "exiting with value %d\n", ret);
327    return ret;
328}
329
330static int32_t PlaybackContinue(Context_t  *context)
331{
332    int32_t ret = cERR_PLAYBACK_NO_ERROR;
333
334    playback_printf(10, "\n");
335
336    if (context->playback->isPlaying &&
337       (context->playback->isPaused || context->playback->isForwarding ||
338        context->playback->BackWard || context->playback->SlowMotion))
339    {
340
341        set_pause_timeout(0);
342
343//obi     
344        if(context->playback->SlowMotion)
345             context->output->Command(context, OUTPUT_CLEAR, NULL);        context->output->Command(context, OUTPUT_PAUSE, NULL);
346//obi (end)
347        context->output->Command(context, OUTPUT_CONTINUE, NULL);
348
349        context->playback->isPaused     = 0;
350        //context->playback->isPlaying  = 1;
351        context->playback->isForwarding = 0;
352        context->playback->BackWard     = 0;
353        context->playback->SlowMotion   = 0;
354        context->playback->Speed        = 1;
355    }
356    else
357    {
358        playback_err("continue not possible\n");
359        ret = cERR_PLAYBACK_ERROR;
360    }
361
362    playback_printf(10, "exiting with value %d\n", ret);
363    return ret;
364}
365
366static int32_t PlaybackStop(Context_t  *context)
367{
368    int32_t ret = cERR_PLAYBACK_NO_ERROR;
369
370    playback_printf(10, "\n");
371   
372    PlaybackDieNow(1);
373
374    if (context && context->playback && context->playback->isPlaying)
375    {
376
377        context->playback->isPaused     = 0;
378        context->playback->isPlaying    = 0;
379        context->playback->isForwarding = 0;
380        context->playback->BackWard     = 0;
381        context->playback->SlowMotion   = 0;
382        context->playback->Speed        = 0;
383
384        context->output->Command(context, OUTPUT_STOP, NULL);
385        context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL);
386
387    }
388    else
389    {
390        playback_err("stop not possible\n");
391        ret = cERR_PLAYBACK_ERROR;
392    }
393
394    playback_printf(10, "exiting with value %d\n", ret);
395    return ret;
396}
397
398static int32_t PlaybackTerminate(Context_t  *context)
399{
400    int32_t ret = cERR_PLAYBACK_NO_ERROR;
401
402    playback_printf(20, "\n");
403   
404    PlaybackDieNow(1);
405
406    if ( context && context->playback && context->playback->isPlaying )
407    {
408        //First Flush and than delete container, else e2 cant read length of file anymore
409
410        if (context->output->Command(context, OUTPUT_FLUSH, NULL) < 0)
411        {
412            playback_err("failed to flush output.\n");
413        }
414
415        ret = context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL);
416
417        context->playback->isPaused     = 0;
418        context->playback->isPlaying    = 0;
419        context->playback->isForwarding = 0;
420        context->playback->BackWard     = 0;
421        context->playback->SlowMotion   = 0;
422        context->playback->Speed        = 0;
423
424    }
425    else
426    {
427        playback_err("%p %p %d\n", context, context->playback, context->playback->isPlaying);
428
429        /* fixme: konfetti: we should return an error here but this seems to be a condition which
430         * can happen and is not a real error, which leads to a dead neutrino. should investigate
431         * here later.
432         */
433    }
434
435    playback_printf(20, "exiting with value %d\n", ret);
436    return ret;
437}
438
439//obi
440static int PlaybackFastForward(Context_t  *context, int* speed) {
441    int32_t ret = cERR_PLAYBACK_NO_ERROR;
442
443    playback_printf(10, "speed %d\n", *speed);
444
445    /* Audio only forwarding not supported */
446    if (context->playback->isVideo && !context->playback->isHttp && !context->playback->BackWard && (!context->playback->isPaused || context->playback->isPlaying)) {
447
448        if ((*speed <= 0) || (*speed > cMaxSpeed_ff))
449        {
450            playback_err("speed %d out of range (1 - %d) \n", *speed, cMaxSpeed_ff);
451            return cERR_PLAYBACK_ERROR;
452        }
453
454        context->playback->isForwarding = 1;
455        context->playback->Speed = *speed;
456
457        playback_printf(20, "Speed: %d x {%d}\n", *speed, context->playback->Speed);
458
459        context->output->Command(context, OUTPUT_FASTFORWARD, NULL);
460    } else
461    {
462        playback_err("fast forward not possible\n");
463        ret = cERR_PLAYBACK_ERROR;
464    }
465
466    playback_printf(10, "exiting with value %d\n", ret);
467
468    return ret;
469}
470
471static int PlaybackFastBackward(Context_t  *context,int* speed) {
472    int32_t ret = cERR_PLAYBACK_NO_ERROR;
473
474    playback_printf(10, "speed = %d\n", *speed);
475
476    /* Audio only reverse play not supported */
477    if (context->playback->isVideo && !context->playback->isForwarding && (!context->playback->isPaused || context->playback->isPlaying)) {
478
479        if ((*speed > 0) || (*speed < cMaxSpeed_fr))
480        {
481            playback_err("speed %d out of range (0 - %d) \n", *speed, cMaxSpeed_fr);
482            return cERR_PLAYBACK_ERROR;
483        }
484
485        if (*speed == 0)
486        {
487            context->playback->BackWard = 0;
488            context->playback->Speed = 0;    /* reverse end */
489        } else
490        {
491            context->playback->isSeeking = 1;
492            context->playback->Speed = *speed;
493            context->playback->BackWard = 2^(*speed);
494         
495            playback_printf(1, "S %d B %f\n", context->playback->Speed, context->playback->BackWard);
496        }
497
498        context->output->Command(context, OUTPUT_AUDIOMUTE, "1");
499        context->output->Command(context, OUTPUT_CLEAR, NULL);
500        if (context->output->Command(context, OUTPUT_REVERSE, NULL) < 0)
501        {
502            playback_err("OUTPUT_REVERSE failed\n");
503            context->playback->BackWard = 0;
504            context->playback->Speed = 1;
505            context->playback->isSeeking = 0;
506            ret = cERR_PLAYBACK_ERROR;
507        }
508    } else
509    {
510        playback_err("fast backward not possible\n");
511        ret = cERR_PLAYBACK_ERROR;
512    }
513
514    context->playback->isSeeking = 0;
515    playback_printf(10, "exiting with value %d\n", ret);
516
517    return ret;
518}
519
520static int32_t PlaybackSlowMotion(Context_t  *context,int* speed) {
521    int32_t ret = cERR_PLAYBACK_NO_ERROR;
522
523    playback_printf(10, "\n");
524
525    //Audio only forwarding not supported
526    if (context->playback->isVideo && !context->playback->isHttp && context->playback->isPlaying) {
527        if(context->playback->isPaused)
528            PlaybackContinue(context);
529
530        switch(*speed) {
531        case 2:
532            context->playback->SlowMotion = 2;
533            break;
534        case 4:
535            context->playback->SlowMotion = 4;
536            break;
537        case 8:
538            context->playback->SlowMotion = 8;
539            break;
540        }
541
542        playback_printf(20, "SlowMotion: %d x {%d}\n", *speed, context->playback->SlowMotion);
543
544        context->output->Command(context, OUTPUT_SLOWMOTION, NULL);
545    } else
546    {
547        playback_err("slowmotion not possible\n");
548        ret = cERR_PLAYBACK_ERROR;
549    }
550
551    playback_printf(10, "exiting with value %d\n", ret);
552
553    return ret;
554}
555//obi (end)
556
557static int32_t PlaybackSeek(Context_t  *context, int64_t *pos, uint8_t absolute)
558{
559    int32_t ret = cERR_PLAYBACK_NO_ERROR;
560
561    playback_printf(10, "pos: %lldd\n", *pos);
562
563    if (context->playback->isPlaying && !context->playback->isForwarding && !context->playback->BackWard && !context->playback->SlowMotion && !context->playback->isPaused)
564    {
565        context->playback->isSeeking = 1;
566        context->output->Command(context, OUTPUT_CLEAR, NULL);
567        if (absolute)
568        {
569            context->container->selectedContainer->Command(context, CONTAINER_SEEK_ABS, pos);
570        }
571        else
572        {
573            context->container->selectedContainer->Command(context, CONTAINER_SEEK, pos);
574        }
575        context->playback->isSeeking = 0;
576    }
577    else
578    {
579        playback_err("not possible\n");
580        ret = cERR_PLAYBACK_ERROR;
581    }
582
583    playback_printf(10, "exiting with value %d\n", ret);
584
585    return ret;
586}
587
588static int32_t PlaybackPts(Context_t  *context, int64_t *pts)
589{
590    int32_t ret = cERR_PLAYBACK_NO_ERROR;
591
592    playback_printf(20, "\n");
593
594    *pts = 0;
595
596    if (context->playback->isPlaying)
597    {
598        ret = context->output->Command(context, OUTPUT_PTS, pts);
599    }
600    else
601    {
602        playback_err("not possible\n");
603        ret = cERR_PLAYBACK_ERROR;
604    }
605
606    playback_printf(20, "exiting with value %d\n", ret);
607
608    return ret;
609}
610
611static int32_t PlaybackGetFrameCount(Context_t  *context, int64_t *frameCount)
612{
613    int ret = cERR_PLAYBACK_NO_ERROR;
614
615    playback_printf(20, "\n");
616
617    *frameCount = 0;
618
619    if (context->playback->isPlaying)
620    {
621        ret = context->output->Command(context, OUTPUT_GET_FRAME_COUNT, frameCount);
622    } else
623    {
624        playback_err("not possible\n");
625        ret = cERR_PLAYBACK_ERROR;
626    }
627
628    playback_printf(20, "exiting with value %d\n", ret);
629
630    return ret;
631}
632
633static int32_t PlaybackLength(Context_t  *context, int64_t *length)
634{
635    int32_t ret = cERR_PLAYBACK_NO_ERROR;
636
637    playback_printf(20, "\n");
638
639    *length = -1;
640
641    if (context->playback->isPlaying)
642    {
643        if (context->container && context->container->selectedContainer)
644        {
645            context->container->selectedContainer->Command(context, CONTAINER_LENGTH, length);
646        }
647    }
648    else
649    {
650        playback_err("not possible\n");
651        ret = cERR_PLAYBACK_ERROR;
652    }
653
654    playback_printf(20, "exiting with value %d\n", ret);
655    return ret;
656}
657
658static int32_t PlaybackSwitchAudio(Context_t  *context, int32_t *track)
659{
660    int32_t ret = cERR_PLAYBACK_NO_ERROR;
661    int32_t curtrackid = 0;
662    int32_t nextrackid = 0;
663
664    playback_printf(10, "\n");
665
666    if (context && context->playback && context->playback->isPlaying)
667    {
668        if (context->manager && context->manager->audio)
669        {
670            context->manager->audio->Command(context, MANAGER_GET, &curtrackid);
671            context->manager->audio->Command(context, MANAGER_SET, track);
672            context->manager->audio->Command(context, MANAGER_GET, &nextrackid);
673        }
674        else
675        {
676            playback_err("switch audio not possible\n");
677            ret = cERR_PLAYBACK_ERROR;
678        }
679
680        if(nextrackid != curtrackid)
681        {
682
683            //PlaybackPause(context);
684            if (context->output && context->output->audio)
685            {
686                context->output->audio->Command(context, OUTPUT_SWITCH, (void*)"audio");
687            }
688
689            if (context->container && context->container->selectedContainer)
690            {
691                context->container->selectedContainer->Command(context, CONTAINER_SWITCH_AUDIO, &nextrackid);
692            }
693            //PlaybackContinue(context);
694        }
695    }
696    else
697    {
698        playback_err("switch audio not possible\n");
699        ret = cERR_PLAYBACK_ERROR;
700    }
701
702    playback_printf(10, "exiting with value %d\n", ret);
703    return ret;
704}
705
706static int32_t PlaybackSwitchSubtitle(Context_t  *context, int32_t *track)
707{
708    int32_t ret = cERR_PLAYBACK_NO_ERROR;
709    int32_t curtrackid = -1;
710    int32_t nextrackid = -1;
711
712    playback_printf(10, "Track: %d\n", *track);
713
714    if (context && context->playback && context->playback->isPlaying )
715    {
716        if (context->manager && context->manager->subtitle)
717        {
718            context->manager->subtitle->Command(context, MANAGER_GET, &curtrackid);
719            context->manager->subtitle->Command(context, MANAGER_SET, track);
720            context->manager->subtitle->Command(context, MANAGER_GET, &nextrackid);
721         
722            if (curtrackid != nextrackid && nextrackid > -1)
723            {
724                if (context->output && context->output->subtitle)
725                {
726                    context->output->subtitle->Command(context, OUTPUT_SWITCH, (void*)"subtitle");
727                }
728
729                if (context->container && context->container->selectedContainer)
730                {
731                    context->container->selectedContainer->Command(context, CONTAINER_SWITCH_SUBTITLE, &nextrackid);
732                }
733            }
734        }
735        else
736        {
737            ret = cERR_PLAYBACK_ERROR;
738            playback_err("no subtitle\n");
739        }
740    }
741    else
742    {
743        playback_err("not possible\n");
744        ret = cERR_PLAYBACK_ERROR;
745    }
746
747    playback_printf(10, "exiting with value %d\n", ret);
748
749    return ret;
750}
751
752static int32_t PlaybackInfo(Context_t  *context, char **infoString)
753{
754    int32_t ret = cERR_PLAYBACK_NO_ERROR;
755
756    playback_printf(10, "\n");
757
758    /* konfetti comment:
759     * removed if clause here (playback running) because its
760     * not necessary for all container. e.g. in case of ffmpeg
761     * container playback must not play to get the info.
762     */
763    if (context->container && context->container->selectedContainer)
764    {
765        context->container->selectedContainer->Command(context, CONTAINER_INFO, infoString);
766    }
767
768    playback_printf(10, "exiting with value %d\n", ret);
769
770    return ret;
771}
772
773static int32_t Command(void* _context, PlaybackCmd_t command, void *argument)
774{
775    Context_t* context = (Context_t*) _context; /* to satisfy compiler */
776    int32_t ret = cERR_PLAYBACK_NO_ERROR;
777
778    playback_printf(20, "Command %d\n", command);
779
780
781    switch(command)
782    {
783        case PLAYBACK_OPEN:
784        {
785            ret = PlaybackOpen(context, (PlayFiles_t*)argument);
786            break;
787        }
788        case PLAYBACK_CLOSE:
789        {
790            ret = PlaybackClose(context);
791            break;
792        }
793        case PLAYBACK_PLAY:
794        {
795            ret = PlaybackPlay(context);
796            break;
797        }
798        case PLAYBACK_STOP:
799        {
800            ret = PlaybackStop(context);
801            break;
802        }
803        case PLAYBACK_PAUSE:
804        {
805            ret = PlaybackPause(context);
806            break;
807        }
808        case PLAYBACK_CONTINUE:
809        {
810            ret = PlaybackContinue(context);
811            break;
812        }
813        case PLAYBACK_TERM:
814        {
815            ret = PlaybackTerminate(context);
816            break;
817        }
818        case PLAYBACK_SEEK:
819        {
820            ret = PlaybackSeek(context, (int64_t*)argument, 0);
821            break;
822        }
823        case PLAYBACK_SEEK_ABS:
824        {
825            ret = PlaybackSeek(context, (int64_t*)argument, -1);
826            break;
827        }
828        case PLAYBACK_PTS:
829        {
830            ret = PlaybackPts(context, (int64_t*)argument);
831            break;
832        }
833        case PLAYBACK_LENGTH:
834        {
835            ret = PlaybackLength(context, (int64_t*)argument);
836            break;
837        }
838        case PLAYBACK_SWITCH_AUDIO:
839        {
840            ret = PlaybackSwitchAudio(context, (int*)argument);
841            break;
842        }
843        case PLAYBACK_SWITCH_SUBTITLE:
844        {
845            ret = PlaybackSwitchSubtitle(context, (int*)argument);
846            break;
847        }
848        case PLAYBACK_INFO:
849        {
850            ret = PlaybackInfo(context, (char**)argument);
851            break;
852        }
853//obi
854        case PLAYBACK_SLOWMOTION:
855        {
856            ret = PlaybackSlowMotion(context,(int*)argument);
857            break;
858        }
859        case PLAYBACK_FASTBACKWARD:
860        {
861            ret = PlaybackFastBackward(context,(int*)argument);
862            break;
863        }
864        case PLAYBACK_FASTFORWARD:
865        {
866            ret = PlaybackFastForward(context,(int*)argument);
867            break;
868        }
869//obi (end)
870        case PLAYBACK_GET_FRAME_COUNT:
871        {
872            ret = PlaybackGetFrameCount(context, (uint64_t*)argument);
873            break;
874        }
875        default:
876            playback_err("PlaybackCmd %d not supported!\n", command);
877            ret = cERR_PLAYBACK_ERROR;
878            break;
879    }
880
881    playback_printf(20, "exiting with value %d\n", ret);
882
883    return ret;
884}
885
886/*
887 * This is very unreadable and must be changed
888 */
889PlaybackHandler_t PlaybackHandler = {
890    "Playback", //name
891    -1,         //fd
892    0,          //isFile
893    0,          //isHttp
894    0,          //isPlaying
895    0,          //isPaused
896    0,          //isForwarding
897    0,          //isSeeking
898    0,          //isCreationPhase
899    0,          //BackWard
900    0,          //SlowMotion
901    0,          //Speed
902    0,          //AVSync
903    0,          //isVideo
904    0,          //isAudio
905    0,          //isSubtitle
906    0,          //abortRequested
907    &Command,   //Command
908    "",         //uri
909    0,          //size
910    0,          //noprobe
911    0,          //isLoopMode
912    0,          //isTSLiveMode
913};
Note: See TracBrowser for help on using the repository browser.