From e30e8e311e14236a979ce061538ec8b8bad8655f Mon Sep 17 00:00:00 2001 From: Jernej Virag Date: Mon, 17 Dec 2012 10:04:15 +0100 Subject: [PATCH 1/3] sapenc: Pass the title on to the chained muxers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes sure it ends up in the SDP, providing a proper session name in the SAP announcements. Signed-off-by: Martin Storsjö --- libavformat/sapenc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c index fd9be4f5a7..7e2bba7a28 100644 --- a/libavformat/sapenc.c +++ b/libavformat/sapenc.c @@ -23,6 +23,7 @@ #include "libavutil/parseutils.h" #include "libavutil/random_seed.h" #include "libavutil/avstring.h" +#include "libavutil/dict.h" #include "libavutil/intreadwrite.h" #include "libavutil/time.h" #include "internal.h" @@ -76,6 +77,7 @@ static int sap_write_header(AVFormatContext *s) struct sockaddr_storage localaddr; socklen_t addrlen = sizeof(localaddr); int udp_fd; + AVDictionaryEntry* title = av_dict_get(s->metadata, "title", NULL, 0); if (!ff_network_init()) return AVERROR(EIO); @@ -158,6 +160,9 @@ static int sap_write_header(AVFormatContext *s) av_strlcpy(contexts[i]->filename, url, sizeof(contexts[i]->filename)); } + if (s->nb_streams > 0 && title) + av_dict_set(&contexts[0]->metadata, "title", title->value, 0); + ff_url_join(url, sizeof(url), "udp", NULL, announce_addr, port, "?ttl=%d&connect=1", ttl); ret = ffurl_open(&sap->ann_fd, url, AVIO_FLAG_WRITE, From 1eaff98c8320d9ba48fbaec2a558f31f4104de98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Axelsson?= Date: Thu, 13 Dec 2012 14:48:25 +0100 Subject: [PATCH 2/3] flvenc: Check whether seeking back to the header succeeded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The FLV muxer tries to update the header in write_trailer, which is impossible if writing to a pipe or network stream. Don't write header data if seeking to the header fails. Signed-off-by: Martin Storsjö --- libavformat/flvenc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 8aeea968b4..ff6d14a248 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -403,10 +403,14 @@ static int flv_write_trailer(AVFormatContext *s) file_size = avio_tell(pb); /* update information */ - avio_seek(pb, flv->duration_offset, SEEK_SET); - put_amf_double(pb, flv->duration / (double)1000); - avio_seek(pb, flv->filesize_offset, SEEK_SET); - put_amf_double(pb, file_size); + if (avio_seek(pb, flv->duration_offset, SEEK_SET) < 0) + av_log(s, AV_LOG_WARNING, "Failed to update header with correct duration.\n"); + else + put_amf_double(pb, flv->duration / (double)1000); + if (avio_seek(pb, flv->filesize_offset, SEEK_SET) < 0) + av_log(s, AV_LOG_WARNING, "Failed to update header with correct filesize.\n"); + else + put_amf_double(pb, file_size); avio_seek(pb, file_size, SEEK_SET); return 0; From a925f723a915bc0255e2673f8817af5212131763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 20 Dec 2012 13:53:27 +0200 Subject: [PATCH 3/3] rtp: Don't read priv_data unless it is allocated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes all users of rtpenc_chain (rtsp muxer, sapenc, mov rtp hinting) work again, broken since 8034130e0. Signed-off-by: Martin Storsjö --- libavformat/rtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/rtp.c b/libavformat/rtp.c index 651220692c..38b2348d45 100644 --- a/libavformat/rtp.c +++ b/libavformat/rtp.c @@ -97,7 +97,7 @@ int ff_rtp_get_payload_type(AVFormatContext *fmt, AVOutputFormat *ofmt = fmt ? fmt->oformat : NULL; /* Was the payload type already specified for the RTP muxer? */ - if (ofmt && ofmt->priv_class) { + if (ofmt && ofmt->priv_class && fmt->priv_data) { int64_t payload_type; if (av_opt_get_int(fmt->priv_data, "payload_type", 0, &payload_type) >= 0 && payload_type >= 0)