From patchwork Sat Dec 4 17:32:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 31958 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp2267925iog; Sat, 4 Dec 2021 09:33:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+h9XBTc7FgjJ97lmvbt9P8LvvPBVaNz8qGGRGkKrBW/gSvVlsy1oxLK/PjSzvP60jdFwv X-Received: by 2002:a17:907:720b:: with SMTP id dr11mr33256867ejc.93.1638639214595; Sat, 04 Dec 2021 09:33:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638639214; cv=none; d=google.com; s=arc-20160816; b=PyrjR+5d+x3Un3uTymx0jDQH6eiMO9Gzg1Uq7ras9LgOuRgV0t1hZZwtfkw11ssEYq IPU4RBRbQtmETDzAbpMramX7NpSG0k//IDEibr5oOiEFsP2mZgWpG2mc29A5aObgNd/V 6H/+8Bq7fcK50dI7972v9p+QfnDo+Ke9vLORR+MCWXka+JZw079NWUuQQ8cLAZYEMV2m oLfUeQm+VlnSMdqK5DJPvIFvR33YS8hteHHymxBF1UNX0EgCs6OnLITYXMWUGg52dtKJ GKKENoRaH3miIZGbu4zAhXP+36caASkF9uGsLtkL0RQrsZ5LZ0Lxmm5MuEL1zJyqRnLI 6KkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=vqfjFkmmdy1jU+cpO2kWQ5AxWgtKS/dzmj9/grzL5OI=; b=PKKppgNsWw1nlGyBjO4WhdBkYu9mZ1Rd6bfJh2fe1kRI20NqnESq7T2IUyOav9l/SY FS59hhvtjRGfFVAY34V1uoqBANplY3wwx6NTjno7mGbSApceeSzkdlB+l5/DjGhfcYMW JcNEnpym8xQEP0EfpmedtXeLiq8vKhJPgR5pttOSt1qxAPBouUXbncxhnpO3fkdlxN0/ qlFcN3tGnKZgUZXQqfB4odHKRPbPzheuoQv9IGPSyV7hX+RdNL6AqtwvZagq6tixuLDF JpPOgV/WFdvZAYuNJCE5z/uHK+WXaeIT6QpxUJsgDozyGWs6AooA4oorFYLw2jMXSN+A gk0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w26si10026941edl.90.2021.12.04.09.33.34; Sat, 04 Dec 2021 09:33:34 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8103368AE3E; Sat, 4 Dec 2021 19:33:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7A9DA680CB2 for ; Sat, 4 Dec 2021 19:33:11 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 20181240179 for ; Sat, 4 Dec 2021 18:33:11 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id UWJQVtVooKyt for ; Sat, 4 Dec 2021 18:33:09 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 36F8224017A for ; Sat, 4 Dec 2021 18:33:09 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 1C1813A067C; Sat, 4 Dec 2021 18:33:09 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 4 Dec 2021 18:32:59 +0100 Message-Id: <20211204173300.5742-2-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211204173300.5742-1-anton@khirnov.net> References: <20211204173300.5742-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] lavf/sdp: reindent switch() according to our conventions X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 5CwmS5UYK2t/ --- libavformat/sdp.c | 504 +++++++++++++++++++++++----------------------- 1 file changed, 252 insertions(+), 252 deletions(-) diff --git a/libavformat/sdp.c b/libavformat/sdp.c index ec5f7b763d..1cdd21c97b 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -487,278 +487,278 @@ static char *sdp_write_media_attributes(char *buff, int size, const AVStream *st const AVCodecParameters *p = st->codecpar; switch (p->codec_id) { - case AV_CODEC_ID_DIRAC: - av_strlcatf(buff, size, "a=rtpmap:%d VC2/90000\r\n", payload_type); - break; - case AV_CODEC_ID_H264: { - int mode = 1; - if (fmt && fmt->oformat && fmt->oformat->priv_class && - av_opt_flag_is_set(fmt->priv_data, "rtpflags", "h264_mode0")) - mode = 0; - if (p->extradata_size) { - config = extradata2psets(fmt, p); - } - av_strlcatf(buff, size, "a=rtpmap:%d H264/90000\r\n" - "a=fmtp:%d packetization-mode=%d%s\r\n", - payload_type, - payload_type, mode, config ? config : ""); - break; + case AV_CODEC_ID_DIRAC: + av_strlcatf(buff, size, "a=rtpmap:%d VC2/90000\r\n", payload_type); + break; + case AV_CODEC_ID_H264: { + int mode = 1; + if (fmt && fmt->oformat && fmt->oformat->priv_class && + av_opt_flag_is_set(fmt->priv_data, "rtpflags", "h264_mode0")) + mode = 0; + if (p->extradata_size) { + config = extradata2psets(fmt, p); } - case AV_CODEC_ID_H261: - { - const char *pic_fmt = NULL; - /* only QCIF and CIF are specified as supported in RFC 4587 */ - if (p->width == 176 && p->height == 144) - pic_fmt = "QCIF=1"; - else if (p->width == 352 && p->height == 288) - pic_fmt = "CIF=1"; - if (payload_type >= RTP_PT_PRIVATE) - av_strlcatf(buff, size, "a=rtpmap:%d H261/90000\r\n", payload_type); - if (pic_fmt) - av_strlcatf(buff, size, "a=fmtp:%d %s\r\n", payload_type, pic_fmt); - break; + av_strlcatf(buff, size, "a=rtpmap:%d H264/90000\r\n" + "a=fmtp:%d packetization-mode=%d%s\r\n", + payload_type, + payload_type, mode, config ? config : ""); + break; + } + case AV_CODEC_ID_H261: + { + const char *pic_fmt = NULL; + /* only QCIF and CIF are specified as supported in RFC 4587 */ + if (p->width == 176 && p->height == 144) + pic_fmt = "QCIF=1"; + else if (p->width == 352 && p->height == 288) + pic_fmt = "CIF=1"; + if (payload_type >= RTP_PT_PRIVATE) + av_strlcatf(buff, size, "a=rtpmap:%d H261/90000\r\n", payload_type); + if (pic_fmt) + av_strlcatf(buff, size, "a=fmtp:%d %s\r\n", payload_type, pic_fmt); + break; + } + case AV_CODEC_ID_H263: + case AV_CODEC_ID_H263P: + /* a=framesize is required by 3GPP TS 26.234 (PSS). It + * actually specifies the maximum video size, but we only know + * the current size. This is required for playback on Android + * stagefright and on Samsung bada. */ + if (!fmt || !fmt->oformat->priv_class || + !av_opt_flag_is_set(fmt->priv_data, "rtpflags", "rfc2190") || + p->codec_id == AV_CODEC_ID_H263P) + av_strlcatf(buff, size, "a=rtpmap:%d H263-2000/90000\r\n" + "a=framesize:%d %d-%d\r\n", + payload_type, + payload_type, p->width, p->height); + break; + case AV_CODEC_ID_HEVC: + if (p->extradata_size) + config = extradata2psets_hevc(p); + av_strlcatf(buff, size, "a=rtpmap:%d H265/90000\r\n", payload_type); + if (config) + av_strlcatf(buff, size, "a=fmtp:%d %s\r\n", + payload_type, config); + break; + case AV_CODEC_ID_MPEG4: + if (p->extradata_size) { + config = extradata2config(fmt, p); } - case AV_CODEC_ID_H263: - case AV_CODEC_ID_H263P: - /* a=framesize is required by 3GPP TS 26.234 (PSS). It - * actually specifies the maximum video size, but we only know - * the current size. This is required for playback on Android - * stagefright and on Samsung bada. */ - if (!fmt || !fmt->oformat->priv_class || - !av_opt_flag_is_set(fmt->priv_data, "rtpflags", "rfc2190") || - p->codec_id == AV_CODEC_ID_H263P) - av_strlcatf(buff, size, "a=rtpmap:%d H263-2000/90000\r\n" - "a=framesize:%d %d-%d\r\n", - payload_type, - payload_type, p->width, p->height); - break; - case AV_CODEC_ID_HEVC: - if (p->extradata_size) - config = extradata2psets_hevc(p); - av_strlcatf(buff, size, "a=rtpmap:%d H265/90000\r\n", payload_type); - if (config) - av_strlcatf(buff, size, "a=fmtp:%d %s\r\n", - payload_type, config); - break; - case AV_CODEC_ID_MPEG4: + av_strlcatf(buff, size, "a=rtpmap:%d MP4V-ES/90000\r\n" + "a=fmtp:%d profile-level-id=1%s\r\n", + payload_type, + payload_type, config ? config : ""); + break; + case AV_CODEC_ID_AAC: + if (fmt && fmt->oformat && fmt->oformat->priv_class && + av_opt_flag_is_set(fmt->priv_data, "rtpflags", "latm")) { + config = latm_context2config(fmt, p); + if (!config) + return NULL; + av_strlcatf(buff, size, "a=rtpmap:%d MP4A-LATM/%d/%d\r\n" + "a=fmtp:%d profile-level-id=%d;cpresent=0;config=%s\r\n", + payload_type, p->sample_rate, p->channels, + payload_type, latm_context2profilelevel(p), config); + } else { if (p->extradata_size) { config = extradata2config(fmt, p); - } - av_strlcatf(buff, size, "a=rtpmap:%d MP4V-ES/90000\r\n" - "a=fmtp:%d profile-level-id=1%s\r\n", - payload_type, - payload_type, config ? config : ""); - break; - case AV_CODEC_ID_AAC: - if (fmt && fmt->oformat && fmt->oformat->priv_class && - av_opt_flag_is_set(fmt->priv_data, "rtpflags", "latm")) { - config = latm_context2config(fmt, p); - if (!config) - return NULL; - av_strlcatf(buff, size, "a=rtpmap:%d MP4A-LATM/%d/%d\r\n" - "a=fmtp:%d profile-level-id=%d;cpresent=0;config=%s\r\n", - payload_type, p->sample_rate, p->channels, - payload_type, latm_context2profilelevel(p), config); } else { - if (p->extradata_size) { - config = extradata2config(fmt, p); - } else { - /* FIXME: maybe we can forge config information based on the - * codec parameters... - */ - av_log(fmt, AV_LOG_ERROR, "AAC with no global headers is currently not supported.\n"); - return NULL; - } - if (!config) { - return NULL; - } - av_strlcatf(buff, size, "a=rtpmap:%d MPEG4-GENERIC/%d/%d\r\n" - "a=fmtp:%d profile-level-id=1;" - "mode=AAC-hbr;sizelength=13;indexlength=3;" - "indexdeltalength=3%s\r\n", - payload_type, p->sample_rate, p->channels, - payload_type, config); - } - break; - case AV_CODEC_ID_PCM_S16BE: - if (payload_type >= RTP_PT_PRIVATE) - av_strlcatf(buff, size, "a=rtpmap:%d L16/%d/%d\r\n", - payload_type, - p->sample_rate, p->channels); - break; - case AV_CODEC_ID_PCM_S24BE: - if (payload_type >= RTP_PT_PRIVATE) - av_strlcatf(buff, size, "a=rtpmap:%d L24/%d/%d\r\n", - payload_type, - p->sample_rate, p->channels); - break; - case AV_CODEC_ID_PCM_MULAW: - if (payload_type >= RTP_PT_PRIVATE) - av_strlcatf(buff, size, "a=rtpmap:%d PCMU/%d/%d\r\n", - payload_type, - p->sample_rate, p->channels); - break; - case AV_CODEC_ID_PCM_ALAW: - if (payload_type >= RTP_PT_PRIVATE) - av_strlcatf(buff, size, "a=rtpmap:%d PCMA/%d/%d\r\n", - payload_type, - p->sample_rate, p->channels); - break; - case AV_CODEC_ID_AMR_NB: - av_strlcatf(buff, size, "a=rtpmap:%d AMR/%d/%d\r\n" - "a=fmtp:%d octet-align=1\r\n", - payload_type, p->sample_rate, p->channels, - payload_type); - break; - case AV_CODEC_ID_AMR_WB: - av_strlcatf(buff, size, "a=rtpmap:%d AMR-WB/%d/%d\r\n" - "a=fmtp:%d octet-align=1\r\n", - payload_type, p->sample_rate, p->channels, - payload_type); - break; - case AV_CODEC_ID_VORBIS: - if (p->extradata_size) - config = xiph_extradata2config(fmt, p); - else - av_log(fmt, AV_LOG_ERROR, "Vorbis configuration info missing\n"); - if (!config) - return NULL; - - av_strlcatf(buff, size, "a=rtpmap:%d vorbis/%d/%d\r\n" - "a=fmtp:%d configuration=%s\r\n", - payload_type, p->sample_rate, p->channels, - payload_type, config); - break; - case AV_CODEC_ID_THEORA: { - const char *pix_fmt; - switch (p->format) { - case AV_PIX_FMT_YUV420P: - pix_fmt = "YCbCr-4:2:0"; - break; - case AV_PIX_FMT_YUV422P: - pix_fmt = "YCbCr-4:2:2"; - break; - case AV_PIX_FMT_YUV444P: - pix_fmt = "YCbCr-4:4:4"; - break; - default: - av_log(fmt, AV_LOG_ERROR, "Unsupported pixel format.\n"); + /* FIXME: maybe we can forge config information based on the + * codec parameters... + */ + av_log(fmt, AV_LOG_ERROR, "AAC with no global headers is currently not supported.\n"); return NULL; } - - if (p->extradata_size) - config = xiph_extradata2config(fmt, p); - else - av_log(fmt, AV_LOG_ERROR, "Theora configuration info missing\n"); - if (!config) - return NULL; - - av_strlcatf(buff, size, "a=rtpmap:%d theora/90000\r\n" - "a=fmtp:%d delivery-method=inline; " - "width=%d; height=%d; sampling=%s; " - "configuration=%s\r\n", - payload_type, payload_type, - p->width, p->height, pix_fmt, config); - break; - } - case AV_CODEC_ID_BITPACKED: - case AV_CODEC_ID_RAWVIDEO: { - const char *pix_fmt; - int bit_depth = 8; - - switch (p->format) { - case AV_PIX_FMT_UYVY422: - pix_fmt = "YCbCr-4:2:2"; - break; - case AV_PIX_FMT_YUV422P10: - pix_fmt = "YCbCr-4:2:2"; - bit_depth = 10; - break; - case AV_PIX_FMT_YUV420P: - pix_fmt = "YCbCr-4:2:0"; - break; - case AV_PIX_FMT_RGB24: - pix_fmt = "RGB"; - break; - case AV_PIX_FMT_BGR24: - pix_fmt = "BGR"; - break; - default: - av_log(fmt, AV_LOG_ERROR, "Unsupported pixel format.\n"); + if (!config) { return NULL; } - - av_strlcatf(buff, size, "a=rtpmap:%d raw/90000\r\n" - "a=fmtp:%d sampling=%s; " - "width=%d; height=%d; " - "depth=%d\r\n", - payload_type, payload_type, - pix_fmt, p->width, p->height, bit_depth); - break; + av_strlcatf(buff, size, "a=rtpmap:%d MPEG4-GENERIC/%d/%d\r\n" + "a=fmtp:%d profile-level-id=1;" + "mode=AAC-hbr;sizelength=13;indexlength=3;" + "indexdeltalength=3%s\r\n", + payload_type, p->sample_rate, p->channels, + payload_type, config); } + break; + case AV_CODEC_ID_PCM_S16BE: + if (payload_type >= RTP_PT_PRIVATE) + av_strlcatf(buff, size, "a=rtpmap:%d L16/%d/%d\r\n", + payload_type, + p->sample_rate, p->channels); + break; + case AV_CODEC_ID_PCM_S24BE: + if (payload_type >= RTP_PT_PRIVATE) + av_strlcatf(buff, size, "a=rtpmap:%d L24/%d/%d\r\n", + payload_type, + p->sample_rate, p->channels); + break; + case AV_CODEC_ID_PCM_MULAW: + if (payload_type >= RTP_PT_PRIVATE) + av_strlcatf(buff, size, "a=rtpmap:%d PCMU/%d/%d\r\n", + payload_type, + p->sample_rate, p->channels); + break; + case AV_CODEC_ID_PCM_ALAW: + if (payload_type >= RTP_PT_PRIVATE) + av_strlcatf(buff, size, "a=rtpmap:%d PCMA/%d/%d\r\n", + payload_type, + p->sample_rate, p->channels); + break; + case AV_CODEC_ID_AMR_NB: + av_strlcatf(buff, size, "a=rtpmap:%d AMR/%d/%d\r\n" + "a=fmtp:%d octet-align=1\r\n", + payload_type, p->sample_rate, p->channels, + payload_type); + break; + case AV_CODEC_ID_AMR_WB: + av_strlcatf(buff, size, "a=rtpmap:%d AMR-WB/%d/%d\r\n" + "a=fmtp:%d octet-align=1\r\n", + payload_type, p->sample_rate, p->channels, + payload_type); + break; + case AV_CODEC_ID_VORBIS: + if (p->extradata_size) + config = xiph_extradata2config(fmt, p); + else + av_log(fmt, AV_LOG_ERROR, "Vorbis configuration info missing\n"); + if (!config) + return NULL; - case AV_CODEC_ID_VP8: - av_strlcatf(buff, size, "a=rtpmap:%d VP8/90000\r\n", - payload_type); - break; - case AV_CODEC_ID_VP9: - av_strlcatf(buff, size, "a=rtpmap:%d VP9/90000\r\n", - payload_type); - break; - case AV_CODEC_ID_MJPEG: - if (payload_type >= RTP_PT_PRIVATE) - av_strlcatf(buff, size, "a=rtpmap:%d JPEG/90000\r\n", - payload_type); + av_strlcatf(buff, size, "a=rtpmap:%d vorbis/%d/%d\r\n" + "a=fmtp:%d configuration=%s\r\n", + payload_type, p->sample_rate, p->channels, + payload_type, config); + break; + case AV_CODEC_ID_THEORA: { + const char *pix_fmt; + switch (p->format) { + case AV_PIX_FMT_YUV420P: + pix_fmt = "YCbCr-4:2:0"; break; - case AV_CODEC_ID_ADPCM_G722: - if (payload_type >= RTP_PT_PRIVATE) - av_strlcatf(buff, size, "a=rtpmap:%d G722/%d/%d\r\n", - payload_type, - 8000, p->channels); + case AV_PIX_FMT_YUV422P: + pix_fmt = "YCbCr-4:2:2"; break; - case AV_CODEC_ID_ADPCM_G726: { - if (payload_type >= RTP_PT_PRIVATE) - av_strlcatf(buff, size, "a=rtpmap:%d AAL2-G726-%d/%d\r\n", - payload_type, - p->bits_per_coded_sample*8, - p->sample_rate); + case AV_PIX_FMT_YUV444P: + pix_fmt = "YCbCr-4:4:4"; break; + default: + av_log(fmt, AV_LOG_ERROR, "Unsupported pixel format.\n"); + return NULL; } - case AV_CODEC_ID_ADPCM_G726LE: { - if (payload_type >= RTP_PT_PRIVATE) - av_strlcatf(buff, size, "a=rtpmap:%d G726-%d/%d\r\n", - payload_type, - p->bits_per_coded_sample*8, - p->sample_rate); + + if (p->extradata_size) + config = xiph_extradata2config(fmt, p); + else + av_log(fmt, AV_LOG_ERROR, "Theora configuration info missing\n"); + if (!config) + return NULL; + + av_strlcatf(buff, size, "a=rtpmap:%d theora/90000\r\n" + "a=fmtp:%d delivery-method=inline; " + "width=%d; height=%d; sampling=%s; " + "configuration=%s\r\n", + payload_type, payload_type, + p->width, p->height, pix_fmt, config); + break; + } + case AV_CODEC_ID_BITPACKED: + case AV_CODEC_ID_RAWVIDEO: { + const char *pix_fmt; + int bit_depth = 8; + + switch (p->format) { + case AV_PIX_FMT_UYVY422: + pix_fmt = "YCbCr-4:2:2"; break; - } - case AV_CODEC_ID_ILBC: - av_strlcatf(buff, size, "a=rtpmap:%d iLBC/%d\r\n" - "a=fmtp:%d mode=%d\r\n", - payload_type, p->sample_rate, - payload_type, p->block_align == 38 ? 20 : 30); + case AV_PIX_FMT_YUV422P10: + pix_fmt = "YCbCr-4:2:2"; + bit_depth = 10; break; - case AV_CODEC_ID_SPEEX: - av_strlcatf(buff, size, "a=rtpmap:%d speex/%d\r\n", - payload_type, p->sample_rate); + case AV_PIX_FMT_YUV420P: + pix_fmt = "YCbCr-4:2:0"; break; - case AV_CODEC_ID_OPUS: - /* The opus RTP draft says that all opus streams MUST be declared - as stereo, to avoid negotiation failures. The actual number of - channels can change on a packet-by-packet basis. The number of - channels a receiver prefers to receive or a sender plans to send - can be declared via fmtp parameters (both default to mono), but - receivers MUST be able to receive and process stereo packets. */ - av_strlcatf(buff, size, "a=rtpmap:%d opus/48000/2\r\n", - payload_type); - if (p->channels == 2) { - av_strlcatf(buff, size, "a=fmtp:%d sprop-stereo=1\r\n", - payload_type); - } + case AV_PIX_FMT_RGB24: + pix_fmt = "RGB"; break; - default: - /* Nothing special to do here... */ + case AV_PIX_FMT_BGR24: + pix_fmt = "BGR"; break; + default: + av_log(fmt, AV_LOG_ERROR, "Unsupported pixel format.\n"); + return NULL; + } + + av_strlcatf(buff, size, "a=rtpmap:%d raw/90000\r\n" + "a=fmtp:%d sampling=%s; " + "width=%d; height=%d; " + "depth=%d\r\n", + payload_type, payload_type, + pix_fmt, p->width, p->height, bit_depth); + break; + } + + case AV_CODEC_ID_VP8: + av_strlcatf(buff, size, "a=rtpmap:%d VP8/90000\r\n", + payload_type); + break; + case AV_CODEC_ID_VP9: + av_strlcatf(buff, size, "a=rtpmap:%d VP9/90000\r\n", + payload_type); + break; + case AV_CODEC_ID_MJPEG: + if (payload_type >= RTP_PT_PRIVATE) + av_strlcatf(buff, size, "a=rtpmap:%d JPEG/90000\r\n", + payload_type); + break; + case AV_CODEC_ID_ADPCM_G722: + if (payload_type >= RTP_PT_PRIVATE) + av_strlcatf(buff, size, "a=rtpmap:%d G722/%d/%d\r\n", + payload_type, + 8000, p->channels); + break; + case AV_CODEC_ID_ADPCM_G726: { + if (payload_type >= RTP_PT_PRIVATE) + av_strlcatf(buff, size, "a=rtpmap:%d AAL2-G726-%d/%d\r\n", + payload_type, + p->bits_per_coded_sample*8, + p->sample_rate); + break; + } + case AV_CODEC_ID_ADPCM_G726LE: { + if (payload_type >= RTP_PT_PRIVATE) + av_strlcatf(buff, size, "a=rtpmap:%d G726-%d/%d\r\n", + payload_type, + p->bits_per_coded_sample*8, + p->sample_rate); + break; + } + case AV_CODEC_ID_ILBC: + av_strlcatf(buff, size, "a=rtpmap:%d iLBC/%d\r\n" + "a=fmtp:%d mode=%d\r\n", + payload_type, p->sample_rate, + payload_type, p->block_align == 38 ? 20 : 30); + break; + case AV_CODEC_ID_SPEEX: + av_strlcatf(buff, size, "a=rtpmap:%d speex/%d\r\n", + payload_type, p->sample_rate); + break; + case AV_CODEC_ID_OPUS: + /* The opus RTP draft says that all opus streams MUST be declared + as stereo, to avoid negotiation failures. The actual number of + channels can change on a packet-by-packet basis. The number of + channels a receiver prefers to receive or a sender plans to send + can be declared via fmtp parameters (both default to mono), but + receivers MUST be able to receive and process stereo packets. */ + av_strlcatf(buff, size, "a=rtpmap:%d opus/48000/2\r\n", + payload_type); + if (p->channels == 2) { + av_strlcatf(buff, size, "a=fmtp:%d sprop-stereo=1\r\n", + payload_type); + } + break; + default: + /* Nothing special to do here... */ + break; } av_free(config);