[libarmbox] libeplayer3-arm code format

Origin commit data
------------------
Branch: master
Commit: c49f9bebba
Author: max_10 <max_10@gmx.de>
Date: 2018-08-30 (Thu, 30 Aug 2018)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
max_10
2018-08-30 14:05:36 +02:00
parent 934dadbfd4
commit 7553673d40
15 changed files with 138 additions and 90 deletions

View File

@@ -105,6 +105,7 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
#define cERR_CONTAINER_FFMPEG_END_OF_FILE -10 #define cERR_CONTAINER_FFMPEG_END_OF_FILE -10
#define IPTV_AV_CONTEXT_MAX_NUM 2 #define IPTV_AV_CONTEXT_MAX_NUM 2
/* ***************************** */ /* ***************************** */
/* Types */ /* Types */
/* ***************************** */ /* ***************************** */
@@ -548,8 +549,7 @@ static void FFMPEGThread(Context_t *context)
threadname[16] = 0; threadname[16] = 0;
prctl(PR_SET_NAME, (unsigned long)&threadname); prctl(PR_SET_NAME, (unsigned long)&threadname);
AVPacket packet; AVPacket packet;
//off_t lastSeek = -1;
//int64_t lastPts = -1;
int64_t currentVideoPts = -1; int64_t currentVideoPts = -1;
int64_t currentAudioPts = -1; int64_t currentAudioPts = -1;
@@ -561,7 +561,6 @@ static void FFMPEGThread(Context_t *context)
int64_t showtime = 0; int64_t showtime = 0;
int64_t bofcount = 0; int64_t bofcount = 0;
//int32_t err = 0;
AudioVideoOut_t avOut; AudioVideoOut_t avOut;
g_context = context; g_context = context;
@@ -583,13 +582,14 @@ static void FFMPEGThread(Context_t *context)
memset(&flv2mpeg4_context, 0, sizeof(Flv2Mpeg4Context)); memset(&flv2mpeg4_context, 0, sizeof(Flv2Mpeg4Context));
#endif #endif
ffmpeg_printf(10, "\n"); ffmpeg_printf(10, "\n");
while (context->playback->isCreationPhase) while (context->playback->isCreationPhase)
{ {
ffmpeg_printf(10, "Thread waiting for end of init phase...\n"); ffmpeg_printf(10, "Thread waiting for end of init phase...\n");
usleep(1000); usleep(1000);
} }
ffmpeg_printf(10, "Running!\n"); ffmpeg_printf(10, "Running!\n");
#ifdef __sh__ #ifdef __sh__
uint32_t bufferSize = 0; uint32_t bufferSize = 0;
context->output->Command(context, OUTPUT_GET_BUFFER_SIZE, &bufferSize); context->output->Command(context, OUTPUT_GET_BUFFER_SIZE, &bufferSize);
@@ -597,6 +597,7 @@ static void FFMPEGThread(Context_t *context)
#endif #endif
int8_t isWaitingForFinish = 0; int8_t isWaitingForFinish = 0;
while (context && context->playback && context->playback->isPlaying) while (context && context->playback && context->playback->isPlaying)
{ {
/* When user press PAUSE we call pause on AUDIO and VIDEO decoders, /* When user press PAUSE we call pause on AUDIO and VIDEO decoders,
@@ -636,19 +637,24 @@ static void FFMPEGThread(Context_t *context)
} }
continue; continue;
} }
if (context->playback->BackWard && av_gettime() >= showtime) {
if (context->playback->BackWard && av_gettime() >= showtime)
{
context->output->Command(context, OUTPUT_CLEAR, "video"); context->output->Command(context, OUTPUT_CLEAR, "video");
if (bofcount == 1) { if (bofcount == 1)
showtime = av_gettime(); {
usleep(100000); showtime = av_gettime();
continue; usleep(100000);
continue;
} }
if (avContextTab[0]->iformat->flags & AVFMT_TS_DISCONT) { if (avContextTab[0]->iformat->flags & AVFMT_TS_DISCONT)
{
off_t pos = avio_tell(avContextTab[0]->pb); off_t pos = avio_tell(avContextTab[0]->pb);
if (pos > 0) { if (pos > 0)
{
float br; float br;
if (avContextTab[0]->bit_rate) if (avContextTab[0]->bit_rate)
br = avContextTab[0]->bit_rate / 8.0; br = avContextTab[0]->bit_rate / 8.0;
@@ -669,7 +675,7 @@ static void FFMPEGThread(Context_t *context)
seek_target_seconds = AV_TIME_BASE; seek_target_seconds = AV_TIME_BASE;
do_seek_target_seconds = 1; do_seek_target_seconds = 1;
} }
showtime = av_gettime() + 300000; //jump back every 300ms showtime = av_gettime() + 300000; //jump back every 300ms
} }
else else
{ {
@@ -770,15 +776,16 @@ static void FFMPEGThread(Context_t *context)
if (!isWaitingForFinish && (ffmpegStatus = av_read_frame(avContextTab[cAVIdx], &packet)) == 0) if (!isWaitingForFinish && (ffmpegStatus = av_read_frame(avContextTab[cAVIdx], &packet)) == 0)
{ {
int64_t pts = 0; int64_t pts = 0;
int64_t dts = 0; int64_t dts = 0;
Track_t *videoTrack = NULL; Track_t *videoTrack = NULL;
Track_t *audioTrack = NULL; Track_t *audioTrack = NULL;
Track_t *subtitleTrack = NULL; Track_t *subtitleTrack = NULL;
int32_t pid = avContextTab[cAVIdx]->streams[packet.stream_index]->id; int32_t pid = avContextTab[cAVIdx]->streams[packet.stream_index]->id;
reset_finish_timeout(); reset_finish_timeout();
if (avContextTab[cAVIdx]->streams[packet.stream_index]->discard != AVDISCARD_ALL) if (avContextTab[cAVIdx]->streams[packet.stream_index]->discard != AVDISCARD_ALL)
{ {
if (context->manager->video->Command(context, MANAGER_GET_TRACK, &videoTrack) < 0) if (context->manager->video->Command(context, MANAGER_GET_TRACK, &videoTrack) < 0)
@@ -992,6 +999,7 @@ static void FFMPEGThread(Context_t *context)
decoded_frame = NULL; decoded_frame = NULL;
} }
} }
#if (LIBAVFORMAT_VERSION_MAJOR > 57) || ((LIBAVFORMAT_VERSION_MAJOR == 57) && (LIBAVFORMAT_VERSION_MINOR > 32)) #if (LIBAVFORMAT_VERSION_MAJOR > 57) || ((LIBAVFORMAT_VERSION_MAJOR == 57) && (LIBAVFORMAT_VERSION_MINOR > 32))
while (packet.size > 0 || (!packet.size && !packet.data)) while (packet.size > 0 || (!packet.size && !packet.data))
#else #else
@@ -1059,6 +1067,7 @@ static void FFMPEGThread(Context_t *context)
continue; continue;
} }
#endif #endif
int32_t e = 0; int32_t e = 0;
if (!swr) if (!swr)
{ {
@@ -1085,6 +1094,7 @@ static void FFMPEGThread(Context_t *context)
{ {
c->channel_layout = av_get_default_channel_layout(c->channels); c->channel_layout = av_get_default_channel_layout(c->channels);
} }
out_channel_layout = c->channel_layout; out_channel_layout = c->channel_layout;
uint8_t downmix = stereo_software_decoder && out_channels > 2 ? 1 : 0; uint8_t downmix = stereo_software_decoder && out_channels > 2 ? 1 : 0;
@@ -1108,7 +1118,6 @@ static void FFMPEGThread(Context_t *context)
av_opt_set_int(swr, "in_sample_fmt", c->sample_fmt, 0); av_opt_set_int(swr, "in_sample_fmt", c->sample_fmt, 0);
av_opt_set_int(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); av_opt_set_int(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0);
e = swr_init(swr); e = swr_init(swr);
if (e < 0) if (e < 0)
{ {
@@ -1344,6 +1353,7 @@ static void FFMPEGThread(Context_t *context)
hasPlayThreadStarted = 0; hasPlayThreadStarted = 0;
context->playback->isPlaying = 0; context->playback->isPlaying = 0;
PlaybackDieNow(1); PlaybackDieNow(1);
ffmpeg_printf(10, "terminating\n"); ffmpeg_printf(10, "terminating\n");
} }
@@ -1886,13 +1896,16 @@ int32_t container_ffmpeg_init(Context_t *context, PlayFiles_t *playFilesNames)
} }
ffmpeg_printf(10, "filename %s\n", playFilesNames->szFirstFile); ffmpeg_printf(10, "filename %s\n", playFilesNames->szFirstFile);
if (playFilesNames->szSecondFile) if (playFilesNames->szSecondFile)
{ {
ffmpeg_printf(10, "second filename %s\n", playFilesNames->szSecondFile); ffmpeg_printf(10, "second filename %s\n", playFilesNames->szSecondFile);
} }
/* initialize ffmpeg */ /* initialize ffmpeg */
avcodec_register_all(); avcodec_register_all();
av_register_all(); av_register_all();
avformat_network_init(); avformat_network_init();
// SULGE DEBUG ENABLED // SULGE DEBUG ENABLED
@@ -1902,7 +1915,8 @@ int32_t container_ffmpeg_init(Context_t *context, PlayFiles_t *playFilesNames)
context->playback->abortRequested = 0; context->playback->abortRequested = 0;
int32_t res = container_ffmpeg_init_av_context(context, playFilesNames->szFirstFile, playFilesNames->iFirstFileSize, \ int32_t res = container_ffmpeg_init_av_context(context, playFilesNames->szFirstFile, playFilesNames->iFirstFileSize, \
playFilesNames->szFirstMoovAtomFile, playFilesNames->iFirstMoovAtomOffset, 0); playFilesNames->szFirstMoovAtomFile, playFilesNames->iFirstMoovAtomOffset, 0);
if (0 != res) if (0 != res)
{ {
return res; return res;
@@ -1911,7 +1925,7 @@ int32_t container_ffmpeg_init(Context_t *context, PlayFiles_t *playFilesNames)
if (playFilesNames->szSecondFile && playFilesNames->szSecondFile[0] != '\0') if (playFilesNames->szSecondFile && playFilesNames->szSecondFile[0] != '\0')
{ {
res = container_ffmpeg_init_av_context(context, playFilesNames->szSecondFile, playFilesNames->iSecondFileSize, \ res = container_ffmpeg_init_av_context(context, playFilesNames->szSecondFile, playFilesNames->iSecondFileSize, \
playFilesNames->szSecondMoovAtomFile, playFilesNames->iSecondMoovAtomOffset, 1); playFilesNames->szSecondMoovAtomFile, playFilesNames->iSecondMoovAtomOffset, 1);
} }
if (0 != res) if (0 != res)
@@ -1970,6 +1984,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
uint32_t cAVIdx = 0; uint32_t cAVIdx = 0;
for (cAVIdx = 0; cAVIdx < IPTV_AV_CONTEXT_MAX_NUM; cAVIdx += 1) for (cAVIdx = 0; cAVIdx < IPTV_AV_CONTEXT_MAX_NUM; cAVIdx += 1)
{ {
if (NULL == avContextTab[cAVIdx]) if (NULL == avContextTab[cAVIdx])
@@ -2080,6 +2095,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
case AVMEDIA_TYPE_VIDEO: case AVMEDIA_TYPE_VIDEO:
ffmpeg_printf(10, "CODEC_TYPE_VIDEO %d\n", get_codecpar(stream)->codec_type); ffmpeg_printf(10, "CODEC_TYPE_VIDEO %d\n", get_codecpar(stream)->codec_type);
stream->discard = AVDISCARD_ALL; /* by default we discard all video streams */ stream->discard = AVDISCARD_ALL; /* by default we discard all video streams */
if (encoding != NULL) if (encoding != NULL)
{ {
track.type = eTypeES; track.type = eTypeES;
@@ -2096,6 +2112,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
*/ */
track.aspect_ratio_num = stream->sample_aspect_ratio.num; track.aspect_ratio_num = stream->sample_aspect_ratio.num;
track.aspect_ratio_den = stream->sample_aspect_ratio.den; track.aspect_ratio_den = stream->sample_aspect_ratio.den;
if (0 == track.aspect_ratio_num || 0 == track.aspect_ratio_den) if (0 == track.aspect_ratio_num || 0 == track.aspect_ratio_den)
{ {
track.aspect_ratio_num = get_codecpar(stream)->sample_aspect_ratio.num; track.aspect_ratio_num = get_codecpar(stream)->sample_aspect_ratio.num;
@@ -2115,6 +2132,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
} }
/* fixme: revise this */ /* fixme: revise this */
if (track.frame_rate < 23970) if (track.frame_rate < 23970)
{ {
track.TimeScale = 1001; track.TimeScale = 1001;
@@ -2179,6 +2197,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
case AVMEDIA_TYPE_AUDIO: case AVMEDIA_TYPE_AUDIO:
ffmpeg_printf(10, "CODEC_TYPE_AUDIO %d\n", get_codecpar(stream)->codec_type); ffmpeg_printf(10, "CODEC_TYPE_AUDIO %d\n", get_codecpar(stream)->codec_type);
stream->discard = AVDISCARD_ALL; stream->discard = AVDISCARD_ALL;
if (encoding != NULL) if (encoding != NULL)
{ {
AVDictionaryEntry *lang; AVDictionaryEntry *lang;
@@ -2197,6 +2216,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
track.have_aacheader = -1; track.have_aacheader = -1;
track.duration = (int64_t)av_rescale(stream->duration, (int64_t)stream->time_base.num * 1000, stream->time_base.den); track.duration = (int64_t)av_rescale(stream->duration, (int64_t)stream->time_base.num * 1000, stream->time_base.den);
if (stream->duration == AV_NOPTS_VALUE) if (stream->duration == AV_NOPTS_VALUE)
{ {
ffmpeg_printf(10, "Stream has no duration so we take the duration from context\n"); ffmpeg_printf(10, "Stream has no duration so we take the duration from context\n");
@@ -2514,7 +2534,9 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
ffmpeg_printf(10, "CODEC_TYPE_SUBTITLE %d\n", get_codecpar(stream)->codec_type); ffmpeg_printf(10, "CODEC_TYPE_SUBTITLE %d\n", get_codecpar(stream)->codec_type);
lang = av_dict_get(stream->metadata, "language", NULL, 0); lang = av_dict_get(stream->metadata, "language", NULL, 0);
track.Name = lang ? lang->value : "und"; track.Name = lang ? lang->value : "und";
ffmpeg_printf(10, "Language %s\n", track.Name); ffmpeg_printf(10, "Language %s\n", track.Name);
track.Encoding = encoding; track.Encoding = encoding;
@@ -2595,6 +2617,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32
} }
releaseMutex(__FILE__, __FUNCTION__, __LINE__); releaseMutex(__FILE__, __FUNCTION__, __LINE__);
return cERR_CONTAINER_FFMPEG_NO_ERROR; return cERR_CONTAINER_FFMPEG_NO_ERROR;
} }
@@ -2623,14 +2646,12 @@ static int32_t container_ffmpeg_play(Context_t *context)
if ((error = pthread_create(&PlayThread, &attr, (void *)&FFMPEGThread, context)) != 0) if ((error = pthread_create(&PlayThread, &attr, (void *)&FFMPEGThread, context)) != 0)
{ {
ffmpeg_printf(10, "Error creating thread, error:%d:%s\n", error, strerror(error)); ffmpeg_printf(10, "Error creating thread, error:%d:%s\n", error, strerror(error));
hasPlayThreadStarted = 0; hasPlayThreadStarted = 0;
ret = cERR_CONTAINER_FFMPEG_ERR; ret = cERR_CONTAINER_FFMPEG_ERR;
} }
else else
{ {
ffmpeg_printf(10, "Created thread\n"); ffmpeg_printf(10, "Created thread\n");
hasPlayThreadStarted = 1; hasPlayThreadStarted = 1;
} }
} }
@@ -2641,6 +2662,7 @@ static int32_t container_ffmpeg_play(Context_t *context)
} }
ffmpeg_printf(10, "exiting with value %d\n", ret); ffmpeg_printf(10, "exiting with value %d\n", ret);
return ret; return ret;
} }
@@ -2670,6 +2692,7 @@ static int32_t container_ffmpeg_stop(Context_t *context)
{ {
/* force close */ /* force close */
ffmpeg_err("Timeout waiting for thread!\n"); ffmpeg_err("Timeout waiting for thread!\n");
ret = cERR_CONTAINER_FFMPEG_ERR; ret = cERR_CONTAINER_FFMPEG_ERR;
/* to speed up close - we are in separate process for the moment this process will /* to speed up close - we are in separate process for the moment this process will
* be closed and whole resources will be free by the system * be closed and whole resources will be free by the system
@@ -2921,15 +2944,16 @@ static int32_t container_ffmpeg_seek(Context_t *context, int64_t sec, uint8_t ab
} }
ffmpeg_printf(10, "iformat->flags 0x%08x\n", avContextTab[0]->iformat->flags); ffmpeg_printf(10, "iformat->flags 0x%08x\n", avContextTab[0]->iformat->flags);
#if defined(TS_BYTES_SEEKING) && TS_BYTES_SEEKING #if defined(TS_BYTES_SEEKING) && TS_BYTES_SEEKING
if (avContextTab[0]->iformat->flags & AVFMT_TS_DISCONT) if (avContextTab[0]->iformat->flags & AVFMT_TS_DISCONT)
{ {
/* konfetti: for ts streams seeking frame per seconds does not work (why?). /* konfetti: for ts streams seeking frame per seconds does not work (why?).
* I take this algo partly from ffplay.c. * I take this algo partly from ffplay.c.
* *
* seeking per HTTP does still not work very good. forward seeks everytime * seeking per HTTP does still not work very good. forward seeks everytime
* about 10 seconds, backward does not work. * about 10 seconds, backward does not work.
*/ */
getMutex(__FILE__, __FUNCTION__, __LINE__); getMutex(__FILE__, __FUNCTION__, __LINE__);
off_t pos = avio_tell(avContextTab[0]->pb); off_t pos = avio_tell(avContextTab[0]->pb);
@@ -3027,6 +3051,7 @@ static int32_t container_ffmpeg_switch_audio(Context_t *context, int32_t *arg __
{ {
ffmpeg_printf(10, "track %d\n", *arg); ffmpeg_printf(10, "track %d\n", *arg);
getMutex(__FILE__, __FUNCTION__, __LINE__); getMutex(__FILE__, __FUNCTION__, __LINE__);
if (context->manager->audio) if (context->manager->audio)
{ {
Track_t *Tracks = NULL; Track_t *Tracks = NULL;
@@ -3127,7 +3152,7 @@ static int32_t container_ffmpeg_get_info(Context_t *context, char **infoString)
return cERR_CONTAINER_FFMPEG_NO_ERROR; return cERR_CONTAINER_FFMPEG_NO_ERROR;
} }
static int container_ffmpeg_get_metadata(Context_t * context, char ***p) static int container_ffmpeg_get_metadata(Context_t *context, char ***p)
{ {
Track_t *videoTrack = NULL; Track_t *videoTrack = NULL;
Track_t *audioTrack = NULL; Track_t *audioTrack = NULL;
@@ -3249,12 +3274,12 @@ static int32_t Command(Context_t *context, ContainerCmd_t command, void *argumen
} }
case CONTAINER_SWITCH_AUDIO: case CONTAINER_SWITCH_AUDIO:
{ {
ret = container_ffmpeg_switch_audio(context, (int32_t *) argument); ret = container_ffmpeg_switch_audio(context, (int32_t *)argument);
break; break;
} }
case CONTAINER_SWITCH_SUBTITLE: case CONTAINER_SWITCH_SUBTITLE:
{ {
ret = container_ffmpeg_switch_subtitle(context, (int32_t *) argument); ret = container_ffmpeg_switch_subtitle(context, (int32_t *)argument);
break; break;
} }
case CONTAINER_INFO: case CONTAINER_INFO:
@@ -3286,7 +3311,7 @@ static int32_t Command(Context_t *context, ContainerCmd_t command, void *argumen
} }
case CONTAINER_GET_METADATA: case CONTAINER_GET_METADATA:
{ {
ret = container_ffmpeg_get_metadata(context, (char ***) argument); ret = container_ffmpeg_get_metadata(context, (char ***)argument);
break; break;
} }
default: default:
@@ -3296,6 +3321,7 @@ static int32_t Command(Context_t *context, ContainerCmd_t command, void *argumen
} }
ffmpeg_printf(50, "exiting with value %d\n", ret); ffmpeg_printf(50, "exiting with value %d\n", ret);
return ret; return ret;
} }

View File

@@ -45,7 +45,6 @@ typedef struct ContainerHandler_s
{ {
char *Name; char *Name;
Container_t *selectedContainer; Container_t *selectedContainer;
int (* Command)(Context_t *, ContainerCmd_t, void *); int (* Command)(Context_t *, ContainerCmd_t, void *);
} ContainerHandler_t; } ContainerHandler_t;

View File

@@ -44,7 +44,7 @@ typedef struct Track_s
/* new field for ffmpeg - add at the end so no problem /* new field for ffmpeg - add at the end so no problem
* can occur with not changed srt saa container * can occur with not changed srt saa container
*/ */
char *language; char *language;
/* length of track */ /* length of track */
int64_t duration; int64_t duration;

View File

@@ -4,7 +4,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
typedef void( * PlaybackDieNowCallback )(); typedef void(* PlaybackDieNowCallback)();
bool PlaybackDieNowRegisterCallback(PlaybackDieNowCallback callback); bool PlaybackDieNowRegisterCallback(PlaybackDieNowCallback callback);
typedef enum { typedef enum {

View File

@@ -252,11 +252,12 @@ static int HandleTracks(const Manager_t *ptrManager, const PlaybackCmd_t playbac
ptrManager->Command(g_player, MANAGER_LIST, &TrackList); ptrManager->Command(g_player, MANAGER_LIST, &TrackList);
if (NULL != TrackList) if (NULL != TrackList)
{ {
int i = 0, Id = -1; int i = 0;
int Id = -1;
char * pch; char * pch;
char Name[] = " "; char Name[] = " ";
fprintf(stderr, "{\"%c_%c\": [", argvBuff[0], argvBuff[1]); fprintf(stderr, "{\"%c_%c\": [", argvBuff[0], argvBuff[1]);
for (i = 0; TrackList[i] != NULL; i+=2) for (i = 0; TrackList[i] != NULL; i += 2)
{ {
pch = strtok(TrackList[i], " "); pch = strtok(TrackList[i], " ");
if (pch != NULL) { if (pch != NULL) {
@@ -272,7 +273,7 @@ static int HandleTracks(const Manager_t *ptrManager, const PlaybackCmd_t playbac
} }
fprintf(stderr, "{\"id\":%d,\"e\":\"%s\",\"n\":\"%s\"}", Id, TrackList[i+1], Name); fprintf(stderr, "{\"id\":%d,\"e\":\"%s\",\"n\":\"%s\"}", Id, TrackList[i+1], Name);
free(TrackList[i]); free(TrackList[i]);
free(TrackList[i+1]); free(TrackList[i + 1]);
} }
fprintf(stderr, "]}\n"); fprintf(stderr, "]}\n");
free(TrackList); free(TrackList);
@@ -297,7 +298,7 @@ static int HandleTracks(const Manager_t *ptrManager, const PlaybackCmd_t playbac
else // video else // video
{ {
fprintf(stderr, "{\"%c_%c\":{\"id\":%d,\"e\":\"%s\",\"n\":\"%s\",\"w\":%d,\"h\":%d,\"f\":%u,\"p\":%d,\"an\":%d,\"ad\":%d}}\n", \ fprintf(stderr, "{\"%c_%c\":{\"id\":%d,\"e\":\"%s\",\"n\":\"%s\",\"w\":%d,\"h\":%d,\"f\":%u,\"p\":%d,\"an\":%d,\"ad\":%d}}\n", \
argvBuff[0], argvBuff[1], track->Id, track->Encoding, track->Name, track->width, track->height, track->frame_rate, track->progressive, track->aspect_ratio_num, track->aspect_ratio_den); argvBuff[0], argvBuff[1], track->Id, track->Encoding, track->Name, track->width, track->height, track->frame_rate, track->progressive, track->aspect_ratio_num, track->aspect_ratio_den);
} }
free(track->Encoding); free(track->Encoding);
free(track->Name); free(track->Name);
@@ -336,7 +337,7 @@ static int HandleTracks(const Manager_t *ptrManager, const PlaybackCmd_t playbac
{ {
int i = 0; int i = 0;
char * pch; char * pch;
for (i = 0; TrackList[i] != NULL; i+=2) for (i = 0; TrackList[i] != NULL; i += 2)
{ {
if (idx == i) if (idx == i)
{ {
@@ -345,7 +346,7 @@ static int HandleTracks(const Manager_t *ptrManager, const PlaybackCmd_t playbac
id = atoi(pch); id = atoi(pch);
} }
free(TrackList[i]); free(TrackList[i]);
free(TrackList[i+1]); free(TrackList[i + 1]);
} }
free(TrackList); free(TrackList);
} }
@@ -501,7 +502,7 @@ static int HandleTracks(const Manager_t *ptrManager, const PlaybackCmd_t playbac
static void UpdateVideoTrack() static void UpdateVideoTrack()
{ {
HandleTracks(g_player->manager->video, (PlaybackCmd_t) - 1, "vc"); HandleTracks(g_player->manager->video, (PlaybackCmd_t) -1, "vc");
} }
static int ParseParams(int argc, char *argv[], PlayFiles_t *playbackFiles, int *pAudioTrackIdx, int *subtitleTrackIdx, uint32_t *linuxDvbBufferSizeMB) static int ParseParams(int argc, char *argv[], PlayFiles_t *playbackFiles, int *pAudioTrackIdx, int *subtitleTrackIdx, uint32_t *linuxDvbBufferSizeMB)
@@ -657,6 +658,7 @@ static int ParseParams(int argc, char *argv[], PlayFiles_t *playbackFiles, int *
ret = 0; ret = 0;
playbackFiles->szFirstFile = malloc(IPTV_MAX_FILE_PATH); playbackFiles->szFirstFile = malloc(IPTV_MAX_FILE_PATH);
playbackFiles->szFirstFile[0] = '\0'; playbackFiles->szFirstFile[0] = '\0';
if (NULL == strstr(argv[optind], "://")) if (NULL == strstr(argv[optind], "://"))
{ {
strcpy(playbackFiles->szFirstFile, "file://"); strcpy(playbackFiles->szFirstFile, "file://");
@@ -692,6 +694,7 @@ int main(int argc, char *argv[])
PlayFiles_t playbackFiles; PlayFiles_t playbackFiles;
memset(&playbackFiles, 0x00, sizeof(playbackFiles)); memset(&playbackFiles, 0x00, sizeof(playbackFiles));
if (0 != ParseParams(argc, argv, &playbackFiles, &audioTrackIdx, &subtitleTrackIdx, &linuxDvbBufferSizeMB)) if (0 != ParseParams(argc, argv, &playbackFiles, &audioTrackIdx, &subtitleTrackIdx, &linuxDvbBufferSizeMB))
{ {
printf("Usage: exteplayer3 filePath [-u user-agent] [-c cookies] [-h headers] [-p prio] [-a] [-d] [-w] [-l] [-s] [-i] [-t audioTrackId] [-9 subtitleTrackId] [-x separateAudioUri] plabackUri\n"); printf("Usage: exteplayer3 filePath [-u user-agent] [-c cookies] [-h headers] [-p prio] [-a] [-d] [-w] [-l] [-s] [-i] [-t audioTrackId] [-9 subtitleTrackId] [-x separateAudioUri] plabackUri\n");
@@ -815,24 +818,24 @@ int main(int argc, char *argv[])
{ {
PlaybackDieNowRegisterCallback(TerminateWakeUp); PlaybackDieNowRegisterCallback(TerminateWakeUp);
HandleTracks(g_player->manager->video, (PlaybackCmd_t) - 1, "vc"); HandleTracks(g_player->manager->video, (PlaybackCmd_t) -1, "vc");
HandleTracks(g_player->manager->audio, (PlaybackCmd_t) - 1, "al"); HandleTracks(g_player->manager->audio, (PlaybackCmd_t) -1, "al");
if (audioTrackIdx >= 0) if (audioTrackIdx >= 0)
{ {
static char cmd[128] = ""; // static to not allocate on stack static char cmd[128] = ""; // static to not allocate on stack
sprintf(cmd, "ai%d\n", audioTrackIdx); sprintf(cmd, "ai%d\n", audioTrackIdx);
commandRetVal = HandleTracks(g_player->manager->audio, PLAYBACK_SWITCH_AUDIO, cmd); commandRetVal = HandleTracks(g_player->manager->audio, PLAYBACK_SWITCH_AUDIO, cmd);
} }
HandleTracks(g_player->manager->audio, (PlaybackCmd_t) - 1, "ac"); HandleTracks(g_player->manager->audio, (PlaybackCmd_t) -1, "ac");
HandleTracks(g_player->manager->subtitle, (PlaybackCmd_t) - 1, "sl"); HandleTracks(g_player->manager->subtitle, (PlaybackCmd_t) -1, "sl");
if (subtitleTrackIdx >= 0) if (subtitleTrackIdx >= 0)
{ {
static char cmd[128] = ""; // static to not allocate on stack static char cmd[128] = ""; // static to not allocate on stack
sprintf(cmd, "si%d\n", subtitleTrackIdx); sprintf(cmd, "si%d\n", subtitleTrackIdx);
commandRetVal = HandleTracks(g_player->manager->subtitle, PLAYBACK_SWITCH_SUBTITLE, cmd); commandRetVal = HandleTracks(g_player->manager->subtitle, PLAYBACK_SWITCH_SUBTITLE, cmd);
} }
HandleTracks(g_player->manager->subtitle, (PlaybackCmd_t) - 1, "sc"); HandleTracks(g_player->manager->subtitle, (PlaybackCmd_t) -1, "sc");
} }
while (g_player->playback->isPlaying && 0 == PlaybackDieNow(0)) while (g_player->playback->isPlaying && 0 == PlaybackDieNow(0))
@@ -854,7 +857,7 @@ int main(int argc, char *argv[])
{ {
case 'v': case 'v':
{ {
HandleTracks(g_player->manager->video, (PlaybackCmd_t) - 1, argvBuff); HandleTracks(g_player->manager->video, (PlaybackCmd_t) -1, argvBuff);
break; break;
} }
case 'a': case 'a':
@@ -965,10 +968,12 @@ int main(int argc, char *argv[])
commandRetVal = g_player->playback->Command(g_player, PLAYBACK_PTS, &pts); commandRetVal = g_player->playback->Command(g_player, PLAYBACK_PTS, &pts);
CurrentSec = (int32_t)(pts / 90000); CurrentSec = (int32_t)(pts / 90000);
if (0 == commandRetVal) if (0 == commandRetVal)
{ {
fprintf(stderr, "{\"J\":{\"ms\":%lld}}\n", pts / 90); fprintf(stderr, "{\"J\":{\"ms\":%lld}}\n", pts / 90);
} }
if (0 == commandRetVal || force) if (0 == commandRetVal || force)
{ {
commandRetVal = g_player->playback->Command(g_player, PLAYBACK_LENGTH, (void *)&length); commandRetVal = g_player->playback->Command(g_player, PLAYBACK_LENGTH, (void *)&length);
@@ -1015,6 +1020,7 @@ int main(int argc, char *argv[])
{ {
int64_t lastPts = 0; int64_t lastPts = 0;
commandRetVal = 1; commandRetVal = 1;
if (g_player->container && g_player->container->selectedContainer) if (g_player->container && g_player->container->selectedContainer)
{ {
commandRetVal = g_player->container->selectedContainer->Command((Context_t*)g_player->container, CONTAINER_LAST_PTS, &lastPts); commandRetVal = g_player->container->selectedContainer->Command((Context_t*)g_player->container, CONTAINER_LAST_PTS, &lastPts);

View File

@@ -128,6 +128,7 @@ static int ManagerAdd(Context_t *context, Track_t track)
} }
audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
return cERR_AUDIO_MGR_NO_ERROR; return cERR_AUDIO_MGR_NO_ERROR;
} }
@@ -137,6 +138,7 @@ static char **ManagerList(Context_t *context __attribute__((unused)))
char **tracklist = NULL; char **tracklist = NULL;
audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); audio_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
if (Tracks != NULL) if (Tracks != NULL)
{ {
tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1)); tracklist = malloc(sizeof(char *) * ((TrackCount * 2) + 1));
@@ -160,9 +162,9 @@ static char **ManagerList(Context_t *context __attribute__((unused)))
tracklist[j] = strdup(tmp); tracklist[j] = strdup(tmp);
tracklist[j + 1] = strdup(Tracks[i].Encoding); tracklist[j + 1] = strdup(Tracks[i].Encoding);
} }
tracklist[j] = NULL; tracklist[j] = NULL;
} }
audio_mgr_printf(10, "%s::%s return %p (%d - %d)\n", __FILE__, __FUNCTION__, tracklist, j, TrackCount); audio_mgr_printf(10, "%s::%s return %p (%d - %d)\n", __FILE__, __FUNCTION__, tracklist, j, TrackCount);
return tracklist; return tracklist;
@@ -256,7 +258,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
{ {
container_ffmpeg_update_tracks(context, context->playback->uri, 0); container_ffmpeg_update_tracks(context, context->playback->uri, 0);
// *((TrackDescription_t **)argument) = ManagerList(context); // *((TrackDescription_t **)argument) = ManagerList(context);
*((char ** *) argument) = (char **) ManagerList(context); *((char ***)argument) = (char **)ManagerList(context);
break; break;
} }
case MANAGER_REF_LIST: case MANAGER_REF_LIST:
@@ -279,7 +281,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
} }
else else
{ {
*((int *)argument) = (int) - 1; *((int *)argument) = (int) -1;
} }
break; break;
} }
@@ -292,9 +294,9 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
if (track) if (track)
{ {
memset(track, 0, sizeof(TrackDescription_t)); memset(track, 0, sizeof(TrackDescription_t));
track->Id = Tracks[CurrentTrack].Id; track->Id = Tracks[CurrentTrack].Id;
track->Name = strdup(Tracks[CurrentTrack].Name); track->Name = strdup(Tracks[CurrentTrack].Name);
track->Encoding = strdup(Tracks[CurrentTrack].Encoding); track->Encoding = strdup(Tracks[CurrentTrack].Encoding);
} }
} }
else else

View File

@@ -134,8 +134,8 @@ static int ManagerAdd(Context_t *context __attribute__((unused)), Track_t track)
static char **ManagerList(Context_t *context __attribute__((unused))) static char **ManagerList(Context_t *context __attribute__((unused)))
{ {
char **tracklist = NULL;
int i = 0, j = 0; int i = 0, j = 0;
char **tracklist = NULL;
subtitle_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); subtitle_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
@@ -162,7 +162,6 @@ static char **ManagerList(Context_t *context __attribute__((unused)))
tracklist[j] = strdup(tmp); tracklist[j] = strdup(tmp);
tracklist[j + 1] = strdup(Tracks[i].Encoding); tracklist[j + 1] = strdup(Tracks[i].Encoding);
} }
tracklist[j] = NULL; tracklist[j] = NULL;
} }
@@ -219,7 +218,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
case MANAGER_LIST: case MANAGER_LIST:
{ {
container_ffmpeg_update_tracks(context, context->playback->uri, 0); container_ffmpeg_update_tracks(context, context->playback->uri, 0);
*((char ** *)argument) = (char **)ManagerList(context); *((char ***)argument) = (char **)ManagerList(context);
break; break;
} }
case MANAGER_GET: case MANAGER_GET:
@@ -230,7 +229,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
} }
else else
{ {
*((int *)argument) = (int) - 1; *((int *)argument) = (int) -1;
} }
break; break;
} }
@@ -243,9 +242,9 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
if (track) if (track)
{ {
memset(track, 0, sizeof(TrackDescription_t)); memset(track, 0, sizeof(TrackDescription_t));
track->Id = Tracks[CurrentTrack].Id; track->Id = Tracks[CurrentTrack].Id;
track->Name = strdup(Tracks[CurrentTrack].Name); track->Name = strdup(Tracks[CurrentTrack].Name);
track->Encoding = strdup(Tracks[CurrentTrack].Encoding); track->Encoding = strdup(Tracks[CurrentTrack].Encoding);
} }
} }
else else
@@ -332,12 +331,12 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
break; break;
} }
default: default:
subtitle_mgr_err("%s:%s: ContainerCmd not supported!", __FILE__, __FUNCTION__); subtitle_mgr_err("%s::%s ContainerCmd not supported!", __FILE__, __FUNCTION__);
ret = cERR_SUBTITLE_MGR_ERROR; ret = cERR_SUBTITLE_MGR_ERROR;
break; break;
} }
subtitle_mgr_printf(50, "%s:%s: returning %d\n", __FILE__, __FUNCTION__, ret); subtitle_mgr_printf(50, "%s::%s returning %d\n", __FILE__, __FUNCTION__, ret);
return ret; return ret;
} }

