@@ -629,10 +629,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
} else if (!strcmp(key, "audiosamplesize") && apar) {
apar->bits_per_coded_sample = num_val;
} else if (!strcmp(key, "stereo") && apar) {
- apar->channels = num_val + 1;
- apar->channel_layout = apar->channels == 2 ?
- AV_CH_LAYOUT_STEREO :
- AV_CH_LAYOUT_MONO;
+ av_channel_layout_default(&apar->ch_layout, num_val + 1);
} else if (!strcmp(key, "width") && vpar) {
vpar->width = num_val;
} else if (!strcmp(key, "height") && vpar) {
@@ -1202,12 +1199,10 @@ retry_duration:
sample_rate = 44100 << ((flags & FLV_AUDIO_SAMPLERATE_MASK) >>
FLV_AUDIO_SAMPLERATE_OFFSET) >> 3;
bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
- if (!st->codecpar->channels || !st->codecpar->sample_rate ||
+ if (!av_channel_layout_check(&st->codecpar->ch_layout) ||
+ !st->codecpar->sample_rate ||
!st->codecpar->bits_per_coded_sample) {
- st->codecpar->channels = channels;
- st->codecpar->channel_layout = channels == 1
- ? AV_CH_LAYOUT_MONO
- : AV_CH_LAYOUT_STEREO;
+ av_channel_layout_default(&st->codecpar->ch_layout, channels);
st->codecpar->sample_rate = sample_rate;
st->codecpar->bits_per_coded_sample = bits_per_coded_sample;
}
@@ -1217,7 +1212,7 @@ retry_duration:
flv->last_sample_rate =
sample_rate = st->codecpar->sample_rate;
flv->last_channels =
- channels = st->codecpar->channels;
+ channels = st->codecpar->ch_layout.nb_channels;
} else {
AVCodecParameters *par = avcodec_parameters_alloc();
if (!par) {
@@ -138,7 +138,7 @@ static int get_audio_flags(AVFormatContext *s, AVCodecParameters *par)
"FLV only supports wideband (16kHz) Speex audio\n");
return AVERROR(EINVAL);
}
- if (par->channels != 1) {
+ if (par->ch_layout.nb_channels != 1) {
av_log(s, AV_LOG_ERROR, "FLV only supports mono Speex audio\n");
return AVERROR(EINVAL);
}
@@ -178,7 +178,7 @@ error:
}
}
- if (par->channels > 1)
+ if (par->ch_layout.nb_channels > 1)
flags |= FLV_STEREO;
switch (par->codec_id) {
@@ -342,7 +342,7 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
put_amf_double(pb, flv->audio_par->codec_id == AV_CODEC_ID_PCM_U8 ? 8 : 16);
put_amf_string(pb, "stereo");
- put_amf_bool(pb, flv->audio_par->channels == 2);
+ put_amf_bool(pb, flv->audio_par->ch_layout.nb_channels == 2);
put_amf_string(pb, "audiocodecid");
put_amf_double(pb, flv->audio_par->codec_tag);
@@ -507,8 +507,8 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i
if (!par->extradata_size && (flv->flags & FLV_AAC_SEQ_HEADER_DETECT)) {
PutBitContext pbc;
int samplerate_index;
- int channels = flv->audio_par->channels
- - (flv->audio_par->channels == 8 ? 1 : 0);
+ int channels = flv->audio_par->ch_layout.nb_channels
+ - (flv->audio_par->ch_layout.nb_channels == 8 ? 1 : 0);
uint8_t data[2];
for (samplerate_index = 0; samplerate_index < 16;