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.
Unified · Split
| @@ -635,10 +635,18 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt) · 634 unmodified lines | ||
| 635 | 635 | rtp_send_ilbc(s1, pkt->data, size); |
| 636 | 636 | break; |
| 637 | 637 | 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 | + } | |
| 638 | 642 | ff_rtp_send_jpeg(s1, pkt->data, size); |
| 639 | 643 | break; |
| 640 | 644 | case AV_CODEC_ID_BITPACKED: |
| 641 | 645 | 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 | + } | |
| 642 | 650 | int interlaced = st->codecpar->field_order != AV_FIELD_PROGRESSIVE; |
| 643 | 651 | |
| 644 | 652 | ff_rtp_send_raw_rfc4175(s1, pkt->data, size, interlaced, 0); |
| @@ -685,5 +693,5 @@ const FFOutputFormat ff_rtp_muxer = { · 40 unmodified lines | ||
| 685 | 693 | .write_packet = rtp_write_packet, |
| 686 | 694 | .write_trailer = rtp_write_trailer, |
| 687 | 695 | .p.priv_class = &rtp_muxer_class, |
| 688 | − .p.flags = AVFMT_TS_NONSTRICT, | |
| 696 | + .p.flags = AVFMT_NODIMENSIONS | AVFMT_TS_NONSTRICT, | |
| 689 | 697 | }; |