summaryrefslogtreecommitdiff
path: root/libavformat/flvdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-06-06 05:06:12 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-06-16 23:43:11 +0200
commit2fbdfba0f2d1851f894002d9d5930799629cc194 (patch)
tree206f3b9fb307f3b6182057c76c7539dfc5d0a592 /libavformat/flvdec.c
parent293d5d7a8e12e38bf70b51f6aa70321e079ffa64 (diff)
avformat/flvdec: Support live flv / NGINX RTMP streams
Fixes Ticket3553 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/flvdec.c')
-rw-r--r--libavformat/flvdec.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index e113cc3f6c..cc40a53ba8 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -56,21 +56,35 @@ typedef struct {
int searched_for_end;
} FLVContext;
-static int flv_probe(AVProbeData *p)
+static int probe(AVProbeData *p, int live)
{
- const uint8_t *d;
+ const uint8_t *d = p->buf;
+ unsigned offset = AV_RB32(d + 5);
- d = p->buf;
if (d[0] == 'F' &&
d[1] == 'L' &&
d[2] == 'V' &&
d[3] < 5 && d[5] == 0 &&
- AV_RB32(d + 5) > 8) {
- return AVPROBE_SCORE_MAX;
+ offset + 100 < p->buf_size &&
+ offset > 8) {
+ int is_live = !memcmp(d + offset + 40, "NGINX RTMP", 10);
+
+ if (live == is_live)
+ return AVPROBE_SCORE_MAX;
}
return 0;
}
+static int flv_probe(AVProbeData *p)
+{
+ return probe(p, 0);
+}
+
+static int live_flv_probe(AVProbeData *p)
+{
+ return probe(p, 1);
+}
+
static AVStream *create_stream(AVFormatContext *s, int codec_type)
{
AVStream *st = avformat_new_stream(s, NULL);
@@ -1049,3 +1063,24 @@ AVInputFormat ff_flv_demuxer = {
.extensions = "flv",
.priv_class = &flv_class,
};
+
+static const AVClass live_flv_class = {
+ .class_name = "flvdec",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+AVInputFormat ff_live_flv_demuxer = {
+ .name = "live_flv",
+ .long_name = NULL_IF_CONFIG_SMALL("live RTMP FLV (Flash Video)"),
+ .priv_data_size = sizeof(FLVContext),
+ .read_probe = live_flv_probe,
+ .read_header = flv_read_header,
+ .read_packet = flv_read_packet,
+ .read_seek = flv_read_seek,
+ .read_close = flv_read_close,
+ .extensions = "flv",
+ .priv_class = &live_flv_class,
+ .flags = AVFMT_TS_DISCONT
+};