View File

@@ -97,7 +97,7 @@ static int ManagerAdd(Context_t *context, Track_t track)
if (Tracks == NULL) if (Tracks == NULL)
{ {
video_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__); video_mgr_err("%s::%s malloc failed\n", __FILE__, __FUNCTION__);
return cERR_VIDEO_MGR_ERROR; return cERR_VIDEO_MGR_ERROR;
} }
@@ -118,7 +118,7 @@ static int ManagerAdd(Context_t *context, Track_t track)
} }
else else
{ {
video_mgr_err("%s:%s TrackCount out if range %d - %d\n", __FILE__, __FUNCTION__, TrackCount, TRACKWRAP); video_mgr_err("%s::%s TrackCount out if range %d - %d\n", __FILE__, __FUNCTION__, TrackCount, TRACKWRAP);
return cERR_VIDEO_MGR_ERROR; return cERR_VIDEO_MGR_ERROR;
} }
@@ -128,6 +128,7 @@ static int ManagerAdd(Context_t *context, Track_t track)
} }
video_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); video_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
return cERR_VIDEO_MGR_NO_ERROR; return cERR_VIDEO_MGR_NO_ERROR;
} }
@@ -144,7 +145,7 @@ static char **ManagerList(Context_t *context __attribute__((unused)))
if (tracklist == NULL) if (tracklist == NULL)
{ {
video_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__); video_mgr_err("%s::%s malloc failed\n", __FILE__, __FUNCTION__);
return NULL; return NULL;
} }
@@ -164,6 +165,7 @@ static char **ManagerList(Context_t *context __attribute__((unused)))
} }
video_mgr_printf(10, "%s::%s return %p (%d - %d)\n", __FILE__, __FUNCTION__, tracklist, j, TrackCount); video_mgr_printf(10, "%s::%s return %p (%d - %d)\n", __FILE__, __FUNCTION__, tracklist, j, TrackCount);
return tracklist; return tracklist;
} }
@@ -213,7 +215,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
case MANAGER_LIST: case MANAGER_LIST:
{ {
container_ffmpeg_update_tracks(context, context->playback->uri, 0); container_ffmpeg_update_tracks(context, context->playback->uri, 0);
*((char ** *)argument) = (char **)ManagerList(context); *((char ***)argument) = (char **)ManagerList(context);
break; break;
} }
case MANAGER_GET: case MANAGER_GET:
@@ -224,7 +226,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
} }
else else
{ {
*((int *)argument) = (int) - 1; *((int *)argument) = (int) -1;
} }
break; break;
} }
@@ -342,7 +344,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
break; break;
} }
video_mgr_printf(10, "%s:%s: returning %d\n", __FILE__, __FUNCTION__, ret); video_mgr_printf(10, "%s::%s returning %d\n", __FILE__, __FUNCTION__, ret);
return ret; return ret;
} }

