diff --git a/libeplayer3-arm/container/buff_ffmpeg.c b/libeplayer3-arm/container/buff_ffmpeg.c index 506aca3..26b37d0 100644 --- a/libeplayer3-arm/container/buff_ffmpeg.c +++ b/libeplayer3-arm/container/buff_ffmpeg.c @@ -101,7 +101,7 @@ static void update_finish_timeout() maxInjectedPts = 0; } - //printf("ret[%d] playPts[%lld] currPts[%lld] maxInjectedPts[%lld]\n", ret, playPts, currPts, maxInjectedPts); + //printf("ret[%d] playPts[%" PRId64 "] currPts[%" PRId64 "] maxInjectedPts[%" PRId64 "]\n", ret, playPts, currPts, maxInjectedPts); /* On some STBs PTS readed from decoder is invalid after seek or at start * this is the reason for additional validation when we what to close immediately @@ -596,7 +596,7 @@ static int64_t ffmpeg_seek(void *opaque __attribute__((unused)), int64_t offset, if (diff > 0 && diff < rwdiff) { /* can do the seek inside the buffer */ - ffmpeg_printf(20, "buffer-seek diff=%lld\n", diff); + ffmpeg_printf(20, "buffer-seek diff=%" PRId64 "\n", diff); if (diff > (ffmpeg_buf + ffmpeg_buf_size) - ffmpeg_buf_read) { ffmpeg_buf_read = ffmpeg_buf + (diff - ((ffmpeg_buf + ffmpeg_buf_size) - ffmpeg_buf_read)); @@ -609,7 +609,7 @@ static int64_t ffmpeg_seek(void *opaque __attribute__((unused)), int64_t offset, else if (diff < 0 && diff * -1 < ffmpeg_buf_valid_size) { /* can do the seek inside the buffer */ - ffmpeg_printf(20, "buffer-seek diff=%lld\n", diff); + ffmpeg_printf(20, "buffer-seek diff=%" PRId64 "\n", diff); int32_t tmpdiff = diff * -1; if (tmpdiff > ffmpeg_buf_read - ffmpeg_buf) { @@ -623,7 +623,7 @@ static int64_t ffmpeg_seek(void *opaque __attribute__((unused)), int64_t offset, else { releasefillerMutex(__FILE__, __FUNCTION__, __LINE__); - ffmpeg_printf(20, "real-seek diff=%lld\n", diff); + ffmpeg_printf(20, "real-seek diff=%" PRId64 "\n", diff); ffmpeg_do_seek_ret = 0; ffmpeg_do_seek = diff; diff --git a/libeplayer3-arm/container/container.c b/libeplayer3-arm/container/container.c index 48ea13a..04ee133 100644 --- a/libeplayer3-arm/container/container.c +++ b/libeplayer3-arm/container/container.c @@ -23,28 +23,7 @@ #include #include "common.h" - -#ifdef SAM_WITH_DEBUG -#define CONTAINER_DEBUG -#else -#define CONTAINER_SILENT -#endif - -#ifdef CONTAINER_DEBUG - -static short debug_level = 0; - -#define container_printf(level, x...) do { \ -if (debug_level >= level) printf(x); } while (0) -#else -#define container_printf(level, x...) -#endif - -#ifndef CONTAINER_SILENT -#define container_err(x...) do { printf(x); } while (0) -#else -#define container_err(x...) -#endif +#include "debug.h" static Container_t *AvailableContainer[] = { diff --git a/libeplayer3-arm/container/container_ffmpeg.c b/libeplayer3-arm/container/container_ffmpeg.c index 095d32a..6bf543b 100644 --- a/libeplayer3-arm/container/container_ffmpeg.c +++ b/libeplayer3-arm/container/container_ffmpeg.c @@ -25,6 +25,7 @@ /* ***************************** */ /* Includes */ /* ***************************** */ +#include "debug.h" #include #include @@ -66,30 +67,7 @@ * due to this we set own which use fopen/fread from * std library. */ -#define SAM_CUSTOM_IO - -//#define SAM_WITH_DEBUG -#ifdef SAM_WITH_DEBUG -#define FFMPEG_DEBUG -#else -#define FFMPEG_SILENT -#endif - -#ifdef FFMPEG_DEBUG - -static short debug_level = 1; - -#define ffmpeg_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s::%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define ffmpeg_printf(level, fmt, x...) -#endif - -#ifndef FFMPEG_SILENT -#define ffmpeg_err(fmt, x...) do { printf("[%s::%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define ffmpeg_err(fmt, x...) -#endif +#define USE_CUSTOM_IO /* Error Constants */ #define cERR_CONTAINER_FFMPEG_NO_ERROR 0 @@ -148,6 +126,7 @@ static int32_t container_ffmpeg_seek(Context_t *context, int64_t sec, uint8_t ab static int32_t container_ffmpeg_get_length(Context_t *context, int64_t *length); static int64_t calcPts(uint32_t avContextIdx, AVStream *stream, int64_t pts); static int32_t container_ffmpeg_stop(Context_t *context); +static int64_t doCalcPts(int64_t start_time, const AVRational time_base, int64_t pts); /* Progressive playback means that we play local file * but this local file can grows up, for example @@ -321,7 +300,7 @@ int32_t ffmpeg_av_dict_set(const char *key, const char *value, int32_t flags) static char *Codec2Encoding(int32_t codec_id, int32_t media_type, uint8_t *extradata, int extradata_size, int profile __attribute__((unused)), int32_t *version) { - ffmpeg_printf(10, "Codec ID: %d (%.8lx)\n", codec_id, codec_id); + ffmpeg_printf(10, "Codec ID: %d (%.8x)\n", codec_id, codec_id); switch (codec_id) { case AV_CODEC_ID_MPEG1VIDEO: @@ -466,32 +445,27 @@ static char *Codec2Encoding(int32_t codec_id, int32_t media_type, uint8_t *extra case AV_CODEC_ID_WEBVTT: return "D_WEBVTT/SUBTITLES"; default: - ffmpeg_err("Codec ID %d (%.8lx) not found\n", codec_id, codec_id); + ffmpeg_err("Codec ID %d (%.8x) not found\n", codec_id, codec_id); // Default to injected-pcm for unhandled audio types. if (media_type == AVMEDIA_TYPE_AUDIO) { return "A_IPCM"; } - ffmpeg_err("Codec ID %d (%.8lx) not found\n", codec_id, codec_id); + ffmpeg_err("Codec ID %d (%.8x) not found\n", codec_id, codec_id); } return NULL; } -static int64_t calcPts(uint32_t avContextIdx, AVStream *stream, int64_t pts) +static int64_t doCalcPts(int64_t start_time, const AVRational time_base, int64_t pts) { - if (!stream || pts == (int64_t)AV_NOPTS_VALUE) + if (time_base.den > 0) { - ffmpeg_err("stream / packet null\n"); - return INVALID_PTS_VALUE; - } - else if (stream->time_base.den > 0) - { - pts = av_rescale(pts, (int64_t)stream->time_base.num * 90000, stream->time_base.den); + pts = av_rescale(pts, (int64_t)time_base.num * 90000, time_base.den); } - if (avContextTab[avContextIdx]->start_time != AV_NOPTS_VALUE) + if (start_time != AV_NOPTS_VALUE) { - pts -= 90000 * avContextTab[avContextIdx]->start_time / AV_TIME_BASE; + pts -= 90000 * start_time / AV_TIME_BASE; } if (pts & 0x8000000000000000ull) @@ -506,6 +480,17 @@ static int64_t calcPts(uint32_t avContextIdx, AVStream *stream, int64_t pts) return pts; } +static int64_t calcPts(uint32_t avContextIdx, AVStream *stream, int64_t pts) +{ + if (!stream || pts == (int64_t)AV_NOPTS_VALUE) + { + ffmpeg_err("stream / packet null\n"); + return INVALID_PTS_VALUE; + } + + return doCalcPts(avContextTab[avContextIdx]->start_time, stream->time_base, pts); +} + /* search for metatdata in context and stream * and map it to our metadata. */ @@ -576,9 +561,7 @@ static void FFMPEGThread(Context_t *context) uint32_t cAVIdx = 0; #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56, 34, 100) - Mpeg4P2Context mpeg4p2_context; - memset(&mpeg4p2_context, 0, sizeof(Mpeg4P2Context)); - AVBitStreamFilterContext *mpeg4p2_bsf_context = av_bitstream_filter_init("mpeg4_unpack_bframes"); + Mpeg4P2Context *mpeg4p2_context = mpeg4p2_context_open(); #endif #ifdef HAVE_FLV2MPEG4_CONVERTER Flv2Mpeg4Context flv2mpeg4_context; @@ -691,7 +674,7 @@ static void FFMPEGThread(Context_t *context) isWaitingForFinish = 0; if (do_seek_target_seconds) { - ffmpeg_printf(10, "seek_target_seconds[%lld]\n", seek_target_seconds); + ffmpeg_printf(10, "seek_target_seconds[%" PRId64 "]\n", seek_target_seconds); uint32_t i = 0; for (; i < IPTV_AV_CONTEXT_MAX_NUM; i += 1) { @@ -746,12 +729,7 @@ static void FFMPEGThread(Context_t *context) } } #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56, 34, 100) - mpeg4p2_context_reset(&mpeg4p2_context); - if (NULL != mpeg4p2_bsf_context) - { - av_bitstream_filter_close(mpeg4p2_bsf_context); - mpeg4p2_bsf_context = av_bitstream_filter_init("mpeg4_unpack_bframes"); - } + mpeg4p2_context_reset(mpeg4p2_context); #endif #ifdef HAVE_FLV2MPEG4_CONVERTER flv2mpeg4_context_reset(&flv2mpeg4_context); @@ -810,7 +788,7 @@ static void FFMPEGThread(Context_t *context) } else { - ffmpeg_printf(1, "SKIP DISCARDED PACKET stream_index[%d] pid[%d]\n", packet.size, (int)packet.stream_index, pid); + ffmpeg_printf(1, "SKIP DISCARDED PACKET packed_size[%d] stream_index[%d] pid[%d]\n", packet.size, (int)packet.stream_index, pid); } ffmpeg_printf(200, "packet.size %d - index %d\n", packet.size, pid); @@ -819,19 +797,9 @@ static void FFMPEGThread(Context_t *context) { #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56, 34, 100) AVCodecContext *codec_context = videoTrack->avCodecCtx; - if (codec_context && codec_context->codec_id == AV_CODEC_ID_MPEG4 && NULL != mpeg4p2_bsf_context) + if (codec_context && codec_context->codec_id == AV_CODEC_ID_MPEG4 && NULL != mpeg4p2_context) { - // should never happen, if it does print error and exit immediately, so we can easily spot it - if (filter_packet(mpeg4p2_bsf_context, codec_context, &packet) < 0) - { - ffmpeg_err("cannot filter mpegp2 packet\n"); - exit(1); - } - if (mpeg4p2_write_packet(context, &mpeg4p2_context, videoTrack, cAVIdx, ¤tVideoPts, &latestPts, &packet) < 0) - { - ffmpeg_err("cannot write mpeg4p2 packet\n"); - exit(1); - } + mpeg4p2_write_packet(context, mpeg4p2_context, videoTrack, cAVIdx, ¤tVideoPts, &latestPts, &packet); update_max_injected_pts(latestPts); } else @@ -886,7 +854,7 @@ static void FFMPEGThread(Context_t *context) continue; } - ffmpeg_printf(200, "VideoTrack index = %d %lld\n", pid, currentVideoPts); + ffmpeg_printf(200, "VideoTrack index = %d %" PRId64 "\n", pid, currentVideoPts); avOut.data = packet.data; avOut.len = packet.size; @@ -1143,7 +1111,7 @@ static void FFMPEGThread(Context_t *context) ffmpeg_err("av_samples_alloc: %d\n", -e); continue; } - int64_t next_in_pts = av_rescale(av_frame_get_best_effort_timestamp(decoded_frame), + int64_t next_in_pts = av_rescale(wrapped_frame_get_best_effort_timestamp(decoded_frame), ((AVStream *) audioTrack->stream)->time_base.num * (int64_t)out_sample_rate * c->sample_rate, ((AVStream *) audioTrack->stream)->time_base.den); int64_t next_out_pts = av_rescale(swr_next_pts(swr, next_in_pts), @@ -1189,7 +1157,7 @@ static void FFMPEGThread(Context_t *context) else if (audioTrack->have_aacheader == 1) { ffmpeg_printf(200, "write audio aac\n"); - ffmpeg_printf(200, ">>>>>>> %x %x %x %x %x %x %x\n", packet.data[0], packet.data[1], packet.data[2], packet.data[3], packet.data[4], packet.data[5], packet.data[6]); + ffmpeg_printf(200, "> %hhx %hhx %hhx %hhx %x %hhx %hhx\n", packet.data[0], packet.data[1], packet.data[2], packet.data[3], packet.data[4], packet.data[5], packet.data[6]); avOut.data = packet.data; avOut.len = packet.size; @@ -1349,11 +1317,7 @@ static void FFMPEGThread(Context_t *context) } #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56, 34, 100) - mpeg4p2_context_reset(&mpeg4p2_context); - if (NULL != mpeg4p2_bsf_context) - { - av_bitstream_filter_close(mpeg4p2_bsf_context); - } + mpeg4p2_context_close(mpeg4p2_context); #endif hasPlayThreadStarted = 0; @@ -1381,7 +1345,7 @@ static int32_t interrupt_cb(void *ctx) return p->abortRequested || PlaybackDieNow(0); } -#ifdef SAM_CUSTOM_IO +#ifdef USE_CUSTOM_IO typedef struct CustomIOCtx_t { FILE *pFile; @@ -1543,7 +1507,7 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uin avContextTab[AVIdx]->interrupt_callback.callback = interrupt_cb; avContextTab[AVIdx]->interrupt_callback.opaque = context->playback; -#ifdef SAM_CUSTOM_IO +#ifdef USE_CUSTOM_IO if (0 == strstr(filename, "://") || 0 == strncmp(filename, "file://", 7)) { @@ -1917,15 +1881,14 @@ int32_t container_ffmpeg_init(Context_t *context, PlayFiles_t *playFilesNames) } /* initialize ffmpeg */ - avcodec_register_all(); - av_register_all(); - + wrapped_register_all(); avformat_network_init(); - // SULGE DEBUG ENABLED - // make ffmpeg silen - // av_log_set_level(AV_LOG_DEBUG); +#if FFMPEG_DEBUG_LEVEL >= 10 + av_log_set_level(AV_LOG_DEBUG); +#else av_log_set_callback(ffmpeg_silen_callback); +#endif context->playback->abortRequested = 0; int32_t res = container_ffmpeg_init_av_context(context, playFilesNames->szFirstFile, playFilesNames->iFirstFileSize, \ @@ -2156,7 +2119,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32 track.TimeScale = 1000; } - ffmpeg_printf(10, "bit_rate [%lld]\n", get_codecpar(stream)->bit_rate); + ffmpeg_printf(10, "bit_rate [%" PRId64 "]\n", get_codecpar(stream)->bit_rate); ffmpeg_printf(10, "time_base.den [%d]\n", stream->time_base.den); ffmpeg_printf(10, "time_base.num [%d]\n", stream->time_base.num); ffmpeg_printf(10, "width [%d]\n", get_codecpar(stream)->width); @@ -2187,7 +2150,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32 { track.avCodecCtx = wrapped_avcodec_get_context(cAVIdx, stream); } - ffmpeg_printf(1, "cAVIdx[%d]: MANAGER_ADD track VIDEO\n"); + ffmpeg_printf(1, "cAVIdx[%d]: MANAGER_ADD track VIDEO\n", cAVIdx); if (context->manager->video->Command(context, MANAGER_ADD, &track) < 0) { /* konfetti: fixme: is this a reason to return with error? */ @@ -2515,7 +2478,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32 if (context->manager->audio) { - ffmpeg_printf(1, "cAVIdx[%d]: MANAGER_ADD track AUDIO\n"); + ffmpeg_printf(1, "cAVIdx[%d]: MANAGER_ADD track AUDIO\n", cAVIdx); if (context->manager->audio->Command(context, MANAGER_ADD, &track) < 0) { if(track.aacbuf){ @@ -2780,7 +2743,7 @@ static int32_t container_ffmpeg_seek_bytes(off_t pos) int32_t flag = AVSEEK_FLAG_BYTE; off_t current_pos = avio_tell(avContextTab[0]->pb); - ffmpeg_printf(20, "seeking to position %lld (bytes)\n", pos); + ffmpeg_printf(20, "seeking to position %" PRId64 " (bytes)\n", pos); if (current_pos > pos) { @@ -2793,7 +2756,7 @@ static int32_t container_ffmpeg_seek_bytes(off_t pos) return cERR_CONTAINER_FFMPEG_ERR; } - ffmpeg_printf(30, "current_pos after seek %lld\n", avio_tell(avContextTab[0]->pb)); + ffmpeg_printf(30, "current_pos after seek %" PRId64 "\n", avio_tell(avContextTab[0]->pb)); return cERR_CONTAINER_FFMPEG_NO_ERROR; } @@ -2807,7 +2770,7 @@ static int32_t container_ffmpeg_seek_rel(Context_t *context, off_t pos, int64_t Track_t *current = NULL; seek_target_flag = 0; - ffmpeg_printf(10, "seeking %f sec relativ to %lld\n", sec, pos); + ffmpeg_printf(10, "seeking %" PRId64 " sec relativ to %" PRId64 "\n", sec, pos); context->manager->video->Command(context, MANAGER_GET_TRACK, &videoTrack); context->manager->audio->Command(context, MANAGER_GET_TRACK, &audioTrack); @@ -2865,7 +2828,7 @@ static int32_t container_ffmpeg_seek_rel(Context_t *context, off_t pos, int64_t return cERR_CONTAINER_FFMPEG_END_OF_FILE; } - ffmpeg_printf(10, "1. seeking to position %lld bytes ->sec %f\n", pos, sec); + ffmpeg_printf(10, "1. seeking to position %" PRId64 " bytes ->sec %f\n", pos, sec); seek_target_bytes = pos; do_seek_target_bytes = 1; @@ -2882,7 +2845,7 @@ static int32_t container_ffmpeg_seek_rel(Context_t *context, off_t pos, int64_t sec = 0; } - 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); + ffmpeg_printf(10, "2. seeking to position %" PRId64 " sec ->time base %f %d\n", sec, av_q2d(((AVStream *) current->stream)->time_base), AV_TIME_BASE); seek_target_seconds = sec * AV_TIME_BASE; do_seek_target_seconds = 1; @@ -2904,7 +2867,7 @@ static int32_t container_ffmpeg_seek(Context_t *context, int64_t sec, uint8_t ab if (!absolute) { - ffmpeg_printf(10, "seeking %lld sec\n", sec / AV_TIME_BASE); + ffmpeg_printf(10, "seeking %" PRId64 " sec\n", sec / AV_TIME_BASE); if (sec == 0) { ffmpeg_err("sec = 0 ignoring\n"); @@ -2928,7 +2891,7 @@ static int32_t container_ffmpeg_seek(Context_t *context, int64_t sec, uint8_t ab } } - ffmpeg_printf(10, "goto %lld sec\n", sec / AV_TIME_BASE); + ffmpeg_printf(10, "goto %" PRId64 " sec\n", sec / AV_TIME_BASE); context->manager->video->Command(context, MANAGER_GET_TRACK, &videoTrack); context->manager->audio->Command(context, MANAGER_GET_TRACK, &audioTrack); @@ -2982,7 +2945,7 @@ static int32_t container_ffmpeg_seek(Context_t *context, int64_t sec, uint8_t ab off_t pos = avio_tell(avContextTab[0]->pb); releaseMutex(__FILE__, __FUNCTION__, __LINE__); - ffmpeg_printf(10, "pos %lld %lld\n", pos, avContextTab[0]->bit_rate); + ffmpeg_printf(10, "pos %" PRId64 " %lld\n", pos, avContextTab[0]->bit_rate); if (avContextTab[0]->bit_rate) { @@ -3001,7 +2964,7 @@ static int32_t container_ffmpeg_seek(Context_t *context, int64_t sec, uint8_t ab pos = 0; } - ffmpeg_printf(10, "1. seeking to position %lld bytes ->sec %lld\n", pos / AV_TIME_BASE, sec / AV_TIME_BASE); + ffmpeg_printf(10, "1. seeking to position %" PRId64 " bytes ->sec %lld\n", pos / AV_TIME_BASE, sec / AV_TIME_BASE); seek_target_bytes = pos / AV_TIME_BASE; do_seek_target_bytes = 1; diff --git a/libeplayer3-arm/container/mpeg4p2_ffmpeg.c b/libeplayer3-arm/container/mpeg4p2_ffmpeg.c old mode 100644 new mode 100755 index 0565912..9b77542 --- a/libeplayer3-arm/container/mpeg4p2_ffmpeg.c +++ b/libeplayer3-arm/container/mpeg4p2_ffmpeg.c @@ -3,108 +3,46 @@ // http://forums.openpli.org/topic/39326-gstreamer10-and-mpeg4-part2/?hl=%2Bmpeg4+%2Bpart2 // -#define MPEG4P2_MAX_B_FRAMES_COUNT 5 - +// mpeg4_unpack_bframes typedef struct { - int b_frames_count; - int first_ip_frame_written; - int64_t packet_duration; - AVPacket *b_frames[MPEG4P2_MAX_B_FRAMES_COUNT]; - AVPacket *second_ip_frame; + const AVBitStreamFilter *bsf; + AVBSFContext *ctx; } Mpeg4P2Context; - -static void set_packet(AVPacket **pkt_dest, AVPacket *pkt_src) +static Mpeg4P2Context *mpeg4p2_context_open() { - if (pkt_dest == NULL) - return; - if (*pkt_dest != NULL) + Mpeg4P2Context *context = NULL; + const AVBitStreamFilter *bsf = av_bsf_get_by_name("mpeg4_unpack_bframes"); + if (bsf) { - wrapped_packet_unref(*pkt_dest); - av_free(*pkt_dest); - } - *pkt_dest = av_malloc(sizeof(AVPacket)); - av_packet_ref(*pkt_dest, pkt_src); -} - -static int filter_packet(AVBitStreamFilterContext *bsf_ctx, AVCodecContext *enc_ctx, AVPacket *pkt) -{ - int ret; - AVPacket new_pkt = *pkt; - ret = av_bitstream_filter_filter(bsf_ctx, enc_ctx, NULL, - &new_pkt.data, &new_pkt.size, - pkt->data, pkt->size, - pkt->flags & AV_PKT_FLAG_KEY); - if (ret == 0 && new_pkt.data != pkt->data) - { - if ((ret = av_packet_ref(&new_pkt, pkt)) < 0) - return -1; - ret = 1; - } - if (ret > 0) - { - pkt->side_data = NULL; - pkt->side_data_elems = 0; - wrapped_packet_unref(pkt); - new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size, - av_buffer_default_free, NULL, 0); - if (!new_pkt.buf) - return -1; - } - if (ret < 0) - { - ffmpeg_err("Failed to filter bitstream with filter %s for stream %d with codec %s\n", - bsf_ctx->filter->name, pkt->stream_index, - avcodec_get_name(enc_ctx->codec_id)); - return -1; - } - *pkt = new_pkt; - return 0; -} - -static void mpeg4p2_context_reset(Mpeg4P2Context *context) -{ - if (context == NULL) - return; - int i; - for (i = 0; i < MPEG4P2_MAX_B_FRAMES_COUNT; i++) - { - if (context->b_frames[i] != NULL) + context = malloc(sizeof(Mpeg4P2Context)); + if (context) { - wrapped_packet_unref(context->b_frames[i]); - av_free(context->b_frames[i]); + memset(context, 0x00, sizeof(Mpeg4P2Context)); + context->bsf = bsf; } - context->b_frames[i] = NULL; } - if (context->second_ip_frame != NULL) - { - wrapped_packet_unref(context->second_ip_frame); - av_free(context->second_ip_frame); - } - context->second_ip_frame = NULL; - - context->b_frames_count = 0; - context->first_ip_frame_written = 0; - context->packet_duration = 0; + return context; } -static void mpeg4p2_write(Context_t *ctx, Track_t *track, int avContextIdx, int64_t *pts_current, int64_t *pts_latest, AVPacket *pkt) +static void mpeg4p2_write(Context_t *ctx, Mpeg4P2Context *mpeg4p2_ctx, Track_t *track, int64_t start_time, int64_t *currentVideoPts, int64_t *latestPts, AVPacket *pkt) { - *pts_current = track->pts = calcPts(avContextIdx, track->stream, pkt->pts); - if ((*pts_current > *pts_latest) && (*pts_current != INVALID_PTS_VALUE)) + *currentVideoPts = track->pts = doCalcPts(start_time, mpeg4p2_ctx->ctx->time_base_out, pkt->pts); + if ((*currentVideoPts > *latestPts) && (*currentVideoPts != INVALID_PTS_VALUE)) { - *pts_latest = *pts_current; + *latestPts = *currentVideoPts; } - track->dts = calcPts(avContextIdx, track->stream, pkt->dts); + + track->dts = doCalcPts(start_time, mpeg4p2_ctx->ctx->time_base_out, pkt->dts); AudioVideoOut_t avOut; avOut.data = pkt->data; avOut.len = pkt->size; avOut.pts = track->pts; avOut.dts = track->dts; - avOut.extradata = track->extraData; - avOut.extralen = track->extraSize; + avOut.extradata = mpeg4p2_ctx->ctx->par_out->extradata; + avOut.extralen = mpeg4p2_ctx->ctx->par_out->extradata_size; avOut.frameRate = track->frame_rate; avOut.timeScale = track->TimeScale; avOut.width = track->width; @@ -117,97 +55,90 @@ static void mpeg4p2_write(Context_t *ctx, Track_t *track, int avContextIdx, int6 } } -static int mpeg4p2_write_packet(Context_t *ctx, Mpeg4P2Context *mpeg4p2_ctx, Track_t *track, int cAVIdx, int64_t *pts_current, int64_t *pts_latest, AVPacket *pkt) +static int mpeg4p2_context_reset(Mpeg4P2Context *context) { - uint8_t *data = pkt->data; - int data_len = pkt->size; - int pos = 0; - if (mpeg4p2_ctx->packet_duration == 0) + int ret = 0; + if (context && context->ctx) { - mpeg4p2_ctx->packet_duration = pkt->duration; - } - while (pos < data_len) - { - if (memcmp(&data[pos], "\x00\x00\x01\xb6", 4)) + // Flush + ret = av_bsf_send_packet(context->ctx, NULL); + if (ret == 0) { - pos++; - continue; - } - pos += 4; - switch ((data[pos] & 0xC0) >> 6) - { - case 0: // I-Frame - case 1: // P-Frame - if (!mpeg4p2_ctx->first_ip_frame_written) - { - mpeg4p2_ctx->first_ip_frame_written = 1; - pkt->pts = pkt->dts + mpeg4p2_ctx->packet_duration; - ffmpeg_printf(100, "Writing first I/P packet\n"); - mpeg4p2_write(ctx, track, cAVIdx, pts_current, pts_latest, pkt); - return 0; - } - else if (!mpeg4p2_ctx->second_ip_frame) - { - set_packet(&mpeg4p2_ctx->second_ip_frame, pkt); - return 0; - } - else - { - if (!mpeg4p2_ctx->b_frames_count) - { - mpeg4p2_ctx->second_ip_frame->pts = mpeg4p2_ctx->second_ip_frame->dts + mpeg4p2_ctx->packet_duration; - ffmpeg_printf(100, "Writing second I/P packet(1)\n"); - mpeg4p2_write(ctx, track, cAVIdx, pts_current, pts_latest, mpeg4p2_ctx->second_ip_frame); - set_packet(&mpeg4p2_ctx->second_ip_frame, pkt); - return 0; - } - else - { - mpeg4p2_ctx->second_ip_frame->pts = mpeg4p2_ctx->b_frames[mpeg4p2_ctx->b_frames_count - 1]->dts + mpeg4p2_ctx->packet_duration; - mpeg4p2_ctx->b_frames[0]->pts = mpeg4p2_ctx->second_ip_frame->dts + mpeg4p2_ctx->packet_duration; - int i; - for (i = 1; i < mpeg4p2_ctx->b_frames_count; i++) - { - mpeg4p2_ctx->b_frames[i]->pts = mpeg4p2_ctx->b_frames[i - 1]->dts + mpeg4p2_ctx->packet_duration; - } - ffmpeg_printf(100, "Writing second I/P packet(2)\n"); - mpeg4p2_write(ctx, track, cAVIdx, pts_current, pts_latest, mpeg4p2_ctx->second_ip_frame); - set_packet(&mpeg4p2_ctx->second_ip_frame, pkt); - for (i = 0; i < mpeg4p2_ctx->b_frames_count; i++) - { - ffmpeg_printf(100, "Writing B-frame[%d]\n", i); - mpeg4p2_write(ctx, track, cAVIdx, pts_current, pts_latest, mpeg4p2_ctx->b_frames[i]); - } - mpeg4p2_ctx->b_frames_count = 0; - return 0; - } - } - break; - case 3: // S-Frame - break; - case 2: // B-Frame - if (!mpeg4p2_ctx->second_ip_frame) - { - ffmpeg_err("Cannot predict B-Frame without surrounding I/P-Frames, dropping..."); - return 0; - } - if (mpeg4p2_ctx->b_frames_count == MPEG4P2_MAX_B_FRAMES_COUNT) - { - ffmpeg_err("Oops max B-Frames count = %d, reached", MPEG4P2_MAX_B_FRAMES_COUNT); - // not recoverable, to fix just increase MPEG4P2_MAX_B_FRAMES_COUNT - return -1; - } - else - { - ffmpeg_printf(100, "Storing B-Frame\n"); - set_packet(&mpeg4p2_ctx->b_frames[mpeg4p2_ctx->b_frames_count++], pkt); - return 0; - } - case 4: - default: - break; + AVPacket *pkt = NULL; + while ((ret = av_bsf_receive_packet(context->ctx, pkt)) == 0) + { + wrapped_frame_unref(pkt); + } } + av_bsf_free(&context->ctx); + } + + return ret; +} + +static int mpeg4p2_write_packet(Context_t *ctx, Mpeg4P2Context *mpeg4p2_ctx, Track_t *track, int cAVIdx, int64_t *pts_current, int64_t *pts_latest, AVPacket *pkt) +{ + int ret = 0; + if (mpeg4p2_ctx) + { + // Setup is needed + if (!mpeg4p2_ctx->ctx) + { + ret = av_bsf_alloc(mpeg4p2_ctx->bsf, &mpeg4p2_ctx->ctx); + if (ret == 0) + { + AVStream *in = track->stream; + ret = avcodec_parameters_copy(mpeg4p2_ctx->ctx->par_in, in->codecpar); + if (ret == 0) + { + mpeg4p2_ctx->ctx->time_base_in = in->time_base; + ret = av_bsf_init(mpeg4p2_ctx->ctx); + } + } + } + + if (ret == 0) + { + ret = av_bsf_send_packet(mpeg4p2_ctx->ctx, pkt); + if (ret == 0) + { + while ((ret = av_bsf_receive_packet(mpeg4p2_ctx->ctx, pkt)) == 0) + { + mpeg4p2_write(ctx, mpeg4p2_ctx, track, avContextTab[cAVIdx]->start_time, pts_current, pts_latest, pkt); + } + + if (ret == AVERROR(EAGAIN)) + { + return 0; + } + + if (ret < 0) + { + ffmpeg_err("av_bsf_receive_packet failed error 0x%x\n", ret); + mpeg4p2_context_reset(mpeg4p2_ctx); + } + } + } + else + { + ffmpeg_err("bsf setup failed error 0x%x\n", ret); + } + + } + else + { + ret = -1; + } + return ret; +} + +static void mpeg4p2_context_close(Mpeg4P2Context *context) +{ + if (context) + { + mpeg4p2_context_reset(context); + free(context); + return; } - return 0; } diff --git a/libeplayer3-arm/container/wrapped_ffmpeg.c b/libeplayer3-arm/container/wrapped_ffmpeg.c index 2bf6bb7..b86e61f 100644 --- a/libeplayer3-arm/container/wrapped_ffmpeg.c +++ b/libeplayer3-arm/container/wrapped_ffmpeg.c @@ -153,8 +153,11 @@ static AVCodecContext *wrapped_avcodec_get_context(uint32_t cAVIdx, AVStream *st avcodec_free_context(&avCodecCtx); return NULL; } +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100) av_codec_set_pkt_timebase(avCodecCtx, stream->time_base); - +#else + avCodecCtx->pkt_timebase = stream->time_base; +#endif store_avcodec_context(avCodecCtx, cAVIdx, stream->id); } @@ -187,3 +190,22 @@ static void wrapped_avcodec_flush_buffers(uint32_t cAVIdx) } #endif } + +static void wrapped_register_all(void) +{ +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100) + avcodec_register_all(); + av_register_all(); +#endif +} + +static int64_t wrapped_frame_get_best_effort_timestamp(const AVFrame *frame) +{ +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100) + return av_frame_get_best_effort_timestamp(frame); +#else + return frame->best_effort_timestamp; +#endif +} + + diff --git a/libeplayer3-arm/external/ffmpeg/src/latmenc.c b/libeplayer3-arm/external/ffmpeg/src/latmenc.c index 9c13c32..2711bc6 100644 --- a/libeplayer3-arm/external/ffmpeg/src/latmenc.c +++ b/libeplayer3-arm/external/ffmpeg/src/latmenc.c @@ -26,18 +26,11 @@ #include #include #include +#include "debug.h" /* ***************************** */ /* Makros/Constants */ /* ***************************** */ -//#define LATMENC_SILENT - -#ifndef LATMENC_SILENT -#define latmenc_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define latmenc_err(fmt, x...) -#endif - int latmenc_decode_extradata(LATMContext *ctx, uint8_t *buf, int size) { diff --git a/libeplayer3-arm/include/debug.h b/libeplayer3-arm/include/debug.h index 1740868..ea27cea 100644 --- a/libeplayer3-arm/include/debug.h +++ b/libeplayer3-arm/include/debug.h @@ -1,21 +1,526 @@ -#ifndef debug_123 -#define debug_123 - #include -#include +#define log_error(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) +#define log_printf(maxlevel, level, fmt, x...) do { if (maxlevel >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -static inline void Hexdump(unsigned char *Data, int length) -{ - int k; - for (k = 0; k < length; k++) - { - printf("%02x ", Data[k]); - if (((k + 1) & 31) == 0) - printf("\n"); - } - printf("\n"); - -} +/******************************************* + * ffmpeg + *******************************************/ +#define FFMPEG_DEBUG_LEVEL 0 +#define FFMPEG_SILENT +#if FFMPEG_DEBUG_LEVEL +#define ffmpeg_printf(...) log_printf(FFMPEG_DEBUG_LEVEL, __VA_ARGS__) +#else +#define ffmpeg_printf(...) #endif + +#ifndef FFMPEG_SILENT +#define ffmpeg_err(...) log_error(__VA_ARGS__) +#else +#define ffmpeg_err(...) +#endif + +/******************************************* + * container + *******************************************/ +#define CONTAINER_DEBUG_LEVEL 0 +#define CONTAINER_SILENT + +#if CONTAINER_DEBUG_LEVEL +#define container_printf(...) log_printf(CONTAINER_DEBUG_LEVEL, __VA_ARGS__) +#else +#define container_printf(...) +#endif + +#ifndef CONTAINER_SILENT +#define container_err(...) log_error(__VA_ARGS__) +#else +#define container_err(...) +#endif + +/******************************************* + * latmenc + *******************************************/ +#define LATMENC_DEBUG_LEVEL 0 +#define LATMENC_SILENT + +#if LATMENC_DEBUG_LEVEL +#define latmenc_printf(...) log_printf(LATMENC_DEBUG_LEVEL, __VA_ARGS__) +#else +#define latmenc_printf(...) +#endif + +#ifndef LATMENC_SILENT +#define latmenc_err(...) log_error(__VA_ARGS__) +#else +#define latmenc_err(...) +#endif + +/******************************************* + * audio_mgr + *******************************************/ +#define AUDIO_MGR_DEBUG_LEVEL 0 +#define AUDIO_MGR_SILENT + +#if AUDIO_MGR_DEBUG_LEVEL +#define audio_mgr_printf(...) log_printf(AUDIO_MGR_DEBUG_LEVEL, __VA_ARGS__) +#else +#define audio_mgr_printf(...) +#endif + +#ifndef AUDIO_MGR_SILENT +#define audio_mgr_err(...) log_error(__VA_ARGS__) +#else +#define audio_mgr_err(...) +#endif + +/******************************************* + * subtitle_mgr + *******************************************/ +#define SUBTITLE_MGR_DEBUG_LEVEL 0 +#define SUBTITLE_MGR_SILENT + +#if SUBTITLE_MGR_DEBUG_LEVEL +#define subtitle_mgr_printf(...) log_printf(SUBTITLE_MGR_DEBUG_LEVEL, __VA_ARGS__) +#else +#define subtitle_mgr_printf(...) +#endif + +#ifndef SUBTITLE_MGR_SILENT +#define subtitle_mgr_err(...) log_error(__VA_ARGS__) +#else +#define subtitle_mgr_err(...) +#endif + +/******************************************* + * video_mgr + *******************************************/ +#define VIDEO_MGR_DEBUG_LEVEL 0 +#define VIDEO_MGR_SILENT + +#if VIDEO_MGR_DEBUG_LEVEL +#define video_mgr_printf(...) log_printf(VIDEO_MGR_DEBUG_LEVEL, __VA_ARGS__) +#else +#define video_mgr_printf(...) +#endif + +#ifndef VIDEO_MGR_SILENT +#define video_mgr_err(...) log_error(__VA_ARGS__) +#else +#define video_mgr_err(...) +#endif + +/******************************************* + * linuxdvb + *******************************************/ +#define LINUXDVB_DEBUG_LEVEL 0 +#define LINUXDVB_SILENT + +#if LINUXDVB_DEBUG_LEVEL +#define linuxdvb_printf(...) log_printf(LINUXDVB_DEBUG_LEVEL, __VA_ARGS__) +#else +#define linuxdvb_printf(...) +#endif + +#ifndef LINUXDVB_SILENT +#define linuxdvb_err(...) log_error(__VA_ARGS__) +#else +#define linuxdvb_err(...) +#endif + +/******************************************* + * buff + *******************************************/ +#define BUFF_DEBUG_LEVEL 0 +#define BUFF_SILENT + +#if BUFF_DEBUG_LEVEL +#define buff_printf(...) log_printf(BUFF_DEBUG_LEVEL, __VA_ARGS__) +#else +#define buff_printf(...) +#endif + +#ifndef BUFF_SILENT +#define buff_err(...) log_error(__VA_ARGS__) +#else +#define buff_err(...) +#endif + +/******************************************* + * output + *******************************************/ +#define OUTPUT_DEBUG_LEVEL 0 +#define OUTPUT_SILENT + +#if OUTPUT_DEBUG_LEVEL +#define output_printf(...) log_printf(OUTPUT_DEBUG_LEVEL, __VA_ARGS__) +#else +#define output_printf(...) +#endif + +#ifndef OUTPUT_SILENT +#define output_err(...) log_error(__VA_ARGS__) +#else +#define output_err(...) +#endif + +/******************************************* + * subtitle + *******************************************/ +#define SUBTITLE_DEBUG_LEVEL 0 +#define SUBTITLE_SILENT + +#if SUBTITLE_DEBUG_LEVEL +#define subtitle_printf(...) log_printf(SUBTITLE_DEBUG_LEVEL, __VA_ARGS__) +#else +#define subtitle_printf(...) +#endif + +#ifndef SUBTITLE_SILENT +#define subtitle_err(...) log_error(__VA_ARGS__) +#else +#define subtitle_err(...) +#endif + +/******************************************* + * writer + *******************************************/ +#define WRITER_DEBUG_LEVEL 0 +#define WRITER_SILENT + +#if WRITER_DEBUG_LEVEL +#define writer_printf(...) log_printf(WRITER_DEBUG_LEVEL, __VA_ARGS__) +#else +#define writer_printf(...) +#endif + +#ifndef WRITER_SILENT +#define writer_err(...) log_error(__VA_ARGS__) +#else +#define writer_err(...) +#endif + +/******************************************* + * playback + *******************************************/ +#define PLAYBACK_DEBUG_LEVEL 0 +#define PLAYBACK_SILENT + +#if PLAYBACK_DEBUG_LEVEL +#define playback_printf(...) log_printf(PLAYBACK_DEBUG_LEVEL, __VA_ARGS__) +#else +#define playback_printf(...) +#endif + +#ifndef PLAYBACK_SILENT +#define playback_err(...) log_error(__VA_ARGS__) +#else +#define playback_err(...) +#endif + +/******************************************* + * aac + *******************************************/ +#define AAC_DEBUG_LEVEL 0 +#define AAC_SILENT + +#if AAC_DEBUG_LEVEL +#define aac_printf(...) log_printf(AAC_DEBUG_LEVEL, __VA_ARGS__) +#else +#define aac_printf(...) +#endif + +#ifndef AAC_SILENT +#define aac_err(...) log_error(__VA_ARGS__) +#else +#define aac_err(...) +#endif + +/******************************************* + * ac3 + *******************************************/ +#define AC3_DEBUG_LEVEL 0 +#define AC3_SILENT + +#if AC3_DEBUG_LEVEL +#define ac3_printf(...) log_printf(AC3_DEBUG_LEVEL, __VA_ARGS__) +#else +#define ac3_printf(...) +#endif + +#ifndef AC3_SILENT +#define ac3_err(...) log_error(__VA_ARGS__) +#else +#define ac3_err(...) +#endif + +/******************************************* + * amr + *******************************************/ +#define AMR_DEBUG_LEVEL 0 +#define AMR_SILENT + +#if AMR_DEBUG_LEVEL +#define amr_printf(...) log_printf(AMR_DEBUG_LEVEL, __VA_ARGS__) +#else +#define amr_printf(...) +#endif + +#ifndef AMR_SILENT +#define amr_err(...) log_error(__VA_ARGS__) +#else +#define amr_err(...) +#endif + +/******************************************* + * divx + *******************************************/ +#define DIVX_DEBUG_LEVEL 0 +#define DIVX_SILENT + +#if DIVX_DEBUG_LEVEL +#define divx_printf(...) log_printf(DIVX_DEBUG_LEVEL, __VA_ARGS__) +#else +#define divx_printf(...) +#endif + +#ifndef DIVX_SILENT +#define divx_err(...) log_error(__VA_ARGS__) +#else +#define divx_err(...) +#endif + +/******************************************* + * dts + *******************************************/ +#define DTS_DEBUG_LEVEL 0 +#define DTS_SILENT + +#if DTS_DEBUG_LEVEL +#define dts_printf(...) log_printf(DTS_DEBUG_LEVEL, __VA_ARGS__) +#else +#define dts_printf(...) +#endif + +#ifndef DTS_SILENT +#define dts_err(...) log_error(__VA_ARGS__) +#else +#define dts_err(...) +#endif + +/******************************************* + * h263 + *******************************************/ +#define H263_DEBUG_LEVEL 0 +#define H263_SILENT + +#if H263_DEBUG_LEVEL +#define h263_printf(...) log_printf(H263_DEBUG_LEVEL, __VA_ARGS__) +#else +#define h263_printf(...) +#endif + +#ifndef H263_SILENT +#define h263_err(...) log_error(__VA_ARGS__) +#else +#define h263_err(...) +#endif + +/******************************************* + * h264 + *******************************************/ +#define H264_DEBUG_LEVEL 0 +#define H264_SILENT + +#if H264_DEBUG_LEVEL +#define h264_printf(...) log_printf(H264_DEBUG_LEVEL, __VA_ARGS__) +#else +#define h264_printf(...) +#endif + +#ifndef H264_SILENT +#define h264_err(...) log_error(__VA_ARGS__) +#else +#define h264_err(...) +#endif + +/******************************************* + * h265 + *******************************************/ +#define H265_DEBUG_LEVEL 0 +#define H265_SILENT + +#if H265_DEBUG_LEVEL +#define h265_printf(...) log_printf(H265_DEBUG_LEVEL, __VA_ARGS__) +#else +#define h265_printf(...) +#endif + +#ifndef H265_SILENT +#define h265_err(...) log_error(__VA_ARGS__) +#else +#define h265_err(...) +#endif + +/******************************************* + * lpcm + *******************************************/ +#define LPCM_DEBUG_LEVEL 0 +#define LPCM_SILENT + +#if LPCM_DEBUG_LEVEL +#define lpcm_printf(...) log_printf(LPCM_DEBUG_LEVEL, __VA_ARGS__) +#else +#define lpcm_printf(...) +#endif + +#ifndef LPCM_SILENT +#define lpcm_err(...) log_error(__VA_ARGS__) +#else +#define lpcm_err(...) +#endif + +/******************************************* + * mp3 + *******************************************/ +#define MP3_DEBUG_LEVEL 0 +#define MP3_SILENT + +#if MP3_DEBUG_LEVEL +#define mp3_printf(...) log_printf(MP3_DEBUG_LEVEL, __VA_ARGS__) +#else +#define mp3_printf(...) +#endif + +#ifndef MP3_SILENT +#define mp3_err(...) log_error(__VA_ARGS__) +#else +#define mp3_err(...) +#endif + +/******************************************* + * mpeg2 + *******************************************/ +#define MPEG2_DEBUG_LEVEL 0 +#define MPEG2_SILENT + +#if MPEG2_DEBUG_LEVEL +#define mpeg2_printf(...) log_printf(MPEG2_DEBUG_LEVEL, __VA_ARGS__) +#else +#define mpeg2_printf(...) +#endif + +#ifndef MPEG2_SILENT +#define mpeg2_err(...) log_error(__VA_ARGS__) +#else +#define mpeg2_err(...) +#endif + +/******************************************* + * mpeg4 + *******************************************/ +#define MPEG4_DEBUG_LEVEL 0 +#define MPEG4_SILENT + +#if MPEG4_DEBUG_LEVEL +#define mpeg4_printf(...) log_printf(MPEG4_DEBUG_LEVEL, __VA_ARGS__) +#else +#define mpeg4_printf(...) +#endif + +#ifndef MPEG4_SILENT +#define mpeg4_err(...) log_error(__VA_ARGS__) +#else +#define mpeg4_err(...) +#endif + +/******************************************* + * pcm + *******************************************/ +#define PCM_DEBUG_LEVEL 0 +#define PCM_SILENT + +#if PCM_DEBUG_LEVEL +#define pcm_printf(...) log_printf(PCM_DEBUG_LEVEL, __VA_ARGS__) +#else +#define pcm_printf(...) +#endif + +#ifndef PCM_SILENT +#define pcm_err(...) log_error(__VA_ARGS__) +#else +#define pcm_err(...) +#endif + +/******************************************* + * vc1 + *******************************************/ +#define VC1_DEBUG_LEVEL 0 +#define VC1_SILENT + +#if VC1_DEBUG_LEVEL +#define vc1_printf(...) log_printf(VC1_DEBUG_LEVEL, __VA_ARGS__) +#else +#define vc1_printf(...) +#endif + +#ifndef VC1_SILENT +#define vc1_err(...) log_error(__VA_ARGS__) +#else +#define vc1_err(...) +#endif + +/******************************************* + * vp + *******************************************/ +#define VP_DEBUG_LEVEL 0 +#define VP_SILENT + +#if VP_DEBUG_LEVEL +#define vp_printf(...) log_printf(VP_DEBUG_LEVEL, __VA_ARGS__) +#else +#define vp_printf(...) +#endif + +#ifndef VP_SILENT +#define vp_err(...) log_error(__VA_ARGS__) +#else +#define vp_err(...) +#endif + +/******************************************* + * wma + *******************************************/ +#define WMA_DEBUG_LEVEL 0 +#define WMA_SILENT + +#if WMA_DEBUG_LEVEL +#define wma_printf(...) log_printf(WMA_DEBUG_LEVEL, __VA_ARGS__) +#else +#define wma_printf(...) +#endif + +#ifndef WMA_SILENT +#define wma_err(...) log_error(__VA_ARGS__) +#else +#define wma_err(...) +#endif + +/******************************************* + * wmv + *******************************************/ +#define WMV_DEBUG_LEVEL 0 +#define WMV_SILENT + +#if WMV_DEBUG_LEVEL +#define wmv_printf(...) log_printf(WMV_DEBUG_LEVEL, __VA_ARGS__) +#else +#define wmv_printf(...) +#endif + +#ifndef WMV_SILENT +#define wmv_err(...) log_error(__VA_ARGS__) +#else +#define wmv_err(...) +#endif \ No newline at end of file diff --git a/libeplayer3-arm/main/exteplayer.c b/libeplayer3-arm/main/exteplayer.c index cba7d2a..aa55253 100644 --- a/libeplayer3-arm/main/exteplayer.c +++ b/libeplayer3-arm/main/exteplayer.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,8 @@ #include "common.h" #include "misc.h" +#include "debug.h" + #define DUMP_BOOL(x) 0 == x ? "false" : "true" #define IPTV_MAX_FILE_PATH 1024 @@ -691,7 +694,7 @@ int main(int argc, char *argv[]) memset(argvBuff, '\0', sizeof(argvBuff)); int commandRetVal = -1; /* inform client that we can handle additional commands */ - fprintf(stderr, "{\"EPLAYER3_EXTENDED\":{\"version\":%d}}\n", 49); + fprintf(stderr, "{\"EPLAYER3_EXTENDED\":{\"version\":%d}}\n", 50); PlayFiles_t playbackFiles; memset(&playbackFiles, 0x00, sizeof(playbackFiles)); @@ -938,7 +941,7 @@ int main(int argc, char *argv[]) if (0 <= gotoPos || force) { commandRetVal = g_player->playback->Command(g_player, PLAYBACK_LENGTH, (void *)&length); - fprintf(stderr, "{\"PLAYBACK_LENGTH\":{\"length\":%lld, \"sts\":%d}}\n", length, commandRetVal); + fprintf(stderr, "{\"PLAYBACK_LENGTH\":{\"length\":%" PRId64 ", \"sts\":%d}}\n", length, commandRetVal); lengthInt = (int32_t)length; if (10 <= lengthInt || force) @@ -950,7 +953,7 @@ int main(int argc, char *argv[]) } commandRetVal = g_player->playback->Command(g_player, PLAYBACK_SEEK_ABS, (void *)&sec); - fprintf(stderr, "{\"PLAYBACK_SEEK_ABS\":{\"sec\":%lld, \"sts\":%d}}\n", sec, commandRetVal); + fprintf(stderr, "{\"PLAYBACK_SEEK_ABS\":{\"sec\":%" PRId64 ", \"sts\":%d}}\n", sec, commandRetVal); } } break; @@ -972,13 +975,13 @@ int main(int argc, char *argv[]) if (0 == commandRetVal) { - fprintf(stderr, "{\"J\":{\"ms\":%lld}}\n", pts / 90); + fprintf(stderr, "{\"J\":{\"ms\":%" PRId64 "}}\n", pts / 90); } if (0 == commandRetVal || force) { commandRetVal = g_player->playback->Command(g_player, PLAYBACK_LENGTH, (void *)&length); - fprintf(stderr, "{\"PLAYBACK_LENGTH\":{\"length\":%lld, \"sts\":%d}}\n", length, commandRetVal); + fprintf(stderr, "{\"PLAYBACK_LENGTH\":{\"length\":%" PRId64 ", \"sts\":%d}}\n", length, commandRetVal); lengthInt = (int32_t)length; if (10 <= lengthInt || force) @@ -1002,7 +1005,7 @@ int main(int argc, char *argv[]) } } commandRetVal = g_player->playback->Command(g_player, PLAYBACK_SEEK, (void *)&sec); - fprintf(stderr, "{\"PLAYBACK_SEEK\":{\"sec\":%lld, \"sts\":%d}}\n", sec, commandRetVal); + fprintf(stderr, "{\"PLAYBACK_SEEK\":{\"sec\":%" PRId64 ", \"sts\":%d}}\n", sec, commandRetVal); } break; } @@ -1010,7 +1013,7 @@ int main(int argc, char *argv[]) { int64_t length = 0; commandRetVal = g_player->playback->Command(g_player, PLAYBACK_LENGTH, (void *)&length); - fprintf(stderr, "{\"PLAYBACK_LENGTH\":{\"length\":%lld, \"sts\":%d}}\n", length, commandRetVal); + fprintf(stderr, "{\"PLAYBACK_LENGTH\":{\"length\":%" PRId64 ", \"sts\":%d}}\n", length, commandRetVal); break; } case 'j': @@ -1029,11 +1032,11 @@ int main(int argc, char *argv[]) if (0 == commandRetVal && lastPts != INVALID_PTS_VALUE) { - fprintf(stderr, "{\"J\":{\"ms\":%lld,\"lms\":%lld}}\n", pts / 90, lastPts / 90); + fprintf(stderr, "{\"J\":{\"ms\":%" PRId64 ",\"lms\":%" PRId64 "}}\n", pts / 90, lastPts / 90); } else { - fprintf(stderr, "{\"J\":{\"ms\":%lld}}\n", pts / 90); + fprintf(stderr, "{\"J\":{\"ms\":%" PRId64 "}}\n", pts / 90); } } break; diff --git a/libeplayer3-arm/manager/audio.c b/libeplayer3-arm/manager/audio.c index 540d432..d2240a0 100644 --- a/libeplayer3-arm/manager/audio.c +++ b/libeplayer3-arm/manager/audio.c @@ -27,6 +27,7 @@ #include #include "manager.h" #include "common.h" +#include "debug.h" /* ***************************** */ /* Makros/Constants */ @@ -34,29 +35,6 @@ #define TRACKWRAP 20 -//#define SAM_WITH_DEBUG -#ifdef SAM_WITH_DEBUG -#define AUDIO_MGR_DEBUG -#else -#define AUDIO_MGR_SILENT -#endif - -#ifdef AUDIO_MGR_DEBUG - -static short debug_level = 40; - -#define audio_mgr_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s::%s] \n" fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define audio_mgr_printf(level, x...) -#endif - -#ifndef AUDIO_MGR_SILENT -#define audio_mgr_err(x...) do { printf(x); } while (0) -#else -#define audio_mgr_err(x...) -#endif - /* Error Constants */ #define cERR_AUDIO_MGR_NO_ERROR 0 #define cERR_AUDIO_MGR_ERROR -1 diff --git a/libeplayer3-arm/manager/subtitle.c b/libeplayer3-arm/manager/subtitle.c index 5386bde..1e26e30 100644 --- a/libeplayer3-arm/manager/subtitle.c +++ b/libeplayer3-arm/manager/subtitle.c @@ -26,6 +26,7 @@ #include "manager.h" #include "common.h" +#include "debug.h" /* ***************************** */ /* Makros/Constants */ @@ -33,30 +34,6 @@ #define TRACKWRAP 20 -//#define SAM_WITH_DEBUG -#ifdef SAM_WITH_DEBUG -#define SUBTITLE_MGR_DEBUG -#else -#define SUBTITLE_MGR_SILENT -#endif - - -#ifdef SUBTITLE_MGR_DEBUG - -static short debug_level = 20; - -#define subtitle_mgr_printf(level, x...) do { \ -if (debug_level >= level) printf(x); } while (0) -#else -#define subtitle_mgr_printf(level, x...) -#endif - -#ifndef SUBTITLE_MGR_SILENT -#define subtitle_mgr_err(x...) do { printf(x); } while (0) -#else -#define subtitle_mgr_err(x...) -#endif - /* Error Constants */ #define cERR_SUBTITLE_MGR_NO_ERROR 0 #define cERR_SUBTITLE_MGR_ERROR -1 diff --git a/libeplayer3-arm/manager/video.c b/libeplayer3-arm/manager/video.c index 93b7073..35a8181 100644 --- a/libeplayer3-arm/manager/video.c +++ b/libeplayer3-arm/manager/video.c @@ -26,6 +26,7 @@ #include "manager.h" #include "common.h" +#include "debug.h" /* ***************************** */ /* Makros/Constants */ @@ -33,28 +34,6 @@ #define TRACKWRAP 4 -#ifdef SAM_WITH_DEBUG -#define VIDEO_MGR_DEBUG -#else -#define VIDEO_MGR_SILENT -#endif - -#ifdef VIDEO_MGR_DEBUG - -static short debug_level = 0; - -#define video_mgr_printf(level, x...) do { \ -if (debug_level >= level) printf(x); } while (0) -#else -#define video_mgr_printf(level, x...) -#endif - -#ifndef VIDEO_MGR_SILENT -#define video_mgr_err(x...) do { printf(x); } while (0) -#else -#define video_mgr_err(x...) -#endif - /* Error Constants */ #define cERR_VIDEO_MGR_NO_ERROR 0 #define cERR_VIDEO_MGR_ERROR -1 @@ -83,7 +62,7 @@ static void (* updatedTrackInfoFnc)(void) = NULL; static int ManagerAdd(Context_t *context, Track_t track) { - video_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); + video_mgr_printf(10, "\n"); if (Tracks == NULL) { @@ -97,7 +76,7 @@ static int ManagerAdd(Context_t *context, Track_t track) if (Tracks == NULL) { - video_mgr_err("%s::%s malloc failed\n", __FILE__, __FUNCTION__); + video_mgr_err("malloc failed\n"); return cERR_VIDEO_MGR_ERROR; } @@ -118,7 +97,7 @@ static int ManagerAdd(Context_t *context, Track_t track) } else { - video_mgr_err("%s::%s TrackCount out if range %d - %d\n", __FILE__, __FUNCTION__, TrackCount, TRACKWRAP); + video_mgr_err("TrackCount out if range %d - %d\n", TrackCount, TRACKWRAP); return cERR_VIDEO_MGR_ERROR; } @@ -127,7 +106,7 @@ static int ManagerAdd(Context_t *context, Track_t track) context->playback->isVideo = 1; } - video_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); + video_mgr_printf(10, "\n"); return cERR_VIDEO_MGR_NO_ERROR; } @@ -137,7 +116,7 @@ static char **ManagerList(Context_t *context __attribute__((unused))) int i = 0, j = 0; char **tracklist = NULL; - video_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); + video_mgr_printf(10, "\n"); if (Tracks != NULL) { @@ -145,7 +124,7 @@ static char **ManagerList(Context_t *context __attribute__((unused))) if (tracklist == NULL) { - video_mgr_err("%s::%s malloc failed\n", __FILE__, __FUNCTION__); + video_mgr_err("malloc failed\n"); return NULL; } @@ -164,7 +143,7 @@ static char **ManagerList(Context_t *context __attribute__((unused))) tracklist[j] = NULL; } - video_mgr_printf(10, "%s::%s return %p (%d - %d)\n", __FILE__, __FUNCTION__, tracklist, j, TrackCount); + video_mgr_printf(10, "return %p (%d - %d)\n", tracklist, j, TrackCount); return tracklist; } @@ -173,7 +152,7 @@ static int ManagerDel(Context_t *context) { int i = 0; - video_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); + video_mgr_printf(10, "\n"); if (Tracks != NULL) { @@ -186,7 +165,7 @@ static int ManagerDel(Context_t *context) } else { - video_mgr_err("%s::%s nothing to delete!\n", __FILE__, __FUNCTION__); + video_mgr_err("nothing to delete!\n"); return cERR_VIDEO_MGR_ERROR; } @@ -194,7 +173,7 @@ static int ManagerDel(Context_t *context) CurrentTrack = 0; context->playback->isVideo = 0; - video_mgr_printf(10, "%s::%s return no error\n", __FILE__, __FUNCTION__); + video_mgr_printf(10, "return no error\n"); return cERR_VIDEO_MGR_NO_ERROR; } @@ -202,7 +181,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) { int ret = cERR_VIDEO_MGR_NO_ERROR; - video_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__); + video_mgr_printf(10, "\n"); switch (command) { @@ -258,7 +237,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) } case MANAGER_GET_TRACK: { - video_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", __FILE__, __FUNCTION__); + video_mgr_printf(20, "MANAGER_GET_TRACK\n"); if ((TrackCount > 0) && (CurrentTrack >= 0)) { @@ -308,7 +287,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) if (i == TrackCount) { - video_mgr_err("%s::%s track id %d unknown\n", __FILE__, __FUNCTION__, *((int *)argument)); + video_mgr_err("track id %d unknown\n", *((int *)argument)); ret = cERR_VIDEO_MGR_ERROR; } break; @@ -339,12 +318,12 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument) break; } default: - video_mgr_err("%s::%s ContainerCmd %d not supported!\n", __FILE__, __FUNCTION__, command); + video_mgr_err("ContainerCmd %d not supported!\n", command); ret = cERR_VIDEO_MGR_ERROR; break; } - video_mgr_printf(10, "%s::%s returning %d\n", __FILE__, __FUNCTION__, ret); + video_mgr_printf(10, "returning %d\n", ret); return ret; } diff --git a/libeplayer3-arm/output/linuxdvb_buffering.c b/libeplayer3-arm/output/linuxdvb_buffering.c index 1df9028..3f70d47 100644 --- a/libeplayer3-arm/output/linuxdvb_buffering.c +++ b/libeplayer3-arm/output/linuxdvb_buffering.c @@ -36,6 +36,7 @@ #include #include "common.h" +#include "debug.h" #include "misc.h" #include "writer.h" @@ -62,29 +63,6 @@ typedef struct BufferingNode_s #define cERR_LINUX_DVB_BUFFERING_NO_ERROR 0 #define cERR_LINUX_DVB_BUFFERING_ERROR -1 -//#define SAM_WITH_DEBUG -#ifdef SAM_WITH_DEBUG -#define LINUX_DVB_BUFFERING_DEBUG -#else -#define LINUX_DVB_BUFFERING_SILENT -#endif - -#ifdef LINUX_DVB_BUFFERING_DEBUG - -static const uint16_t debug_level = 40; - -#define buff_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%d:%s] " fmt, __FILE__, __LINE__, __FUNCTION__, ## x); } while (0) -#else -#define buff_printf(level, fmt, x...) -#endif - -#ifndef LINUX_DVB_BUFFERING_SILENT -#define buff_err(fmt, x...) do { printf("[%s:%d:%s] " fmt, __FILE__, __LINE__, __FUNCTION__, ## x); } while (0) -#else -#define buff_err(fmt, x...) -#endif - /* ***************************** */ /* Variables */ /* ***************************** */ diff --git a/libeplayer3-arm/output/linuxdvb_fake.c b/libeplayer3-arm/output/linuxdvb_fake.c new file mode 100644 index 0000000..7bf4422 --- /dev/null +++ b/libeplayer3-arm/output/linuxdvb_fake.c @@ -0,0 +1,529 @@ +/* + * LinuxDVB Output handling. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* ***************************** */ +/* Includes */ +/* ***************************** */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common.h" +#include "debug.h" +#include "output.h" +#include "writer.h" +#include "misc.h" +#include "pes.h" + +/* ***************************** */ +/* Makros/Constants */ +/* ***************************** */ + +#define cERR_LINUXDVB_NO_ERROR 0 +#define cERR_LINUXDVB_ERROR -1 + +static const char VIDEODEV[] = "/tmp/e2i_video0"; +static const char AUDIODEV[] = "/tmp/e2i_audio0"; + +static int videofd = -1; +static int audiofd = -1; + +struct DVBApiVideoInfo_s +{ + int aspect_ratio; + int progressive; + int frame_rate; + int width, height; +}; +static struct DVBApiVideoInfo_s videoInfo = {-1, -1, -1, -1, -1}; + +unsigned long long int sCURRENT_PTS = 0; +bool isBufferedOutput = false; + +pthread_mutex_t LinuxDVBmutex; + +/* ***************************** */ +/* Prototypes */ +/* ***************************** */ +int32_t LinuxDvbBuffOpen(Context_t *context, char *type, int outfd); +int32_t LinuxDvbBuffClose(Context_t *context); +int32_t LinuxDvbBuffFlush(Context_t *context); +int32_t LinuxDvbBuffResume(Context_t *context); + +ssize_t BufferingWriteV(int fd, const struct iovec *iov, int ic); +int32_t LinuxDvbBuffSetSize(const uint32_t bufferSize); +uint32_t LinuxDvbBuffGetSize(); + +int LinuxDvbStop(Context_t *context, char *type); + +/* ***************************** */ +/* MISC Functions */ +/* ***************************** */ + +#define getLinuxDVBMutex() pthread_mutex_lock(&LinuxDVBmutex) +#define releaseLinuxDVBMutex() pthread_mutex_unlock(&LinuxDVBmutex) + + +int LinuxDvbOpen(Context_t *context __attribute__((unused)), char *type) +{ + uint8_t video = !strcmp("video", type); + uint8_t audio = !strcmp("audio", type); + + linuxdvb_printf(10, "v%d a%d\n", video, audio); + + if (video && videofd < 0) + { + videofd = open(VIDEODEV, O_CREAT | O_TRUNC | O_WRONLY | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + } + + if (audio && audiofd < 0) + { + audiofd = open(AUDIODEV, O_CREAT | O_TRUNC | O_WRONLY | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + } + + return 0; +} + +int LinuxDvbClose(Context_t *context __attribute__((unused)), char *type __attribute__((unused))) +{ + return 0; +} + +int LinuxDvbPlay(Context_t *context __attribute__((unused)), char *type __attribute__((unused))) +{ + return 0; +} + +int LinuxDvbStop(Context_t *context __attribute__((unused)), char *type __attribute__((unused))) +{ + return 0; +} + +int LinuxDvbPause(Context_t *context __attribute__((unused)), char *type __attribute__((unused))) +{ + return 0; +} + +int LinuxDvbContinue(Context_t *context __attribute__((unused)), char *type) +{ + int32_t ret = cERR_LINUXDVB_NO_ERROR; + uint8_t video = !strcmp("video", type); + uint8_t audio = !strcmp("audio", type); + + linuxdvb_printf(10, "v%d a%d\n", video, audio); + + if (video && videofd != -1) + { + if (ioctl(videofd, VIDEO_CONTINUE, NULL) == -1) + { + linuxdvb_err("VIDEO_CONTINUE: ERROR %d, %s\n", errno, strerror(errno)); + ret = cERR_LINUXDVB_ERROR; + } + } + + if (audio && audiofd != -1) + { + if (ioctl(audiofd, AUDIO_CONTINUE, NULL) == -1) + { + linuxdvb_err("AUDIO_CONTINUE: ERROR %d, %s\n", errno, strerror(errno)); + ret = cERR_LINUXDVB_ERROR; + } + } + + if (isBufferedOutput) + LinuxDvbBuffResume(context); + + linuxdvb_printf(10, "exiting\n"); + + return ret; +} + +int LinuxDvbAudioMute(Context_t *context __attribute__((unused)), char *flag __attribute__((unused))) +{ + return 0; +} + +int LinuxDvbFlush(Context_t *context __attribute__((unused)), char *type __attribute__((unused))) +{ + return 0; +} + +int LinuxDvbSlowMotion(Context_t *context __attribute__((unused)), char *type __attribute__((unused))) +{ + return 0; +} + +int LinuxDvbAVSync(Context_t *context __attribute__((unused)), char *type __attribute__((unused))) +{ + return 0; +} + +int LinuxDvbClear(Context_t *context __attribute__((unused)), char *type __attribute__((unused))) +{ + return 0; +} + +int LinuxDvbPts(Context_t *context __attribute__((unused)), unsigned long long int *pts) +{ + *((unsigned long long int *)pts) = (unsigned long long int)0; + return 0; +} + +int LinuxDvbGetFrameCount(Context_t *context __attribute__((unused)), unsigned long long int *frameCount __attribute__((unused))) +{ + return cERR_LINUXDVB_NO_ERROR; +} + +int LinuxDvbSwitch(Context_t *context __attribute__((unused)), char *type __attribute__((unused))) +{ + + return cERR_LINUXDVB_NO_ERROR; +} + +static int Write(Context_t *context, void *_out) +{ + AudioVideoOut_t *out = (AudioVideoOut_t *) _out; + int32_t ret = cERR_LINUXDVB_NO_ERROR; + int32_t res = 0; + uint8_t video = 0; + uint8_t audio = 0; + Writer_t *writer = NULL; + WriterAVCallData_t call; + + if (out == NULL) + { + linuxdvb_err("null pointer passed\n"); + return cERR_LINUXDVB_ERROR; + } + + video = !strcmp("video", out->type); + audio = !strcmp("audio", out->type); + + linuxdvb_printf(20, "DataLength=%u PrivateLength=%u Pts=%"PRIu64" FrameRate=%d\n", + out->len, out->extralen, out->pts, out->frameRate); + linuxdvb_printf(20, "v%d a%d\n", video, audio); + + if (video) + { + char *Encoding = NULL; + context->manager->video->Command(context, MANAGER_GETENCODING, &Encoding); + + linuxdvb_printf(20, "Encoding = %s\n", Encoding); + + writer = getWriter(Encoding); + + if (writer == NULL) + { + linuxdvb_printf(20, "searching default writer ... %s\n", Encoding); + writer = getDefaultVideoWriter(); + } + + if (writer == NULL) + { + linuxdvb_err("unknown video codec and no default writer %s\n", Encoding); + ret = cERR_LINUXDVB_ERROR; + } + else + { + struct pollfd pfd[1]; + pfd[0].fd = videofd; + pfd[0].events = POLLPRI; + int pollret = poll(pfd, 1, 0); + if (pollret > 0 && pfd[0].revents & POLLPRI) + { + struct video_event evt; + if (ioctl(videofd, VIDEO_GET_EVENT, &evt) == -1) + { + linuxdvb_err("ioctl failed with errno %d\n", errno); + linuxdvb_err("VIDEO_GET_EVENT: %s\n", strerror(errno)); + } + else + { + if (evt.type == VIDEO_EVENT_SIZE_CHANGED) + { + linuxdvb_printf(10, "VIDEO_EVENT_SIZE_CHANGED type: 0x%x\n", evt.type); + linuxdvb_printf(10, "width : %d\n", evt.u.size.w); + linuxdvb_printf(10, "height : %d\n", evt.u.size.h); + linuxdvb_printf(10, "aspect : %d\n", evt.u.size.aspect_ratio); + videoInfo.width = evt.u.size.w; + videoInfo.height = evt.u.size.h; + videoInfo.aspect_ratio = evt.u.size.aspect_ratio; + } + else if (evt.type == VIDEO_EVENT_FRAME_RATE_CHANGED) + { + linuxdvb_printf(10, "VIDEO_EVENT_FRAME_RATE_CHANGED type: 0x%x\n", evt.type); + linuxdvb_printf(10, "framerate : %d\n", evt.u.frame_rate); + videoInfo.frame_rate = evt.u.frame_rate; + } + else if (evt.type == 16 /*VIDEO_EVENT_PROGRESSIVE_CHANGED*/) + { + linuxdvb_printf(10, "VIDEO_EVENT_PROGRESSIVE_CHANGED type: 0x%x\n", evt.type); + linuxdvb_printf(10, "progressive : %d\n", evt.u.frame_rate); + videoInfo.progressive = evt.u.frame_rate; + context->manager->video->Command(context, MANAGER_UPDATED_TRACK_INFO, NULL); + } + else + { + linuxdvb_err("unhandled DVBAPI Video Event %d\n", evt.type); + } + } + } + + call.fd = videofd; + call.data = out->data; + call.len = out->len; + call.Pts = out->pts; + call.Dts = out->dts; + call.private_data = out->extradata; + call.private_size = out->extralen; + call.FrameRate = out->frameRate; + call.FrameScale = out->timeScale; + call.Width = out->width; + call.Height = out->height; + call.InfoFlags = out->infoFlags; + call.Version = 0; + call.WriteV = isBufferedOutput ? BufferingWriteV : writev_with_retry; + + if (writer->writeData) + { + res = writer->writeData(&call); + } + + if (res < 0) + { + linuxdvb_err("failed to write data %d - %d\n", res, errno); + linuxdvb_err("%s\n", strerror(errno)); + ret = cERR_LINUXDVB_ERROR; + } + } + + free(Encoding); + } + else if (audio) + { + char *Encoding = NULL; + context->manager->audio->Command(context, MANAGER_GETENCODING, &Encoding); + + linuxdvb_printf(20, "Encoding = %s\n", Encoding); + + writer = getWriter(Encoding); + + if (writer == NULL) + { + linuxdvb_printf(20, "searching default writer ... %s\n", Encoding); + writer = getDefaultAudioWriter(); + } + + if (writer == NULL) + { + linuxdvb_err("unknown audio codec %s and no default writer\n", Encoding); + ret = cERR_LINUXDVB_ERROR; + } + else + { + call.fd = audiofd; + call.data = out->data; + call.len = out->len; + call.Pts = out->pts; + call.Dts = out->dts; + call.private_data = out->extradata; + call.private_size = out->extralen; + call.FrameRate = out->frameRate; + call.FrameScale = out->timeScale; + call.InfoFlags = out->infoFlags; + call.Version = 0; + call.WriteV = isBufferedOutput ? BufferingWriteV : writev_with_retry; + + if (writer->writeData) + { + res = writer->writeData(&call); + } + + if (res < 0) + { + linuxdvb_err("failed to write data %d - %d\n", res, errno); + linuxdvb_err("%s\n", strerror(errno)); + ret = cERR_LINUXDVB_ERROR; + } + } + + free(Encoding); + } + + return ret; +} + +static int reset(Context_t *context __attribute__((unused))) +{ + return 0; +} + +static int Command(Context_t *context, OutputCmd_t command, void *argument) +{ + int ret = cERR_LINUXDVB_NO_ERROR; + + linuxdvb_printf(50, "Command %d\n", command); + + switch (command) + { + case OUTPUT_OPEN: + { + ret = LinuxDvbOpen(context, (char *)argument); + break; + } + case OUTPUT_CLOSE: + { + ret = LinuxDvbClose(context, (char *)argument); + reset(context); + sCURRENT_PTS = 0; + break; + } + case OUTPUT_PLAY: // 4 + { + sCURRENT_PTS = 0; + ret = LinuxDvbPlay(context, (char *)argument); + break; + } + case OUTPUT_STOP: + { + reset(context); + ret = LinuxDvbStop(context, (char *)argument); + sCURRENT_PTS = 0; + break; + } + case OUTPUT_FLUSH: + { + ret = LinuxDvbFlush(context, (char *)argument); + reset(context); + sCURRENT_PTS = 0; + break; + } + case OUTPUT_PAUSE: + { + ret = LinuxDvbPause(context, (char *)argument); + break; + } + case OUTPUT_CONTINUE: + { + ret = LinuxDvbContinue(context, (char *)argument); + break; + } + case OUTPUT_AVSYNC: + { + ret = LinuxDvbAVSync(context, (char *)argument); + break; + } + case OUTPUT_CLEAR: + { + ret = LinuxDvbClear(context, (char *)argument); + reset(context); + sCURRENT_PTS = 0; + break; + } + case OUTPUT_PTS: + { + unsigned long long int pts = 0; + ret = LinuxDvbPts(context, &pts); + *((unsigned long long int *)argument) = (unsigned long long int)pts; + break; + } + case OUTPUT_SWITCH: + { + ret = LinuxDvbSwitch(context, (char *)argument); + break; + } + case OUTPUT_SLOWMOTION: + { + return LinuxDvbSlowMotion(context, (char *)argument); + break; + } + case OUTPUT_AUDIOMUTE: + { + return LinuxDvbAudioMute(context, (char *)argument); + break; + } + case OUTPUT_GET_FRAME_COUNT: + { + unsigned long long int frameCount = 0; + ret = LinuxDvbGetFrameCount(context, &frameCount); + *((unsigned long long int *)argument) = (unsigned long long int)frameCount; + break; + } + case OUTPUT_GET_PROGRESSIVE: + { + ret = cERR_LINUXDVB_NO_ERROR; + *((int *)argument) = videoInfo.progressive; + break; + } + case OUTPUT_SET_BUFFER_SIZE: + { + ret = cERR_LINUXDVB_ERROR; + if (!isBufferedOutput) + { + uint32_t bufferSize = *((uint32_t *)argument); + ret = cERR_LINUXDVB_NO_ERROR; + if (bufferSize > 0) + { + LinuxDvbBuffSetSize(bufferSize); + isBufferedOutput = true; + } + } + break; + } + case OUTPUT_GET_BUFFER_SIZE: + { + ret = cERR_LINUXDVB_NO_ERROR; + *((uint32_t *)argument) = LinuxDvbBuffGetSize(); + break; + } + default: + linuxdvb_err("ContainerCmd %d not supported!\n", command); + ret = cERR_LINUXDVB_ERROR; + break; + } + + linuxdvb_printf(50, "exiting with value %d\n", ret); + + return ret; +} + +static char *LinuxDvbCapabilities[] = { "audio", "video", NULL }; + +struct Output_s LinuxDvbOutput = +{ + "LinuxDvb", + &Command, + &Write, + LinuxDvbCapabilities +}; diff --git a/libeplayer3-arm/output/linuxdvb_mipsel.c b/libeplayer3-arm/output/linuxdvb_mipsel.c index e1e85d1..95d36ce 100644 --- a/libeplayer3-arm/output/linuxdvb_mipsel.c +++ b/libeplayer3-arm/output/linuxdvb_mipsel.c @@ -22,6 +22,7 @@ /* ***************************** */ #include +#include #include #include #include @@ -41,6 +42,7 @@ #include "bcm_ioctls.h" #include "common.h" +#include "debug.h" #include "output.h" #include "writer.h" #include "misc.h" @@ -50,29 +52,6 @@ /* Makros/Constants */ /* ***************************** */ -//#define SAM_WITH_DEBUG -#ifdef SAM_WITH_DEBUG -#define LINUXDVB_DEBUG -static unsigned short debug_level = 20; -#else -#define LINUXDVB_SILENT -#endif - -static const char FILENAME[] = __FILE__; - -#ifdef LINUXDVB_DEBUG -#define linuxdvb_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define linuxdvb_printf(x...) -#endif - -#ifndef LINUXDVB_SILENT -#define linuxdvb_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define linuxdvb_err(x...) -#endif - #define cERR_LINUXDVB_NO_ERROR 0 #define cERR_LINUXDVB_ERROR -1 @@ -114,15 +93,8 @@ int LinuxDvbStop(Context_t *context, char *type); /* MISC Functions */ /* ***************************** */ -void getLinuxDVBMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int line __attribute__((unused))) -{ - pthread_mutex_lock(&LinuxDVBmutex); -} - -void releaseLinuxDVBMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int line __attribute__((unused))) -{ - pthread_mutex_unlock(&LinuxDVBmutex); -} +#define getLinuxDVBMutex() pthread_mutex_lock(&LinuxDVBmutex) +#define releaseLinuxDVBMutex() pthread_mutex_unlock(&LinuxDVBmutex) static int LinuxDvbMapBypassMode(int bypass) { @@ -214,7 +186,7 @@ int LinuxDvbClose(Context_t *context, char *type) */ LinuxDvbStop(context, type); - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (isBufferedOutput) LinuxDvbBuffClose(context); @@ -230,7 +202,7 @@ int LinuxDvbClose(Context_t *context, char *type) audiofd = -1; } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); return cERR_LINUXDVB_NO_ERROR; } @@ -335,7 +307,7 @@ int LinuxDvbStop(Context_t *context __attribute__((unused)), char *type) linuxdvb_printf(10, "v%d a%d\n", video, audio); - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (video && videofd != -1) { @@ -370,7 +342,7 @@ int LinuxDvbStop(Context_t *context __attribute__((unused)), char *type) ioctl(audiofd, AUDIO_SELECT_SOURCE, AUDIO_SOURCE_DEMUX); } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); return ret; } @@ -383,7 +355,7 @@ int LinuxDvbPause(Context_t *context __attribute__((unused)), char *type) linuxdvb_printf(10, "v%d a%d\n", video, audio); - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (video && videofd != -1) { @@ -403,7 +375,7 @@ int LinuxDvbPause(Context_t *context __attribute__((unused)), char *type) } } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); return ret; } @@ -495,19 +467,20 @@ int LinuxDvbFastForward(Context_t *context, char *type) if (video && videofd != -1) { - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); // konfetti comment: speed is a value given in skipped frames if (ioctl(videofd, VIDEO_FAST_FORWARD, context->playback->Speed) == -1) { linuxdvb_err("VIDEO_FAST_FORWARD: ERROR %d, %s\n", errno, strerror(errno)); ret = cERR_LINUXDVB_ERROR; } + if (ioctl(videofd, VIDEO_CONTINUE, NULL) == -1) { linuxdvb_err("VIDEO_CONTINUE: ERROR %d, %s\n", errno, strerror(errno)); ret = cERR_LINUXDVB_ERROR; } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); } linuxdvb_printf(10, "exiting with value %d\n", ret); @@ -525,7 +498,7 @@ int LinuxDvbSlowMotion(Context_t *context, char *type) if ((video && videofd != -1) || (audio && audiofd != -1)) { - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (video && videofd != -1) { @@ -536,7 +509,7 @@ int LinuxDvbSlowMotion(Context_t *context, char *type) } } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); } linuxdvb_printf(10, "exiting with value %d\n", ret); @@ -555,7 +528,7 @@ int LinuxDvbAVSync(Context_t *context __attribute__((unused)), char *type __attr */ if (audiofd != -1) { - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (ioctl(audiofd, AUDIO_SET_AV_SYNC, 0) == -1) //context->playback->AVSync) == -1) { @@ -563,7 +536,7 @@ int LinuxDvbAVSync(Context_t *context __attribute__((unused)), char *type __attr ret = cERR_LINUXDVB_ERROR; } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); } return ret; @@ -579,7 +552,7 @@ int LinuxDvbClear(Context_t *context __attribute__((unused)), char *type) if ((video && videofd != -1) || (audio && audiofd != -1)) { - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (video && videofd != -1) { @@ -598,7 +571,7 @@ int LinuxDvbClear(Context_t *context __attribute__((unused)), char *type) } } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); } linuxdvb_printf(10, "exiting\n"); @@ -659,7 +632,7 @@ int LinuxDvbSwitch(Context_t *context, char *type) if ((video && videofd != -1) || (audio && audiofd != -1)) { - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (audio && audiofd != -1) { @@ -756,7 +729,7 @@ int LinuxDvbSwitch(Context_t *context, char *type) } } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); } @@ -784,7 +757,7 @@ static int Write(Context_t *context, void *_out) video = !strcmp("video", out->type); audio = !strcmp("audio", out->type); - linuxdvb_printf(20, "DataLength=%u PrivateLength=%u Pts=%llu FrameRate=%f\n", + linuxdvb_printf(20, "DataLength=%u PrivateLength=%u Pts=%" PRIu64 " FrameRate=%d\n", out->len, out->extralen, out->pts, out->frameRate); linuxdvb_printf(20, "v%d a%d\n", video, audio); @@ -826,7 +799,7 @@ static int Write(Context_t *context, void *_out) { if (evt.type == VIDEO_EVENT_SIZE_CHANGED) { - linuxdvb_printf(10, "VIDEO_EVENT_SIZE_CHANGED\n", evt.type); + linuxdvb_printf(10, "VIDEO_EVENT_SIZE_CHANGED type: 0x%x\n", evt.type); linuxdvb_printf(10, "width : %d\n", evt.u.size.w); linuxdvb_printf(10, "height : %d\n", evt.u.size.h); linuxdvb_printf(10, "aspect : %d\n", evt.u.size.aspect_ratio); @@ -836,13 +809,13 @@ static int Write(Context_t *context, void *_out) } else if (evt.type == VIDEO_EVENT_FRAME_RATE_CHANGED) { - linuxdvb_printf(10, "VIDEO_EVENT_FRAME_RATE_CHANGED\n", evt.type); + linuxdvb_printf(10, "VIDEO_EVENT_FRAME_RATE_CHANGED type: 0x%x\n", evt.type); linuxdvb_printf(10, "framerate : %d\n", evt.u.frame_rate); videoInfo.frame_rate = evt.u.frame_rate; } else if (evt.type == 16 /*VIDEO_EVENT_PROGRESSIVE_CHANGED*/) { - linuxdvb_printf(10, "VIDEO_EVENT_PROGRESSIVE_CHANGED\n", evt.type); + linuxdvb_printf(10, "VIDEO_EVENT_PROGRESSIVE_CHANGED type: 0x%x\n", evt.type); linuxdvb_printf(10, "progressive : %d\n", evt.u.frame_rate); videoInfo.progressive = evt.u.frame_rate; context->manager->video->Command(context, MANAGER_UPDATED_TRACK_INFO, NULL); @@ -889,7 +862,7 @@ static int Write(Context_t *context, void *_out) char *Encoding = NULL; context->manager->audio->Command(context, MANAGER_GETENCODING, &Encoding); - linuxdvb_printf(20, "%s::%s Encoding = %s\n", FILENAME, __FUNCTION__, Encoding); + linuxdvb_printf(20, "Encoding = %s\n", Encoding); writer = getWriter(Encoding); diff --git a/libeplayer3-arm/output/linuxdvb_sh4.c b/libeplayer3-arm/output/linuxdvb_sh4.c index be04aa7..a29dc07 100644 --- a/libeplayer3-arm/output/linuxdvb_sh4.c +++ b/libeplayer3-arm/output/linuxdvb_sh4.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -40,8 +39,10 @@ #include #include "bcm_ioctls.h" +#include "stm_ioctls.h" #include "common.h" +#include "debug.h" #include "output.h" #include "writer.h" #include "misc.h" @@ -51,27 +52,6 @@ /* Makros/Constants */ /* ***************************** */ -//#define LINUXDVB_DEBUG -#define LINUXDVB_SILENT - -static unsigned short debug_level = 0; - -static const char FILENAME[] = __FILE__; - -#ifdef LINUXDVB_DEBUG -#define linuxdvb_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define linuxdvb_printf(x...) -#endif - -#ifndef LINUXDVB_SILENT -#define linuxdvb_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define linuxdvb_err(x...) -#endif - - #define cERR_LINUXDVB_NO_ERROR 0 #define cERR_LINUXDVB_ERROR -1 @@ -113,23 +93,8 @@ int LinuxDvbStop(Context_t *context, char *type); /* MISC Functions */ /* ***************************** */ -void getLinuxDVBMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int line __attribute__((unused))) -{ - - linuxdvb_printf(250, "requesting mutex\n"); - - pthread_mutex_lock(&LinuxDVBmutex); - - linuxdvb_printf(250, "received mutex\n"); -} - -void releaseLinuxDVBMutex(const char *filename __attribute__((unused)), const char *function __attribute__((unused)), int line __attribute__((unused))) -{ - pthread_mutex_unlock(&LinuxDVBmutex); - - linuxdvb_printf(250, "released mutex\n"); - -} +#define getLinuxDVBMutex() pthread_mutex_lock(&LinuxDVBmutex) +#define releaseLinuxDVBMutex() pthread_mutex_unlock(&LinuxDVBmutex) int LinuxDvbOpen(Context_t *context __attribute__((unused)), char *type) { @@ -206,7 +171,7 @@ int LinuxDvbOpen(Context_t *context __attribute__((unused)), char *type) linuxdvb_err("ioctl failed with errno %d\n", errno); linuxdvb_err("AUDIO_SET_STREAMTYPE: %s\n", strerror(errno)); } - + if (isBufferedOutput) LinuxDvbBuffOpen(context, type, audiofd); } @@ -214,7 +179,7 @@ int LinuxDvbOpen(Context_t *context __attribute__((unused)), char *type) return cERR_LINUXDVB_NO_ERROR; } -int LinuxDvbClose(Context_t *context, char *type) +int LinuxDvbClose(Context_t *context, char *type) { uint8_t video = !strcmp("video", type); uint8_t audio = !strcmp("audio", type); @@ -227,7 +192,7 @@ int LinuxDvbClose(Context_t *context, char *type) */ LinuxDvbStop(context, type); - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (isBufferedOutput) LinuxDvbBuffClose(context); @@ -237,13 +202,14 @@ int LinuxDvbClose(Context_t *context, char *type) close(videofd); videofd = -1; } + if (audio && audiofd != -1) { close(audiofd); audiofd = -1; } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); return cERR_LINUXDVB_NO_ERROR; } @@ -269,7 +235,7 @@ int LinuxDvbPlay(Context_t *context, char *type) if (writer == NULL) { linuxdvb_err("cannot found writer for encoding %s using default\n", Encoding); - if (ioctl(videofd, VIDEO_SET_ENCODING, (void *) VIDEO_ENCODING_AUTO) == -1) + if (ioctl(videofd, VIDEO_SET_ENCODING, VIDEO_ENCODING_AUTO) == -1) { linuxdvb_err("ioctl failed with errno %d\n", errno); linuxdvb_err("VIDEO_SET_ENCODING: %s\n", strerror(errno)); @@ -279,7 +245,7 @@ int LinuxDvbPlay(Context_t *context, char *type) else { linuxdvb_printf(20, "found writer %s for encoding %s\n", writer->caps->name, Encoding); - if (ioctl(videofd, VIDEO_SET_ENCODING, (void *) writer->caps->dvbEncoding) == -1) + if (ioctl(videofd, VIDEO_SET_ENCODING, writer->caps->dvbEncoding) == -1) { linuxdvb_err("ioctl failed with errno %d\n", errno); linuxdvb_err("VIDEO_SET_ENCODING: %s\n", strerror(errno)); @@ -295,6 +261,7 @@ int LinuxDvbPlay(Context_t *context, char *type) } free(Encoding); } + if (audio && audiofd != -1) { char *Encoding = NULL; @@ -317,7 +284,7 @@ int LinuxDvbPlay(Context_t *context, char *type) else { linuxdvb_printf(20, "found writer %s for encoding %s\n", writer->caps->name, Encoding); - if (ioctl(audiofd, AUDIO_SET_ENCODING, (void *) writer->caps->dvbEncoding) == -1) + if (ioctl(audiofd, AUDIO_SET_ENCODING, writer->caps->dvbEncoding) == -1) { linuxdvb_err("ioctl failed with errno %d\n", errno); linuxdvb_err("AUDIO_SET_ENCODING: %s\n", strerror(errno)); @@ -345,7 +312,7 @@ int LinuxDvbStop(Context_t *context __attribute__((unused)), char *type) linuxdvb_printf(10, "v%d a%d\n", video, audio); - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (video && videofd != -1) { @@ -368,6 +335,7 @@ int LinuxDvbStop(Context_t *context __attribute__((unused)), char *type) ret = cERR_LINUXDVB_ERROR; } } + if (audio && audiofd != -1) { if (ioctl(audiofd, AUDIO_CLEAR_BUFFER) == -1) @@ -390,7 +358,7 @@ int LinuxDvbStop(Context_t *context __attribute__((unused)), char *type) } } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); return ret; } @@ -403,7 +371,7 @@ int LinuxDvbPause(Context_t *context __attribute__((unused)), char *type) linuxdvb_printf(10, "v%d a%d\n", video, audio); - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (video && videofd != -1) { @@ -424,7 +392,7 @@ int LinuxDvbPause(Context_t *context __attribute__((unused)), char *type) } } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); return ret; } @@ -455,7 +423,7 @@ int LinuxDvbContinue(Context_t *context __attribute__((unused)), char *type) ret = cERR_LINUXDVB_ERROR; } } - + if (isBufferedOutput) LinuxDvbBuffResume(context); @@ -472,7 +440,7 @@ int LinuxDvbReverseDiscontinuity(Context_t *context __attribute__((unused)), int linuxdvb_printf(50, "\n"); - if (ioctl(videofd, VIDEO_DISCONTINUITY, (void *) dis_type) == -1) + if (ioctl(videofd, VIDEO_DISCONTINUITY, dis_type) == -1) { linuxdvb_err("ioctl failed with errno %d\n", errno); linuxdvb_err("VIDEO_DISCONTINUITY: %s\n", strerror(errno)); @@ -532,7 +500,7 @@ int LinuxDvbFlush(Context_t *context __attribute__((unused)), char *type) if ((video && videofd != -1) || (audio && audiofd != -1)) { - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (video && videofd != -1) { @@ -552,7 +520,7 @@ int LinuxDvbFlush(Context_t *context __attribute__((unused)), char *type) } } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); } linuxdvb_printf(10, "exiting\n"); @@ -572,8 +540,7 @@ int LinuxDvbFastForward(Context_t *context, char *type) if (video && videofd != -1) { - - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); /* konfetti comment: speed is a value given in skipped frames */ @@ -584,7 +551,7 @@ int LinuxDvbFastForward(Context_t *context, char *type) ret = cERR_LINUXDVB_ERROR; } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); } linuxdvb_printf(10, "exiting with value %d\n", ret); @@ -612,8 +579,7 @@ int LinuxDvbFastForward(Context_t *context, char *type) if (video && videofd != -1) { - - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); speedIndex = context->playback->Speed % (sizeof(SpeedList) / sizeof(int)); @@ -626,13 +592,12 @@ int LinuxDvbFastForward(Context_t *context, char *type) ret = cERR_LINUXDVB_ERROR; } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); } if (audio && audiofd != -1) { - - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); speedIndex = context->playback->Speed % (sizeof(SpeedList) / sizeof(int)); @@ -645,7 +610,7 @@ int LinuxDvbFastForward(Context_t *context, char *type) ret = cERR_LINUXDVB_ERROR; } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); } linuxdvb_printf(10, "exiting with value %d\n", ret); @@ -672,7 +637,7 @@ int LinuxDvbSlowMotion(Context_t *context, char *type) if ((video && videofd != -1) || (audio && audiofd != -1)) { - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (video && videofd != -1) { @@ -684,7 +649,7 @@ int LinuxDvbSlowMotion(Context_t *context, char *type) } } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); } linuxdvb_printf(10, "exiting with value %d\n", ret); @@ -703,7 +668,7 @@ int LinuxDvbAVSync(Context_t *context, char *type __attribute__((unused))) */ if (audiofd != -1) { - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (ioctl(audiofd, AUDIO_SET_AV_SYNC, context->playback->AVSync) == -1) { @@ -712,7 +677,7 @@ int LinuxDvbAVSync(Context_t *context, char *type __attribute__((unused))) ret = cERR_LINUXDVB_ERROR; } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); } return ret; @@ -728,7 +693,7 @@ int LinuxDvbClear(Context_t *context __attribute__((unused)), char *type) if ((video && videofd != -1) || (audio && audiofd != -1)) { - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (video && videofd != -1) { @@ -749,7 +714,7 @@ int LinuxDvbClear(Context_t *context __attribute__((unused)), char *type) } } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); } linuxdvb_printf(10, "exiting\n"); @@ -764,7 +729,7 @@ int LinuxDvbPts(Context_t *context __attribute__((unused)), unsigned long long i linuxdvb_printf(50, "\n"); // pts is a non writting requests and can be done in parallel to other requests - //getLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__); + //getLinuxDVBMutex(); if (videofd > -1 && !ioctl(videofd, VIDEO_GET_PTS, (void *)&sCURRENT_PTS)) { @@ -794,7 +759,7 @@ int LinuxDvbPts(Context_t *context __attribute__((unused)), unsigned long long i *((unsigned long long int *)pts) = (unsigned long long int)sCURRENT_PTS; - //releaseLinuxDVBMutex(FILENAME, __FUNCTION__,__LINE__); + //releaseLinuxDVBMutex(); return ret; } @@ -806,7 +771,7 @@ int LinuxDvbGetFrameCount(Context_t *context __attribute__((unused)), unsigned l linuxdvb_printf(50, "\n"); - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (videofd != -1) { @@ -836,7 +801,7 @@ int LinuxDvbGetFrameCount(Context_t *context __attribute__((unused)), unsigned l if (ret == cERR_LINUXDVB_NO_ERROR) *((unsigned long long int *)frameCount) = playInfo.frame_count; - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); return ret; } @@ -851,7 +816,7 @@ int LinuxDvbSwitch(Context_t *context, char *type) if ((video && videofd != -1) || (audio && audiofd != -1)) { - getLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + getLinuxDVBMutex(); if (audio && audiofd != -1) { @@ -881,7 +846,7 @@ int LinuxDvbSwitch(Context_t *context, char *type) if (writer == NULL) { linuxdvb_err("cannot found writer for encoding %s using default\n", Encoding); - if (ioctl(audiofd, AUDIO_SET_ENCODING, (void *) AUDIO_ENCODING_MP3) == -1) + if (ioctl(audiofd, AUDIO_SET_ENCODING, AUDIO_ENCODING_MP3) == -1) { linuxdvb_err("ioctl failed with errno %d\n", errno); linuxdvb_err("AUDIO_SET_ENCODING: %s\n", strerror(errno)); @@ -890,7 +855,7 @@ int LinuxDvbSwitch(Context_t *context, char *type) else { linuxdvb_printf(10, "found writer %s for encoding %s\n", writer->caps->name, Encoding); - if (ioctl(audiofd, AUDIO_SET_ENCODING, (void *) writer->caps->dvbEncoding) == -1) + if (ioctl(audiofd, AUDIO_SET_ENCODING, writer->caps->dvbEncoding) == -1) { linuxdvb_err("ioctl failed with errno %d\n", errno); linuxdvb_err("AUDIO_SET_ENCODING: %s\n", strerror(errno)); @@ -945,7 +910,7 @@ int LinuxDvbSwitch(Context_t *context, char *type) else { linuxdvb_printf(10, "found writer %s for encoding %s\n", writer->caps->name, Encoding); - if (ioctl(videofd, VIDEO_SET_ENCODING, (void *) writer->caps->dvbEncoding) == -1) + if (ioctl(videofd, VIDEO_SET_ENCODING, writer->caps->dvbEncoding) == -1) { linuxdvb_err("ioctl failed with errno %d\n", errno); linuxdvb_err("VIDEO_SET_ENCODING: %s\n", strerror(errno)); @@ -968,7 +933,7 @@ int LinuxDvbSwitch(Context_t *context, char *type) } } - releaseLinuxDVBMutex(FILENAME, __FUNCTION__, __LINE__); + releaseLinuxDVBMutex(); } @@ -1188,7 +1153,7 @@ static int reset(Context_t *context) } free(Encoding); - + if (isBufferedOutput) LinuxDvbBuffFlush(context); @@ -1313,7 +1278,7 @@ static int Command(void *_context, OutputCmd_t command, void *argument) ret = cERR_LINUXDVB_ERROR; if (!isBufferedOutput) { - uint32_t bufferSize = *((uint32_t*)argument); + uint32_t bufferSize = *((uint32_t *)argument); ret = cERR_LINUXDVB_NO_ERROR; if (bufferSize > 0) { @@ -1326,7 +1291,7 @@ static int Command(void *_context, OutputCmd_t command, void *argument) case OUTPUT_GET_BUFFER_SIZE: { ret = cERR_LINUXDVB_NO_ERROR; - *((uint32_t*)argument) = LinuxDvbBuffGetSize(); + *((uint32_t *)argument) = LinuxDvbBuffGetSize(); break; } default: diff --git a/libeplayer3-arm/output/output.c b/libeplayer3-arm/output/output.c index c1b3ce4..89ebd5b 100644 --- a/libeplayer3-arm/output/output.c +++ b/libeplayer3-arm/output/output.c @@ -24,6 +24,7 @@ #include #include +#include "debug.h" #include "common.h" #include "output.h" @@ -31,28 +32,6 @@ /* Makros/Constants */ /* ***************************** */ -#ifdef SAM_WITH_DEBUG -#define OUTPUT_DEBUG -#else -#define OUTPUT_SILENT -#endif - -#ifdef OUTPUT_DEBUG - -static short debug_level = 0; - -#define output_printf(level, x...) do { \ -if (debug_level >= level) fprintf(stderr, x); } while (0) -#else -#define output_printf(level, x...) -#endif - -#ifndef OUTPUT_SILENT -#define output_err(x...) do { printf(x); } while (0) -#else -#define output_err(x...) -#endif - /* Error Constants */ #define cERR_OUTPUT_NO_ERROR 0 #define cERR_OUTPUT_INTERNAL_ERROR -1 diff --git a/libeplayer3-arm/output/output_subtitle.c b/libeplayer3-arm/output/output_subtitle.c index 6d301ab..22a6257 100644 --- a/libeplayer3-arm/output/output_subtitle.c +++ b/libeplayer3-arm/output/output_subtitle.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -34,36 +35,13 @@ #include #include "common.h" +#include "debug.h" #include "output.h" /* ***************************** */ /* Makros/Constants */ /* ***************************** */ -//SULGE DEBUG ENABLED -//#define SAM_WITH_DEBUG -#ifdef SAM_WITH_DEBUG -#define SUBTITLE_DEBUG -#else -#define SUBTITLE_SILENT -#endif - -#ifdef SUBTITLE_DEBUG - -static short debug_level = 0; - -#define subtitle_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define subtitle_printf(level, fmt, x...) -#endif - -#ifndef SUBTITLE_SILENT -#define subtitle_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define subtitle_err(fmt, x...) -#endif - /* Error Constants */ #define cERR_SUBTITLE_NO_ERROR 0 #define cERR_SUBTITLE_ERROR -1 @@ -226,15 +204,15 @@ static int Write(Context_t *context, void *data) if (!strncmp("S_TEXT/SUBRIP", Encoding, 13)) { - fprintf(stderr, "{\"s_a\":{\"id\":%d,\"s\":%lld,\"e\":%lld,\"t\":\"%s\"}}\n", out->trackId, out->pts / 90, out->pts / 90 + out->durationMS, json_string_escape((char *)out->data)); + fprintf(stderr, "{\"s_a\":{\"id\":%d,\"s\":%" PRId64 ",\"e\":%" PRId64 ",\"t\":\"%s\"}}\n", out->trackId, out->pts / 90, out->pts / 90 + out->durationMS, json_string_escape((char *)out->data)); } else if (!strncmp("S_TEXT/ASS", Encoding, 10)) { - fprintf(stderr, "{\"s_a\":{\"id\":%d,\"s\":%lld,\"e\":%lld,\"t\":\"%s\"}}\n", out->trackId, out->pts / 90, out->pts / 90 + out->durationMS, ass_get_text((char *)out->data)); + fprintf(stderr, "{\"s_a\":{\"id\":%d,\"s\":%" PRId64 ",\"e\":%" PRId64 ",\"t\":\"%s\"}}\n", out->trackId, out->pts / 90, out->pts / 90 + out->durationMS, ass_get_text((char *)out->data)); } else if (!strncmp("D_WEBVTT/SUBTITLES", Encoding, 18)) { - fprintf(stderr, "{\"s_a\":{\"id\":%d,\"s\":%lld,\"e\":%lld,\"t\":\"%s\"}}\n", out->trackId, out->pts / 90, out->pts / 90 + out->durationMS, json_string_escape((char *)out->data)); + fprintf(stderr, "{\"s_a\":{\"id\":%d,\"s\":%" PRId64 ",\"e\":%" PRId64 ",\"t\":\"%s\"}}\n", out->trackId, out->pts / 90, out->pts / 90 + out->durationMS, json_string_escape((char *)out->data)); } else { diff --git a/libeplayer3-arm/output/writer/common/writer.c b/libeplayer3-arm/output/writer/common/writer.c index 0ad4b3e..8f8a18d 100644 --- a/libeplayer3-arm/output/writer/common/writer.c +++ b/libeplayer3-arm/output/writer/common/writer.c @@ -28,30 +28,13 @@ #include "misc.h" #include "writer.h" +#include "debug.h" #include "common.h" /* ***************************** */ /* Makros/Constants */ /* ***************************** */ -//#define WRITER_DEBUG - -#ifdef WRITER_DEBUG - -static short debug_level = 0; - -#define writer_printf(level, x...) do { \ -if (debug_level >= level) printf(x); } while (0) -#else -#define writer_printf(level, x...) -#endif - -#ifndef WRITER_SILENT -#define writer_err(x...) do { printf(x); } while (0) -#else -#define writer_err(x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/mipsel/aac.c b/libeplayer3-arm/output/writer/mipsel/aac.c index e75556c..c808927 100644 --- a/libeplayer3-arm/output/writer/mipsel/aac.c +++ b/libeplayer3-arm/output/writer/mipsel/aac.c @@ -45,6 +45,7 @@ #include "stm_ioctls.h" #include "bcm_ioctls.h" +#include "debug.h" #include "common.h" #include "output.h" #include "debug.h" @@ -57,30 +58,6 @@ /* Makros/Constants */ /* ***************************** */ -//#define SAM_WITH_DEBUG - -#ifdef SAM_WITH_DEBUG -#define AAC_DEBUG -#else -#define AAC_SILENT -#endif - -#ifdef AAC_DEBUG - -static short debug_level = 0; - -#define aac_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define aac_printf(level, fmt, x...) -#endif - -#ifndef AAC_SILENT -#define aac_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define aac_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ @@ -180,7 +157,7 @@ static int _writeData(WriterAVCallData_t *call, int type) aac_err("parsing Data with missing syncword. ignoring...\n"); return 0; } - + // STB can handle only AAC LC profile if (0 == (call->data[2] & 0xC0)) { diff --git a/libeplayer3-arm/output/writer/mipsel/ac3.c b/libeplayer3-arm/output/writer/mipsel/ac3.c index 12ade9a..c1e2f57 100644 --- a/libeplayer3-arm/output/writer/mipsel/ac3.c +++ b/libeplayer3-arm/output/writer/mipsel/ac3.c @@ -42,6 +42,7 @@ #include "stm_ioctls.h" #include "bcm_ioctls.h" +#include "debug.h" #include "common.h" #include "output.h" #include "debug.h" @@ -54,24 +55,6 @@ /* ***************************** */ #define AC3_HEADER_LENGTH 7 -#define AC3_DEBUG - -#ifdef AC3_DEBUG - -static short debug_level = 0; - -#define ac3_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define ac3_printf(level, fmt, x...) -#endif - -#ifndef AC3_SILENT -#define ac3_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define ac3_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ @@ -124,7 +107,7 @@ static int writeData(WriterAVCallData_t *call) struct iovec iov[3]; iov[0].iov_base = PesHeader; - iov[0].iov_len = InsertPesHeader(PesHeader, call->len, MPEG_AUDIO_PES_START_CODE, call->Pts, 0); //+ sizeof(AC3_SYNC_HEADER) + iov[0].iov_len = InsertPesHeader(PesHeader, call->len, MPEG_AUDIO_PES_START_CODE, call->Pts, 0); //+ sizeof(AC3_SYNC_HEADER) //PesHeader[6] = 0x81; //PesHeader[7] = 0x80; @@ -135,7 +118,7 @@ static int writeData(WriterAVCallData_t *call) iov[1].iov_base = call->data; iov[1].iov_len = call->len; - ac3_printf(40, "PES HEADER LEN %d\n", iov[0].iov_len); + ac3_printf(40, "PES HEADER LEN %d\n", (int)iov[0].iov_len); return call->WriteV(call->fd, iov, 2); } diff --git a/libeplayer3-arm/output/writer/mipsel/amr.c b/libeplayer3-arm/output/writer/mipsel/amr.c index 98cc1a4..381e0f8 100644 --- a/libeplayer3-arm/output/writer/mipsel/amr.c +++ b/libeplayer3-arm/output/writer/mipsel/amr.c @@ -39,9 +39,10 @@ #include #include -#include "stm_ioctls.h" +//#include "stm_ioctls.h" #include "bcm_ioctls.h" +#include "debug.h" #include "common.h" #include "output.h" #include "debug.h" @@ -52,28 +53,6 @@ /* ***************************** */ /* Makros/Constants */ /* ***************************** */ -#define SAM_WITH_DEBUG -#ifdef SAM_WITH_DEBUG -#define AMR_DEBUG -#else -#define AMR_SILENT -#endif - -#ifdef AMR_DEBUG - -static short debug_level = 0; - -#define amr_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define amr_printf(level, fmt, x...) -#endif - -#ifndef AMR_SILENT -#define amr_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define amr_err(fmt, x...) -#endif /* ***************************** */ /* Types */ diff --git a/libeplayer3-arm/output/writer/mipsel/divx3.c b/libeplayer3-arm/output/writer/mipsel/divx3.c index d4de31f..40256a0 100644 --- a/libeplayer3-arm/output/writer/mipsel/divx3.c +++ b/libeplayer3-arm/output/writer/mipsel/divx3.c @@ -42,6 +42,7 @@ #include "stm_ioctls.h" #include "bcm_ioctls.h" +#include "debug.h" #include "common.h" #include "output.h" #include "debug.h" @@ -56,28 +57,6 @@ #define B_GET_BITS(w,e,b) (((w)>>(b))&(((unsigned)(-1))>>((sizeof(unsigned))*8-(e+1-b)))) #define B_SET_BITS(name,v,e,b) (((unsigned)(v))<<(b)) -#ifdef SAM_WITH_DEBUG -#define DIVX_DEBUG -#else -#define DIVX_SILENT -#endif - -#ifdef DIVX_DEBUG - -static short debug_level = 0; - -#define divx_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define divx_printf(level, fmt, x...) -#endif - -#ifndef DIVX_SILENT -#define divx_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define divx_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/mipsel/dts.c b/libeplayer3-arm/output/writer/mipsel/dts.c index 7e1ea7a..a9acd96 100644 --- a/libeplayer3-arm/output/writer/mipsel/dts.c +++ b/libeplayer3-arm/output/writer/mipsel/dts.c @@ -42,6 +42,7 @@ #include "stm_ioctls.h" #include "bcm_ioctls.h" +#include "debug.h" #include "common.h" #include "output.h" #include "debug.h" @@ -58,28 +59,6 @@ #define PES_AUDIO_PACKET_SIZE 2028 #define SPDIF_AUDIO_PACKET_SIZE (1024 * sizeof(unsigned int) * 2) // stereo 32bit samples. -#ifdef SAM_WITH_DEBUG -#define DTS_DEBUG -#else -#define DTS_SILENT -#endif - -#ifdef DTS_DEBUG - -static int16_t debug_level = 0; - -#define dts_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define dts_printf(level, fmt, x...) -#endif - -#ifndef DTS_SILENT -#define dts_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define dts_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/mipsel/h263.c b/libeplayer3-arm/output/writer/mipsel/h263.c index 1d8b0e5..647300d 100644 --- a/libeplayer3-arm/output/writer/mipsel/h263.c +++ b/libeplayer3-arm/output/writer/mipsel/h263.c @@ -42,6 +42,7 @@ #include "stm_ioctls.h" #include "bcm_ioctls.h" +#include "debug.h" #include "common.h" #include "output.h" #include "debug.h" @@ -52,23 +53,6 @@ /* ***************************** */ /* Makros/Constants */ /* ***************************** */ -//#define H263_DEBUG - -#ifdef H263_DEBUG - -static short debug_level = 0; - -#define h263_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define h263_printf(level, fmt, x...) -#endif - -#ifndef H263_SILENT -#define h263_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define h263_err(fmt, x...) -#endif /* ***************************** */ /* Types */ diff --git a/libeplayer3-arm/output/writer/mipsel/h264.c b/libeplayer3-arm/output/writer/mipsel/h264.c index b5b37da..905832c 100644 --- a/libeplayer3-arm/output/writer/mipsel/h264.c +++ b/libeplayer3-arm/output/writer/mipsel/h264.c @@ -45,6 +45,7 @@ #include "stm_ioctls.h" #include "bcm_ioctls.h" +#include "debug.h" #include "common.h" #include "output.h" #include "debug.h" @@ -55,23 +56,6 @@ /* ***************************** */ /* Makros/Constants */ /* ***************************** */ -#define H264_SILENT -//#define H264_DEBUG -#ifdef H264_DEBUG - -static short debug_level = 0; - -#define h264_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define h264_printf(level, fmt, x...) -#endif - -#ifndef H264_SILENT -#define h264_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define h264_err(fmt, x...) -#endif #define IOVEC_SIZE 128 diff --git a/libeplayer3-arm/output/writer/mipsel/h265.c b/libeplayer3-arm/output/writer/mipsel/h265.c index 1e61411..8555cb0 100644 --- a/libeplayer3-arm/output/writer/mipsel/h265.c +++ b/libeplayer3-arm/output/writer/mipsel/h265.c @@ -55,23 +55,6 @@ /* ***************************** */ /* Makros/Constants */ /* ***************************** */ -#define H264_SILENT -//#define H265_DEBUG -#ifdef H265_DEBUG - -static short debug_level = 10; - -#define h264_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define h264_printf(level, fmt, x...) -#endif - -#ifndef H265_SILENT -#define h264_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define h264_err(fmt, x...) -#endif #define IOVEC_SIZE 128 @@ -99,14 +82,14 @@ static unsigned int CodecDataLen = 0; static int32_t PreparCodecData(unsigned char *data, unsigned int cd_len, unsigned int *NalLength) { - h264_printf(10, "H265 check codec data..!\n"); + h265_printf(10, "H265 check codec data..!\n"); int32_t ret = -100; if (data) { unsigned char tmp[2048]; unsigned int tmp_len = 0; - h264_printf(10, "H265 have codec data..!"); + h265_printf(10, "H265 have codec data..!"); if (cd_len > 3 && (data[0] || data[1] || data[2] > 1)) { @@ -115,7 +98,7 @@ static int32_t PreparCodecData(unsigned char *data, unsigned int cd_len, unsigne int i; if (data[0] != 0) { - h264_printf(10, "Unsupported extra data version %d, decoding may fail", (int)data[0]); + h265_printf(10, "Unsupported extra data version %d, decoding may fail", (int)data[0]); } *NalLength = (data[21] & 3) + 1; @@ -126,7 +109,7 @@ static int32_t PreparCodecData(unsigned char *data, unsigned int cd_len, unsigne int j; if (pos + 3 > cd_len) { - h264_printf(10, "Buffer underrun in extra header (%d >= %u)", pos + 3, cd_len); + h265_printf(10, "Buffer underrun in extra header (%d >= %u)", pos + 3, cd_len); break; } // ignore flags + NAL type (1 byte) @@ -136,14 +119,14 @@ static int32_t PreparCodecData(unsigned char *data, unsigned int cd_len, unsigne { if (pos + 2 > cd_len) { - h264_printf(10, "Buffer underrun in extra nal header (%d >= %u)", pos + 2, cd_len); + h265_printf(10, "Buffer underrun in extra nal header (%d >= %u)", pos + 2, cd_len); break; } int nal_size = data[pos] << 8 | data[pos + 1]; pos += 2; if (pos + nal_size > cd_len) { - h264_printf(10, "Buffer underrun in extra nal (%d >= %u)", pos + 2 + nal_size, cd_len); + h265_printf(10, "Buffer underrun in extra nal (%d >= %u)", pos + 2 + nal_size, cd_len); break; } memcpy(tmp + tmp_len, "\x00\x00\x00\x01", 4); @@ -183,7 +166,7 @@ static int writeData(WriterAVCallData_t *call) unsigned int len = 0; int ic = 0; struct iovec iov[IOVEC_SIZE]; - h264_printf(20, "\n"); + h265_printf(20, "\n"); if (call == NULL) { @@ -198,7 +181,7 @@ static int writeData(WriterAVCallData_t *call) if (TimeScale) {} VideoPts = call->Pts; - h264_printf(20, "VideoPts %lld - %d %d\n", call->Pts, TimeDelta, TimeScale); + h265_printf(20, "VideoPts %lld - %d %d\n", call->Pts, TimeDelta, TimeScale); if ((call->data == NULL) || (call->len <= 0)) { @@ -212,9 +195,9 @@ static int writeData(WriterAVCallData_t *call) return 0; } - if (call->InfoFlags & 0x1) // TS container + if (call->InfoFlags & 0x1) // TS container { - h264_printf(10, "H265 simple inject method!\n"); + h265_printf(10, "H265 simple inject method!\n"); uint32_t PacketLength = 0; uint32_t FakeStartCode = (call->Version << 8) | PES_VERSION_FAKE_START_CODE; @@ -304,7 +287,7 @@ static int writeData(WriterAVCallData_t *call) } while ((pos + NalLengthBytes) < call->len); - h264_printf(10, "<<<< PacketLength [%d]\n", PacketLength); + h265_printf(10, "<<<< PacketLength [%d]\n", PacketLength); iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, 0); len = call->WriteV(call->fd, iov, ic); @@ -315,7 +298,7 @@ static int writeData(WriterAVCallData_t *call) } } - h264_printf(10, "< len %d\n", len); + h265_printf(10, "< len %d\n", len); return len; } diff --git a/libeplayer3-arm/output/writer/mipsel/lpcm.c b/libeplayer3-arm/output/writer/mipsel/lpcm.c index cf099a2..f8c1abc 100644 --- a/libeplayer3-arm/output/writer/mipsel/lpcm.c +++ b/libeplayer3-arm/output/writer/mipsel/lpcm.c @@ -58,29 +58,6 @@ /* Makros/Constants */ /* ***************************** */ -//#define SAM_WITH_DEBUG -#ifdef SAM_WITH_DEBUG -#define LPCM_DEBUG -#else -#define LPCM_SILENT -#endif - -#ifdef LPCM_DEBUG - -static uint16_t debug_level = 1; - -#define lpcm_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define lpcm_printf(level, fmt, x...) -#endif - -#ifndef LPCM_SILENT -#define lpcm_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define lpcm_err(fmt, x...) -#endif - #define LLPCM_VOB_HEADER_LEN (6) /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/mipsel/mp3.c b/libeplayer3-arm/output/writer/mipsel/mp3.c index 9eb9f5c..fa225fd 100644 --- a/libeplayer3-arm/output/writer/mipsel/mp3.c +++ b/libeplayer3-arm/output/writer/mipsel/mp3.c @@ -52,23 +52,6 @@ /* ***************************** */ /* Makros/Constants */ /* ***************************** */ -#define MP3_DEBUG - -#ifdef MP3_DEBUG - -static short debug_level = 0; - -#define mp3_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define mp3_printf(level, fmt, x...) -#endif - -#ifndef MP3_SILENT -#define mp3_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define mp3_err(fmt, x...) -#endif /* ***************************** */ /* Types */ diff --git a/libeplayer3-arm/output/writer/mipsel/mpeg2.c b/libeplayer3-arm/output/writer/mipsel/mpeg2.c index aecc701..c40667b 100644 --- a/libeplayer3-arm/output/writer/mipsel/mpeg2.c +++ b/libeplayer3-arm/output/writer/mipsel/mpeg2.c @@ -53,24 +53,6 @@ /* Makros/Constants */ /* ***************************** */ -#define MPEG2_DEBUG - -#ifdef MPEG2_DEBUG - -static short debug_level = 0; - -#define mpeg2_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define mpeg2_printf(level, fmt, x...) -#endif - -#ifndef MPEG2_SILENT -#define mpeg2_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define mpeg2_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/mipsel/mpeg4.c b/libeplayer3-arm/output/writer/mipsel/mpeg4.c index 0086992..dab2ca6 100644 --- a/libeplayer3-arm/output/writer/mipsel/mpeg4.c +++ b/libeplayer3-arm/output/writer/mipsel/mpeg4.c @@ -53,29 +53,6 @@ /* Makros/Constants */ /* ***************************** */ -//#define SAM_WITH_DEBUG -#ifdef SAM_WITH_DEBUG -#define MPEG4_DEBUG -#else -#define MPEG4_SILENT -#endif - -#ifdef MPEG4_DEBUG - -static short debug_level = 0; - -#define mpeg4_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define mpeg4_printf(level, fmt, x...) -#endif - -#ifndef MPEG4_SILENT -#define mpeg4_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define mpeg4_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/mipsel/pcm.c b/libeplayer3-arm/output/writer/mipsel/pcm.c index f50ab64..f8bb938 100644 --- a/libeplayer3-arm/output/writer/mipsel/pcm.c +++ b/libeplayer3-arm/output/writer/mipsel/pcm.c @@ -56,28 +56,6 @@ /* Makros/Constants */ /* ***************************** */ -#ifdef SAM_WITH_DEBUG -#define PCM_DEBUG -#else -#define PCM_SILENT -#endif - -#ifdef PCM_DEBUG - -static uint16_t debug_level = 0; - -#define pcm_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define pcm_printf(level, fmt, x...) -#endif - -#ifndef PCM_SILENT -#define pcm_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define pcm_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ @@ -139,17 +117,6 @@ static int writeData(WriterAVCallData_t *call) if (pcmPrivateData->bResampling || NULL == fixed_buffer) { - if (0) - { - printf("ioctl %d", ioctl(call->fd, AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY)); - printf("ioctl %d", ioctl(call->fd, AUDIO_PAUSE)); - printf("ioctl %d", ioctl(call->fd, AUDIO_SET_BYPASS_MODE, 0x30)); - printf("ioctl %d", ioctl(call->fd, AUDIO_PLAY)); - printf("ioctl %d", ioctl(call->fd, AUDIO_CONTINUE)); - } - - int32_t format = 0x01; - int32_t width = 0; int32_t depth = 0; int32_t rate = (uint64_t)pcmPrivateData->sample_rate; @@ -193,6 +160,7 @@ static int writeData(WriterAVCallData_t *call) } uint8_t *data = codec_data; + uint16_t format = LE ? 0x0001 : 0x0100; byterate = channels * rate * width / 8; block_align = channels * width / 8; @@ -237,7 +205,7 @@ static int writeData(WriterAVCallData_t *call) fixed_bufferfilled = 0; /* avoid compiler warning */ if (LE) {} - //printf("PCM fixed_buffersize [%u] [%s]\n", fixed_buffersize, LE ? "LE":"BE"); + pcm_printf(40, "PCM fixed_buffersize [%u] [%s]\n", fixed_buffersize, LE ? "LE" : "BE"); } while (size > 0) @@ -286,11 +254,6 @@ static int writeData(WriterAVCallData_t *call) iov[1].iov_len = fixed_buffersize; call->WriteV(call->fd, iov, 2); fixed_buffertimestamp += fixed_bufferduration; - - int g_fd_dump = open("/hdd/lpcm/ffmpeg.pes", O_CREAT | - O_RDWR | O_APPEND, S_IRUSR | S_IWUSR); - call->WriteV(g_fd_dump, iov, 2); - close(g_fd_dump); } return size; diff --git a/libeplayer3-arm/output/writer/mipsel/vc1.c b/libeplayer3-arm/output/writer/mipsel/vc1.c index 0cdb63b..8d54c10 100644 --- a/libeplayer3-arm/output/writer/mipsel/vc1.c +++ b/libeplayer3-arm/output/writer/mipsel/vc1.c @@ -56,30 +56,6 @@ #define VC1_SEQUENCE_LAYER_METADATA_START_CODE 0x80 #define VC1_FRAME_START_CODE 0x0d -#define SAM_WITH_DEBUG -#ifdef SAM_WITH_DEBUG -#define VC1_DEBUG -#else -#define VC1_SILENT -#endif - -#ifdef VC1_DEBUG - -static short debug_level = 10; - -#define vc1_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define vc1_printf(level, fmt, x...) -#endif - -#ifndef VC1_SILENT -#define vc1_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define vc1_err(fmt, x...) -#endif - - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/mipsel/vp.c b/libeplayer3-arm/output/writer/mipsel/vp.c index a9f75aa..b64291f 100644 --- a/libeplayer3-arm/output/writer/mipsel/vp.c +++ b/libeplayer3-arm/output/writer/mipsel/vp.c @@ -53,30 +53,6 @@ /* Makros/Constants */ /* ***************************** */ -//#define SAM_WITH_DEBUG -#ifdef SAM_WITH_DEBUG -#define VP_DEBUG -#else -#define VP_SILENT -#endif - -#ifdef VP_DEBUG - -static short debug_level = 10; - -#define vp_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define vp_printf(level, fmt, x...) -#endif - -#ifndef VP_SILENT -#define vp_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define vp_err(fmt, x...) -#endif - - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/mipsel/wma.c b/libeplayer3-arm/output/writer/mipsel/wma.c index e953ed8..9d888e9 100644 --- a/libeplayer3-arm/output/writer/mipsel/wma.c +++ b/libeplayer3-arm/output/writer/mipsel/wma.c @@ -53,28 +53,6 @@ /* Makros/Constants */ /* ***************************** */ -#ifdef SAM_WITH_DEBUG -#define WMA_DEBUG -#else -#define WMA_SILENT -#endif - -#ifdef WMA_DEBUG - -static short debug_level = 0; - -#define wma_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define wma_printf(level, fmt, x...) -#endif - -#ifndef WMA_SILENT -#define wma_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define wma_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/mipsel/wmv.c b/libeplayer3-arm/output/writer/mipsel/wmv.c index 13934c7..36ee772 100644 --- a/libeplayer3-arm/output/writer/mipsel/wmv.c +++ b/libeplayer3-arm/output/writer/mipsel/wmv.c @@ -55,29 +55,6 @@ #define WMV_FRAME_START_CODE 0x0d -//#define SAM_WITH_DEBUG -#ifdef SAM_WITH_DEBUG -#define WMV_DEBUG -#else -#define WMV_SILENT -#endif - -#ifdef WMV_DEBUG - -static short debug_level = 10; - -#define wmv_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define wmv_printf(level, fmt, x...) -#endif - -#ifndef WMV_SILENT -#define wmv_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define wmv_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/mipsel/writer.c b/libeplayer3-arm/output/writer/mipsel/writer.c index c5ccb35..4ce9539 100644 --- a/libeplayer3-arm/output/writer/mipsel/writer.c +++ b/libeplayer3-arm/output/writer/mipsel/writer.c @@ -30,29 +30,12 @@ #include "misc.h" #include "writer.h" #include "common.h" +#include "debug.h" /* ***************************** */ /* Makros/Constants */ /* ***************************** */ -#define WRITER_DEBUG - -#ifdef WRITER_DEBUG - -static short debug_level = 0; - -#define writer_printf(level, x...) do { \ -if (debug_level >= level) printf(x); } while (0) -#else -#define writer_printf(level, x...) -#endif - -#ifndef WRITER_SILENT -#define writer_err(x...) do { printf(x); } while (0) -#else -#define writer_err(x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ @@ -110,8 +93,8 @@ ssize_t WriteWithRetry(Context_t *context, int pipefd, int fd, const void *buf, int retval = -1; int maxFd = pipefd > fd ? pipefd : fd; struct timeval tv; - - while(size > 0 && 0 == PlaybackDieNow(0) && !context->playback->isSeeking) + + while (size > 0 && 0 == PlaybackDieNow(0) && !context->playback->isSeeking) { FD_ZERO(&rfds); FD_ZERO(&wfds); @@ -143,19 +126,19 @@ ssize_t WriteWithRetry(Context_t *context, int pipefd, int fd, const void *buf, // continue; //} - if(FD_ISSET(pipefd, &rfds)) + if (FD_ISSET(pipefd, &rfds)) { FlushPipe(pipefd); //printf("RETURN FROM SELECT DUE TO pipefd SET\n"); continue; } - if(FD_ISSET(fd, &wfds)) + if (FD_ISSET(fd, &wfds)) { ret = write(fd, buf, size); if (ret < 0) { - switch(errno) + switch (errno) { case EINTR: case EAGAIN: diff --git a/libeplayer3-arm/output/writer/sh4/aac.c b/libeplayer3-arm/output/writer/sh4/aac.c index 62978e5..4d36753 100644 --- a/libeplayer3-arm/output/writer/sh4/aac.c +++ b/libeplayer3-arm/output/writer/sh4/aac.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -42,7 +41,7 @@ #include #include "ffmpeg/latmenc.h" - +#include "stm_ioctls.h" #include "common.h" #include "output.h" @@ -56,30 +55,6 @@ /* Makros/Constants */ /* ***************************** */ -//#define SAM_WITH_DEBUG - -#ifdef SAM_WITH_DEBUG -#define AAC_DEBUG -#else -#define AAC_SILENT -#endif - -#ifdef AAC_DEBUG - -static short debug_level = 0; - -#define aac_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define aac_printf(level, fmt, x...) -#endif - -#ifndef AAC_SILENT -#define aac_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define aac_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ @@ -181,7 +156,7 @@ static int _writeData(void *_call, int type) aac_err("parsing Data with missing syncword. ignoring...\n"); return 0; } - + // STB can handle only AAC LC profile if (0 == (call->data[2] & 0xC0)) { diff --git a/libeplayer3-arm/output/writer/sh4/ac3.c b/libeplayer3-arm/output/writer/sh4/ac3.c index cba2445..8fa881f 100644 --- a/libeplayer3-arm/output/writer/sh4/ac3.c +++ b/libeplayer3-arm/output/writer/sh4/ac3.c @@ -34,12 +34,12 @@ #include #include #include -#include #include #include #include #include +#include "stm_ioctls.h" #include "common.h" #include "output.h" #include "debug.h" @@ -52,28 +52,6 @@ /* ***************************** */ #define AC3_HEADER_LENGTH 7 -#ifdef SAM_WITH_DEBUG -#define AC3_DEBUG -#else -#define AC3_SILENT -#endif - -#ifdef AC3_DEBUG - -static short debug_level = 0; - -#define ac3_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define ac3_printf(level, fmt, x...) -#endif - -#ifndef AC3_SILENT -#define ac3_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define ac3_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/sh4/divx.c b/libeplayer3-arm/output/writer/sh4/divx.c index c1b97c7..ee184ef 100644 --- a/libeplayer3-arm/output/writer/sh4/divx.c +++ b/libeplayer3-arm/output/writer/sh4/divx.c @@ -34,12 +34,12 @@ #include #include #include -#include #include #include #include #include +#include "stm_ioctls.h" #include "common.h" #include "output.h" #include "debug.h" @@ -51,28 +51,6 @@ /* Makros/Constants */ /* ***************************** */ -#ifdef SAM_WITH_DEBUG -#define DIVX_DEBUG -#else -#define DIVX_SILENT -#endif - -#ifdef DIVX_DEBUG - -static short debug_level = 0; - -#define divx_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define divx_printf(level, fmt, x...) -#endif - -#ifndef DIVX_SILENT -#define divx_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define divx_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/sh4/divx2.c b/libeplayer3-arm/output/writer/sh4/divx2.c index fc80917..044d2e0 100644 --- a/libeplayer3-arm/output/writer/sh4/divx2.c +++ b/libeplayer3-arm/output/writer/sh4/divx2.c @@ -34,12 +34,12 @@ #include #include #include -#include #include #include #include #include +#include "stm_ioctls.h" #include "common.h" #include "output.h" #include "debug.h" @@ -51,28 +51,6 @@ /* Makros/Constants */ /* ***************************** */ -#ifdef SAM_WITH_DEBUG -#define DIVX_DEBUG -#else -#define DIVX_SILENT -#endif - -#ifdef DIVX_DEBUG - -static short debug_level = 0; - -#define divx_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define divx_printf(level, fmt, x...) -#endif - -#ifndef DIVX_SILENT -#define divx_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define divx_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/sh4/dts.c b/libeplayer3-arm/output/writer/sh4/dts.c index f6cc94c..d631231 100644 --- a/libeplayer3-arm/output/writer/sh4/dts.c +++ b/libeplayer3-arm/output/writer/sh4/dts.c @@ -34,12 +34,12 @@ #include #include #include -#include #include #include #include #include +#include "stm_ioctls.h" #include "common.h" #include "output.h" #include "debug.h" @@ -56,28 +56,6 @@ #define PES_AUDIO_PACKET_SIZE 2028 #define SPDIF_AUDIO_PACKET_SIZE (1024 * sizeof(unsigned int) * 2) // stereo 32bit samples. -#ifdef SAM_WITH_DEBUG -#define DTS_DEBUG -#else -#define DTS_SILENT -#endif - -#ifdef DTS_DEBUG - -static short debug_level = 0; - -#define dts_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define dts_printf(level, fmt, x...) -#endif - -#ifndef DTS_SILENT -#define dts_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define dts_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/sh4/h263.c b/libeplayer3-arm/output/writer/sh4/h263.c index c29309b..c1b95fa 100644 --- a/libeplayer3-arm/output/writer/sh4/h263.c +++ b/libeplayer3-arm/output/writer/sh4/h263.c @@ -33,13 +33,13 @@ #include #include #include -#include #include #include #include #include #include +#include "stm_ioctls.h" #include "common.h" #include "output.h" #include "debug.h" @@ -51,28 +51,6 @@ /* Makros/Constants */ /* ***************************** */ -#ifdef SAM_WITH_DEBUG -#define H263_DEBUG -#else -#define H263_SILENT -#endif - -#ifdef H263_DEBUG -static short debug_level = 0; -static const char *FILENAME = "h263.c"; - -#define h263_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, FILENAME, __FUNCTION__, ## x); } while (0) -#else -#define h263_printf(level, fmt, x...) -#endif - -#ifndef H263_SILENT -#define h263_err(fmt, x...) do { printf("[%s:%s] " fmt, FILENAME, __FUNCTION__, ## x); } while (0) -#else -#define h263_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/sh4/h264.c b/libeplayer3-arm/output/writer/sh4/h264.c index b749139..a81b535 100644 --- a/libeplayer3-arm/output/writer/sh4/h264.c +++ b/libeplayer3-arm/output/writer/sh4/h264.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -42,6 +41,7 @@ #include #include +#include "stm_ioctls.h" #include "common.h" #include "output.h" #include "debug.h" @@ -53,28 +53,6 @@ /* Makros/Constants */ /* ***************************** */ -#ifdef SAM_WITH_DEBUG -#define H264_DEBUG -#else -#define H264_SILENT -#endif - -#ifdef H264_DEBUG - -static short debug_level = 0; - -#define h264_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define h264_printf(level, fmt, x...) -#endif - -#ifndef H264_SILENT -#define h264_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define h264_err(fmt, x...) -#endif - #define NALU_TYPE_PLAYER2_CONTAINER_PARAMETERS 24 #define CONTAINER_PARAMETERS_VERSION 0x00 @@ -267,7 +245,7 @@ static int32_t writeData(void *_call) iov[ic++].iov_base = PesHeader; initialHeader = 0; - if (initialHeader) + if (initialHeader) { initialHeader = 0; iov[ic].iov_base = call->private_data; diff --git a/libeplayer3-arm/output/writer/sh4/mp3.c b/libeplayer3-arm/output/writer/sh4/mp3.c index 72b0aa5..962c640 100644 --- a/libeplayer3-arm/output/writer/sh4/mp3.c +++ b/libeplayer3-arm/output/writer/sh4/mp3.c @@ -34,12 +34,12 @@ #include #include #include -#include #include #include #include #include +#include "stm_ioctls.h" #include "common.h" #include "output.h" #include "debug.h" @@ -51,28 +51,6 @@ /* Makros/Constants */ /* ***************************** */ -#ifdef SAM_WITH_DEBUG -#define MP3_DEBUG -#else -#define MP3_SILENT -#endif - -#ifdef MP3_DEBUG - -static short debug_level = 0; - -#define mp3_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define mp3_printf(level, fmt, x...) -#endif - -#ifndef MP3_SILENT -#define mp3_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define mp3_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ @@ -182,3 +160,4 @@ struct Writer_s WriterAudioVORBIS = &writeData, &caps_vorbis }; + diff --git a/libeplayer3-arm/output/writer/sh4/mpeg2.c b/libeplayer3-arm/output/writer/sh4/mpeg2.c index 5dae349..d7fb298 100644 --- a/libeplayer3-arm/output/writer/sh4/mpeg2.c +++ b/libeplayer3-arm/output/writer/sh4/mpeg2.c @@ -34,12 +34,12 @@ #include #include #include -#include #include #include #include #include +#include "stm_ioctls.h" #include "common.h" #include "output.h" #include "debug.h" @@ -51,28 +51,6 @@ /* Makros/Constants */ /* ***************************** */ -#ifdef SAM_WITH_DEBUG -#define MPEG2_DEBUG -#else -#define MPEG2_SILENT -#endif - -#ifdef MPEG2_DEBUG - -static short debug_level = 0; - -#define mpeg2_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define mpeg2_printf(level, fmt, x...) -#endif - -#ifndef MPEG2_SILENT -#define mpeg2_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define mpeg2_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/sh4/pcm.c b/libeplayer3-arm/output/writer/sh4/pcm.c index e9bef07..43e1709 100644 --- a/libeplayer3-arm/output/writer/sh4/pcm.c +++ b/libeplayer3-arm/output/writer/sh4/pcm.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -42,6 +41,7 @@ #include +#include "stm_ioctls.h" #include "common.h" #include "output.h" #include "debug.h" @@ -54,28 +54,6 @@ /* Makros/Constants */ /* ***************************** */ -#ifdef SAM_WITH_DEBUG -#define PCM_DEBUG -#else -#define PCM_SILENT -#endif - -#ifdef PCM_DEBUG - -static short debug_level = 0; - -#define pcm_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define pcm_printf(level, fmt, x...) -#endif - -#ifndef PCM_SILENT -#define pcm_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define pcm_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/sh4/pes.c b/libeplayer3-arm/output/writer/sh4/pes.c index 12a7bd6..5ce53aa 100644 --- a/libeplayer3-arm/output/writer/sh4/pes.c +++ b/libeplayer3-arm/output/writer/sh4/pes.c @@ -33,12 +33,12 @@ #include #include #include -#include #include #include #include #include +#include "stm_ioctls.h" #include "common.h" #include "output.h" #include "debug.h" diff --git a/libeplayer3-arm/output/writer/sh4/vc1.c b/libeplayer3-arm/output/writer/sh4/vc1.c index 8545eba..f9fba12 100644 --- a/libeplayer3-arm/output/writer/sh4/vc1.c +++ b/libeplayer3-arm/output/writer/sh4/vc1.c @@ -34,12 +34,12 @@ #include #include #include -#include #include #include #include #include +#include "stm_ioctls.h" #include "common.h" #include "output.h" #include "debug.h" @@ -61,28 +61,6 @@ #define VC1_SEQUENCE_LAYER_METADATA_START_CODE 0x80 #define VC1_FRAME_START_CODE 0x0d -#ifdef SAM_WITH_DEBUG -#define VC1_DEBUG -#else -#define VC1_SILENT -#endif - -#ifdef VC1_DEBUG - -static short debug_level = 0; - -#define vc1_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define vc1_printf(level, fmt, x...) -#endif - -#ifndef VC1_SILENT -#define vc1_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define vc1_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/sh4/vorbis.c b/libeplayer3-arm/output/writer/sh4/vorbis.c index 3ed1cb2..e51513e 100644 --- a/libeplayer3-arm/output/writer/sh4/vorbis.c +++ b/libeplayer3-arm/output/writer/sh4/vorbis.c @@ -38,10 +38,10 @@ #include #include +#include "stm_ioctls.h" #include "common.h" #include "output.h" #include "debug.h" -#include "stm_ioctls.h" #include "misc.h" #include "pes.h" #include "writer.h" @@ -50,28 +50,6 @@ /* Makros/Constants */ /* ***************************** */ -#ifdef SAM_WITH_DEBUG -#define VORBIS_DEBUG -#else -#define VORBIS_SILENT -#endif - -#ifdef VORBIS_DEBUG - -static short debug_level = 1; - -#define vorbis_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define vorbis_printf(level, fmt, x...) -#endif - -#ifndef VORBIS_SILENT -#define vorbis_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define vorbis_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/sh4/wma.c b/libeplayer3-arm/output/writer/sh4/wma.c index 35408df..4a52055 100644 --- a/libeplayer3-arm/output/writer/sh4/wma.c +++ b/libeplayer3-arm/output/writer/sh4/wma.c @@ -34,12 +34,12 @@ #include #include #include -#include #include #include #include #include +#include "stm_ioctls.h" #include "common.h" #include "output.h" #include "debug.h" @@ -51,28 +51,6 @@ /* Makros/Constants */ /* ***************************** */ -#ifdef SAM_WITH_DEBUG -#define WMA_DEBUG -#else -#define WMA_SILENT -#endif - -#ifdef WMA_DEBUG - -static short debug_level = 0; - -#define wma_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define wma_printf(level, fmt, x...) -#endif - -#ifndef WMA_SILENT -#define wma_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define wma_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/sh4/wmv.c b/libeplayer3-arm/output/writer/sh4/wmv.c index 9a644d9..2204195 100644 --- a/libeplayer3-arm/output/writer/sh4/wmv.c +++ b/libeplayer3-arm/output/writer/sh4/wmv.c @@ -34,12 +34,12 @@ #include #include #include -#include #include #include #include #include +#include "stm_ioctls.h" #include "common.h" #include "output.h" #include "debug.h" @@ -58,28 +58,6 @@ #define METADATA_STRUCT_B_FRAMERATE_START 32 #define METADATA_STRUCT_C_START 8 -#ifdef SAM_WITH_DEBUG -#define WMV_DEBUG -#else -#define WMV_SILENT -#endif - -#ifdef WMV_DEBUG - -static short debug_level = 0; - -#define wmv_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define wmv_printf(level, fmt, x...) -#endif - -#ifndef WMV_SILENT -#define wmv_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define wmv_err(fmt, x...) -#endif - /* ***************************** */ /* Types */ /* ***************************** */ diff --git a/libeplayer3-arm/output/writer/sh4/writer.c b/libeplayer3-arm/output/writer/sh4/writer.c index 71aa862..653b299 100644 --- a/libeplayer3-arm/output/writer/sh4/writer.c +++ b/libeplayer3-arm/output/writer/sh4/writer.c @@ -100,47 +100,47 @@ static Writer_t *AvailableWriter[] = ssize_t WriteWithRetry(Context_t *context, int pipefd, int fd, const void *buf, int size) { fd_set rfds; - + ssize_t ret; int retval = -1; struct timeval tv; - - while(size > 0 && 0 == PlaybackDieNow(0) && !context->playback->isSeeking) + + while (size > 0 && 0 == PlaybackDieNow(0) && !context->playback->isSeeking) { if (context->playback->isPaused) { FD_ZERO(&rfds); FD_SET(pipefd, &rfds); - + tv.tv_sec = 0; tv.tv_usec = 500000; // 500ms - + retval = select(pipefd + 1, &rfds, NULL, NULL, &tv); if (retval < 0) { break; } - + if (retval == 0) { //printf("RETURN FROM SELECT DUE TO TIMEOUT TIMEOUT\n"); continue; } - - if(FD_ISSET(pipefd, &rfds)) + + if (FD_ISSET(pipefd, &rfds)) { FlushPipe(pipefd); //printf("RETURN FROM SELECT DUE TO pipefd SET\n"); continue; } } - + //printf(">> Before Write fd [%d]\n", fd); ret = write(fd, buf, size); //printf(">> After Write ret[%d] size[%d]\n", (int)ret, size); if (ret == size) ret = 0; // no error - + break; } return ret; @@ -199,3 +199,4 @@ Writer_t *getDefaultAudioWriter() return NULL; } + diff --git a/libeplayer3-arm/playback/playback.c b/libeplayer3-arm/playback/playback.c index a4814c5..280faa1 100644 --- a/libeplayer3-arm/playback/playback.c +++ b/libeplayer3-arm/playback/playback.c @@ -8,6 +8,7 @@ /* ***************************** */ #include +#include #include #include #include @@ -21,6 +22,7 @@ #include #include "playback.h" +#include "debug.h" #include "common.h" #include "misc.h" @@ -28,29 +30,6 @@ /* Makros/Constants */ /* ***************************** */ -// SULGE DEBUG -//#define SAM_WITH_DEBUG - -#ifdef SAM_WITH_DEBUG -#define PLAYBACK_DEBUG -static short debug_level = 20; -#else -#define PLAYBACK_SILENT -#endif - -#ifdef PLAYBACK_DEBUG -#define playback_printf(level, fmt, x...) do { \ -if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define playback_printf(level, fmt, x...) -#endif - -#ifndef PLAYBACK_SILENT -#define playback_err(fmt, x...) do { printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x); } while (0) -#else -#define playback_err(fmt, x...) -#endif - #define cERR_PLAYBACK_NO_ERROR 0 #define cERR_PLAYBACK_ERROR -1 @@ -71,6 +50,7 @@ static int hasThreadStarted = 0; /* ***************************** */ static int32_t PlaybackTerminate(Context_t *context); + static int8_t dieNow = 0; static PlaybackDieNowCallback playbackDieNowCallbacks[MAX_PLAYBACK_DIE_NOW_CALLBACKS] = {NULL}; @@ -651,7 +631,7 @@ static int32_t PlaybackSeek(Context_t *context, int64_t *pos, uint8_t absolute) { int32_t ret = cERR_PLAYBACK_NO_ERROR; - playback_printf(10, "pos: %lldd\n", *pos); + playback_printf(10, "pos: %" PRIu64 "\n", *pos); if (context->playback->isPlaying && !context->playback->isForwarding && !context->playback->BackWard && !context->playback->SlowMotion && !context->playback->isPaused) {