diff options
author | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-10 20:58:15 +0100 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-10 20:59:55 +0100 |
commit | 6f69f7a8bf6a0d013985578df2ef42ee6b1c7994 (patch) | |
tree | 0c2ec8349ff1763d5f48454b8b9f26374dbd80b0 /libavdevice/pulse_audio_enc.c | |
parent | 60b75186b2c878b6257b43c8fcc0b1356ada218e (diff) | |
parent | 9200514ad8717c63f82101dc394f4378854325bf (diff) | |
download | ffmpeg-6f69f7a8bf6a0d013985578df2ef42ee6b1c7994.tar.gz |
Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf':
lavf: replace AVStream.codec with AVStream.codecpar
This has been a HUGE effort from:
- Derek Buitenhuis <derek.buitenhuis@gmail.com>
- Hendrik Leppkes <h.leppkes@gmail.com>
- wm4 <nfxjfg@googlemail.com>
- Clément Bœsch <clement@stupeflix.com>
- James Almer <jamrial@gmail.com>
- Michael Niedermayer <michael@niedermayer.cc>
- Rostislav Pehlivanov <atomnuker@gmail.com>
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavdevice/pulse_audio_enc.c')
-rw-r--r-- | libavdevice/pulse_audio_enc.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/libavdevice/pulse_audio_enc.c b/libavdevice/pulse_audio_enc.c index b419a38d46..6fb634ee2b 100644 --- a/libavdevice/pulse_audio_enc.c +++ b/libavdevice/pulse_audio_enc.c @@ -452,7 +452,7 @@ static av_cold int pulse_write_header(AVFormatContext *h) PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_NOT_MONOTONIC; - if (h->nb_streams != 1 || h->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO) { + if (h->nb_streams != 1 || h->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) { av_log(s, AV_LOG_ERROR, "Only a single audio stream is supported.\n"); return AVERROR(EINVAL); } @@ -468,8 +468,8 @@ static av_cold int pulse_write_header(AVFormatContext *h) if (s->buffer_duration) { int64_t bytes = s->buffer_duration; - bytes *= st->codec->channels * st->codec->sample_rate * - av_get_bytes_per_sample(st->codec->sample_fmt); + bytes *= st->codecpar->channels * st->codecpar->sample_rate * + av_get_bytes_per_sample(st->codecpar->format); bytes /= 1000; buffer_attributes.tlength = FFMAX(s->buffer_size, av_clip64(bytes, 0, UINT32_MAX - 1)); av_log(s, AV_LOG_DEBUG, @@ -483,9 +483,9 @@ static av_cold int pulse_write_header(AVFormatContext *h) if (s->minreq) buffer_attributes.minreq = s->minreq; - sample_spec.format = ff_codec_id_to_pulse_format(st->codec->codec_id); - sample_spec.rate = st->codec->sample_rate; - sample_spec.channels = st->codec->channels; + sample_spec.format = ff_codec_id_to_pulse_format(st->codecpar->codec_id); + sample_spec.rate = st->codecpar->sample_rate; + sample_spec.channels = st->codecpar->channels; if (!pa_sample_spec_valid(&sample_spec)) { av_log(s, AV_LOG_ERROR, "Invalid sample spec.\n"); return AVERROR(EINVAL); @@ -494,10 +494,10 @@ static av_cold int pulse_write_header(AVFormatContext *h) if (sample_spec.channels == 1) { channel_map.channels = 1; channel_map.map[0] = PA_CHANNEL_POSITION_MONO; - } else if (st->codec->channel_layout) { - if (av_get_channel_layout_nb_channels(st->codec->channel_layout) != st->codec->channels) + } else if (st->codecpar->channel_layout) { + if (av_get_channel_layout_nb_channels(st->codecpar->channel_layout) != st->codecpar->channels) return AVERROR(EINVAL); - pulse_map_channels_to_pulse(st->codec->channel_layout, &channel_map); + pulse_map_channels_to_pulse(st->codecpar->channel_layout, &channel_map); /* Unknown channel is present in channel_layout, let PulseAudio use its default. */ if (channel_map.channels != sample_spec.channels) { av_log(s, AV_LOG_WARNING, "Unknown channel. Using defaul channel map.\n"); @@ -637,9 +637,8 @@ static int pulse_write_packet(AVFormatContext *h, AVPacket *pkt) s->timestamp += pkt->duration; } else { AVStream *st = h->streams[0]; - AVCodecContext *codec_ctx = st->codec; - AVRational r = { 1, codec_ctx->sample_rate }; - int64_t samples = pkt->size / (av_get_bytes_per_sample(codec_ctx->sample_fmt) * codec_ctx->channels); + AVRational r = { 1, st->codecpar->sample_rate }; + int64_t samples = pkt->size / (av_get_bytes_per_sample(st->codecpar->format) * st->codecpar->channels); s->timestamp += av_rescale_q(samples, r, st->time_base); } @@ -678,7 +677,7 @@ static int pulse_write_frame(AVFormatContext *h, int stream_index, /* Planar formats are not supported yet. */ if (flags & AV_WRITE_UNCODED_FRAME_QUERY) - return av_sample_fmt_is_planar(h->streams[stream_index]->codec->sample_fmt) ? + return av_sample_fmt_is_planar(h->streams[stream_index]->codecpar->format) ? AVERROR(EINVAL) : 0; pkt.data = (*frame)->data[0]; |