View File

@@ -252,6 +252,7 @@ int LinuxDvbPlay(Context_t *context, char *type)
linuxdvb_printf(10, "V %s\n", Encoding); linuxdvb_printf(10, "V %s\n", Encoding);
writer = getWriter(Encoding); writer = getWriter(Encoding);
if (writer == NULL) if (writer == NULL)
{ {
linuxdvb_err("cannot found writer for encoding %s using default\n", Encoding); linuxdvb_err("cannot found writer for encoding %s using default\n", Encoding);
@@ -324,7 +325,6 @@ int LinuxDvbPlay(Context_t *context, char *type)
ret = cERR_LINUXDVB_NO_ERROR; ret = cERR_LINUXDVB_NO_ERROR;
return ret; return ret;
//return 0;
} }
int LinuxDvbStop(Context_t *context __attribute__((unused)), char *type) int LinuxDvbStop(Context_t *context __attribute__((unused)), char *type)
@@ -354,6 +354,7 @@ int LinuxDvbStop(Context_t *context __attribute__((unused)), char *type)
ioctl(videofd, VIDEO_FAST_FORWARD, 0); ioctl(videofd, VIDEO_FAST_FORWARD, 0);
ioctl(videofd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX); ioctl(videofd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX);
} }
if (audio && audiofd != -1) if (audio && audiofd != -1)
{ {
if (ioctl(audiofd, AUDIO_CLEAR_BUFFER) == -1) if (ioctl(audiofd, AUDIO_CLEAR_BUFFER) == -1)
@@ -634,6 +635,7 @@ int LinuxDvbPts(Context_t *context __attribute__((unused)), unsigned long long i
} }
*((unsigned long long int *)pts) = (unsigned long long int)sCURRENT_PTS; *((unsigned long long int *)pts) = (unsigned long long int)sCURRENT_PTS;
return ret; return ret;
} }
@@ -1095,7 +1097,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument)
case OUTPUT_GET_BUFFER_SIZE: case OUTPUT_GET_BUFFER_SIZE:
{ {
ret = cERR_LINUXDVB_NO_ERROR; ret = cERR_LINUXDVB_NO_ERROR;
*((uint32_t*)argument) = LinuxDvbBuffGetSize(); *((uint32_t *)argument) = LinuxDvbBuffGetSize();
break; break;
} }
default: default:

