From ccd2c57a831649f909032db86033c6cd0186fcef Mon Sep 17 00:00:00 2001 From: martii Date: Sat, 5 Apr 2014 16:02:06 +0200 Subject: [PATCH] libeplayer3: c++ adjustments Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/ec307c0f098761879e4f1e2842dd59675ad93b83 Author: martii Date: 2014-04-05 (Sat, 05 Apr 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libeplayer3/Makefile.am | 25 ++- libeplayer3/container/container.cpp | 2 +- libeplayer3/container/container_ffmpeg.cpp | 66 +++---- libeplayer3/include/common.h | 2 +- libeplayer3/include/container.h | 11 +- libeplayer3/include/manager.h | 14 +- libeplayer3/include/output.h | 14 +- libeplayer3/include/playback.h | 5 +- libeplayer3/include/writer.h | 6 +- libeplayer3/manager/audio.cpp | 208 ++++++--------------- libeplayer3/manager/chapter.cpp | 114 +++-------- libeplayer3/manager/manager.cpp | 22 --- libeplayer3/manager/subtitle.cpp | 194 +++++-------------- libeplayer3/manager/teletext.cpp | 177 ++++-------------- libeplayer3/manager/video.cpp | 170 ++++------------- libeplayer3/output/linuxdvb.cpp | 4 +- libeplayer3/output/output.cpp | 14 +- libeplayer3/output/writer/h264.cpp | 2 +- libeplayer3/output/writer/wmv.cpp | 2 +- libeplayer3/playback/playback.cpp | 68 +++---- libspark/playback_libeplayer3.cpp | 8 +- 21 files changed, 308 insertions(+), 820 deletions(-) diff --git a/libeplayer3/Makefile.am b/libeplayer3/Makefile.am index 7d85736..8baa601 100644 --- a/libeplayer3/Makefile.am +++ b/libeplayer3/Makefile.am @@ -2,21 +2,20 @@ noinst_LTLIBRARIES = libeplayer3.la CXXFLAGS = -Wall -AM_CPPFLAGS = \ - -I$(srcdir)/include +AM_CPPFLAGS = -I$(srcdir)/include +AM_CPPFLAGS += -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE +AM_CPPFLAGS += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS libeplayer3_la_SOURCES = \ - container/container.c container/container_ffmpeg.c \ - manager/audio.c manager/manager.c manager/subtitle.c manager/video.c \ - manager/teletext.c manager/chapter.c \ - output/linuxdvb.c output/output.c \ - playback/playback.c output/writer/writer.c output/writer/wmv.c \ - output/writer/ac3.c output/writer/divx.c output/writer/pes.c \ - output/writer/dts.c output/writer/mpeg2.c output/writer/mp3.c output/writer/misc.c \ - output/writer/h264.c output/writer/h263.c output/writer/vc1.c \ - output/writer/flac.c output/writer/pcm.c - -AM_CFLAGS = -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE + container/container.cpp container/container_ffmpeg.cpp \ + manager/audio.cpp manager/manager.cpp manager/subtitle.cpp manager/video.cpp \ + manager/teletext.cpp manager/chapter.cpp \ + output/linuxdvb.cpp output/output.cpp \ + playback/playback.cpp output/writer/writer.cpp output/writer/wmv.cpp \ + output/writer/ac3.cpp output/writer/divx.cpp output/writer/pes.cpp \ + output/writer/dts.cpp output/writer/mpeg2.cpp output/writer/mp3.cpp output/writer/misc.cpp \ + output/writer/h264.cpp output/writer/h263.cpp output/writer/vc1.cpp \ + output/writer/flac.cpp output/writer/pcm.cpp LIBEPLAYER3_LIBS = libeplayer3.la -lpthread -lavformat -lavcodec -lavutil -lswresample -lm diff --git a/libeplayer3/container/container.cpp b/libeplayer3/container/container.cpp index 654a31b..033b885 100644 --- a/libeplayer3/container/container.cpp +++ b/libeplayer3/container/container.cpp @@ -41,7 +41,7 @@ if (debug_level >= level) printf(x); } while (0) #define container_err(x...) #endif -static int Command(Context_t *context, ContainerCmd_t command, void *argument __attribute__((unused))) +static int Command(Context_t *context, ContainerCmd_t command, const char *argument __attribute__((unused))) { int ret = 0; diff --git a/libeplayer3/container/container_ffmpeg.cpp b/libeplayer3/container/container_ffmpeg.cpp index 0341bb5..82db104 100644 --- a/libeplayer3/container/container_ffmpeg.cpp +++ b/libeplayer3/container/container_ffmpeg.cpp @@ -103,7 +103,7 @@ static float seek_sec_abs = -1.0, seek_sec_rel = 0.0; /* MISC Functions */ /* ***************************** */ -static char *Codec2Encoding(AVCodecContext * codec) +static const char *Codec2Encoding(AVCodecContext * codec) { fprintf(stderr, "Codec ID: %ld (%.8lx)\n", (long) codec->codec_id, (long) codec->codec_id); switch (codec->codec_id) { @@ -214,14 +214,15 @@ int64_t calcPts(AVFormatContext *avfc, AVStream * stream, int64_t pts) /* **************************** */ // from neutrino-mp/lib/libdvbsubtitle/dvbsub.cpp -extern void dvbsub_write(AVSubtitle *, int64_t); -extern void dvbsub_ass_write(AVCodecContext *c, AVSubtitle *sub, int pid); -extern void dvbsub_ass_clear(void); +extern "C" void dvbsub_write(AVSubtitle *, int64_t); +extern "C" void dvbsub_ass_write(AVCodecContext *c, AVSubtitle *sub, int pid); +extern "C" void dvbsub_ass_clear(void); // from neutrino-mp/lib/lib/libtuxtxt/tuxtxt_common.h -extern void teletext_write(int pid, uint8_t *data, int size); +extern "C" void teletext_write(int pid, uint8_t *data, int size); -static void FFMPEGThread(Context_t * context) +static void *FFMPEGThread(void *arg) { + Context_t *context = (Context_t *) arg; char threadname[17]; strncpy(threadname, __func__, sizeof(threadname)); threadname[16] = 0; @@ -443,6 +444,7 @@ static void FFMPEGThread(Context_t * context) hasPlayThreadStarted = 0; ffmpeg_printf(10, "terminating\n"); + pthread_exit(NULL); } /* **************************** */ @@ -463,10 +465,10 @@ static void log_callback(void *ptr __attribute__ ((unused)), int lvl __attribute } static void container_ffmpeg_read_subtitle(Context_t * context, const char *filename, const char *format, int pid) { - char *lastDot = strrchr(filename, '.'); + const char *lastDot = strrchr(filename, '.'); if (!lastDot) return; - char *subfile = alloca(strlen(filename) + strlen(format)); + char *subfile = (char *) alloca(strlen(filename) + strlen(format)); strcpy(subfile, filename); strcpy(subfile + (lastDot + 1 - filename), format); @@ -496,18 +498,6 @@ static void container_ffmpeg_read_subtitle(Context_t * context, const char *file } AVPacket avpkt; av_init_packet(&avpkt); -#if 0 - // FIXME, use custom values - if (c->subtitle_header && !strcmp(format, "srt")) { - av_freep(&c->subtitle_header); - - #define ASS_DEFAULT_FONT "Arial" - #define ASS_DEFAULT_FONT_SIZE 16 - #define ASS_DEFAULT_COLOR 0xffffff - - ff_ass_subtitle_header(c, ASS_DEFAULT_FONT, ASS_DEFAULT_FONT_SIZE, ASS_DEFAULT_COLOR, 0, 0, 0, 0, 2); - } -#endif if (c->subtitle_header) fprintf(stderr, "%s\n", c->subtitle_header); @@ -525,8 +515,7 @@ static void container_ffmpeg_read_subtitle(Context_t * context, const char *file avformat_free_context(avfc); Track_t track; - memset(&track, 0, sizeof(track)); - track.Name = (char *) format; + track.Name = format; track.is_static = 1; track.Id = pid; track.Encoding = strcmp(format, "srt") ? "S_TEXT/ASS" : "S_TEXT/SRT"; @@ -542,7 +531,7 @@ static void container_ffmpeg_read_subtitles(Context_t * context, const char *fil container_ffmpeg_read_subtitle(context, filename, "ssa", 0xFFFD); } -int container_ffmpeg_init(Context_t * context, char *filename) +int container_ffmpeg_init(Context_t * context, const char *filename) { int err; @@ -640,7 +629,7 @@ int container_ffmpeg_init(Context_t * context, char *filename) return res; } -int container_ffmpeg_update_tracks(Context_t * context, char *filename) +int container_ffmpeg_update_tracks(Context_t * context, const char *filename) { if (terminating) return cERR_CONTAINER_FFMPEG_NO_ERROR; @@ -650,13 +639,12 @@ int container_ffmpeg_update_tracks(Context_t * context, char *filename) context->manager->video->Command(context, MANAGER_INIT_UPDATE, NULL); for (i = 0; i < avContext->nb_chapters; i++) { Track_t track; - memset(&track, 0, sizeof(track)); track.Id = i; AVDictionaryEntry *title; AVChapter *ch = avContext->chapters[i]; title = av_dict_get(ch->metadata, "title", NULL, 0); track.Name = strdup(title ? title->value : "und"); - ffmpeg_printf(10, "Chapter %s\n", track.Name); + ffmpeg_printf(10, "Chapter %s\n", track.Name.c_str()); track.chapter_start = (double) ch->start * av_q2d(ch->time_base) * 1000.0; track.chapter_end = (double) ch->end * av_q2d(ch->time_base) * 1000.0; context->manager->chapter->Command(context, MANAGER_ADD, &track); @@ -683,18 +671,13 @@ int container_ffmpeg_update_tracks(Context_t * context, char *filename) Track_t track; AVStream *stream = avContext->streams[n]; - char *encoding = Codec2Encoding(stream->codec); + const char *encoding = Codec2Encoding(stream->codec); if (encoding != NULL) ffmpeg_printf(1, "%d. encoding = %s\n", n, encoding); if (!stream->id) - stream->id = n; - - /* some values in track are unset and therefor copyTrack segfaults. - * so set it by default to NULL! - */ - memset(&track, 0, sizeof(track)); + stream->id = n + 1; track.avfc = avContext; track.stream = stream; @@ -736,7 +719,7 @@ int container_ffmpeg_update_tracks(Context_t * context, char *filename) track.Name = lang ? lang->value : "und"; - ffmpeg_printf(10, "Language %s\n", track.Name); + ffmpeg_printf(10, "Language %s\n", track.Name.c_str()); track.Encoding = encoding; track.Id = stream->id; @@ -770,7 +753,7 @@ int container_ffmpeg_update_tracks(Context_t * context, char *filename) track.Name = lang ? lang->value : "und"; - ffmpeg_printf(10, "Language %s\n", track.Name); + ffmpeg_printf(10, "Language %s\n", track.Name.c_str()); track.Encoding = encoding; track.Id = stream->id; @@ -786,7 +769,7 @@ int container_ffmpeg_update_tracks(Context_t * context, char *filename) ffmpeg_printf(10, "subtitle height %d\n", stream->codec->height); ffmpeg_printf(10, "subtitle stream %p\n", stream); - ffmpeg_printf(10, "FOUND SUBTITLE %s\n", track.Name); + ffmpeg_printf(10, "FOUND SUBTITLE %s\n", track.Name.c_str()); if (stream->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT && context->manager->teletext) { ffmpeg_printf(10, "dvb_teletext\n"); @@ -853,7 +836,7 @@ static int container_ffmpeg_play(Context_t * context) pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - if ((error = pthread_create(&PlayThread, &attr, (void *) &FFMPEGThread, context)) != 0) { + if ((error = pthread_create(&PlayThread, &attr, FFMPEGThread, context)) != 0) { ffmpeg_printf(10, "Error creating thread, error:%d:%s\n", error, strerror(error)); ret = cERR_CONTAINER_FFMPEG_ERR; } else { @@ -997,7 +980,7 @@ static int container_ffmpeg_get_metadata(Context_t * context, char ***p) if (audioTrack) psize += av_dict_count(((AVStream *)(audioTrack->stream))->metadata); - *p = malloc(sizeof(char *) * psize * 2); + *p = (char **) malloc(sizeof(char *) * psize * 2); if (!*p) { fprintf(stderr, "MALLOC %s:%d\n", __func__, __LINE__); return cERR_CONTAINER_FFMPEG_ERR; @@ -1030,7 +1013,7 @@ static int container_ffmpeg_get_metadata(Context_t * context, char ***p) return cERR_CONTAINER_FFMPEG_NO_ERROR; } -static int Command(Context_t *context, ContainerCmd_t command, void *argument) +static int Command(Context_t *context, ContainerCmd_t command, const char *argument) { int ret = cERR_CONTAINER_FFMPEG_NO_ERROR; @@ -1042,8 +1025,7 @@ static int Command(Context_t *context, ContainerCmd_t command, void *argument) return cERR_CONTAINER_FFMPEG_ERR; switch (command) { case CONTAINER_INIT:{ - char *filename = (char *) argument; - ret = container_ffmpeg_init(context, filename); + ret = container_ffmpeg_init(context, argument); break; } case CONTAINER_PLAY:{ @@ -1096,7 +1078,7 @@ static int Command(Context_t *context, ContainerCmd_t command, void *argument) return ret; } -static char *FFMPEG_Capabilities[] = { "avi", "mkv", "mp4", "ts", "mov", "flv", "flac", "mp3", "mpg", +static const char *FFMPEG_Capabilities[] = { "avi", "mkv", "mp4", "ts", "mov", "flv", "flac", "mp3", "mpg", "m2ts", "vob", "wmv", "wma", "asf", "mp2", "m4v", "m4a", "divx", "dat", "mpeg", "trp", "mts", "vdr", "ogg", "wav", "wtv", "ogm", "3gp", NULL }; diff --git a/libeplayer3/include/common.h b/libeplayer3/include/common.h index 57da81a..1ff14dc 100644 --- a/libeplayer3/include/common.h +++ b/libeplayer3/include/common.h @@ -16,5 +16,5 @@ typedef struct Context_s { int64_t *currentAudioPtsP; } Context_t; -int container_ffmpeg_update_tracks(Context_t * context, char *filename); +int container_ffmpeg_update_tracks(Context_t * context, const char *filename); #endif diff --git a/libeplayer3/include/container.h b/libeplayer3/include/container.h index 3f924e2..c2d243a 100644 --- a/libeplayer3/include/container.h +++ b/libeplayer3/include/container.h @@ -22,19 +22,18 @@ struct Context_s; typedef struct Context_s Context_t; typedef struct Container_s { - char *Name; - int (*Command) (Context_t *, ContainerCmd_t, void *); - char **Capabilities; - + const char *Name; + int (*Command) (Context_t *, ContainerCmd_t, const char *); + const char **Capabilities; } Container_t; extern Container_t FFMPEGContainer; typedef struct ContainerHandler_s { - char *Name; + const char *Name; Container_t *selectedContainer; - int (*Command) (Context_t *, ContainerCmd_t, void *); + int (*Command) (Context_t *, ContainerCmd_t, const char *); } ContainerHandler_t; #endif diff --git a/libeplayer3/include/manager.h b/libeplayer3/include/manager.h index b558db5..eae1d6e 100644 --- a/libeplayer3/include/manager.h +++ b/libeplayer3/include/manager.h @@ -3,12 +3,15 @@ #include #include +#include +extern "C" { #include #include #include #include #include +} typedef enum { MANAGER_ADD, @@ -28,8 +31,8 @@ typedef enum { } eTrackTypeEplayer; typedef struct Track_s { - char *Name; - char *Encoding; + std::string Name; + const char *Encoding; int Id; /* new field for ffmpeg - add at the end so no problem @@ -50,20 +53,21 @@ typedef struct Track_s { int is_static; long long int chapter_start; long long int chapter_end; + Track_s() : Encoding(NULL), Id(0), language(NULL), duration(-1), avfc(NULL), stream(NULL), pending(0), is_static(0), chapter_start(0), chapter_end(0) {} } Track_t; struct Context_s; typedef struct Context_s Context_t; typedef struct Manager_s { - char *Name; + const char *Name; int (*Command) ( Context_t *, ManagerCmd_t, void *); - char **Capabilities; + const char **Capabilities; } Manager_t; typedef struct ManagerHandler_s { - char *Name; + const char *Name; Manager_t *audio; Manager_t *video; Manager_t *subtitle; diff --git a/libeplayer3/include/output.h b/libeplayer3/include/output.h index 0cdeb53..e924f75 100644 --- a/libeplayer3/include/output.h +++ b/libeplayer3/include/output.h @@ -4,11 +4,13 @@ #include #include +extern "C" { #include #include #include #include #include +} typedef enum { OUTPUT_INIT, @@ -46,7 +48,7 @@ typedef struct { int64_t pts; - char *type; + const char *type; AVFormatContext *avfc; AVStream *stream; @@ -57,10 +59,10 @@ struct Context_s; typedef struct Context_s Context_t; typedef struct Output_s { - char *Name; - int (*Command) (Context_t *, OutputCmd_t, void *); + const char *Name; + int (*Command) (Context_t *, OutputCmd_t, const char *); int (*Write) (Context_t *, AudioVideoOut_t *privateData); - char **Capabilities; + const char **Capabilities; } Output_t; @@ -68,10 +70,10 @@ extern Output_t LinuxDvbOutput; extern Output_t SubtitleOutput; typedef struct OutputHandler_s { - char *Name; + const char *Name; Output_t *audio; Output_t *video; - int (*Command) (Context_t *, OutputCmd_t, void *); + int (*Command) (Context_t *, OutputCmd_t, const char *); } OutputHandler_t; #endif diff --git a/libeplayer3/include/playback.h b/libeplayer3/include/playback.h index 3e080d2..8577b28 100644 --- a/libeplayer3/include/playback.h +++ b/libeplayer3/include/playback.h @@ -1,6 +1,7 @@ #ifndef PLAYBACK_H_ #define PLAYBACK_H_ #include +#include typedef enum { PLAYBACK_OPEN, PLAYBACK_CLOSE, PLAYBACK_PLAY, PLAYBACK_STOP, PLAYBACK_PAUSE, PLAYBACK_CONTINUE, PLAYBACK_FLUSH, PLAYBACK_TERM, @@ -15,7 +16,7 @@ struct Context_s; typedef struct Context_s Context_t; typedef struct PlaybackHandler_s { - char *Name; + const char *Name; int fd; @@ -37,7 +38,7 @@ typedef struct PlaybackHandler_s { unsigned char abortPlayback; int (*Command) ( Context_t *, PlaybackCmd_t, void *); - char *uri; + std::string uri; unsigned char noprobe; /* hack: only minimal probing in av_find_stream_info */ unsigned long long readCount; } PlaybackHandler_t; diff --git a/libeplayer3/include/writer.h b/libeplayer3/include/writer.h index ac37738..c3dbc3b 100644 --- a/libeplayer3/include/writer.h +++ b/libeplayer3/include/writer.h @@ -4,11 +4,13 @@ #include #include +extern "C" { #include #include #include #include #include +} typedef enum { eNone, eAudio, eVideo, eGfx } eWriterType_t; @@ -32,9 +34,9 @@ typedef struct { } WriterAVCallData_t; typedef struct WriterCaps_s { - char *name; + const char *name; eWriterType_t type; - char *textEncoding; + const char *textEncoding; /* fixme: revise if this is an enum! */ int dvbEncoding; } WriterCaps_t; diff --git a/libeplayer3/manager/audio.cpp b/libeplayer3/manager/audio.cpp index 2db650a..2a8aba9 100644 --- a/libeplayer3/manager/audio.cpp +++ b/libeplayer3/manager/audio.cpp @@ -23,15 +23,14 @@ #include #include +#include -#include #include "manager.h" #include "common.h" /* ***************************** */ /* Makros/Constants */ /* ***************************** */ -#define TRACKWRAP 20 #define AUDIO_MGR_DEBUG @@ -65,9 +64,8 @@ static const char FILENAME[] = __FILE__; /* Varaibles */ /* ***************************** */ -static Track_t *Tracks = NULL; -static int TrackCount = 0; -static int CurrentTrack = 0; //TRACK[0] as default. +static std::map Tracks; +static int CurrentPid = -1; /* ***************************** */ /* Prototypes */ @@ -79,109 +77,39 @@ static int CurrentTrack = 0; //TRACK[0] as default. static int ManagerAdd(Context_t * context, Track_t track) { - - audio_mgr_printf(10, "%s::%s name=\"%s\" encoding=\"%s\" id=%d\n", - FILENAME, __FUNCTION__, track.Name, track.Encoding, - track.Id); - - if (Tracks == NULL) { - Tracks = malloc(sizeof(Track_t) * TRACKWRAP); - int i; - for (i = 0; i < TRACKWRAP; i++) - Tracks[i].Id = -1; - } - - if (Tracks == NULL) { - audio_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__); - return cERR_AUDIO_MGR_ERROR; - } - - int i; - for (i = 0; i < TRACKWRAP; i++) { - if (Tracks[i].Id == track.Id) { - Tracks[i].pending = 0; - return cERR_AUDIO_MGR_NO_ERROR; - } - } - - if (TrackCount < TRACKWRAP) { - copyTrack(&Tracks[TrackCount], &track); - TrackCount++; - } else { - audio_mgr_err("%s:%s TrackCount out if range %d - %d\n", FILENAME, - __FUNCTION__, TrackCount, TRACKWRAP); - return cERR_AUDIO_MGR_ERROR; - } - - if (TrackCount > 0) + Tracks[track.Id] = track; context->playback->isAudio = 1; - audio_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); + if (CurrentPid < 0) + CurrentPid = track.Id; - return cERR_AUDIO_MGR_NO_ERROR; + return cERR_AUDIO_MGR_NO_ERROR; } static char **ManagerList(Context_t * context __attribute__ ((unused))) { - int i = 0, j = 0; - char **tracklist = NULL; + int j = 0; + char **tracklist = (char **) malloc(sizeof(char *) * ((Tracks.size() * 2) + 1)); - audio_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); - - if (Tracks != NULL) { - - tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1)); - - if (tracklist == NULL) { - audio_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__); - return NULL; - } - - for (i = 0, j = 0; i < TrackCount; i++, j += 2) { - if (Tracks[i].pending) - continue; - size_t len = strlen(Tracks[i].Name) + 20; - char tmp[len]; - snprintf(tmp, len, "%d %s\n", Tracks[i].Id, Tracks[i].Name); - tracklist[j] = strdup(tmp); - tracklist[j + 1] = strdup(Tracks[i].Encoding); + for(std::map::iterator it = Tracks.begin(); it != Tracks.end(); ++it) + { + size_t len = it->second.Name.length() + 20; + char tmp[len]; + snprintf(tmp, len, "%d %s\n", it->second.Id, it->second.Name.c_str()); + tracklist[j] = strdup(tmp); + tracklist[j + 1] = strdup(it->second.Encoding); } tracklist[j] = NULL; - } - audio_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME, - __FUNCTION__, tracklist, j, TrackCount); - - return tracklist; + return tracklist; } static int ManagerDel(Context_t * context) { - - int i = 0; - - audio_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); - - if (Tracks != NULL) { - for (i = 0; i < TrackCount; i++) { - freeTrack(&Tracks[i]); - } - free(Tracks); - Tracks = NULL; - } else { - audio_mgr_err("%s::%s nothing to delete!\n", FILENAME, - __FUNCTION__); - return cERR_AUDIO_MGR_ERROR; - } - - TrackCount = 0; - CurrentTrack = 0; - context->playback->isAudio = 0; - - audio_mgr_printf(10, "%s::%s return no error\n", FILENAME, - __FUNCTION__); - - return cERR_AUDIO_MGR_NO_ERROR; + Tracks.clear(); + CurrentPid = -1; + context->playback->isAudio = 0; + return cERR_AUDIO_MGR_NO_ERROR; } @@ -193,90 +121,64 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) switch (command) { case MANAGER_ADD:{ - Track_t *track = argument; - + Track_t *track = (Track_t *) argument; ret = ManagerAdd(context, *track); break; } case MANAGER_LIST:{ - container_ffmpeg_update_tracks(context, context->playback->uri); + container_ffmpeg_update_tracks(context, context->playback->uri.c_str()); *((char ***) argument) = (char **) ManagerList(context); break; } case MANAGER_GET:{ - audio_mgr_printf(20, "%s::%s MANAGER_GET\n", FILENAME, - __FUNCTION__); - - if ((TrackCount > 0) && (CurrentTrack >= 0)) - *((int *) argument) = (int) Tracks[CurrentTrack].Id; - else - *((int *) argument) = (int) -1; - break; + *((int *) argument) = (int) CurrentPid; + break; } case MANAGER_GET_TRACK:{ - audio_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME, - __FUNCTION__); - - if ((TrackCount > 0) && (CurrentTrack >= 0)) - *((Track_t **) argument) = - (Track_t *) & Tracks[CurrentTrack]; - else - *((Track_t **) argument) = NULL; - break; + if (CurrentPid > -1) + *((Track_t **) argument) = &Tracks[CurrentPid]; + else + *((Track_t **) argument) = NULL; + break; } case MANAGER_GETENCODING:{ - if ((TrackCount > 0) && (CurrentTrack >= 0)) - *((char **) argument) = - (char *) strdup(Tracks[CurrentTrack].Encoding); - else - *((char **) argument) = (char *) strdup(""); - break; + if (CurrentPid > -1) + *((char **) argument) = strdup(Tracks[CurrentPid].Encoding); + else + *((char **) argument) = strdup(""); + break; } case MANAGER_GETNAME:{ - if ((TrackCount > 0) && (CurrentTrack >= 0)) - *((char **) argument) = - (char *) strdup(Tracks[CurrentTrack].Name); - else - *((char **) argument) = (char *) strdup(""); - break; + if (CurrentPid > -1) + *((char **) argument) = strdup(Tracks[CurrentPid].Name.c_str()); + else + *((char **) argument) = strdup(""); + break; } case MANAGER_SET:{ - int i; - audio_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME, - __FUNCTION__, *((int *) argument)); - - for (i = 0; i < TrackCount; i++) - if (Tracks[i].Id == *((int *) argument)) { - CurrentTrack = i; - break; - } - - if (i == TrackCount) { - audio_mgr_err("%s::%s track id %d unknown\n", FILENAME, - __FUNCTION__, *((int *) argument)); - ret = cERR_AUDIO_MGR_ERROR; - } - break; + std::map::iterator it = Tracks.find(*((int *) argument)); + if (it != Tracks.end()) + CurrentPid = *((int *) argument); + else + ret = cERR_AUDIO_MGR_ERROR; + break; } case MANAGER_DEL:{ - ret = ManagerDel(context); - break; + ret = ManagerDel(context); + break; } case MANAGER_INIT_UPDATE:{ - int i; - for (i = 0; i < TrackCount; i++) - Tracks[i].pending = 1; - break; + for (std::map::iterator it = Tracks.begin(); it != Tracks.end(); ++it) + it->second.pending = 1; + break; } default: - audio_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, - __FUNCTION__, command); - ret = cERR_AUDIO_MGR_ERROR; - break; + audio_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command); + ret = cERR_AUDIO_MGR_ERROR; + break; } - audio_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__, - ret); + audio_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__, ret); return ret; } diff --git a/libeplayer3/manager/chapter.cpp b/libeplayer3/manager/chapter.cpp index 4e6fbe7..8d4dfcd 100644 --- a/libeplayer3/manager/chapter.cpp +++ b/libeplayer3/manager/chapter.cpp @@ -23,6 +23,7 @@ #include #include +#include #include "manager.h" #include "common.h" @@ -30,7 +31,6 @@ /* ***************************** */ /* Makros/Constants */ /* ***************************** */ -#define TRACKWRAP 64 #define CHAPTER_MGR_DEBUG @@ -64,9 +64,7 @@ static const char FILENAME[] = __FILE__; /* Varaibles */ /* ***************************** */ -static Track_t *Tracks = NULL; -static int TrackCount = 0; -static int CurrentTrack = 0; //TRACK[0] as default. +static std::map Tracks; /* ***************************** */ /* Prototypes */ @@ -78,101 +76,33 @@ static int CurrentTrack = 0; //TRACK[0] as default. static int ManagerAdd(Context_t * context __attribute__((unused)), Track_t track) { - chapter_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); + Tracks[track.Id] = track; - if (Tracks == NULL) { - Tracks = malloc(sizeof(Track_t) * TRACKWRAP); - int i; - for (i = 0; i < TRACKWRAP; i++) - Tracks[i].Id = -1; - } - - if (Tracks == NULL) { - chapter_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__); - return cERR_CHAPTER_MGR_ERROR; - } - - int i; - for (i = 0; i < TRACKWRAP; i++) { - if (Tracks[i].Id == track.Id) { - Tracks[i].pending = 0; - return cERR_CHAPTER_MGR_NO_ERROR; - } - } - - if (TrackCount < TRACKWRAP) { - copyTrack(&Tracks[TrackCount], &track); - - TrackCount++; - } else { - chapter_mgr_err("%s:%s TrackCount out if range %d - %d\n", FILENAME, - __FUNCTION__, TrackCount, TRACKWRAP); - return cERR_CHAPTER_MGR_ERROR; - } - - chapter_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); - - return cERR_CHAPTER_MGR_NO_ERROR; + return cERR_CHAPTER_MGR_NO_ERROR; } static char **ManagerList(Context_t * context __attribute__ ((unused))) { - int i = 0, j = 0; - char **tracklist = NULL; + int j = 0; + char **tracklist = (char **) malloc(sizeof(char *) * ((Tracks.size() * 2) + 1)); - chapter_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); - - if (Tracks != NULL) { - - tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1)); - - if (tracklist == NULL) { - chapter_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__); - return NULL; - } - - for (i = 0, j = 0; i < TrackCount; i++, j += 2) { - if (Tracks[i].pending) - continue; - char tmp[20]; - snprintf(tmp, sizeof(tmp), "%d", (int)Tracks[i].chapter_start); - tracklist[j] = strdup(tmp); - tracklist[j + 1] = strdup(Tracks[i].Name); + for(std::map::iterator it = Tracks.begin(); it != Tracks.end(); ++it) + { + size_t len = it->second.Name.length() + 20; + char tmp[len]; + snprintf(tmp, len, "%d %s\n", it->second.Id, it->second.Name.c_str()); + tracklist[j] = strdup(tmp); + tracklist[j + 1] = strdup(it->second.Encoding); } tracklist[j] = NULL; - } - - chapter_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME, - __FUNCTION__, tracklist, j, TrackCount); return tracklist; } static int ManagerDel(Context_t * context __attribute__((unused))) { - int i = 0; - - chapter_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); - - if (Tracks != NULL) { - for (i = 0; i < TrackCount; i++) { - freeTrack(&Tracks[i]); - } - free(Tracks); - Tracks = NULL; - } else { - chapter_mgr_err("%s::%s nothing to delete!\n", FILENAME, - __FUNCTION__); - return cERR_CHAPTER_MGR_ERROR; - } - - TrackCount = 0; - CurrentTrack = 0; - - chapter_mgr_printf(10, "%s::%s return no error\n", FILENAME, - __FUNCTION__); - - return cERR_CHAPTER_MGR_NO_ERROR; + Tracks.clear(); + return cERR_CHAPTER_MGR_NO_ERROR; } static int Command(Context_t *context, ManagerCmd_t command, void *argument) @@ -183,12 +113,12 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) switch (command) { case MANAGER_ADD:{ - Track_t *track = argument; + Track_t *track = (Track_t *) argument; ret = ManagerAdd(context, *track); break; } case MANAGER_LIST:{ - container_ffmpeg_update_tracks(context, context->playback->uri); + container_ffmpeg_update_tracks(context, context->playback->uri.c_str()); *((char ***) argument) = (char **) ManagerList(context); break; } @@ -197,14 +127,12 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) break; } case MANAGER_INIT_UPDATE:{ - int i; - for (i = 0; i < TrackCount; i++) - Tracks[i].pending = 1; - break; + for (std::map::iterator it = Tracks.begin(); it != Tracks.end(); ++it) + it->second.pending = 1; + break; } default: - chapter_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, - __FUNCTION__, command); + chapter_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command); ret = cERR_CHAPTER_MGR_ERROR; break; } diff --git a/libeplayer3/manager/manager.cpp b/libeplayer3/manager/manager.cpp index bf5b0af..a1088cf 100644 --- a/libeplayer3/manager/manager.cpp +++ b/libeplayer3/manager/manager.cpp @@ -63,16 +63,6 @@ void copyTrack(Track_t * to, Track_t * from) { *to = *from; - if (from->Name != NULL) - to->Name = strdup(from->Name); - else - to->Name = strdup("Unknown"); - - if (from->Encoding != NULL) - to->Encoding = strdup(from->Encoding); - else - to->Encoding = strdup("Unknown"); - if (from->language != NULL) to->language = strdup(from->language); else @@ -81,18 +71,6 @@ void copyTrack(Track_t * to, Track_t * from) void freeTrack(Track_t * track) { - if (track->Name != NULL) - free(track->Name); - - if (track->Encoding != NULL) - free(track->Encoding); - if (track->language != NULL) free(track->language); - -#if 0 - if (track->aacbuf != NULL) - free(track->aacbuf); -#endif - } diff --git a/libeplayer3/manager/subtitle.cpp b/libeplayer3/manager/subtitle.cpp index 422220d..0112008 100644 --- a/libeplayer3/manager/subtitle.cpp +++ b/libeplayer3/manager/subtitle.cpp @@ -23,6 +23,7 @@ #include #include +#include #include "manager.h" #include "common.h" @@ -30,7 +31,6 @@ /* ***************************** */ /* Makros/Constants */ /* ***************************** */ -#define TRACKWRAP 20 #define SUBTITLE_MGR_DEBUG @@ -64,9 +64,8 @@ static const char FILENAME[] = __FILE__; /* Varaibles */ /* ***************************** */ -static Track_t *Tracks = NULL; -static int TrackCount = 0; -static int CurrentTrack = -1; //no as default. +static std::map Tracks; +static int CurrentPid = -1; /* ***************************** */ /* Prototypes */ @@ -78,184 +77,85 @@ static int CurrentTrack = -1; //no as default. static int ManagerAdd(Context_t * context __attribute__((unused)), Track_t track) { + Tracks[track.Id] = track; + context->playback->isAudio = 1; - subtitle_mgr_printf(10, "%s::%s %s %s %d\n", FILENAME, __FUNCTION__, - track.Name, track.Encoding, track.Id); - - if (Tracks == NULL) { - Tracks = malloc(sizeof(Track_t) * TRACKWRAP); - int i; - for (i = 0; i < TRACKWRAP; i++) - Tracks[i].Id = -1; - } - - if (Tracks == NULL) { - subtitle_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__); - return cERR_SUBTITLE_MGR_ERROR; - } - - int i; - for (i = 0; i < TRACKWRAP; i++) { - if (Tracks[i].Id == track.Id) { - Tracks[i].pending = 0; - return cERR_SUBTITLE_MGR_NO_ERROR; - } - } - - if (TrackCount < TRACKWRAP) { - copyTrack(&Tracks[TrackCount], &track); - TrackCount++; - } else { - - subtitle_mgr_err("%s:%s TrackCount out if range %d - %d\n", - FILENAME, __FUNCTION__, TrackCount, TRACKWRAP); - return cERR_SUBTITLE_MGR_ERROR; - } - - subtitle_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); - - return cERR_SUBTITLE_MGR_NO_ERROR; + return cERR_SUBTITLE_MGR_NO_ERROR; } static char **ManagerList(Context_t * context __attribute__ ((unused))) { - char **tracklist = NULL; - int i = 0, j = 0; + int j = 0; + char **tracklist = (char **) malloc(sizeof(char *) * ((Tracks.size() * 2) + 1)); - subtitle_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); - - if (Tracks != NULL) { - tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1)); - - if (tracklist == NULL) { - subtitle_mgr_err("%s:%s malloc failed\n", FILENAME, - __FUNCTION__); - return NULL; + for(std::map::iterator it = Tracks.begin(); it != Tracks.end(); ++it) + { + size_t len = it->second.Name.length() + 20; + char tmp[len]; + snprintf(tmp, len, "%d %s\n", it->second.Id, it->second.Name.c_str()); + tracklist[j] = strdup(tmp); + tracklist[j + 1] = strdup(it->second.Encoding); } - - for (i = 0, j = 0; i < TrackCount; i++, j += 2) { - if (Tracks[i].pending) - continue; - size_t len = strlen(Tracks[i].Name) + 20; - char tmp[len]; - snprintf(tmp, len, "%d %s\n", Tracks[i].Id, Tracks[i].Name); - tracklist[j] = strdup(tmp); - tracklist[j + 1] = strdup(Tracks[i].Encoding); - } - tracklist[j] = NULL; - } - - subtitle_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME, - __FUNCTION__, tracklist, j, TrackCount); return tracklist; } static int ManagerDel(Context_t * context __attribute__((unused))) { - - int i = 0; - - subtitle_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); - - if (Tracks != NULL) { - for (i = 0; i < TrackCount; i++) { - freeTrack(&Tracks[i]); - } - - free(Tracks); - Tracks = NULL; - } else { - subtitle_mgr_err("%s::%s nothing to delete!\n", FILENAME, - __FUNCTION__); - return cERR_SUBTITLE_MGR_ERROR; - } - - TrackCount = 0; - CurrentTrack = -1; - - subtitle_mgr_printf(10, "%s::%s return no error\n", FILENAME, - __FUNCTION__); - - return cERR_SUBTITLE_MGR_NO_ERROR; + Tracks.clear(); + CurrentPid = -1; + return cERR_SUBTITLE_MGR_NO_ERROR; } static int Command(Context_t *context, ManagerCmd_t command, void *argument) { int ret = cERR_SUBTITLE_MGR_NO_ERROR; - subtitle_mgr_printf(50, "%s::%s %d\n", FILENAME, __FUNCTION__, - command); + subtitle_mgr_printf(50, "%s::%s %d\n", FILENAME, __FUNCTION__, command); switch (command) { case MANAGER_ADD:{ - Track_t *track = argument; + Track_t *track = (Track_t *) argument; ret = ManagerAdd(context, *track); break; } case MANAGER_LIST:{ - container_ffmpeg_update_tracks(context, context->playback->uri); + container_ffmpeg_update_tracks(context, context->playback->uri.c_str()); *((char ***) argument) = (char **) ManagerList(context); break; } case MANAGER_GET:{ - if (TrackCount > 0 && CurrentTrack >= 0) - *((int *) argument) = (int) Tracks[CurrentTrack].Id; - else - *((int *) argument) = (int) -1; + *((int *) argument) = (int) CurrentPid; break; } case MANAGER_GET_TRACK:{ - //subtitle_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME, __FUNCTION__); - - if ((TrackCount > 0) && (CurrentTrack >= 0)) { - subtitle_mgr_printf(120, "return %d, %p\n", CurrentTrack, - &Tracks[CurrentTrack]); - *((Track_t **) argument) = - (Track_t *) & Tracks[CurrentTrack]; - } else { - subtitle_mgr_printf(20, "return NULL\n"); - *((Track_t **) argument) = NULL; - } + if (CurrentPid > -1) + *((Track_t **) argument) = &Tracks[CurrentPid]; + else + *((Track_t **) argument) = NULL; break; } case MANAGER_GETENCODING:{ - if (TrackCount > 0 && CurrentTrack >= 0) - *((char **) argument) = - (char *) strdup(Tracks[CurrentTrack].Encoding); - else - *((char **) argument) = (char *) strdup(""); - break; + if (CurrentPid > -1) + *((char **) argument) = strdup(Tracks[CurrentPid].Encoding); + else + *((char **) argument) = strdup(""); + break; } case MANAGER_GETNAME:{ - if (TrackCount > 0 && CurrentTrack >= 0) - *((char **) argument) = - (char *) strdup(Tracks[CurrentTrack].Name); - else - *((char **) argument) = (char *) strdup(""); - break; + if (CurrentPid > -1) + *((char **) argument) = strdup(Tracks[CurrentPid].Name.c_str()); + else + *((char **) argument) = strdup(""); + break; } case MANAGER_SET:{ - int i; - subtitle_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME, - __FUNCTION__, *((int *) argument)); - - if (*((int *) argument) < 0) { - CurrentTrack = -1; - break; - } - - for (i = 0; i < TrackCount; i++) - if (Tracks[i].Id == *((int *) argument)) { - CurrentTrack = i; - break; - } - if (i == TrackCount) { - subtitle_mgr_err("%s::%s track id %d unknown\n", FILENAME, - __FUNCTION__, *((int *) argument)); - ret = cERR_SUBTITLE_MGR_ERROR; - } + std::map::iterator it = Tracks.find(*((int *) argument)); + if (it != Tracks.end()) + CurrentPid = *((int *) argument); + else + ret = cERR_SUBTITLE_MGR_ERROR; break; } case MANAGER_DEL:{ @@ -263,21 +163,17 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) break; } case MANAGER_INIT_UPDATE:{ - int i; - for (i = 0; i < TrackCount; i++) - if (!Tracks[i].is_static) - Tracks[i].pending = 1; + for (std::map::iterator it = Tracks.begin(); it != Tracks.end(); ++it) + it->second.pending = 1; break; } default: - subtitle_mgr_err("%s:%s: ConatinerCmd not supported!", FILENAME, - __FUNCTION__); + subtitle_mgr_err("%s:%s: ConatinerCmd not supported!", FILENAME, __FUNCTION__); ret = cERR_SUBTITLE_MGR_ERROR; break; } - subtitle_mgr_printf(50, "%s:%s: returning %d\n", FILENAME, - __FUNCTION__, ret); + subtitle_mgr_printf(50, "%s:%s: returning %d\n", FILENAME, __FUNCTION__, ret); return ret; } diff --git a/libeplayer3/manager/teletext.cpp b/libeplayer3/manager/teletext.cpp index 6a73960..2f2922f 100644 --- a/libeplayer3/manager/teletext.cpp +++ b/libeplayer3/manager/teletext.cpp @@ -23,15 +23,14 @@ #include #include +#include -#include #include "manager.h" #include "common.h" /* ***************************** */ /* Makros/Constants */ /* ***************************** */ -#define TRACKWRAP 20 #define TELETEXT_MGR_DEBUG @@ -65,9 +64,8 @@ static const char FILENAME[] = __FILE__; /* Varaibles */ /* ***************************** */ -static Track_t *Tracks = NULL; -static int TrackCount = 0; -static int CurrentTrack = -1; +static std::map Tracks; +static int CurrentPid = -1; /* ***************************** */ /* Prototypes */ @@ -79,106 +77,35 @@ static int CurrentTrack = -1; static int ManagerAdd(Context_t * context __attribute__((unused)), Track_t track) { + Tracks[track.Id] = track; + context->playback->isAudio = 1; - teletext_mgr_printf(10, "%s::%s name=\"%s\" encoding=\"%s\" id=%d\n", - FILENAME, __FUNCTION__, track.Name, track.Encoding, - track.Id); - - if (Tracks == NULL) { - Tracks = malloc(sizeof(Track_t) * TRACKWRAP); - int i; - for (i = 0; i < TRACKWRAP; i++) - Tracks[i].Id = -1; - } - - if (Tracks == NULL) { - teletext_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__); - return cERR_TELETEXT_MGR_ERROR; - } - - int i; - for (i = 0; i < TRACKWRAP; i++) { - if (Tracks[i].Id == track.Id) { - Tracks[i].pending = 0; - return cERR_TELETEXT_MGR_NO_ERROR; - } - } - - if (TrackCount < TRACKWRAP) { - copyTrack(&Tracks[TrackCount], &track); - TrackCount++; - } else { - teletext_mgr_err("%s:%s TrackCount out if range %d - %d\n", - FILENAME, __FUNCTION__, TrackCount, TRACKWRAP); - return cERR_TELETEXT_MGR_ERROR; - } - - teletext_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); - - return cERR_TELETEXT_MGR_NO_ERROR; + return cERR_TELETEXT_MGR_NO_ERROR; } static char **ManagerList(Context_t * context __attribute__ ((unused))) { - int i = 0, j = 0; - char **tracklist = NULL; + int j = 0; + char **tracklist = (char **) malloc(sizeof(char *) * ((Tracks.size() * 2) + 1)); - teletext_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); - - if (Tracks != NULL) { - - tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1)); - - if (tracklist == NULL) { - teletext_mgr_err("%s:%s malloc failed\n", FILENAME, - __FUNCTION__); - return NULL; - } - - for (i = 0, j = 0; i < TrackCount; i++, j += 2) { - if (Tracks[i].pending) - continue; - size_t len = strlen(Tracks[i].Name) + 20; - char tmp[len]; - snprintf(tmp, len, "%d %s\n", Tracks[i].Id, Tracks[i].Name); - tracklist[j] = strdup(tmp); - tracklist[j + 1] = strdup(Tracks[i].Encoding); + for(std::map::iterator it = Tracks.begin(); it != Tracks.end(); ++it) + { + size_t len = it->second.Name.length() + 20; + char tmp[len]; + snprintf(tmp, len, "%d %s\n", it->second.Id, it->second.Name.c_str()); + tracklist[j] = strdup(tmp); + tracklist[j + 1] = strdup(it->second.Encoding); } tracklist[j] = NULL; - } - - teletext_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME, - __FUNCTION__, tracklist, j, TrackCount); return tracklist; } static int ManagerDel(Context_t * context __attribute__((unused))) { - - int i = 0; - - teletext_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); - - if (Tracks != NULL) { - for (i = 0; i < TrackCount; i++) { - freeTrack(&Tracks[i]); - } - free(Tracks); - Tracks = NULL; - } else { - teletext_mgr_err("%s::%s nothing to delete!\n", FILENAME, - __FUNCTION__); - return cERR_TELETEXT_MGR_ERROR; - } - - TrackCount = 0; - CurrentTrack = -1; - - teletext_mgr_printf(10, "%s::%s return no error\n", FILENAME, - __FUNCTION__); - - return cERR_TELETEXT_MGR_NO_ERROR; + Tracks.clear(); + CurrentPid = -1; + return cERR_TELETEXT_MGR_NO_ERROR; } @@ -190,69 +117,46 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) switch (command) { case MANAGER_ADD:{ - Track_t *track = argument; - + Track_t *track = (Track_t *) argument; ret = ManagerAdd(context, *track); break; } case MANAGER_LIST:{ - container_ffmpeg_update_tracks(context, context->playback->uri); + container_ffmpeg_update_tracks(context, context->playback->uri.c_str()); *((char ***) argument) = (char **) ManagerList(context); break; } case MANAGER_GET:{ - teletext_mgr_printf(20, "%s::%s MANAGER_GET\n", FILENAME, - __FUNCTION__); - - if ((TrackCount > 0) && (CurrentTrack >= 0)) - *((int *) argument) = (int) Tracks[CurrentTrack].Id; - else - *((int *) argument) = (int) -1; + *((int *) argument) = (int) CurrentPid; break; } case MANAGER_GET_TRACK:{ - teletext_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME, - __FUNCTION__); - - if ((TrackCount > 0) && (CurrentTrack >= 0)) - *((Track_t **) argument) = - (Track_t *) & Tracks[CurrentTrack]; + if (CurrentPid > -1) + *((Track_t **) argument) = &Tracks[CurrentPid]; else *((Track_t **) argument) = NULL; break; } case MANAGER_GETENCODING:{ - if ((TrackCount > 0) && (CurrentTrack >= 0)) - *((char **) argument) = - (char *) strdup(Tracks[CurrentTrack].Encoding); + if (CurrentPid > -1) + *((char **) argument) = strdup(Tracks[CurrentPid].Encoding); else - *((char **) argument) = (char *) strdup(""); + *((char **) argument) = strdup(""); break; } case MANAGER_GETNAME:{ - if ((TrackCount > 0) && (CurrentTrack >= 0)) - *((char **) argument) = - (char *) strdup(Tracks[CurrentTrack].Name); - else - *((char **) argument) = (char *) strdup(""); - break; + if (CurrentPid > -1) + *((char **) argument) = strdup(Tracks[CurrentPid].Name.c_str()); + else + *((char **) argument) = strdup(""); + break; } case MANAGER_SET:{ - int i; - teletext_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME, - __FUNCTION__, *((int *) argument)); - - for (i = 0; i < TrackCount; i++) - if (Tracks[i].Id == *((int *) argument)) { - CurrentTrack = i; - break; - } - - if (i == TrackCount) { - teletext_mgr_err("%s::%s track id %d unknown\n", FILENAME, - __FUNCTION__, *((int *) argument)); + std::map::iterator it = Tracks.find(*((int *) argument)); + if (it != Tracks.end()) + CurrentPid = *((int *) argument); + else ret = cERR_TELETEXT_MGR_ERROR; - } break; } case MANAGER_DEL:{ @@ -260,20 +164,17 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) break; } case MANAGER_INIT_UPDATE:{ - int i; - for (i = 0; i < TrackCount; i++) - Tracks[i].pending = 1; + for (std::map::iterator it = Tracks.begin(); it != Tracks.end(); ++it) + it->second.pending = 1; break; } default: - teletext_mgr_err("%s::%s ContainerCmd %d not supported!\n", - FILENAME, __FUNCTION__, command); + teletext_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command); ret = cERR_TELETEXT_MGR_ERROR; break; } - teletext_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, - __FUNCTION__, ret); + teletext_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__, ret); return ret; } diff --git a/libeplayer3/manager/video.cpp b/libeplayer3/manager/video.cpp index 75b6632..d56f49f 100644 --- a/libeplayer3/manager/video.cpp +++ b/libeplayer3/manager/video.cpp @@ -23,6 +23,7 @@ #include #include +#include #include "manager.h" #include "common.h" @@ -30,7 +31,6 @@ /* ***************************** */ /* Makros/Constants */ /* ***************************** */ -#define TRACKWRAP 4 #define VIDEO_MGR_DEBUG @@ -64,9 +64,8 @@ static const char FILENAME[] = __FILE__; /* Varaibles */ /* ***************************** */ -static Track_t *Tracks = NULL; -static int TrackCount = 0; -static int CurrentTrack = 0; //TRACK[0] as default. +static std::map Tracks; +static int CurrentPid = -1; /* ***************************** */ /* Prototypes */ @@ -78,106 +77,39 @@ static int CurrentTrack = 0; //TRACK[0] as default. static int ManagerAdd(Context_t * context, Track_t track) { - video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); - - if (Tracks == NULL) { - Tracks = malloc(sizeof(Track_t) * TRACKWRAP); - int i; - for (i = 0; i < TRACKWRAP; i++) - Tracks[i].Id = -1; - } - - if (Tracks == NULL) { - video_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__); - return cERR_VIDEO_MGR_ERROR; - } - - int i; - for (i = 0; i < TRACKWRAP; i++) { - if (Tracks[i].Id == track.Id) { - Tracks[i].pending = 0; - return cERR_VIDEO_MGR_NO_ERROR; - } - } - - if (TrackCount < TRACKWRAP) { - copyTrack(&Tracks[TrackCount], &track); - - TrackCount++; - } else { - video_mgr_err("%s:%s TrackCount out if range %d - %d\n", FILENAME, - __FUNCTION__, TrackCount, TRACKWRAP); - return cERR_VIDEO_MGR_ERROR; - } - - if (TrackCount > 0) + Tracks[track.Id] = track; context->playback->isVideo = 1; - video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); + if (CurrentPid < 0) + CurrentPid = track.Id; - return cERR_VIDEO_MGR_NO_ERROR; + return cERR_VIDEO_MGR_NO_ERROR; } static char **ManagerList(Context_t * context __attribute__ ((unused))) { - int i = 0, j = 0; - char **tracklist = NULL; + int j = 0; + char **tracklist = (char **) malloc(sizeof(char *) * ((Tracks.size() * 2) + 1)); - video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); - - if (Tracks != NULL) { - - tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1)); - - if (tracklist == NULL) { - video_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__); - return NULL; - } - - for (i = 0, j = 0; i < TrackCount; i++, j += 2) { - if (Tracks[i].pending) - continue; - size_t len = strlen(Tracks[i].Name) + 20; - char tmp[len]; - snprintf(tmp, len, "%d %s\n", Tracks[i].Id, Tracks[i].Name); - tracklist[j] = strdup(tmp); - tracklist[j + 1] = strdup(Tracks[i].Encoding); + for(std::map::iterator it = Tracks.begin(); it != Tracks.end(); ++it) + { + size_t len = it->second.Name.length() + 20; + char tmp[len]; + snprintf(tmp, len, "%d %s\n", it->second.Id, it->second.Name.c_str()); + tracklist[j] = strdup(tmp); + tracklist[j + 1] = strdup(it->second.Encoding); } tracklist[j] = NULL; - } - - video_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME, - __FUNCTION__, tracklist, j, TrackCount); return tracklist; } static int ManagerDel(Context_t * context) { - int i = 0; - - video_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); - - if (Tracks != NULL) { - for (i = 0; i < TrackCount; i++) { - freeTrack(&Tracks[i]); - } - free(Tracks); - Tracks = NULL; - } else { - video_mgr_err("%s::%s nothing to delete!\n", FILENAME, - __FUNCTION__); - return cERR_VIDEO_MGR_ERROR; - } - - TrackCount = 0; - CurrentTrack = 0; - context->playback->isVideo = 0; - - video_mgr_printf(10, "%s::%s return no error\n", FILENAME, - __FUNCTION__); - - return cERR_VIDEO_MGR_NO_ERROR; + Tracks.clear(); + CurrentPid = -1; + context->playback->isAudio = 0; + return cERR_VIDEO_MGR_NO_ERROR; } static int Command(Context_t *context, ManagerCmd_t command, void *argument) @@ -188,63 +120,46 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) switch (command) { case MANAGER_ADD:{ - Track_t *track = argument; + Track_t *track = (Track_t *)argument; ret = ManagerAdd(context, *track); break; } case MANAGER_LIST:{ - container_ffmpeg_update_tracks(context, context->playback->uri); + container_ffmpeg_update_tracks(context, context->playback->uri.c_str()); *((char ***) argument) = (char **) ManagerList(context); break; } case MANAGER_GET:{ - if ((TrackCount > 0) && (CurrentTrack >= 0)) - *((int *) argument) = (int) Tracks[CurrentTrack].Id; - else - *((int *) argument) = (int) -1; - break; + *((int *) argument) = (int) CurrentPid; + break; } case MANAGER_GET_TRACK:{ - video_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME, - __FUNCTION__); - - if ((TrackCount > 0) && (CurrentTrack >= 0)) - *((Track_t **) argument) = - (Track_t *) & Tracks[CurrentTrack]; + if (CurrentPid > -1) + *((Track_t **) argument) = &Tracks[CurrentPid]; else *((Track_t **) argument) = NULL; break; } case MANAGER_GETENCODING:{ - if ((TrackCount > 0) && (CurrentTrack >= 0)) - *((char **) argument) = - (char *) strdup(Tracks[CurrentTrack].Encoding); + if (CurrentPid > -1) + *((char **) argument) = strdup(Tracks[CurrentPid].Encoding); else - *((char **) argument) = (char *) strdup(""); + *((char **) argument) = strdup(""); break; } case MANAGER_GETNAME:{ - if ((TrackCount > 0) && (CurrentTrack >= 0)) - *((char **) argument) = - (char *) strdup(Tracks[CurrentTrack].Name); + if (CurrentPid > -1) + *((char **) argument) = strdup(Tracks[CurrentPid].Name.c_str()); else - *((char **) argument) = (char *) strdup(""); + *((char **) argument) = strdup(""); break; } case MANAGER_SET:{ - int i; - - for (i = 0; i < TrackCount; i++) - if (Tracks[i].Id == *((int *) argument)) { - CurrentTrack = i; - break; - } - - if (i == TrackCount) { - video_mgr_err("%s::%s track id %d unknown\n", FILENAME, - __FUNCTION__, *((int *) argument)); - ret = cERR_VIDEO_MGR_ERROR; - } + std::map::iterator it = Tracks.find(*((int *) argument)); + if (it != Tracks.end()) + CurrentPid = *((int *) argument); + else + ret = cERR_VIDEO_MGR_ERROR; break; } case MANAGER_DEL:{ @@ -252,20 +167,17 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) break; } case MANAGER_INIT_UPDATE:{ - int i; - for (i = 0; i < TrackCount; i++) - Tracks[i].pending = 1; + for (std::map::iterator it = Tracks.begin(); it != Tracks.end(); ++it) + it->second.pending = 1; break; } default: - video_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, - __FUNCTION__, command); + video_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command); ret = cERR_VIDEO_MGR_ERROR; break; } - video_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__, - ret); + video_mgr_printf(10, "%s:%s: returning %d\n", FILENAME, __FUNCTION__, ret); return ret; } diff --git a/libeplayer3/output/linuxdvb.cpp b/libeplayer3/output/linuxdvb.cpp index bb16b83..01d94cd 100644 --- a/libeplayer3/output/linuxdvb.cpp +++ b/libeplayer3/output/linuxdvb.cpp @@ -1040,7 +1040,7 @@ static int reset(Context_t * context) return ret; } -static int Command(Context_t *context, OutputCmd_t command, void *argument) +static int Command(Context_t *context, OutputCmd_t command, const char *argument) { int ret = cERR_LINUXDVB_NO_ERROR; @@ -1141,7 +1141,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) return ret; } -static char *LinuxDvbCapabilities[] = { "audio", "video", NULL }; +static const char *LinuxDvbCapabilities[] = { "audio", "video", NULL }; struct Output_s LinuxDvbOutput = { "LinuxDvb", diff --git a/libeplayer3/output/output.cpp b/libeplayer3/output/output.cpp index 316a774..400e94e 100644 --- a/libeplayer3/output/output.cpp +++ b/libeplayer3/output/output.cpp @@ -127,7 +127,7 @@ static void OutputDel(Context_t * context, char *port) } -static int Command(Context_t *context, OutputCmd_t command, void *argument) +static int Command(Context_t *context, OutputCmd_t command, const char *argument) { int ret = cERR_OUTPUT_NO_ERROR; @@ -264,9 +264,9 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) case OUTPUT_PTS:{ if (context && context->playback) { if (context->playback->isVideo) - return context->output->video->Command(context, OUTPUT_PTS, argument); + return context->output->video->Command(context, OUTPUT_PTS, (const char *) argument); if (context->playback->isAudio) - return context->output->audio->Command(context, OUTPUT_PTS, argument); + return context->output->audio->Command(context, OUTPUT_PTS, (const char *) argument); } else ret = cERR_OUTPUT_INTERNAL_ERROR; break; @@ -296,7 +296,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) case OUTPUT_AUDIOMUTE:{ if (context && context->playback) { if (context->playback->isAudio) - ret |= context->output->audio->Command(context, OUTPUT_AUDIOMUTE, (char *) argument); + ret |= context->output->audio->Command(context, OUTPUT_AUDIOMUTE, (const char *) argument); } else ret = cERR_OUTPUT_INTERNAL_ERROR; break; @@ -304,7 +304,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) case OUTPUT_DISCONTINUITY_REVERSE:{ if (context && context->playback) { if (context->playback->isVideo) - ret |= context->output->video->Command(context, OUTPUT_DISCONTINUITY_REVERSE, (void *) argument); + ret |= context->output->video->Command(context, OUTPUT_DISCONTINUITY_REVERSE, (const char *) argument); } else ret = cERR_OUTPUT_INTERNAL_ERROR; break; @@ -312,9 +312,9 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument) case OUTPUT_GET_FRAME_COUNT:{ if (context && context->playback) { if (context->playback->isVideo) - return context->output->video->Command(context, OUTPUT_GET_FRAME_COUNT, argument); + return context->output->video->Command(context, OUTPUT_GET_FRAME_COUNT, (const char *)argument); if (context->playback->isAudio) - return context->output->audio->Command(context, OUTPUT_GET_FRAME_COUNT, argument); + return context->output->audio->Command(context, OUTPUT_GET_FRAME_COUNT, (const char *)argument); } else ret = cERR_OUTPUT_INTERNAL_ERROR; break; diff --git a/libeplayer3/output/writer/h264.cpp b/libeplayer3/output/writer/h264.cpp index 3a845c8..9ce4064 100644 --- a/libeplayer3/output/writer/h264.cpp +++ b/libeplayer3/output/writer/h264.cpp @@ -163,7 +163,7 @@ static int writeData(WriterAVCallData_t *call) /*Hellmaster1024: some packets will only be accepted by the player if we send one byte more than data is available. The content of this byte does not matter. It will be ignored by the player */ - iov[ic].iov_base = ""; + iov[ic].iov_base = (char *) ""; iov[ic++].iov_len = 1; iov[0].iov_len = InsertPesHeader(PesHeader, PacketLength, diff --git a/libeplayer3/output/writer/wmv.cpp b/libeplayer3/output/writer/wmv.cpp index 5f16315..3615a1e 100644 --- a/libeplayer3/output/writer/wmv.cpp +++ b/libeplayer3/output/writer/wmv.cpp @@ -243,7 +243,7 @@ static int writeData(WriterAVCallData_t *call) insertSampleHeader = 0; } - PacketStart = malloc(call->len + HeaderLength); + PacketStart = (unsigned char *) malloc(call->len + HeaderLength); memcpy(PacketStart, PesHeader, HeaderLength); memcpy(PacketStart + HeaderLength, call->data + Position, PacketLength); diff --git a/libeplayer3/playback/playback.cpp b/libeplayer3/playback/playback.cpp index a2ce672..e0b2801 100644 --- a/libeplayer3/playback/playback.cpp +++ b/libeplayer3/playback/playback.cpp @@ -71,8 +71,9 @@ static int PlaybackTerminate(Context_t * context); /* Supervisor Thread */ /* **************************** */ -static void SupervisorThread(Context_t * context) +static void *SupervisorThread(void *arg) { + Context_t *context = (Context_t *) arg; hasThreadStarted = 1; playback_printf(10, ">\n"); @@ -88,6 +89,7 @@ static void SupervisorThread(Context_t * context) playback_printf(0, "terminating\n"); hasThreadStarted = 0; + pthread_exit(NULL); } /* ***************************** */ @@ -108,44 +110,32 @@ static int PlaybackOpen(Context_t * context, char *uri) return cERR_PLAYBACK_ERROR; } - char *extension = NULL; - - context->playback->uri = strdup(uri); - context->playback->isHttp = 0; if (!strncmp("file://", uri, 7) || !strncmp("myts://", uri, 7)) { if (!strncmp("myts://", uri, 7)) { - memcpy(context->playback->uri, "file", 4); + context->playback->uri = "file"; + context->playback->uri += (uri + 4); context->playback->noprobe = 1; - } else + } else { context->playback->noprobe = 0; - - extension = getExtension(context->playback->uri + 7); - if (!extension) - return cERR_PLAYBACK_ERROR; + context->playback->uri = uri; + } } else if (strstr(uri, "://")) { context->playback->isHttp = 1; - extension = "mp3"; if (!strncmp("mms://", uri, 6)) { - // mms is in reality called rtsp, and ffmpeg expects this - char *tUri = (char *) malloc(strlen(uri) + 2); - strncpy(tUri + 1, uri, strlen(uri) + 1); - strncpy(tUri, "mmst", 4); - free(context->playback->uri); - context->playback->uri = tUri; - } + context->playback->uri = "mmst"; + context->playback->uri += (uri + 3); + } else + context->playback->uri = uri; } else { playback_err("Unknown stream (%s)\n", uri); return cERR_PLAYBACK_ERROR; } - if ((context->container->Command(context, CONTAINER_ADD, extension) < - 0) + if ((context->container->Command(context, CONTAINER_ADD, NULL) < 0) || (!context->container->selectedContainer) - || (context->container-> - selectedContainer->Command(context, CONTAINER_INIT, - context->playback->uri) < 0)) + || (context->container->selectedContainer->Command(context, CONTAINER_INIT, context->playback->uri.c_str()) < 0)) return cERR_PLAYBACK_ERROR; playback_printf(10, "exiting with value 0\n"); @@ -175,10 +165,7 @@ static int PlaybackClose(Context_t * context) context->playback->BackWard = 0; context->playback->SlowMotion = 0; context->playback->Speed = 0; - if (context->playback->uri) { - free(context->playback->uri); - context->playback->uri = NULL; - } + context->playback->uri.clear(); playback_printf(10, "exiting with value %d\n", ret); @@ -222,9 +209,7 @@ static int PlaybackPlay(Context_t * context) PTHREAD_CREATE_DETACHED); if ((error = - pthread_create(&supervisorThread, &attr, - (void *) &SupervisorThread, - context)) != 0) { + pthread_create(&supervisorThread, &attr, SupervisorThread, context)) != 0) { playback_printf(10, "Error creating thread, error:%d:%s\n", error, strerror(error)); @@ -557,9 +542,9 @@ static int PlaybackSeek(Context_t * context, float *pos, int absolute) context->output->Command(context, OUTPUT_CLEAR, NULL); if (absolute) - context->container->selectedContainer->Command(context, CONTAINER_SEEK_ABS, pos); + context->container->selectedContainer->Command(context, CONTAINER_SEEK_ABS, (const char *)pos); else - context->container->selectedContainer->Command(context, CONTAINER_SEEK, pos); + context->container->selectedContainer->Command(context, CONTAINER_SEEK, (const char *)pos); playback_printf(10, "exiting with value %d\n", ret); @@ -575,7 +560,7 @@ static int PlaybackPts(Context_t * context, unsigned long long int *pts) *pts = 0; if (context->playback->isPlaying) { - ret = context->output->Command(context, OUTPUT_PTS, pts); + ret = context->output->Command(context, OUTPUT_PTS, (const char *)pts); } else { playback_err("not possible\n"); ret = cERR_PLAYBACK_ERROR; @@ -598,7 +583,7 @@ static int PlaybackGetFrameCount(Context_t * context, if (context->playback->isPlaying) { ret = context->output->Command(context, OUTPUT_GET_FRAME_COUNT, - frameCount); + (const char *)frameCount); } else { playback_err("not possible\n"); ret = cERR_PLAYBACK_ERROR; @@ -621,7 +606,7 @@ static int PlaybackLength(Context_t * context, double *length) if (context->container && context->container->selectedContainer) context->container->selectedContainer->Command(context, CONTAINER_LENGTH, - length); + (const char *)length); } else { playback_err("not possible\n"); ret = cERR_PLAYBACK_ERROR; @@ -654,14 +639,11 @@ static int PlaybackSwitchAudio(Context_t * context, int *track) //PlaybackPause(context); if (context->output && context->output->audio) - context->output->audio->Command(context, OUTPUT_SWITCH, - (void *) "audio"); + context->output->audio->Command(context, OUTPUT_SWITCH, "audio"); if (context->container && context->container->selectedContainer) - context->container->selectedContainer->Command(context, - CONTAINER_SWITCH_AUDIO, - &nextrackid); + context->container->selectedContainer->Command(context, CONTAINER_SWITCH_AUDIO, (const char *)&nextrackid); //PlaybackContinue(context); } @@ -722,7 +704,7 @@ static int PlaybackSwitchTeletext(Context_t * context, int *pid) playback_err("no ttxsubtitle\n"); if (*pid < 0) - container_ffmpeg_update_tracks(context, context->playback->uri); + container_ffmpeg_update_tracks(context, context->playback->uri.c_str()); playback_printf(10, "exiting with value %d\n", ret); @@ -736,7 +718,7 @@ static int PlaybackMetadata(Context_t * context, char ***metadata) if (context->container && context->container->selectedContainer) context->container->selectedContainer->Command(context, CONTAINER_METADATA, - metadata); + (const char *)metadata); return ret; } diff --git a/libspark/playback_libeplayer3.cpp b/libspark/playback_libeplayer3.cpp index 3ebdedb..a0b2abc 100644 --- a/libspark/playback_libeplayer3.cpp +++ b/libspark/playback_libeplayer3.cpp @@ -64,8 +64,8 @@ bool cPlayback::Open(playmode_t PlayMode) //Registration of output devices if(player && player->output) { - player->output->Command(player,OUTPUT_ADD, (void*)"audio"); - player->output->Command(player,OUTPUT_ADD, (void*)"video"); + player->output->Command(player,OUTPUT_ADD, "audio"); + player->output->Command(player,OUTPUT_ADD, "video"); } return 0; @@ -246,8 +246,8 @@ bool cPlayback::Stop(void) player->output->Command(player, OUTPUT_CLOSE, NULL); if(player && player->output) { - player->output->Command(player,OUTPUT_DEL, (void*)"audio"); - player->output->Command(player,OUTPUT_DEL, (void*)"video"); + player->output->Command(player,OUTPUT_DEL, "audio"); + player->output->Command(player,OUTPUT_DEL, "video"); } if(player && player->playback)