summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavformat/rtp.c11
-rw-r--r--libavformat/rtp.h6
-rw-r--r--libavformat/rtpenc.c4
-rw-r--r--libavformat/sdp.c2
4 files changed, 18 insertions, 5 deletions
diff --git a/libavformat/rtp.c b/libavformat/rtp.c
index 35edb5066a..5dee4362db 100644
--- a/libavformat/rtp.c
+++ b/libavformat/rtp.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <libavutil/opt.h>
#include "avformat.h"
#include "rtp.h"
@@ -89,9 +90,17 @@ int ff_rtp_get_codec_info(AVCodecContext *codec, int payload_type)
return -1;
}
-int ff_rtp_get_payload_type(AVCodecContext *codec)
+int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec)
{
int i, payload_type;
+ AVOutputFormat *ofmt = fmt ? fmt->oformat : NULL;
+
+ /* Was the payload type already specified for the RTP muxer? */
+ if (ofmt && ofmt->priv_class)
+ payload_type = av_get_int(fmt->priv_data, "payload_type", NULL);
+
+ if (payload_type >= 0)
+ return payload_type;
/* compute the payload type */
for (payload_type = -1, i = 0; AVRtpPayloadTypes[i].pt >= 0; ++i)
diff --git a/libavformat/rtp.h b/libavformat/rtp.h
index 4d948ada82..4f35142afd 100644
--- a/libavformat/rtp.h
+++ b/libavformat/rtp.h
@@ -21,15 +21,17 @@
#ifndef AVFORMAT_RTP_H
#define AVFORMAT_RTP_H
+#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
/**
- * Return the payload type for a given codec.
+ * Return the payload type for a given codec used in the given format context.
*
+ * @param fmt The context of the format
* @param codec The context of the codec
* @return The payload type (the 'PT' field in the RTP header).
*/
-int ff_rtp_get_payload_type(AVCodecContext *codec);
+int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec);
/**
* Initialize a codec context based on the payload type.
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 1f5d9ba37a..ce42e3e9aa 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -32,6 +32,7 @@
static const AVOption options[] = {
FF_RTP_FLAG_OPTS(RTPMuxContext, flags),
+ { "payload_type", "Specify RTP payload type", offsetof(RTPMuxContext, payload_type), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 127, AV_OPT_FLAG_ENCODING_PARAM },
{ NULL },
};
@@ -92,7 +93,8 @@ static int rtp_write_header(AVFormatContext *s1)
return -1;
}
- s->payload_type = ff_rtp_get_payload_type(st->codec);
+ if (s->payload_type < 0)
+ s->payload_type = ff_rtp_get_payload_type(s1, st->codec);
s->base_timestamp = av_get_random_seed();
s->timestamp = s->base_timestamp;
s->cur_timestamp = 0;
diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index f27a89936c..a586690d3f 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -532,7 +532,7 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *des
const char *type;
int payload_type;
- payload_type = ff_rtp_get_payload_type(c);
+ payload_type = ff_rtp_get_payload_type(fmt, c);
switch (c->codec_type) {
case AVMEDIA_TYPE_VIDEO : type = "video" ; break;