View File

@@ -90,6 +90,7 @@ static void printOutputCapabilities()
for (i = 0; AvailableOutput[i] != NULL; i++) for (i = 0; AvailableOutput[i] != NULL; i++)
{ {
output_printf(10, "\t%s : ", AvailableOutput[i]->Name); output_printf(10, "\t%s : ", AvailableOutput[i]->Name);
for (j = 0; AvailableOutput[i]->Capabilities[j] != NULL; j++) for (j = 0; AvailableOutput[i]->Capabilities[j] != NULL; j++)
{ {
output_printf(10, "%s ", AvailableOutput[i]->Capabilities[j]); output_printf(10, "%s ", AvailableOutput[i]->Capabilities[j]);

View File

@@ -266,8 +266,6 @@ static int32_t subtitle_Open(Context_t *context __attribute__((unused)))
static int32_t subtitle_Close(Context_t *context __attribute__((unused))) static int32_t subtitle_Close(Context_t *context __attribute__((unused)))
{ {
//uint32_t i = 0 ;
subtitle_printf(10, "\n"); subtitle_printf(10, "\n");
getMutex(__LINE__); getMutex(__LINE__);
@@ -341,6 +339,7 @@ static int Command(Context_t *context, OutputCmd_t command, void *argument __att
} }
subtitle_printf(50, "exiting with value %d\n", ret); subtitle_printf(50, "exiting with value %d\n", ret);
return ret; return ret;
} }

View File

@@ -70,5 +70,5 @@ if (debug_level >= level) printf(x); } while (0)
void FlushPipe(int pipefd) void FlushPipe(int pipefd)
{ {
char tmp; char tmp;
while(1 == read(pipefd, &tmp, 1)); while (1 == read(pipefd, &tmp, 1));
} }

View File

@@ -52,6 +52,7 @@
/* ***************************** */ /* ***************************** */
/* Makros/Constants */ /* Makros/Constants */
/* ***************************** */ /* ***************************** */
#define PES_AUDIO_PRIVATE_HEADER_SIZE 16 // consider maximum private header size. #define PES_AUDIO_PRIVATE_HEADER_SIZE 16 // consider maximum private header size.
#define PES_AUDIO_HEADER_SIZE (32 + PES_AUDIO_PRIVATE_HEADER_SIZE) #define PES_AUDIO_HEADER_SIZE (32 + PES_AUDIO_PRIVATE_HEADER_SIZE)
#define PES_AUDIO_PACKET_SIZE 2028 #define PES_AUDIO_PACKET_SIZE 2028

View File

@@ -169,6 +169,7 @@ static int writeData(WriterAVCallData_t *call)
iov[0].iov_len = headerSize; iov[0].iov_len = headerSize;
iov[1].iov_base = call->data; iov[1].iov_base = call->data;
iov[1].iov_len = call->len; iov[1].iov_len = call->len;
return call->WriteV(call->fd, iov, 2); return call->WriteV(call->fd, iov, 2);
} }

