On 12/30/2014 03:05 AM, Michael Niedermayer wrote: > On Mon, Dec 29, 2014 at 07:19:14PM +0530, Anshul wrote: >> On 12/29/2014 06:08 PM, Michael Niedermayer wrote: >>> On Mon, Dec 29, 2014 at 01:31:18PM +0530, Anshul wrote: >>>> On December 18, 2014 4:08:56 PM IST, Michael Niedermayer >>>> <michae...@gmx.at> wrote: >>>>> On Wed, Dec 17, 2014 at 11:53:10PM +0530, Anshul wrote: >>>>>> Hi >>>>>> >>>>>> I was doing development of scte-35 message cue in ffmpeg. >>>>>> >>>>>> I have attached a draft patch. >>>>>> >>>>>> I would like to have some comments of this community. >>>>>> -Anshul >>>>>> libavcodec/Makefile | 2 ++ >>>>>> libavcodec/allcodecs.c | 2 ++ >>>>>> libavcodec/avcodec.h | 1 + >>>>>> libavcodec/codec_desc.c | 6 ++++++ >>>>>> libavformat/mpegts.c | 40 >>>>> +++++++++++++++++++++++++++++++++------- >>>>>> 5 files changed, 44 insertions(+), 7 deletions(-) >>>>>> 4b584484a54a78c130c4bbaa48c38551b3ca75fb >>>>> 0001-trying-muxing-demuxing-of-scte_35-message-cue.patch >>>>>> From 2ff4edfdeae131df72ea19005eb6ad85d5332f7c Mon Sep 17 00:00:00 >>>>> 2001 >>>>>> From: Anshul Maheshwari <anshul.ffm...@gmail.com> >>>>>> Date: Wed, 17 Dec 2014 22:13:10 +0530 >>>>>> Subject: [PATCH] trying muxing demuxing of scte_35 message cue >>>>>> >>>>>> --- >>>>>> libavcodec/Makefile | 2 ++ >>>>>> libavcodec/allcodecs.c | 2 ++ >>>>>> libavcodec/avcodec.h | 1 + >>>>>> libavcodec/codec_desc.c | 6 ++++++ >>>>>> libavformat/mpegts.c | 40 >>>>> +++++++++++++++++++++++++++++++++------- >>>>>> 5 files changed, 44 insertions(+), 7 deletions(-) >>>>>> >>>>>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile >>>>>> index b35a796..9d2a49f 100644 >>>>>> --- a/libavcodec/Makefile >>>>>> +++ b/libavcodec/Makefile >>>>>> @@ -408,6 +408,7 @@ OBJS-$(CONFIG_SAMI_DECODER) += >>>>> samidec.o ass.o >>>>>> OBJS-$(CONFIG_S302M_DECODER) += s302m.o >>>>>> OBJS-$(CONFIG_S302M_ENCODER) += s302menc.o >>>>>> OBJS-$(CONFIG_SANM_DECODER) += sanm.o >>>>>> +OBJS-$(CONFIG_SCTE_35_DECODER) += scte_35.o >>>>> this patch doesnt contain a scte_35.c >>>>> did you forget git add ? >>>>> >>>>> [...] >>>> I have attached another patch, still its draft. >>>> I do want some opinion about the approach of this development. >>>> >>>> to use this patch, one can pass below command >>>> ./ffmpeg -loglevel debug -i ~/test_videos/mpegwithscte35.ts -dcodec >>>> cue_xml -map 0:0 -f rawvideo some.raw >>>> >>>> There still some issue with this patch, like I have disabled estimate >>>> timing of all stream since data stream does not have similar timing, i >>>> will add condition there. >>>> >>>> FFmpeg hangs after running command, it might be because of EOF not >>>> handled properly, looking at the issue. >>>> >>>> >>>> My vision for this patch is that we can add custom advertisement >>>> if stream have scte-cue. >>>> >>>> This patch might also help end-user to remove advertisements automatically. >>>> >>>> for broadcaster it will help to show advertisement in local language. >>>> or for local product. >>>> just now I am very far away from my goal but will not always be. >>>> >>>> >>>> This patch have all files which I have developed. >>> ar: libavcodec/scte_35.o: No such file or directory >>> >>> [...] >>> >>> >>> >>> _______________________________________________ >>> ffmpeg-devel mailing list >>> ffmpeg-devel@ffmpeg.org >>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> I am sorry, I attached the wrong patch file. >> -Anshul >> ffmpeg.c | 40 ++++++ >> ffmpeg_opt.c | 9 - >> libavcodec/Makefile | 2 >> libavcodec/allcodecs.c | 2 >> libavcodec/avcodec.h | 17 ++ >> libavcodec/codec_desc.c | 12 + >> libavcodec/cue_xml.c | 196 ++++++++++++++++++++++++++++++++ >> libavcodec/scte_35.c | 294 >> ++++++++++++++++++++++++++++++++++++++++++++++++ >> libavcodec/scte_35.h | 31 +++++ >> libavcodec/utils.c | 33 ++++- >> libavformat/avformat.h | 16 ++ >> libavformat/mpegts.c | 44 ++++++- >> libavformat/utils.c | 3 >> libavutil/avstring.c | 26 ++++ >> libavutil/avstring.h | 15 ++ >> 15 files changed, 724 insertions(+), 16 deletions(-) >> 5e5649190d21989599df2f78194b28ed29ebdae7 >> 0001-trying-handle-scte_35-messagecue.patch >> From 6e04f65c33c4d4f873bbadabcc9d1d8464d49314 Mon Sep 17 00:00:00 2001 >> From: Anshul Maheshwari <anshul.ffm...@gmail.com> >> Date: Mon, 29 Dec 2014 12:42:41 +0530 >> Subject: [PATCH] trying handle scte_35 messagecue > Applying: trying handle scte_35 messagecue > fatal: sha1 information is lacking or useless (libavcodec/Makefile). > Repository lacks necessary blobs to fall back on 3-way merge. > Cannot fall back to three-way merge. > Patch failed at 0001 trying handle scte_35 messagecue > When you have resolved this problem run "git am --resolved". > If you would prefer to skip this patch, instead run "git am --skip". > To restore the original branch and stop patching run "git am --abort". > > > [...] > > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel Attached another patch with git cloned this morning.
>From 7a8042f2b54b6713fe9b268c9ad9ec37f1be1ba4 Mon Sep 17 00:00:00 2001 From: Anshul Maheshwari <anshul.ffm...@gmail.com> Date: Tue, 30 Dec 2014 15:41:16 +0530 Subject: [PATCH] handle scte 35 message cue data stream
--- ffmpeg.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- ffmpeg_opt.c | 9 +++++---- libavcodec/Makefile | 2 ++ libavcodec/allcodecs.c | 2 ++ libavcodec/avcodec.h | 17 +++++++++++++++++ libavcodec/codec_desc.c | 12 ++++++++++++ libavcodec/utils.c | 33 ++++++++++++++++++++++++++++++--- libavformat/avformat.h | 16 ++++++++++++++++ libavformat/mpegts.c | 45 +++++++++++++++++++++++++++++++++++++++------ libavformat/utils.c | 1 + libavutil/avstring.c | 25 +++++++++++++++++++++++++ libavutil/avstring.h | 15 +++++++++++++++ 12 files changed, 209 insertions(+), 14 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index ddf4272..14712cd 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2063,6 +2063,44 @@ fail: return err < 0 ? err : ret; } +static int transcode_data(InputStream *ist, AVPacket *pkt, int *got_output) +{ + AVCodecContext *dec = ist->dec_ctx; + enum AVCodecID in_codec_id = AV_CODEC_ID_NONE; + AVData input; + AVData output; + AVPacket outpkt; + int ret, i; + + if (dec->codec) + in_codec_id = dec->codec->id; + + input.valid = 0; + update_benchmark(NULL); + ret = avcodec_decode_data(dec, &input, pkt); + update_benchmark("decode_data %d.%d", ist->file_index, ist->st->index); + *got_output = input.valid; + + if (ret < 0 || !input.valid) { + return ret; + } + for (i = 0; i < nb_output_streams && *got_output; i++) { + OutputStream *ost = output_streams[i]; + + if (!check_output_constraints(ist, ost) || !ost->encoding_needed + || ost->enc->type != AVMEDIA_TYPE_DATA) + continue; + ret = avcodec_encode_data(output_streams[i]->enc_ctx, &input, &output, in_codec_id); + av_init_packet(&outpkt); + outpkt.data = output.data; + outpkt.size = output.len; + write_frame(output_files[ost->file_index]->ctx, &outpkt, ost); + + } + + return ret; + +} static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output) { AVSubtitle subtitle; @@ -2203,6 +2241,9 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt) case AVMEDIA_TYPE_SUBTITLE: ret = transcode_subtitles(ist, &avpkt, &got_output); break; + case AVMEDIA_TYPE_DATA: + ret = transcode_data(ist, &avpkt, &got_output); + break; default: return -1; } @@ -2907,6 +2948,8 @@ static int transcode_init(void) enc_ctx->height = input_streams[ost->source_index]->st->codec->height; } break; + case AVMEDIA_TYPE_DATA: + break; default: abort(); break; @@ -3464,7 +3507,8 @@ static int process_input(int file_index) OutputStream *ost = output_streams[j]; if (ost->source_index == ifile->ist_index + i && - (ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE)) + (ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE + || ost->enc->type == AVMEDIA_TYPE_DATA )) finish_output_stream(ost); } } diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index ac93eb5..f7b20fd 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -804,6 +804,7 @@ static int open_input_file(OptionsContext *o, const char *filename) char * video_codec_name = NULL; char * audio_codec_name = NULL; char *subtitle_codec_name = NULL; + char * data_codec_name = NULL; int scan_all_pmts_set = 0; if (o->format) { @@ -864,6 +865,8 @@ static int open_input_file(OptionsContext *o, const char *filename) find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0)->id : AV_CODEC_ID_NONE; ic->subtitle_codec_id= subtitle_codec_name ? find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0)->id : AV_CODEC_ID_NONE; + ic->data_codec_id = data_codec_name ? + find_codec_or_die(data_codec_name, AVMEDIA_TYPE_DATA, 0)->id : AV_CODEC_ID_NONE; if (video_codec_name) av_format_set_video_codec (ic, find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0)); @@ -871,6 +874,8 @@ static int open_input_file(OptionsContext *o, const char *filename) av_format_set_audio_codec (ic, find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0)); if (subtitle_codec_name) av_format_set_subtitle_codec(ic, find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0)); + if (data_codec_name) + av_format_set_data_codec(ic, find_codec_or_die(data_codec_name, AVMEDIA_TYPE_DATA, 0)); ic->flags |= AVFMT_FLAG_NONBLOCK; ic->interrupt_callback = int_cb; @@ -1522,10 +1527,6 @@ static OutputStream *new_data_stream(OptionsContext *o, AVFormatContext *oc, int OutputStream *ost; ost = new_output_stream(o, oc, AVMEDIA_TYPE_DATA, source_index); - if (!ost->stream_copy) { - av_log(NULL, AV_LOG_FATAL, "Data stream encoding not supported yet (only streamcopy)\n"); - exit_program(1); - } return ost; } diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 107661b..c7cb069 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -293,6 +293,7 @@ OBJS-$(CONFIG_LOCO_DECODER) += loco.o OBJS-$(CONFIG_MACE3_DECODER) += mace.o OBJS-$(CONFIG_MACE6_DECODER) += mace.o OBJS-$(CONFIG_MDEC_DECODER) += mdec.o mpeg12.o mpeg12data.o +OBJS-$(CONFIG_CUE_XML_ENCODER) += cue_xml.o OBJS-$(CONFIG_METASOUND_DECODER) += metasound.o metasound_data.o \ twinvq.o OBJS-$(CONFIG_MICRODVD_DECODER) += microdvddec.o ass.o @@ -412,6 +413,7 @@ OBJS-$(CONFIG_SAMI_DECODER) += samidec.o ass.o OBJS-$(CONFIG_S302M_DECODER) += s302m.o OBJS-$(CONFIG_S302M_ENCODER) += s302menc.o OBJS-$(CONFIG_SANM_DECODER) += sanm.o +OBJS-$(CONFIG_SCTE_35_DECODER) += scte_35.o OBJS-$(CONFIG_SGI_DECODER) += sgidec.o OBJS-$(CONFIG_SGI_ENCODER) += sgienc.o rle.o OBJS-$(CONFIG_SGIRLE_DECODER) += sgirledec.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 8ceee2f..a965087 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -536,6 +536,8 @@ void avcodec_register_all(void) REGISTER_ENCODER(LIBAACPLUS, libaacplus); /* text */ + REGISTER_DECODER(SCTE_35, scte_35) + REGISTER_ENCODER(CUE_XML, cue_xml); REGISTER_DECODER(BINTEXT, bintext); REGISTER_DECODER(XBIN, xbin); REGISTER_DECODER(IDF, idf); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 99467bb..bd966d5 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -523,6 +523,8 @@ enum AVCodecID { /* other specific kind of codecs (generally used for attachments) */ AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. AV_CODEC_ID_TTF = 0x18000, + AV_CODEC_ID_SCTE_35 = MKBETAG('C','U','E','I'), + AV_CODEC_ID_CUE_XML = MKBETAG('C','U','E','X'), AV_CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'), AV_CODEC_ID_XBIN = MKBETAG('X','B','I','N'), AV_CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'), @@ -3157,6 +3159,13 @@ typedef struct AVCodecDefault AVCodecDefault; struct AVSubtitle; +typedef struct AVData { + void *data; + int len; + int ref_count; + int valid; +} AVData; + /** * AVCodec. */ @@ -3233,6 +3242,8 @@ typedef struct AVCodec { int (*init)(AVCodecContext *); int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size, const struct AVSubtitle *sub); + int (*encode_data)(AVCodecContext *avctx, const AVData *input, AVData *output, + enum AVCodecID in_codec_id); /** * Encode data to an AVPacket. * @@ -3246,6 +3257,7 @@ typedef struct AVCodec { int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr); int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt); + int (*decode_data)(AVCodecContext *,AVData *output, const AVPacket *avpkt); int (*close)(AVCodecContext *); /** * Flush buffers. @@ -4195,6 +4207,9 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt); +int avcodec_decode_data(AVCodecContext *avctx, + AVData *output, + const AVPacket *avpkt); /** * @defgroup lavc_parsing Frame parsing * @{ @@ -4585,6 +4600,8 @@ int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub); +int avcodec_encode_data(AVCodecContext *avctx,const AVData *input, AVData *output, + enum AVCodecID in_codec_id); /** diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 0af66f4..d26cd2f 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2739,6 +2739,18 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("binary data"), .mime_types= MT("application/octet-stream"), }, + { + .id = AV_CODEC_ID_SCTE_35, + .type = AVMEDIA_TYPE_DATA, + .name = "scte_35", + .long_name = NULL_IF_CONFIG_SMALL("SCTE 35 Message Queue"), + }, + { + .id = AV_CODEC_ID_CUE_XML, + .type = AVMEDIA_TYPE_DATA, + .name = "cue_xml", + .long_name = NULL_IF_CONFIG_SMALL("Message Queue to Insert Add"), + }, /* deprecated codec ids */ { diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 1ec5cae..bdbc0a4 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -186,12 +186,12 @@ static av_cold void avcodec_init(void) int av_codec_is_encoder(const AVCodec *codec) { - return codec && (codec->encode_sub || codec->encode2); + return codec && (codec->encode_sub || codec->encode2 || codec->encode_data); } int av_codec_is_decoder(const AVCodec *codec) { - return codec && codec->decode; + return codec && ( codec->decode || codec->decode_data); } av_cold void avcodec_register(AVCodec *codec) @@ -2173,7 +2173,14 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, avctx->frame_number++; return ret; } - +int avcodec_encode_data(AVCodecContext *avctx, const AVData *input, AVData *output, + enum AVCodecID in_codec_id) +{ + int ret; + ret = avctx->codec->encode_data(avctx, input, output, in_codec_id); + avctx->frame_number++; + return ret; +} /** * Attempt to guess proper monotonic timestamps for decoded video frames * which might have incorrect times. Input timestamps may wrap around, in @@ -2624,6 +2631,26 @@ fail: return ret; } +int attribute_align_arg avcodec_decode_data(AVCodecContext *avctx, + AVData *output, + const AVPacket *avpkt) +{ + AVCodecInternal *avci = avctx->internal; + int ret = 0; + + if (!avctx->codec) + return AVERROR(EINVAL); + if (avctx->codec->type != AVMEDIA_TYPE_DATA) { + av_log(avctx, AV_LOG_ERROR, "Invalid media type for data\n"); + return AVERROR(EINVAL); + } + + ret = avctx->codec->decode_data(avctx, output, avpkt); + + return ret; + + +} #define UTF8_MAX_BYTES 4 /* 5 and 6 bytes sequences should not be used */ static int recode_subtitle(AVCodecContext *avctx, AVPacket *outpkt, const AVPacket *inpkt) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 2e54ed1..7fd96ac 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1367,6 +1367,12 @@ typedef struct AVFormatContext { enum AVCodecID subtitle_codec_id; /** + * Forced Data codec_id. + * Demuxing: Set by user. + */ + enum AVCodecID data_codec_id; + + /** * Maximum amount of memory in bytes to use for the index of each stream. * If the index exceeds this size, entries will be discarded as * needed to maintain a smaller size. This can lead to slower or less @@ -1705,6 +1711,14 @@ typedef struct AVFormatContext { AVCodec *subtitle_codec; /** + * Forced data codec. + * This allows forcing a specific decoder, even when there are multiple with + * the same codec_id. + * Demuxing: Set by user via av_format_set_data_codec (NO direct access). + */ + AVCodec *data_codec; + + /** * Number of bytes to be written as padding in a metadata header. * Demuxing: Unused. * Muxing: Set by user via av_format_set_metadata_header_padding. @@ -1764,6 +1778,8 @@ AVCodec * av_format_get_audio_codec(const AVFormatContext *s); void av_format_set_audio_codec(AVFormatContext *s, AVCodec *c); AVCodec * av_format_get_subtitle_codec(const AVFormatContext *s); void av_format_set_subtitle_codec(AVFormatContext *s, AVCodec *c); +AVCodec * av_format_get_data_codec(const AVFormatContext *s); +void av_format_set_data_codec(AVFormatContext *s, AVCodec *c); int av_format_get_metadata_header_padding(const AVFormatContext *s); void av_format_set_metadata_header_padding(AVFormatContext *s, int c); void * av_format_get_opaque(const AVFormatContext *s); diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index f61388b..6971e93 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -57,6 +57,7 @@ enum MpegTSFilterType { MPEGTS_PES, MPEGTS_SECTION, MPEGTS_PCR, + MPEGTS_DATA, }; typedef struct MpegTSFilter MpegTSFilter; @@ -498,6 +499,11 @@ static MpegTSFilter *mpegts_open_pcr_filter(MpegTSContext *ts, unsigned int pid) return mpegts_open_filter(ts, pid, MPEGTS_PCR); } +static MpegTSFilter *mpegts_open_data_filter(MpegTSContext *ts, unsigned int pid) +{ + return mpegts_open_filter(ts, pid, MPEGTS_DATA); +} + static void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter) { int pid; @@ -676,6 +682,7 @@ static const StreamType ISO_types[] = { { 0x1b, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264 }, { 0x24, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC }, { 0x42, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_CAVS }, + { 0x86, AVMEDIA_TYPE_DATA, AV_CODEC_ID_SCTE_35 }, { 0xd1, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_DIRAC }, { 0xea, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VC1 }, { 0 }, @@ -824,6 +831,12 @@ static void reset_pes_packet_state(PESContext *pes) av_buffer_unref(&pes->buffer); } +static void new_data_packet(const uint8_t *buffer, int len, AVPacket *pkt) +{ + av_init_packet(pkt); + pkt->data = buffer; + pkt->size = len; +} static void new_pes_packet(PESContext *pes, AVPacket *pkt) { av_init_packet(pkt); @@ -1886,7 +1899,20 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len pes->st->id = pes->pid; } st = pes->st; - } else if (stream_type != 0x13) { + } else if (stream_type == 0x86 ) { + int idx = ff_find_stream_index(ts->stream, pid); + if (idx >= 0) { + st = ts->stream->streams[idx]; + } else { + st = avformat_new_stream(ts->stream, NULL); + if (!st) + goto out; + st->id = pid; + st->codec->codec_type = AVMEDIA_TYPE_DATA; + mpegts_find_stream_type(st, stream_type, ISO_types); + mpegts_open_data_filter(ts, pid); + } + }else if (stream_type != 0x13 ) { if (ts->pids[pid]) mpegts_close_filter(ts, ts->pids[pid]); // wrongly added sdt filter probably pes = add_pes_stream(ts, pid, pcr_pid); @@ -2222,14 +2248,17 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) } } - } else { + } else if (tss->type == MPEGTS_DATA) { + /* may be pointer field is 0 and to be ignored*/ + p++; + new_data_packet(p,p_end - p, ts->pkt); + ts->stop_parse = 1; + } else if (tss->type == MPEGTS_PES) { int ret; // Note: The position here points actually behind the current packet. - if (tss->type == MPEGTS_PES) { - if ((ret = tss->u.pes_filter.pes_cb(tss, p, p_end - p, is_start, + if ((ret = tss->u.pes_filter.pes_cb(tss, p, p_end - p, is_start, pos - ts->raw_packet_size)) < 0) - return ret; - } + return ret; } return 0; @@ -2616,6 +2645,10 @@ static int mpegts_read_packet(AVFormatContext *s, AVPacket *pkt) ret = 0; break; } + } else if (ts->pids[i] && ts->pids[i]->type == MPEGTS_DATA) { + // ret = 0; + //ts->pkt->size = 0; + return ret; } } diff --git a/libavformat/utils.c b/libavformat/utils.c index 752270d..b8fef74 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -110,6 +110,7 @@ MAKE_ACCESSORS(AVStream, stream, char *, recommended_encoder_configuration) MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, video_codec) MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, audio_codec) MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, subtitle_codec) +MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, data_codec) MAKE_ACCESSORS(AVFormatContext, format, int, metadata_header_padding) MAKE_ACCESSORS(AVFormatContext, format, void *, opaque) MAKE_ACCESSORS(AVFormatContext, format, av_format_control_message, control_message_cb) diff --git a/libavutil/avstring.c b/libavutil/avstring.c index 25c65b4..a866ee3 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -144,6 +144,31 @@ char *av_d2str(double d) return str; } +char *av_int2str(int i) +{ + char *str = av_malloc(16); + if (str) + snprintf(str, 16, "%d", i); + return str; +} +char *av_uint2str(unsigned int i) +{ + char *str = av_malloc(16); + if (str) + snprintf(str, 16, "%u", i); + return str; +} +/** + * 0xff ff ff ff ff ff ff ff = 18446744073709551615 + * therefor taking 20 digit + */ +char *av_uint64_t2str(uint64_t val) +{ + char *str = av_malloc(20); + if (str) + snprintf(str, 20, "%llu", val); + return str; +} #define WHITESPACES " \n\t" char *av_get_token(const char **buf, const char *term) diff --git a/libavutil/avstring.h b/libavutil/avstring.h index ffb7aa6..a516a11 100644 --- a/libavutil/avstring.h +++ b/libavutil/avstring.h @@ -161,6 +161,21 @@ char *av_asprintf(const char *fmt, ...) av_printf_format(1, 2); char *av_d2str(double d); /** + * Convert a int to a av_malloced string. + */ +char *av_int2str(int i); + +/** + * Convert a unsigned int to a av_malloced string. + */ +char *av_uint2str(unsigned int ui); + +/** + * Convert a 64 bit decimal to a av_malloced string. + */ +char *av_uint64_t2str(uint64_t val); + +/** * Unescape the given string until a non escaped terminating char, * and return the token corresponding to the unescaped string. * -- 1.8.1.4
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel