History

avformat/rtpenc: Add flag AVFMT_NODIMENSIONS.

Not all rtp formats require the video dimensions to be available up front. H264 and HEVC will send them as stream parameters. The flag is restrictive and prevents RTP repacketization without parsing the codec information out of the stream. This change checks to see if the codec parameters are available on the rtp formats that need it.

Koushik Dutta committed 1 year ago

Commit 2657e161 parent 5fac8d01 file · +9 −1Browse files

Unified · Split

libavformat/rtpenc.c+9−1
@@ -635,10 +635,18 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt) · 634 unmodified lines
635635 rtp_send_ilbc(s1, pkt->data, size);
636636 break;
637637 case AV_CODEC_ID_MJPEG:
638+ if (st->codecpar->width <= 0 || st->codecpar->height <= 0) {
639+ av_log(s1, AV_LOG_ERROR, "dimensions not set\n");
640+ return AVERROR(EINVAL);
641+ }
638642 ff_rtp_send_jpeg(s1, pkt->data, size);
639643 break;
640644 case AV_CODEC_ID_BITPACKED:
641645 case AV_CODEC_ID_RAWVIDEO: {
646+ if (st->codecpar->width <= 0 || st->codecpar->height <= 0) {
647+ av_log(s1, AV_LOG_ERROR, "dimensions not set\n");
648+ return AVERROR(EINVAL);
649+ }
642650 int interlaced = st->codecpar->field_order != AV_FIELD_PROGRESSIVE;
643651
644652 ff_rtp_send_raw_rfc4175(s1, pkt->data, size, interlaced, 0);
@@ -685,5 +693,5 @@ const FFOutputFormat ff_rtp_muxer = { · 40 unmodified lines
685693 .write_packet = rtp_write_packet,
686694 .write_trailer = rtp_write_trailer,
687695 .p.priv_class = &rtp_muxer_class,
688− .p.flags = AVFMT_TS_NONSTRICT,
696+ .p.flags = AVFMT_NODIMENSIONS | AVFMT_TS_NONSTRICT,
689697 };

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t