View File

@@ -54,7 +54,7 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
#define cERR_PLAYBACK_NO_ERROR 0 #define cERR_PLAYBACK_NO_ERROR 0
#define cERR_PLAYBACK_ERROR -1 #define cERR_PLAYBACK_ERROR -1
#define cMaxSpeed_ff 128 /* fixme: revise */ #define cMaxSpeed_ff 128 /* fixme: revise */
#define cMaxSpeed_fr -320 /* fixme: revise */ #define cMaxSpeed_fr -320 /* fixme: revise */
#define MAX_PLAYBACK_DIE_NOW_CALLBACKS 10 #define MAX_PLAYBACK_DIE_NOW_CALLBACKS 10
@@ -140,6 +140,7 @@ static void SupervisorThread(Context_t *context)
{ {
usleep(100000); usleep(100000);
} }
playback_printf(10, "<\n"); playback_printf(10, "<\n");
hasThreadStarted = 2; hasThreadStarted = 2;
PlaybackTerminate(context); PlaybackTerminate(context);
@@ -293,6 +294,7 @@ static int PlaybackPlay(Context_t *context)
{ {
playback_err("OUTPUT_PLAY failed!\n"); playback_err("OUTPUT_PLAY failed!\n");
playback_err("clearing isCreationPhase!\n"); playback_err("clearing isCreationPhase!\n");
context->playback->isCreationPhase = 0; // allow thread to go into next state context->playback->isCreationPhase = 0; // allow thread to go into next state
context->playback->isPlaying = 0; context->playback->isPlaying = 0;
context->playback->isPaused = 0; context->playback->isPaused = 0;
@@ -300,6 +302,7 @@ static int PlaybackPlay(Context_t *context)
context->playback->BackWard = 0; context->playback->BackWard = 0;
context->playback->SlowMotion = 0; context->playback->SlowMotion = 0;
context->playback->Speed = 0; context->playback->Speed = 0;
if (context->container && context->container->selectedContainer) if (context->container && context->container->selectedContainer)
context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL); context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL);
} }
@@ -317,7 +320,8 @@ static int PlaybackPlay(Context_t *context)
int error; int error;
pthread_attr_init(&attr); pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if ((error = pthread_create(&supervisorThread, &attr, (void *) &SupervisorThread, context)) != 0)
if ((error = pthread_create(&supervisorThread, &attr, (void *)&SupervisorThread, context)) != 0)
{ {
playback_printf(10, "Error creating thread, error:%d:%s\n", error, strerror(error)); playback_printf(10, "Error creating thread, error:%d:%s\n", error, strerror(error));
ret = cERR_PLAYBACK_ERROR; ret = cERR_PLAYBACK_ERROR;
@@ -331,13 +335,14 @@ static int PlaybackPlay(Context_t *context)
playback_printf(10, "clearing isCreationPhase!\n"); playback_printf(10, "clearing isCreationPhase!\n");
context->playback->isCreationPhase = 0; // allow thread to go into next state context->playback->isCreationPhase = 0; // allow thread to go into next state
if (context->container && context->container->selectedContainer) if (context->container && context->container->selectedContainer)
ret = context->container->selectedContainer->Command(context, CONTAINER_PLAY, NULL); ret = context->container->selectedContainer->Command(context, CONTAINER_PLAY, NULL);
if (ret != 0) if (ret != 0)
{ {
playback_err("CONTAINER_PLAY failed!\n"); playback_err("CONTAINER_PLAY failed!\n");
} }
} }
} }
else else
@@ -362,10 +367,9 @@ static int PlaybackPause(Context_t *context)
if (context->playback->SlowMotion) if (context->playback->SlowMotion)
context->output->Command(context, OUTPUT_CLEAR, NULL); context->output->Command(context, OUTPUT_CLEAR, NULL);
context->playback->isPaused = 1;
context->output->Command(context, OUTPUT_PAUSE, NULL); context->output->Command(context, OUTPUT_PAUSE, NULL);
context->playback->isPaused = 1;
//context->playback->isPlaying = 1; //context->playback->isPlaying = 1;
context->playback->isForwarding = 0; context->playback->isForwarding = 0;
context->playback->BackWard = 0; context->playback->BackWard = 0;
@@ -395,6 +399,8 @@ static int32_t PlaybackContinue(Context_t *context)
if (context->playback->SlowMotion || context->playback->isForwarding || context->playback->BackWard) if (context->playback->SlowMotion || context->playback->isForwarding || context->playback->BackWard)
context->output->Command(context, OUTPUT_CLEAR, NULL); context->output->Command(context, OUTPUT_CLEAR, NULL);
context->output->Command(context, OUTPUT_CONTINUE, NULL);
if (context->playback->BackWard) if (context->playback->BackWard)
context->output->Command(context, OUTPUT_AUDIOMUTE, "0"); context->output->Command(context, OUTPUT_AUDIOMUTE, "0");
@@ -404,7 +410,6 @@ static int32_t PlaybackContinue(Context_t *context)
context->playback->BackWard = 0; context->playback->BackWard = 0;
context->playback->SlowMotion = 0; context->playback->SlowMotion = 0;
context->playback->Speed = 1; context->playback->Speed = 1;
context->output->Command(context, OUTPUT_CONTINUE, NULL);
} }
else else
{ {
@@ -413,6 +418,7 @@ static int32_t PlaybackContinue(Context_t *context)
} }
playback_printf(10, "exiting with value %d\n", ret); playback_printf(10, "exiting with value %d\n", ret);
return ret; return ret;
} }
@@ -427,7 +433,6 @@ static int32_t PlaybackStop(Context_t *context)
if (context && context->playback && context->playback->isPlaying) if (context && context->playback && context->playback->isPlaying)
{ {
context->playback->isPaused = 0; context->playback->isPaused = 0;
context->playback->isPlaying = 0; context->playback->isPlaying = 0;
context->playback->isForwarding = 0; context->playback->isForwarding = 0;
@@ -437,7 +442,6 @@ static int32_t PlaybackStop(Context_t *context)
context->output->Command(context, OUTPUT_STOP, NULL); context->output->Command(context, OUTPUT_STOP, NULL);
context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL); context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL);
} }
else else
{ {
@@ -458,13 +462,13 @@ static int32_t PlaybackStop(Context_t *context)
} }
playback_printf(10, "exiting with value %d\n", ret); playback_printf(10, "exiting with value %d\n", ret);
return ret; return ret;
} }
static int32_t PlaybackTerminate(Context_t *context) static int32_t PlaybackTerminate(Context_t *context)
{ {
int32_t ret = cERR_PLAYBACK_NO_ERROR; int32_t ret = cERR_PLAYBACK_NO_ERROR;
int wait_time = 20; int wait_time = 20;
playback_printf(20, "\n"); playback_printf(20, "\n");
@@ -474,12 +478,13 @@ static int32_t PlaybackTerminate(Context_t *context)
if (context && context->playback && context->playback->isPlaying) if (context && context->playback && context->playback->isPlaying)
{ {
//First Flush and than delete container, else e2 cant read length of file anymore //First Flush and than delete container, else e2 cant read length of file anymore
if (context->output->Command(context, OUTPUT_FLUSH, NULL) < 0) if (context->output->Command(context, OUTPUT_FLUSH, NULL) < 0)
{ {
playback_err("failed to flush output.\n"); playback_err("failed to flush output.\n");
} }
ret = context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL);
context->playback->isPaused = 0; context->playback->isPaused = 0;
context->playback->isPlaying = 0; context->playback->isPlaying = 0;
context->playback->isForwarding = 0; context->playback->isForwarding = 0;
@@ -487,7 +492,6 @@ static int32_t PlaybackTerminate(Context_t *context)
context->playback->SlowMotion = 0; context->playback->SlowMotion = 0;
context->playback->Speed = 0; context->playback->Speed = 0;
context->output->Command(context, OUTPUT_STOP, NULL); context->output->Command(context, OUTPUT_STOP, NULL);
ret = context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL);
} }
else else
{ {
@@ -512,6 +516,7 @@ static int32_t PlaybackTerminate(Context_t *context)
} }
playback_printf(20, "exiting with value %d\n", ret); playback_printf(20, "exiting with value %d\n", ret);
return ret; return ret;
} }
@@ -529,6 +534,7 @@ static int PlaybackFastForward(Context_t *context, int *speed)
playback_err("speed %d out of range (1 - %d) \n", *speed, cMaxSpeed_ff); playback_err("speed %d out of range (1 - %d) \n", *speed, cMaxSpeed_ff);
return cERR_PLAYBACK_ERROR; return cERR_PLAYBACK_ERROR;
} }
context->playback->isForwarding = 1; context->playback->isForwarding = 1;
context->playback->Speed = *speed; context->playback->Speed = *speed;
playback_printf(20, "Speed: %d x {%d}\n", *speed, context->playback->Speed); playback_printf(20, "Speed: %d x {%d}\n", *speed, context->playback->Speed);
@@ -561,6 +567,7 @@ static int PlaybackFastBackward(Context_t *context, int *speed)
playback_err("speed %d out of range (0 - %d) \n", *speed, cMaxSpeed_fr); playback_err("speed %d out of range (0 - %d) \n", *speed, cMaxSpeed_fr);
return cERR_PLAYBACK_ERROR; return cERR_PLAYBACK_ERROR;
} }
if (*speed == 0) if (*speed == 0)
{ {
context->playback->BackWard = 0; context->playback->BackWard = 0;
@@ -601,6 +608,7 @@ static int32_t PlaybackSlowMotion(Context_t *context, int *speed)
{ {
if (context->playback->isPaused) if (context->playback->isPaused)
PlaybackContinue(context); PlaybackContinue(context);
switch (*speed) switch (*speed)
{ {
case 2: case 2:
@@ -613,7 +621,9 @@ static int32_t PlaybackSlowMotion(Context_t *context, int *speed)
context->playback->SlowMotion = 8; context->playback->SlowMotion = 8;
break; break;
} }
playback_printf(20, "SlowMotion: %d x {%d}\n", *speed, context->playback->SlowMotion); playback_printf(20, "SlowMotion: %d x {%d}\n", *speed, context->playback->SlowMotion);
context->output->Command(context, OUTPUT_SLOWMOTION, NULL); context->output->Command(context, OUTPUT_SLOWMOTION, NULL);
} }
else else
@@ -726,6 +736,7 @@ static int32_t PlaybackLength(Context_t *context, int64_t *length)
} }
playback_printf(20, "exiting with value %d\n", ret); playback_printf(20, "exiting with value %d\n", ret);
return ret; return ret;
} }
@@ -753,7 +764,6 @@ static int32_t PlaybackSwitchAudio(Context_t *context, int32_t *track)
if (nextrackid != curtrackid) if (nextrackid != curtrackid)
{ {
//PlaybackPause(context); //PlaybackPause(context);
if (context->output && context->output->audio) if (context->output && context->output->audio)
{ {
@@ -774,6 +784,7 @@ static int32_t PlaybackSwitchAudio(Context_t *context, int32_t *track)
} }
playback_printf(10, "exiting with value %d\n", ret); playback_printf(10, "exiting with value %d\n", ret);
return ret; return ret;
} }
@@ -860,7 +871,6 @@ static int32_t Command(Context_t *context, PlaybackCmd_t command, void *argument
playback_printf(20, "Command %d\n", command); playback_printf(20, "Command %d\n", command);
switch (command) switch (command)
{ {
case PLAYBACK_OPEN: case PLAYBACK_OPEN:
@@ -898,6 +908,11 @@ static int32_t Command(Context_t *context, PlaybackCmd_t command, void *argument
ret = PlaybackTerminate(context); ret = PlaybackTerminate(context);
break; break;
} }
case PLAYBACK_FASTFORWARD:
{
ret = PlaybackFastForward(context, (int *)argument);
break;
}
case PLAYBACK_SEEK: case PLAYBACK_SEEK:
{ {
ret = PlaybackSeek(context, (int64_t *)argument, 0); ret = PlaybackSeek(context, (int64_t *)argument, 0);
@@ -943,11 +958,6 @@ static int32_t Command(Context_t *context, PlaybackCmd_t command, void *argument
ret = PlaybackFastBackward(context, (int *)argument); ret = PlaybackFastBackward(context, (int *)argument);
break; break;
} }
case PLAYBACK_FASTFORWARD:
{
ret = PlaybackFastForward(context, (int *)argument);
break;
}
case PLAYBACK_GET_FRAME_COUNT: case PLAYBACK_GET_FRAME_COUNT:
{ {
ret = PlaybackGetFrameCount(context, (uint64_t *)argument); ret = PlaybackGetFrameCount(context, (uint64_t *)argument);