On Tue, 13 Nov 2012, Luca Barbato wrote:
Support multiple video/audio streams with different format in the
same session.
Signed-off-by: Luca Barbato <[email protected]>
---
The patch seems to work ok now, there's a few small things I'd like to
have investigated/tweaked still, but it should be pretty simple (I hope).
diff --git a/libavformat/rtp.h b/libavformat/rtp.h
index 6df4ed4..a7c9ec0 100644
--- a/libavformat/rtp.h
+++ b/libavformat/rtp.h
@@ -25,13 +25,17 @@
#include "libavcodec/avcodec.h"
/**
- * Return the payload type for a given codec used in the given format context.
+ * Return the payload type for a given stream used in the given format context.
+ * Static payload types are derived from the codec.
+ * Dynamic payload type are derived from the id field in AVStream.
+ * The format context private option payload_type overrides both.
*
* @param fmt The context of the format
* @param codec The context of the codec
+ * @param idx The stream index
* @return The payload type (the 'PT' field in the RTP header).
*/
-int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec);
+int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *c, int idx);
/**
* Initialize a codec context based on the payload type.
Don't rename the codec parameter here, it makes it no longer match the
doxygen above.
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index b17c465..9e88dd7 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -101,8 +101,17 @@ static int rtp_write_header(AVFormatContext *s1)
return -1;
}
- if (s->payload_type < 0)
- s->payload_type = ff_rtp_get_payload_type(s1, st->codec);
+ if (s->payload_type < 0) {
+ /* Re-validate non-dynamic payload types */
+ if (st->id < RTP_PT_PRIVATE)
+ s->payload_type = ff_rtp_get_payload_type(s1, st->codec, -1);
+ else
+ s->payload_type = st->id;
+ } else {
+ /* private option takes priority */
+ st->id = s->payload_type;
+ }
+
I think it'd be good to update st->id for the st->id < RTP_PT_PRIVATE case
as well - it might be useful in some odd interaction between SDP
generation and the RTP muxer to have the actual value present there.
diff --git a/libavformat/rtspenc.c b/libavformat/rtspenc.c
index 9b3c7c9..9eea9d9 100644
--- a/libavformat/rtspenc.c
+++ b/libavformat/rtspenc.c
@@ -122,9 +122,10 @@ static int rtsp_write_record(AVFormatContext *s)
static int rtsp_write_header(AVFormatContext *s)
{
- int ret;
+ int ret, i;
ret = ff_rtsp_connect(s);
+
if (ret)
return ret;
Stray changes
I think the patch should be good with this changed/cleaned up.
// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel