diff mbox series

[FFmpeg-devel,138/281] sdp: convert to new channel layout API

Message ID 20220113015806.519-20-jamrial@gmail.com
State Accepted
Commit ca36f0ece801801862888d7bcad8e6ac43713d37
Headers show
Series New channel layout API | expand

Commit Message

James Almer Jan. 13, 2022, 1:57 a.m. UTC
From: Vittorio Giovara <vittorio.giovara@gmail.com>

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/sdp.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index d63a0b34c4..0802b99af7 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -450,16 +450,16 @@  static int latm_context2profilelevel(const AVCodecParameters *par)
      * Different Object Types should implement different Profile Levels */
 
     if (par->sample_rate <= 24000) {
-        if (par->channels <= 2)
+        if (par->ch_layout.nb_channels <= 2)
             profile_level = 0x28; // AAC Profile, Level 1
     } else if (par->sample_rate <= 48000) {
-        if (par->channels <= 2) {
+        if (par->ch_layout.nb_channels <= 2) {
             profile_level = 0x29; // AAC Profile, Level 2
-        } else if (par->channels <= 5) {
+        } else if (par->ch_layout.nb_channels <= 5) {
             profile_level = 0x2A; // AAC Profile, Level 4
         }
     } else if (par->sample_rate <= 96000) {
-        if (par->channels <= 5) {
+        if (par->ch_layout.nb_channels <= 5) {
             profile_level = 0x2B; // AAC Profile, Level 5
         }
     }
@@ -491,7 +491,7 @@  static int latm_context2config(AVFormatContext *s, const AVCodecParameters *par,
     config_byte[0] = 0x40;
     config_byte[1] = 0;
     config_byte[2] = 0x20 | rate_index;
-    config_byte[3] = par->channels << 4;
+    config_byte[3] = par->ch_layout.nb_channels << 4;
     config_byte[4] = 0x3f;
     config_byte[5] = 0xc0;
 
@@ -591,7 +591,7 @@  static int sdp_write_media_attributes(char *buff, int size, const AVStream *st,
                 return ret;
             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, p->sample_rate, p->ch_layout.nb_channels,
                                      payload_type, latm_context2profilelevel(p), config);
         } else {
             if (p->extradata_size) {
@@ -609,7 +609,7 @@  static int sdp_write_media_attributes(char *buff, int size, const AVStream *st,
                                     "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, p->sample_rate, p->ch_layout.nb_channels,
                                      payload_type, config);
         }
         break;
@@ -617,36 +617,36 @@  static int sdp_write_media_attributes(char *buff, int size, const AVStream *st,
         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);
+                                     p->sample_rate, p->ch_layout.nb_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);
+                                     p->sample_rate, p->ch_layout.nb_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);
+                                     p->sample_rate, p->ch_layout.nb_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);
+                                     p->sample_rate, p->ch_layout.nb_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, p->sample_rate, p->ch_layout.nb_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, p->sample_rate, p->ch_layout.nb_channels,
                                  payload_type);
         break;
     case AV_CODEC_ID_VORBIS:
@@ -661,7 +661,7 @@  static int sdp_write_media_attributes(char *buff, int size, const AVStream *st,
 
         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, p->sample_rate, p->ch_layout.nb_channels,
                                 payload_type, config);
         break;
     case AV_CODEC_ID_THEORA: {
@@ -754,7 +754,7 @@  static int sdp_write_media_attributes(char *buff, int size, const AVStream *st,
         if (payload_type >= RTP_PT_PRIVATE)
             av_strlcatf(buff, size, "a=rtpmap:%d G722/%d/%d\r\n",
                                      payload_type,
-                                     8000, p->channels);
+                                     8000, p->ch_layout.nb_channels);
         break;
     case AV_CODEC_ID_ADPCM_G726: {
         if (payload_type >= RTP_PT_PRIVATE)
@@ -791,7 +791,7 @@  static int sdp_write_media_attributes(char *buff, int size, const AVStream *st,
            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) {
+        if (p->ch_layout.nb_channels == 2) {
             av_strlcatf(buff, size, "a=fmtp:%d sprop-stereo=1\r\n",
                                      payload_type);
         }