summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavformat/rtp.c11
-rw-r--r--libavformat/rtpdec.c4
-rw-r--r--libavformat/rtpdec_amr.c4
-rw-r--r--libavformat/rtpenc.c14
-rw-r--r--libavformat/rtsp.c6
-rw-r--r--libavformat/rtsp.h1
6 files changed, 21 insertions, 19 deletions
diff --git a/libavformat/rtp.c b/libavformat/rtp.c
index c536a6f082..564489b613 100644
--- a/libavformat/rtp.c
+++ b/libavformat/rtp.c
@@ -77,8 +77,11 @@ int ff_rtp_get_codec_info(AVCodecParameters *par, int payload_type)
if (rtp_payload_types[i].codec_id != AV_CODEC_ID_NONE) {
par->codec_type = rtp_payload_types[i].codec_type;
par->codec_id = rtp_payload_types[i].codec_id;
- if (rtp_payload_types[i].audio_channels > 0)
- par->channels = rtp_payload_types[i].audio_channels;
+ if (rtp_payload_types[i].audio_channels > 0) {
+ av_channel_layout_uninit(&par->ch_layout);
+ par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
+ par->ch_layout.nb_channels = rtp_payload_types[i].audio_channels;
+ }
if (rtp_payload_types[i].clock_rate > 0)
par->sample_rate = rtp_payload_types[i].clock_rate;
return 0;
@@ -111,13 +114,13 @@ int ff_rtp_get_payload_type(const AVFormatContext *fmt,
/* G722 has 8000 as nominal rate even if the sample rate is 16000,
* see section 4.5.2 in RFC 3551. */
if (par->codec_id == AV_CODEC_ID_ADPCM_G722 &&
- par->sample_rate == 16000 && par->channels == 1)
+ par->sample_rate == 16000 && par->ch_layout.nb_channels == 1)
return rtp_payload_types[i].pt;
if (par->codec_type == AVMEDIA_TYPE_AUDIO &&
((rtp_payload_types[i].clock_rate > 0 &&
par->sample_rate != rtp_payload_types[i].clock_rate) ||
(rtp_payload_types[i].audio_channels > 0 &&
- par->channels != rtp_payload_types[i].audio_channels)))
+ par->ch_layout.nb_channels != rtp_payload_types[i].audio_channels)))
continue;
return rtp_payload_types[i].pt;
}
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index f285a41cf4..fa7544cc07 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -538,7 +538,7 @@ static int opus_write_extradata(AVCodecParameters *codecpar)
* This mapping family only supports mono and stereo layouts. And RFC7587
* specifies that the number of channels in the SDP must be 2.
*/
- if (codecpar->channels > 2) {
+ if (codecpar->ch_layout.nb_channels > 2) {
return AVERROR_INVALIDDATA;
}
@@ -553,7 +553,7 @@ static int opus_write_extradata(AVCodecParameters *codecpar)
/* Version */
bytestream_put_byte (&bs, 0x1);
/* Channel count */
- bytestream_put_byte (&bs, codecpar->channels);
+ bytestream_put_byte (&bs, codecpar->ch_layout.nb_channels);
/* Pre skip */
bytestream_put_le16 (&bs, 0);
/* Input sample rate */
diff --git a/libavformat/rtpdec_amr.c b/libavformat/rtpdec_amr.c
index 988b7bddfd..ca4f0ff03a 100644
--- a/libavformat/rtpdec_amr.c
+++ b/libavformat/rtpdec_amr.c
@@ -64,11 +64,11 @@ static int amr_handle_packet(AVFormatContext *ctx, PayloadContext *data,
return AVERROR_INVALIDDATA;
}
- if (st->codecpar->channels != 1) {
+ if (st->codecpar->ch_layout.nb_channels != 1) {
av_log(ctx, AV_LOG_ERROR, "Only mono AMR is supported\n");
return AVERROR_INVALIDDATA;
}
- st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+ av_channel_layout_default(&st->codecpar->ch_layout, 1);
/* The AMR RTP packet consists of one header byte, followed
* by one TOC byte for each AMR frame in the packet, followed
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 6be67b5885..ce629a8095 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -236,7 +236,7 @@ static int rtp_write_header(AVFormatContext *s1)
avpriv_set_pts_info(st, 32, 1, 8000);
break;
case AV_CODEC_ID_OPUS:
- if (st->codecpar->channels > 2) {
+ if (st->codecpar->ch_layout.nb_channels > 2) {
av_log(s1, AV_LOG_ERROR, "Multistream opus not supported in RTP\n");
goto fail;
}
@@ -264,7 +264,7 @@ static int rtp_write_header(AVFormatContext *s1)
av_log(s1, AV_LOG_ERROR, "RTP max payload size too small for AMR\n");
goto fail;
}
- if (st->codecpar->channels != 1) {
+ if (st->codecpar->ch_layout.nb_channels != 1) {
av_log(s1, AV_LOG_ERROR, "Only mono is supported\n");
goto fail;
}
@@ -541,24 +541,24 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
case AV_CODEC_ID_PCM_ALAW:
case AV_CODEC_ID_PCM_U8:
case AV_CODEC_ID_PCM_S8:
- return rtp_send_samples(s1, pkt->data, size, 8 * st->codecpar->channels);
+ return rtp_send_samples(s1, pkt->data, size, 8 * st->codecpar->ch_layout.nb_channels);
case AV_CODEC_ID_PCM_U16BE:
case AV_CODEC_ID_PCM_U16LE:
case AV_CODEC_ID_PCM_S16BE:
case AV_CODEC_ID_PCM_S16LE:
- return rtp_send_samples(s1, pkt->data, size, 16 * st->codecpar->channels);
+ return rtp_send_samples(s1, pkt->data, size, 16 * st->codecpar->ch_layout.nb_channels);
case AV_CODEC_ID_PCM_S24BE:
- return rtp_send_samples(s1, pkt->data, size, 24 * st->codecpar->channels);
+ return rtp_send_samples(s1, pkt->data, size, 24 * st->codecpar->ch_layout.nb_channels);
case AV_CODEC_ID_ADPCM_G722:
/* The actual sample size is half a byte per sample, but since the
* stream clock rate is 8000 Hz while the sample rate is 16000 Hz,
* the correct parameter for send_samples_bits is 8 bits per stream
* clock. */
- return rtp_send_samples(s1, pkt->data, size, 8 * st->codecpar->channels);
+ return rtp_send_samples(s1, pkt->data, size, 8 * st->codecpar->ch_layout.nb_channels);
case AV_CODEC_ID_ADPCM_G726:
case AV_CODEC_ID_ADPCM_G726LE:
return rtp_send_samples(s1, pkt->data, size,
- st->codecpar->bits_per_coded_sample * st->codecpar->channels);
+ st->codecpar->bits_per_coded_sample * st->codecpar->ch_layout.nb_channels);
case AV_CODEC_ID_MP2:
case AV_CODEC_ID_MP3:
rtp_send_mpegaudio(s1, pkt->data, size);
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 70c18941ca..5fa756bf5c 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -323,19 +323,19 @@ static int sdp_parse_rtpmap(AVFormatContext *s,
case AVMEDIA_TYPE_AUDIO:
av_log(s, AV_LOG_DEBUG, "audio codec set to: %s\n", c_name);
par->sample_rate = RTSP_DEFAULT_AUDIO_SAMPLERATE;
- par->channels = RTSP_DEFAULT_NB_AUDIO_CHANNELS;
+ par->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
if (i > 0) {
par->sample_rate = i;
avpriv_set_pts_info(st, 32, 1, par->sample_rate);
get_word_sep(buf, sizeof(buf), "/", &p);
i = atoi(buf);
if (i > 0)
- par->channels = i;
+ av_channel_layout_default(&par->ch_layout, i);
}
av_log(s, AV_LOG_DEBUG, "audio samplerate set to: %i\n",
par->sample_rate);
av_log(s, AV_LOG_DEBUG, "audio channels set to: %i\n",
- par->channels);
+ par->ch_layout.nb_channels);
break;
case AVMEDIA_TYPE_VIDEO:
av_log(s, AV_LOG_DEBUG, "video codec set to: %s\n", c_name);
diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
index 8b64e29d70..3133bf61c1 100644
--- a/libavformat/rtsp.h
+++ b/libavformat/rtsp.h
@@ -75,7 +75,6 @@ enum RTSPControlTransport {
#define RTSPS_DEFAULT_PORT 322
#define RTSP_MAX_TRANSPORTS 8
#define RTSP_TCP_MAX_PACKET_SIZE 1472
-#define RTSP_DEFAULT_NB_AUDIO_CHANNELS 1
#define RTSP_DEFAULT_AUDIO_SAMPLERATE 44100
#define RTSP_RTP_PORT_MIN 5000
#define RTSP_RTP_PORT_MAX 65000