mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
pw-cat: Add fallback for the older libavcodec channel layout API
Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
This commit is contained in:
parent
e261f2ac1c
commit
59ad6c26aa
1 changed files with 11 additions and 2 deletions
|
|
@ -1278,6 +1278,7 @@ static int setup_encodedfile(struct data *data)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int bits_per_sample;
|
int bits_per_sample;
|
||||||
|
int num_channels;
|
||||||
char path[256] = { 0 };
|
char path[256] = { 0 };
|
||||||
|
|
||||||
/* We do not support record with encoded media */
|
/* We do not support record with encoded media */
|
||||||
|
|
@ -1317,14 +1318,22 @@ static int setup_encodedfile(struct data *data)
|
||||||
printf("Number of streams: %d Codec id: %x\n", data->fmt_context->nb_streams,
|
printf("Number of streams: %d Codec id: %x\n", data->fmt_context->nb_streams,
|
||||||
data->ctx->codec_id);
|
data->ctx->codec_id);
|
||||||
|
|
||||||
|
/* FFmpeg 5.1 (which contains libavcodec 59.37.100) introduced
|
||||||
|
* a new channel layout API and deprecated the old one. */
|
||||||
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59, 37, 100)
|
||||||
|
num_channels = data->ctx->ch_layout.nb_channels;
|
||||||
|
#else
|
||||||
|
num_channels = data->ctx->channels;
|
||||||
|
#endif
|
||||||
|
|
||||||
data->rate = data->ctx->sample_rate;
|
data->rate = data->ctx->sample_rate;
|
||||||
data->channels = data->ctx->ch_layout.nb_channels;
|
data->channels = num_channels;
|
||||||
data->sfmt = data->ctx->sample_fmt;
|
data->sfmt = data->ctx->sample_fmt;
|
||||||
data->stride = 1; // Don't care
|
data->stride = 1; // Don't care
|
||||||
|
|
||||||
bits_per_sample = av_get_bits_per_sample(data->ctx->codec_id);
|
bits_per_sample = av_get_bits_per_sample(data->ctx->codec_id);
|
||||||
data->bitrate = bits_per_sample ?
|
data->bitrate = bits_per_sample ?
|
||||||
data->ctx->sample_rate * data->ctx->ch_layout.nb_channels * bits_per_sample : data->ctx->bit_rate;
|
data->ctx->sample_rate * num_channels * bits_per_sample : data->ctx->bit_rate;
|
||||||
|
|
||||||
data->spa_format = SPA_AUDIO_FORMAT_ENCODED;
|
data->spa_format = SPA_AUDIO_FORMAT_ENCODED;
|
||||||
data->fill = playback_fill_fn(data->spa_format);
|
data->fill = playback_fill_fn(data->spa_format);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue