[FFmpeg-cvslog] avformat/flvdec: add support for OnCaption
Michael Niedermayer
git at videolan.org
Fri Mar 13 16:47:44 CET 2015
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Mar 13 16:25:27 2015 +0100| [3727cd5416788df8e4a54dbde903de858de7de7b] | committer: Michael Niedermayer
avformat/flvdec: add support for OnCaption
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3727cd5416788df8e4a54dbde903de858de7de7b
---
libavformat/flvdec.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 0d8b3ac..b625c78 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -546,7 +546,8 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
}
#define TYPE_ONTEXTDATA 1
-#define TYPE_UNKNOWN 2
+#define TYPE_ONCAPTION 2
+#define TYPE_UNKNOWN 9
static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
{
@@ -573,6 +574,9 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
if (!strcmp(buffer, "onTextData"))
return TYPE_ONTEXTDATA;
+ if (!strcmp(buffer, "onCaption"))
+ return TYPE_ONCAPTION;
+
if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint"))
return TYPE_UNKNOWN;
@@ -717,8 +721,11 @@ static int flv_data_packet(AVFormatContext *s, AVPacket *pkt,
char buf[20];
int ret = AVERROR_INVALIDDATA;
int i, length = -1;
+ int array = 0;
switch (avio_r8(pb)) {
+ case AMF_DATA_TYPE_ARRAY:
+ array = 1;
case AMF_DATA_TYPE_MIXEDARRAY:
avio_seek(pb, 4, SEEK_CUR);
case AMF_DATA_TYPE_OBJECT:
@@ -727,9 +734,9 @@ static int flv_data_packet(AVFormatContext *s, AVPacket *pkt,
goto skip;
}
- while ((ret = amf_get_string(pb, buf, sizeof(buf))) > 0) {
+ while (array || (ret = amf_get_string(pb, buf, sizeof(buf))) > 0) {
AMFDataType type = avio_r8(pb);
- if (type == AMF_DATA_TYPE_STRING && !strcmp(buf, "text")) {
+ if (type == AMF_DATA_TYPE_STRING && (array || !strcmp(buf, "text"))) {
length = avio_rb16(pb);
ret = av_get_packet(pb, pkt, length);
if (ret < 0)
@@ -839,6 +846,8 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
} else if (type == TYPE_ONTEXTDATA) {
avpriv_request_sample(s, "OnTextData packet");
return flv_data_packet(s, pkt, dts, next);
+ } else if (type == TYPE_ONCAPTION) {
+ return flv_data_packet(s, pkt, dts, next);
}
avio_seek(s->pb, meta_pos, SEEK_SET);
}
@@ -955,6 +964,8 @@ retry_duration:
}
} else if (stream_type == FLV_STREAM_TYPE_VIDEO) {
size -= flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK, 1);
+ } else if (stream_type == FLV_STREAM_TYPE_DATA) {
+ st->codec->codec_id = AV_CODEC_ID_TEXT;
}
if (st->codec->codec_id == AV_CODEC_ID_AAC ||
More information about the ffmpeg-cvslog
mailing list