libeplayer3: cleanup

This commit is contained in:
martii
2013-06-08 12:05:36 +02:00
parent 6e25a6f00f
commit 4f56cae01d
28 changed files with 27 additions and 530 deletions

View File

@@ -75,11 +75,7 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
#define ASS_RING_SIZE 5
#ifdef MARTII
#define ASS_FONT "/share/fonts/neutrino.ttf"
#else
#define ASS_FONT "/usr/share/fonts/FreeSans.ttf"
#endif
/* ***************************** */
/* Types */
@@ -386,24 +382,16 @@ static void ASSThread(Context_t *context) {
continue;
}
#ifndef MARTII
getMutex(__LINE__);
#endif
//FIXME: durch den sleep bleibt die cpu usage zw. 5 und 13%, ohne
// steigt sie bei Verwendung von subtiteln bis auf 95%.
// ich hoffe dadurch gehen keine subtitle verloren, wenn die playPts
// durch den sleep verschlafen wird. Besser w<>re es den n<>chsten
// subtitel zeitpunkt zu bestimmen und solange zu schlafen.
#ifdef MARTII
usleep(10000);
if(!context->playback->mayWriteToFramebuffer)
continue;
getMutex(__LINE__);
checkRegions();
#else
usleep(1000);
#endif
if(ass_renderer && ass_track)
img = ass_render_frame(ass_renderer, ass_track, playPts / 90.0, &change);
@@ -428,11 +416,7 @@ static void ASSThread(Context_t *context) {
if (ass_track && ass_track->events)
{
#ifdef MARTII
undisplay = now + (ass_track->events->Duration + 500) / 90000;
#else
undisplay = now + ass_track->events->Duration / 1000 + 0.5;
#endif
}
ass_printf(100, "w %d h %d s %d x %d y %d c %d chg %d now %ld und %ld\n",
@@ -481,7 +465,6 @@ static void ASSThread(Context_t *context) {
* so there is hopefully installed an output callback
* in the subtitle output!
*/
#ifdef MARTII
SubtitleOut_t sub_out;
sub_out.type = eSub_Gfx;
@@ -505,31 +488,6 @@ static void ASSThread(Context_t *context) {
if(context && context->playback && context->playback->isPlaying &&
context->output && context->output->subtitle)
context->output->subtitle->Write(context, &sub_out);
#else
SubtitleOut_t out;
out.type = eSub_Gfx;
if (ass_track->events)
{
/* fixme: check values */
out.pts = ass_track->events->Start * 90.0;
out.duration = ass_track->events->Duration / 1000.0;
} else
{
out.pts = playPts;
out.duration = 10.0;
}
out.u.gfx.data = img->bitmap;
out.u.gfx.Width = img->w;
out.u.gfx.Height = img->h;
out.u.gfx.x = img->dst_x;
out.u.gfx.y = img->dst_y;
if(context && context->playback && context->playback->isPlaying &&
context->output && context->output->subtitle)
context->output->subtitle->Write(context, &out);
#endif
}
}
@@ -549,21 +507,15 @@ static void ASSThread(Context_t *context) {
}
/* cleanup no longer used but not overwritten regions */
#ifdef MARTII
getMutex(__LINE__);
#endif
checkRegions();
#ifdef MARTII
releaseMutex(__LINE__);
#endif
} /* while */
hasPlayThreadStarted = 0;
ass_printf(10, "terminating\n");
#ifdef MARTII
pthread_exit(NULL);
#endif
}
/* **************************** */
@@ -641,18 +593,10 @@ int container_ass_init(Context_t *context)
}
ass_set_use_margins(ass_renderer, 0 );
#ifdef MARTII
ass_set_font_scale(ass_renderer, (ass_font_scale * screen_height) / 240.0);
#else
ass_set_font_scale(ass_renderer, ass_font_scale);
#endif
ass_set_hinting(ass_renderer, ASS_HINTING_LIGHT);
#ifdef MARTII
ass_set_line_spacing(ass_renderer, (ass_line_spacing * screen_height) / 240.0);
#else
ass_set_line_spacing(ass_renderer, ass_line_spacing);
#endif
ass_set_fonts(ass_renderer, ASS_FONT, "Arial", 0, NULL, 1);
if(threeDMode == 0){
@@ -691,10 +635,8 @@ int container_ass_process_data(Context_t *context, SubtitleData_t* data)
ass_err("error creating ass_track\n");
return cERR_CONTAINER_ASS_ERROR;
}
#ifdef MARTII
ass_track->PlayResX = screen_width;
ass_track->PlayResY = screen_height;
#endif
}
if ((data->extradata) && (first_kiss))

View File

@@ -36,21 +36,17 @@
#include <errno.h>
#include <sys/poll.h>
#include <pthread.h>
#ifdef MARTII
#include <sys/prctl.h>
#endif
#include <libavutil/avutil.h>
#include <libavformat/avformat.h>
#ifdef MARTII
#define USE_LIBSWRESAMPLE
# ifdef USE_LIBSWRESAMPLE
# include <libswresample/swresample.h>
# else
# include <libavresample/avresample.h>
# endif
# include <libavutil/opt.h>
#ifdef USE_LIBSWRESAMPLE
# include <libswresample/swresample.h>
#else
# include <libavresample/avresample.h>
#endif
#include <libavutil/opt.h>
#include "common.h"
#include "misc.h"
@@ -114,21 +110,13 @@ static AVFormatContext* avContext = NULL;
static unsigned char isContainerRunning = 0;
#ifdef MARTII
long long int latestPts = 0;
#else
static long long int latestPts = 0;
#endif
/* ***************************** */
/* Prototypes */
/* ***************************** */
static int container_ffmpeg_seek_bytes(off_t pos);
#ifdef MARTII
static int container_ffmpeg_seek(Context_t *context, float sec, int absolute);
#else
static int container_ffmpeg_seek(Context_t *context, float sec);
#endif
static int container_ffmpeg_seek_rel(Context_t *context, off_t pos, long long int pts, float sec);
static int container_ffmpeg_seek_bytes_rel(off_t start, off_t bytes);
@@ -152,9 +140,7 @@ void releaseMutex(const char *filename, const const char *function, int line) {
static char* Codec2Encoding(enum CodecID id, int* version)
{
#ifdef MARTII
fprintf(stderr, "Codec ID: %.8lx\n", (long)id);
#endif
switch (id)
{
case CODEC_ID_MPEG1VIDEO:
@@ -205,7 +191,7 @@ static char* Codec2Encoding(enum CodecID id, int* version)
case CODEC_ID_MP3:
return "A_MP3";
case CODEC_ID_AAC:
#ifdef MARTII
#if 1
return "A_IPCM";
#else
return "A_AAC";
@@ -217,7 +203,7 @@ static char* Codec2Encoding(enum CodecID id, int* version)
case CODEC_ID_WMAV1:
case CODEC_ID_WMAV2:
case 86056: //CODEC_ID_WMAPRO
#ifdef MARTII
#if 1
return "A_IPCM";
#else
return "A_WMA";
@@ -237,7 +223,7 @@ static char* Codec2Encoding(enum CodecID id, int* version)
#else
case CODEC_ID_PCM_S16LE:
#endif
#ifdef MARTII
#if 1
return "A_IPCM";
#else
return "A_PCM";
@@ -356,23 +342,17 @@ static char* searchMeta(AVDictionary * metadata, char* ourTag)
/* **************************** */
static void FFMPEGThread(Context_t *context) {
#ifdef MARTII
char threadname[17];
strncpy(threadname, __func__, sizeof(threadname));
threadname[16] = 0;
prctl (PR_SET_NAME, (unsigned long)&threadname);
#endif
AVPacket packet;
#ifndef MARTII
off_t currentReadPosition = 0; /* last read position */
#endif
off_t lastReverseSeek = 0; /* max address to read before seek again in reverse play */
off_t lastSeek = -1;
long long int lastPts = -1, currentVideoPts = -1, currentAudioPts = -1, showtime = 0, bofcount = 0;
int err = 0, gotlastPts = 0, audioMute = 0;
AudioVideoOut_t avOut;
#ifdef MARTII
#ifdef USE_LIBSWRESAMPLE
SwrContext *swr = NULL;
#else
@@ -381,11 +361,6 @@ static void FFMPEGThread(Context_t *context) {
AVFrame *decoded_frame = NULL;
int out_sample_rate = 44100;
uint64_t out_channel_layout = AV_CH_LAYOUT_STEREO;
#else
/* Softdecoding buffer*/
unsigned char *samples = NULL;
#endif
ffmpeg_printf(10, "\n");
@@ -436,11 +411,7 @@ static void FFMPEGThread(Context_t *context) {
}
#ifdef MARTII
if((err = container_ffmpeg_seek_rel(context, lastSeek, lastPts, (float) context->playback->Speed * 15)) < 0)
#else
if((err = container_ffmpeg_seek_rel(context, lastSeek, lastPts, (float) context->playback->Speed)) < 0)
#endif
{
ffmpeg_err( "Error seeking\n");
@@ -543,22 +514,10 @@ static void FFMPEGThread(Context_t *context) {
Track_t * audioTrack = NULL;
Track_t * subtitleTrack = NULL;
#ifdef MARTII
Track_t * dvbsubtitleTrack = NULL;
Track_t * teletextTrack = NULL;
int ix = packet.stream_index;
#else
int index = packet.stream_index;
#endif
#ifndef MARTII
#if LIBAVCODEC_VERSION_MAJOR < 54
currentReadPosition = url_ftell(avContext->pb);
#else
currentReadPosition = avio_tell(avContext->pb);
#endif
#endif
if (context->manager->video->Command(context, MANAGER_GET_TRACK, &videoTrack) < 0)
ffmpeg_err("error getting video track\n");
@@ -568,26 +527,17 @@ static void FFMPEGThread(Context_t *context) {
if (context->manager->subtitle->Command(context, MANAGER_GET_TRACK, &subtitleTrack) < 0)
ffmpeg_err("error getting subtitle track\n");
#ifdef MARTII
if (context->manager->dvbsubtitle->Command(context, MANAGER_GET_TRACK, &dvbsubtitleTrack) < 0)
ffmpeg_err("error getting dvb subtitle track\n");
if (context->manager->teletext->Command(context, MANAGER_GET_TRACK, &teletextTrack) < 0)
ffmpeg_err("error getting teletext track\n");
#endif
#ifdef MARTII
ffmpeg_printf(200, "packet.size %d - index %d\n", packet.size, ix);
#else
ffmpeg_printf(200, "packet.size %d - index %d\n", packet.size, index);
#endif
if (videoTrack != NULL) {
#ifdef MARTII
if (videoTrack->Id == ix) {
#else
if (videoTrack->Id == index) {
#endif
currentVideoPts = videoTrack->pts = pts = calcPts(videoTrack->stream, &packet);
if ((currentVideoPts > latestPts) && (currentVideoPts != INVALID_PTS_VALUE))
@@ -601,11 +551,7 @@ static void FFMPEGThread(Context_t *context) {
}
#endif
#ifdef MARTII
ffmpeg_printf(200, "VideoTrack index = %d %lld\n",ix, currentVideoPts);
#else
ffmpeg_printf(200, "VideoTrack index = %d %lld\n",index, currentVideoPts);
#endif
avOut.data = packet.data;
avOut.len = packet.size;
@@ -625,11 +571,7 @@ static void FFMPEGThread(Context_t *context) {
}
if (audioTrack != NULL) {
#ifdef MARTII
if (audioTrack->Id == ix) {
#else
if (audioTrack->Id == index) {
#endif
currentAudioPts = audioTrack->pts = pts = calcPts(audioTrack->stream, &packet);
if ((currentAudioPts > latestPts) && (!videoTrack))
@@ -643,11 +585,7 @@ static void FFMPEGThread(Context_t *context) {
}
#endif
#ifdef MARTII
ffmpeg_printf(200, "AudioTrack index = %d\n",ix);
#else
ffmpeg_printf(200, "AudioTrack index = %d\n",index);
#endif
if (audioTrack->inject_raw_pcm == 1){
ffmpeg_printf(200,"write audio raw pcm\n");
@@ -678,7 +616,6 @@ static void FFMPEGThread(Context_t *context) {
}
else if (audioTrack->inject_as_pcm == 1)
{
#ifdef MARTII
AVCodecContext *c = ((AVStream*)(audioTrack->stream))->codec;
AVPacket avpkt = packet;
@@ -723,13 +660,11 @@ static void FFMPEGThread(Context_t *context) {
#else
avr = avresample_alloc_context();
#endif
#if 1
if (c->channel_layout == 0) {
// FIXME -- need to guess, looks pretty much like a bug in the FFMPEG WMA decoder
c->channel_layout = AV_CH_LAYOUT_STEREO;
}
#endif
out_channel_layout = c->channel_layout;
// player2 won't play mono
out_channel_layout = (c->channel_layout == AV_CH_LAYOUT_MONO) ? AV_CH_LAYOUT_STEREO : c->channel_layout;
@@ -820,58 +755,6 @@ static void FFMPEGThread(Context_t *context) {
ffmpeg_err("writing data to audio device failed\n");
av_freep(&output);
}
#else
int bytesDone = 0;
unsigned int samples_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
AVPacket avpkt;
avpkt = packet;
// This way the buffer is only allocated if we really need it
if(samples == NULL)
samples = (unsigned char *)malloc(samples_size);
while(avpkt.size > 0)
{
int decoded_data_size = samples_size;
bytesDone = avcodec_decode_audio3(( (AVStream*) audioTrack->stream)->codec,
(short *)(samples), &decoded_data_size, &avpkt);
if(bytesDone < 0) // Error Happend
break;
avpkt.data += bytesDone;
avpkt.size -= bytesDone;
if(decoded_data_size <= 0)
continue;
pcmPrivateData_t extradata;
extradata.uNoOfChannels = ((AVStream*) audioTrack->stream)->codec->channels;
extradata.uSampleRate = ((AVStream*) audioTrack->stream)->codec->sample_rate;
extradata.uBitsPerSample = 16;
extradata.bLittleEndian = 1;
avOut.data = samples;
avOut.len = decoded_data_size;
avOut.pts = pts;
avOut.extradata = &extradata;
avOut.extralen = sizeof(extradata);
avOut.frameRate = 0;
avOut.timeScale = 0;
avOut.width = 0;
avOut.height = 0;
avOut.type = "audio";
#ifdef reverse_playback_3
if (!context->playback->BackWard)
#endif
if (context->output->audio->Write(context, &avOut) < 0)
ffmpeg_err("writing data to audio device failed\n");
}
#endif
}
else if (audioTrack->have_aacheader == 1)
{
@@ -922,11 +805,7 @@ static void FFMPEGThread(Context_t *context) {
}
if (subtitleTrack != NULL) {
#ifdef MARTII
if (subtitleTrack->Id == ix) {
#else
if (subtitleTrack->Id == index) {
#endif
float duration=3.0;
ffmpeg_printf(100, "subtitleTrack->stream %p \n", subtitleTrack->stream);
@@ -939,11 +818,7 @@ static void FFMPEGThread(Context_t *context) {
ffmpeg_printf(20, "Packet duration %d\n", packet.duration);
ffmpeg_printf(20, "Packet convergence_duration %lld\n", packet.convergence_duration);
#ifdef MARTII
if(packet.duration != 0) // FIXME: packet.duration is 32 bit, AV_NOPTS_VALUE is 64 bit --martii
#else
if(packet.duration != 0 && packet.duration != AV_NOPTS_VALUE )
#endif
duration=((float)packet.duration)/1000.0;
else if(packet.convergence_duration != 0 && packet.convergence_duration != AV_NOPTS_VALUE )
duration=((float)packet.convergence_duration)/1000.0;
@@ -1026,11 +901,7 @@ static void FFMPEGThread(Context_t *context) {
SubtitleData_t data;
data.data = line;
data.len = strlen((char*)line);
#ifdef MARTII
data.extradata = (unsigned char *) DEFAULT_ASS_HEAD;
#else
data.extradata = DEFAULT_ASS_HEAD;
#endif
data.extralen = strlen(DEFAULT_ASS_HEAD);
data.pts = pts;
data.duration = duration;
@@ -1041,7 +912,6 @@ static void FFMPEGThread(Context_t *context) {
} /* duration */
}
}
#ifdef MARTII
if (dvbsubtitleTrack != NULL) {
if (dvbsubtitleTrack->Id == ix) {
dvbsubtitleTrack->pts = pts = calcPts(dvbsubtitleTrack->stream, &packet);
@@ -1088,7 +958,6 @@ static void FFMPEGThread(Context_t *context) {
}
}
}
#endif
if (packet.data)
av_free_packet(&packet);
@@ -1103,24 +972,16 @@ static void FFMPEGThread(Context_t *context) {
} /* while */
#ifdef MARTII
# ifdef USE_LIBSWRESAMPLE
#ifdef USE_LIBSWRESAMPLE
if (swr) {
swr_free(&swr);
}
# else
#else
if (avr) {
avresample_close(avr);
avresample_free(&avr);
avcodec_free_frame(&decoded_frame);
}
# endif
#else
// Freeing the allocated buffer for softdecoding
if (samples != NULL) {
free(samples);
samples = NULL;
}
#endif
hasPlayThreadStarted = 0;
@@ -1131,22 +992,18 @@ static void FFMPEGThread(Context_t *context) {
/* **************************** */
/* Container part for ffmpeg */
/* **************************** */
#ifdef MARTII
static int terminating = 0;
static int interrupt_cb(void *ctx)
{
PlaybackHandler_t *p = (PlaybackHandler_t *)ctx;
return p->abortRequested;
}
#endif
int container_ffmpeg_init(Context_t *context, char * filename)
{
#ifdef MARTII
int err;
#else
int n, err;
#endif
ffmpeg_printf(10, ">\n");
@@ -1175,15 +1032,13 @@ int container_ffmpeg_init(Context_t *context, char * filename)
/* initialize ffmpeg */
avcodec_register_all();
av_register_all();
#ifdef MARTII //TDT
avformat_network_init();
#endif
#ifdef MARTII
context->playback->abortRequested = 0;
avContext = avformat_alloc_context();
avContext->interrupt_callback.callback = interrupt_cb;
avContext->interrupt_callback.opaque = context->playback;
#endif
#if LIBAVCODEC_VERSION_MAJOR < 54
if ((err = av_open_input_file(&avContext, filename, NULL, 0, NULL)) != 0) {
@@ -1222,11 +1077,7 @@ int container_ffmpeg_init(Context_t *context, char * filename)
* but the file is played back well. so remove this
* until other works are done and we can prove this.
*/
#ifdef MARTII
avformat_close_input(&avContext);
#else
av_close_input_file(avContext);
#endif
//for buffered io
ffmpeg_buf_free();
//for buffered io (end)
@@ -1235,7 +1086,6 @@ int container_ffmpeg_init(Context_t *context, char * filename)
#endif
}
#ifdef MARTII
terminating = 0;
latestPts = 0;
isContainerRunning = 1;
@@ -1257,7 +1107,6 @@ int container_ffmpeg_update_tracks(Context_t *context, char *filename)
context->manager->dvbsubtitle->Command(context, MANAGER_DEL, NULL);
if (context->manager->teletext)
context->manager->teletext->Command(context, MANAGER_DEL, NULL);
#endif
ffmpeg_printf(20, "dump format\n");
#if LIBAVCODEC_VERSION_MAJOR < 54
@@ -1360,14 +1209,7 @@ int container_ffmpeg_update_tracks(Context_t *context, char *filename)
lang = av_dict_get(stream->metadata, "language", NULL, 0);
#ifdef MARTII
track.Name = lang ? lang->value : "und";
#else
if (lang)
track.Name = strdup(lang->value);
else
track.Name = strdup("und");
#endif
ffmpeg_printf(10, "Language %s\n", track.Name);
@@ -1388,14 +1230,6 @@ int container_ffmpeg_update_tracks(Context_t *context, char *filename)
track.duration = (double) stream->duration * av_q2d(stream->time_base) * 1000.0;
}
#ifndef MARTII
if(!strncmp(encoding, "A_PCM", 5))
{
track.inject_raw_pcm = 1;
ffmpeg_printf(10, " Handle inject_raw_pcm = %d\n", track.inject_as_pcm);
}
else
#endif
if(!strncmp(encoding, "A_IPCM", 6))
{
track.inject_as_pcm = 1;
@@ -1404,16 +1238,12 @@ int container_ffmpeg_update_tracks(Context_t *context, char *filename)
AVCodec *codec = avcodec_find_decoder(stream->codec->codec_id);
//( (AVStream*) audioTrack->stream)->codec->flags |= CODEC_FLAG_TRUNCATED;
#ifdef MARTII
if(codec != NULL && !avcodec_open2(stream->codec, codec, NULL))
#else
if(codec != NULL && !avcodec_open(stream->codec, codec))
#endif
printf("AVCODEC__INIT__SUCCESS\n");
else
printf("AVCODEC__INIT__FAILED\n");
}
#ifndef MARTII
#if 0
else if(stream->codec->codec_id == CODEC_ID_AAC) {
ffmpeg_printf(10,"Create AAC ExtraData\n");
ffmpeg_printf(10,"stream->codec->extradata_size %d\n", stream->codec->extradata_size);
@@ -1466,11 +1296,7 @@ int container_ffmpeg_update_tracks(Context_t *context, char *filename)
} else if(stream->codec->codec_id == CODEC_ID_WMAV1
|| stream->codec->codec_id == CODEC_ID_WMAV2
#ifdef MARTII
|| stream->codec->codec_id == 86056 ) //CODEC_ID_WMAPRO) //if (stream->codec->extradata_size > 0)
#else
|| 86056 ) //CODEC_ID_WMAPRO) //if (stream->codec->extradata_size > 0)
#endif
{
ffmpeg_printf(10,"Create WMA ExtraData\n");
track.aacbuflen = 104 + stream->codec->extradata_size;
@@ -1583,14 +1409,7 @@ int container_ffmpeg_update_tracks(Context_t *context, char *filename)
lang = av_dict_get(stream->metadata, "language", NULL, 0);
#ifdef MARTII
track.Name = lang ? lang->value : "und";
#else
if (lang)
track.Name = strdup(lang->value);
else
track.Name = strdup("und");
#endif
ffmpeg_printf(10, "Language %s\n", track.Name);
@@ -1622,11 +1441,8 @@ int container_ffmpeg_update_tracks(Context_t *context, char *filename)
track.duration = (double) stream->duration * av_q2d(stream->time_base) * 1000.0;
}
#ifndef MARTII
if (track.Name)
#endif
ffmpeg_printf(10, "FOUND SUBTITLE %s\n", track.Name);
#ifdef MARTII
ffmpeg_printf(10, "FOUND SUBTITLE %s\n", track.Name);
if (stream->codec->codec_id == CODEC_ID_DVB_TELETEXT && context->manager->teletext) {
ffmpeg_printf(10, "dvb_teletext\n");
int i = 0;
@@ -1648,10 +1464,7 @@ int container_ffmpeg_update_tracks(Context_t *context, char *filename)
if (context->manager->dvbsubtitle->Command(context, MANAGER_ADD, &track) < 0) {
ffmpeg_err("failed to add dvbsubtitle track %d\n", n);
}
} else
#endif
if (context->manager->subtitle)
} else if (context->manager->subtitle)
if (context->manager->subtitle->Command(context, MANAGER_ADD, &track) < 0) {
/* konfetti: fixme: is this a reason to return with error? */
ffmpeg_err("failed to add subtitle track %d\n", n);
@@ -1670,12 +1483,6 @@ int container_ffmpeg_update_tracks(Context_t *context, char *filename)
} /* for */
#ifndef MARTII
/* init */
latestPts = 0;
isContainerRunning = 1;
#endif
releaseMutex(FILENAME, __FUNCTION__,__LINE__);
return cERR_CONTAINER_FFMPEG_NO_ERROR;
@@ -1734,10 +1541,8 @@ static int container_ffmpeg_stop(Context_t *context) {
ffmpeg_err("Container not running\n");
return cERR_CONTAINER_FFMPEG_ERR;
}
#ifdef MARTII
if (context->playback)
context->playback->isPlaying = 0;
#endif
while ( (hasPlayThreadStarted != 0) && (--wait_time) > 0 ) {
ffmpeg_printf(10, "Waiting for ffmpeg thread to terminate itself, will try another %d times\n", wait_time);
@@ -1752,26 +1557,15 @@ static int container_ffmpeg_stop(Context_t *context) {
}
hasPlayThreadStarted = 0;
#ifdef MARTII
terminating = 1;
#endif
getMutex(FILENAME, __FUNCTION__,__LINE__);
#ifdef MARTII
if (avContext)
avformat_close_input(&avContext);
#else
if (avContext != NULL) {
av_close_input_file(avContext);
avContext = NULL;
}
#endif
isContainerRunning = 0;
#ifdef MARTII //TDT
avformat_network_deinit();
#endif
releaseMutex(FILENAME, __FUNCTION__,__LINE__);
@@ -1954,17 +1748,12 @@ static int container_ffmpeg_seek_rel(Context_t *context, off_t pos, long long in
return cERR_CONTAINER_FFMPEG_NO_ERROR;
}
#ifdef MARTII
static int container_ffmpeg_seek(Context_t *context, float sec, int absolute) {
#else
static int container_ffmpeg_seek(Context_t *context, float sec) {
#endif
Track_t * videoTrack = NULL;
Track_t * audioTrack = NULL;
Track_t * current = NULL;
int flag = 0;
#ifdef MARTII
if (absolute) {
ffmpeg_printf(10, "goto %f sec\n", sec);
@@ -1979,25 +1768,6 @@ static int container_ffmpeg_seek(Context_t *context, float sec) {
return cERR_CONTAINER_FFMPEG_ERR;
}
}
#else
#if !defined(VDR1722)
ffmpeg_printf(10, "seeking %f sec\n", sec);
if (sec == 0.0)
{
ffmpeg_err("sec = 0.0 ignoring\n");
return cERR_CONTAINER_FFMPEG_ERR;
}
#else
ffmpeg_printf(10, "goto %f sec\n", sec);
if (sec < 0.0)
{
ffmpeg_err("sec < 0.0 ignoring\n");
return cERR_CONTAINER_FFMPEG_ERR;
}
#endif
#endif
context->manager->video->Command(context, MANAGER_GET_TRACK, &videoTrack);
context->manager->audio->Command(context, MANAGER_GET_TRACK, &audioTrack);
@@ -2007,11 +1777,7 @@ static int container_ffmpeg_seek(Context_t *context, float sec) {
current = audioTrack;
if (current == NULL) {
#ifdef MARTII
ffmpeg_err( "no track available to seek\n");
#else
ffmpeg_err( "no track avaibale to seek\n");
#endif
return cERR_CONTAINER_FFMPEG_ERR;
}
@@ -2048,27 +1814,12 @@ static int container_ffmpeg_seek(Context_t *context, float sec) {
{
sec *= 180000.0;
}
#ifdef MARTII
if (absolute)
pos = sec;
else
pos += sec;
#else
#if !defined(VDR1722)
pos += sec;
#else
pos = sec;
#endif
#endif
if (pos < 0)
{
#ifdef MARTII
pos = 0;
#else
ffmpeg_err("end of file reached\n");
return cERR_CONTAINER_FFMPEG_END_OF_FILE;
#endif
}
ffmpeg_printf(10, "1. seeking to position %lld bytes ->sec %f\n", pos, sec);
@@ -2081,14 +1832,8 @@ static int container_ffmpeg_seek(Context_t *context, float sec) {
} else
{
#ifdef MARTII
if (!absolute)
sec += ((float) current->pts / 90000.0f);
#else
#if !defined(VDR1722)
sec += ((float) current->pts / 90000.0f);
#endif
#endif
ffmpeg_printf(10, "2. seeking to position %f sec ->time base %f %d\n", sec, av_q2d(((AVStream*) current->stream)->time_base), AV_TIME_BASE);
if (av_seek_frame(avContext, -1 /* or streamindex */, sec * AV_TIME_BASE, flag) < 0) {
@@ -2161,7 +1906,7 @@ static int container_ffmpeg_swich_subtitle(Context_t* context, int* arg)
/* Hellmaster1024: nothing to do here!*/
return cERR_CONTAINER_FFMPEG_NO_ERROR;
}
#ifdef MARTII
static int container_ffmpeg_switch_dvbsubtitle(Context_t* context, int* arg)
{
return cERR_CONTAINER_FFMPEG_NO_ERROR;
@@ -2171,7 +1916,6 @@ static int container_ffmpeg_switch_teletext(Context_t* context, int* arg)
{
return cERR_CONTAINER_FFMPEG_NO_ERROR;
}
#endif
/* konfetti comment: I dont like the mechanism of overwriting
* the pointer in infostring. This lead in most cases to
@@ -2245,20 +1989,13 @@ static int Command(void *_context, ContainerCmd_t command, void * argument)
ffmpeg_printf(50, "Command %d\n", command);
#ifdef MARTII
if (command != CONTAINER_INIT && !avContext)
return cERR_CONTAINER_FFMPEG_ERR;
#endif
switch(command)
{
case CONTAINER_INIT: {
#ifdef MARTII
char * filename = (char *)argument;
ret = container_ffmpeg_init(context, filename);
#else
char * FILENAME = (char *)argument;
ret = container_ffmpeg_init(context, FILENAME);
#endif
break;
}
case CONTAINER_PLAY: {
@@ -2270,19 +2007,13 @@ static int Command(void *_context, ContainerCmd_t command, void * argument)
break;
}
case CONTAINER_SEEK: {
#ifdef MARTII
ret = container_ffmpeg_seek(context, (float)*((float*)argument), 0);
#else
ret = container_ffmpeg_seek(context, (float)*((float*)argument));
#endif
break;
}
#ifdef MARTII
case CONTAINER_SEEK_ABS: {
ret = container_ffmpeg_seek(context, (float)*((float*)argument), -1);
break;
}
#endif
case CONTAINER_LENGTH: {
double length = 0;
ret = container_ffmpeg_get_length(context, &length);
@@ -2310,7 +2041,6 @@ static int Command(void *_context, ContainerCmd_t command, void * argument)
*((long long int*)argument) = latestPts;
break;
}
#ifdef MARTII
case CONTAINER_SWITCH_DVBSUBTITLE: {
ret = container_ffmpeg_switch_dvbsubtitle(context, (int*) argument);
break;
@@ -2319,7 +2049,6 @@ static int Command(void *_context, ContainerCmd_t command, void * argument)
ret = container_ffmpeg_switch_teletext(context, (int*) argument);
break;
}
#endif
default:
ffmpeg_err("ContainerCmd %d not supported!\n", command);
ret = cERR_CONTAINER_FFMPEG_ERR;
@@ -2331,11 +2060,7 @@ static int Command(void *_context, ContainerCmd_t command, void * argument)
return ret;
}
#ifdef MARTII
static 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", NULL };
#else
static 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", NULL };
#endif
Container_t FFMPEGContainer = {
"FFMPEG",

View File

@@ -116,11 +116,7 @@ void data_to_manager(Context_t *context, char* Text, unsigned long long int Pts,
SubtitleData_t data;
data.data = line;
data.len = strlen((char*)line);
#ifdef MARTII
data.extradata = (unsigned char *) DEFAULT_ASS_HEAD;
#else
data.extradata = DEFAULT_ASS_HEAD;
#endif
data.extralen = strlen(DEFAULT_ASS_HEAD);
data.pts = Pts*90;
data.duration = Duration;

View File

@@ -104,12 +104,8 @@ static int hasThreadStarted = 0;
char *SSAgetLine()
{
char *strAux = NULL, *strInput;
#ifdef MARTII
char c[SSA_BUFFER_SIZE];
int ch;
#else
char c[SSA_BUFFER_SIZE], ch;
#endif
int k, tam, tamAux;
k = tamAux = 0;
@@ -162,13 +158,8 @@ char *SSAgetLine()
/* ***************************** */
/* Worker Thread */
/* ***************************** */
#ifdef MARTII
static void* SsaSubtitleThread(void *Data) {
Context_t *context = (Context_t*) Data;
#else
static void* SsaSubtitleThread(void *data) {
Context_t *context = (Context_t*) data;
#endif
char * head =malloc(sizeof(char)*1);
ssa_printf(10, "\n");