aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/flvdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-03-13 16:25:27 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-03-13 16:25:27 +0100
commit3727cd5416788df8e4a54dbde903de858de7de7b (patch)
tree9158be173ca4f7ab597ad86bdbc6d5c23b5464ba /libavformat/flvdec.c
parent1df64d6c46ed522e74ebf082a0ea3f0dcadc1950 (diff)
downloadffmpeg-3727cd5416788df8e4a54dbde903de858de7de7b.tar.gz
avformat/flvdec: add support for OnCaption
Diffstat (limited to 'libavformat/flvdec.c')
-rw-r--r--libavformat/flvdec.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 0d8b3acf37..b625c787a5 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 ||