summaryrefslogtreecommitdiff
path: root/libavformat/rtpenc.c
diff options
context:
space:
mode:
authorLuca Abeni <lucabe72@email.it>2009-03-27 21:36:44 +0000
committerLuca Abeni <lucabe72@email.it>2009-03-27 21:36:44 +0000
commit0766c3ee989f105651a1094496fdb24d637b57e6 (patch)
tree35e1a589c1e2206dc7ba0ce6815c914f8cad6844 /libavformat/rtpenc.c
parent5b00e88bb2b202a8cca7dfaa0132ac425f4bfe45 (diff)
Make rtp_write_header() fail in case of unsupported payload type
Originally committed as revision 18204 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/rtpenc.c')
-rw-r--r--libavformat/rtpenc.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 3563cbe8b1..17c44d877c 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -39,6 +39,31 @@ static uint64_t ntp_time(void)
return (av_gettime() / 1000) * 1000 + NTP_OFFSET_US;
}
+static int is_supported(enum CodecID id)
+{
+ switch(id) {
+ case CODEC_ID_H264:
+ case CODEC_ID_MPEG1VIDEO:
+ case CODEC_ID_MPEG2VIDEO:
+ case CODEC_ID_MPEG4:
+ case CODEC_ID_AAC:
+ case CODEC_ID_MP2:
+ case CODEC_ID_MP3:
+ case CODEC_ID_PCM_ALAW:
+ case CODEC_ID_PCM_MULAW:
+ case CODEC_ID_PCM_S8:
+ case CODEC_ID_PCM_S16BE:
+ case CODEC_ID_PCM_S16LE:
+ case CODEC_ID_PCM_U16BE:
+ case CODEC_ID_PCM_U16LE:
+ case CODEC_ID_PCM_U8:
+ case CODEC_ID_MPEG2TS:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
static int rtp_write_header(AVFormatContext *s1)
{
RTPMuxContext *s = s1->priv_data;
@@ -48,6 +73,11 @@ static int rtp_write_header(AVFormatContext *s1)
if (s1->nb_streams != 1)
return -1;
st = s1->streams[0];
+ if (!is_supported(st->codec->codec_id)) {
+ av_log(s1, AV_LOG_ERROR, "Unsupported codec %x\n", st->codec->codec_id);
+
+ return -1;
+ }
payload_type = ff_rtp_get_payload_type(st->codec);
if (payload_type < 0)