[FFmpeg-devel] [PATCH 2/4] lavd/pulse_audio_dec: add audio_device option
Paul B Mahol
onemda at gmail.com
Fri Oct 11 10:34:47 CEST 2013
On 10/10/13, Lukasz Marek <lukasz.m.luki at gmail.com> wrote:
> Device can be selected by passing AVOption as well.
>
> Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
> ---
> doc/indevs.texi | 11 +++++------
> libavdevice/pulse_audio_dec.c | 10 ++++++++--
> 2 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/doc/indevs.texi b/doc/indevs.texi
> index 6bcb237..b7981c6 100644
> --- a/doc/indevs.texi
> +++ b/doc/indevs.texi
> @@ -489,12 +489,6 @@ PulseAudio input device.
>
> To enable this output device you need to configure FFmpeg with
> @code{--enable-libpulse}.
>
> -The filename to provide to the input device is a source device or the
> -string "default"
> -
> -To list the PulseAudio source devices and their properties you can invoke
> -the command @command{pactl list sources}.
> -
> @subsection Options
> @table @option
> @item server
> @@ -508,6 +502,11 @@ by default it is the @code{LIBAVFORMAT_IDENT} string.
> Specify the stream name PulseAudio will use when showing active streams,
> by default it is "record".
>
> + at item audio_device
> +Specify the device to use. The specified input name is used as default.
> +String "default" can be used to specify default device.
> +List of input devices can be obtained with command @command{pactl list
> sources}.
> +
This is breaking backward compatibility.
Seriously I do not like such changes, next thing on such list are
useless cosmetics changes.
> @item sample_rate
> Specify the samplerate in Hz, by default 48kHz is used.
>
> diff --git a/libavdevice/pulse_audio_dec.c b/libavdevice/pulse_audio_dec.c
> index 21b3caa..aa0c995 100644
> --- a/libavdevice/pulse_audio_dec.c
> +++ b/libavdevice/pulse_audio_dec.c
> @@ -40,6 +40,7 @@ typedef struct PulseData {
> char *server;
> char *name;
> char *stream_name;
> + const char *device;
> int sample_rate;
> int channels;
> int frame_size;
> @@ -53,7 +54,7 @@ static av_cold int pulse_read_header(AVFormatContext *s)
> {
> PulseData *pd = s->priv_data;
> AVStream *st;
> - char *device = NULL;
> + const char *device = NULL;
> int ret;
> enum AVCodecID codec_id =
> s->audio_codec_id == AV_CODEC_ID_NONE ? DEFAULT_CODEC_ID :
> s->audio_codec_id;
> @@ -72,8 +73,12 @@ static av_cold int pulse_read_header(AVFormatContext *s)
>
> attr.fragsize = pd->fragment_size;
>
> - if (strcmp(s->filename, "default"))
> + if (pd->device)
> + device = pd->device;
> + else
> device = s->filename;
> + if (device && !strcmp(device, "default"))
> + device = NULL; /* Set default device */
>
> pd->s = pa_simple_new(pd->server, pd->name,
> PA_STREAM_RECORD,
> @@ -147,6 +152,7 @@ static const AVOption options[] = {
> { "server", "pulse server name",
> OFFSET(server), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, D },
> { "name", "application name",
> OFFSET(name), AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0,
> 0, D },
> { "stream_name", "stream description",
> OFFSET(stream_name), AV_OPT_TYPE_STRING, {.str = "record"}, 0, 0, D },
> + { "audio_device", "set device name",
> OFFSET(device), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, D },
> { "sample_rate", "sample rate in Hz",
> OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = 48000}, 1, INT_MAX, D
> },
> { "channels", "number of audio channels",
> OFFSET(channels), AV_OPT_TYPE_INT, {.i64 = 2}, 1, INT_MAX, D
> },
> { "frame_size", "number of bytes per frame",
> OFFSET(frame_size), AV_OPT_TYPE_INT, {.i64 = 1024}, 1, INT_MAX, D
> },
> --
> 1.7.10.4
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
More information about the ffmpeg-devel
mailing list