FFmpeg
Loading...
Searching...
No Matches
alsa_dec.c File Reference

ALSA input and output: input. More...

#include <alsa/asoundlib.h>
#include "libavutil/internal.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/time.h"
#include "libavformat/demux.h"
#include "libavformat/internal.h"
#include "avdevice.h"
#include "alsa.h"

Go to the source code of this file.

Functions

static av_cold int audio_read_header (AVFormatContext *s1)
 
static int audio_read_packet (AVFormatContext *s1, AVPacket *pkt)
 
static int audio_get_device_list (AVFormatContext *h, AVDeviceInfoList *device_list)
 

Variables

static const AVOption options []
 
static const AVClass alsa_demuxer_class
 
const FFInputFormat ff_alsa_demuxer
 

Detailed Description

ALSA input and output: input.

Author
Luca Abeni ( lucabe72 email it )
Benoit Fouet ( benoit fouet free fr )
Nicolas George ( nicolas george normalesup org )

This avdevice decoder can capture audio from an ALSA (Advanced Linux Sound Architecture) device.

The filename parameter is the name of an ALSA PCM device capable of capture, for example "default" or "plughw:1"; see the ALSA documentation for naming conventions. The empty string is equivalent to "default".

The capture period is set to the lower value available for the device, which gives a low latency suitable for real-time capture.

The PTS are an Unix time in microsecond.

Due to a bug in the ALSA library (https://bugtrack.alsa-project.org/alsa-bug/view.php?id=4308), this decoder does not work with certain ALSA plugins, especially the dsnoop plugin.

Definition in file alsa_dec.c.

Function Documentation

◆ audio_read_header()

static av_cold int audio_read_header ( AVFormatContext * s1)
static

Definition at line 61 of file alsa_dec.c.

◆ audio_read_packet()

static int audio_read_packet ( AVFormatContext * s1,
AVPacket * pkt )
static

Definition at line 106 of file alsa_dec.c.

◆ audio_get_device_list()

static int audio_get_device_list ( AVFormatContext * h,
AVDeviceInfoList * device_list )
static

Definition at line 146 of file alsa_dec.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "sample_rate", "", 0x42 , AV_OPT_TYPE_INT, {.i64 = 48000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
{ "ch_layout", "", 0x42 , AV_OPT_TYPE_CHLAYOUT, {.str = NULL}, INT_MIN, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
{ NULL },
}
#define NULL
Definition coverity.c:32
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
Definition opt.h:355
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
Definition opt.h:330

Definition at line 151 of file alsa_dec.c.

◆ alsa_demuxer_class

const AVClass alsa_demuxer_class
static
Initial value:
= {
.class_name = "ALSA indev",
.item_name = av_default_item_name,
.option = options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
@ AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT
Definition log.h:44

Definition at line 157 of file alsa_dec.c.

◆ ff_alsa_demuxer

const FFInputFormat ff_alsa_demuxer
Initial value:
= {
.p.name = "alsa",
.p.long_name = NULL_IF_CONFIG_SMALL("ALSA audio input"),
.p.flags = AVFMT_NOFILE,
.p.priv_class = &alsa_demuxer_class,
.priv_data_size = sizeof(AlsaData),
.get_device_list = audio_get_device_list,
}
av_cold int ff_alsa_close(AVFormatContext *s1)
Close the ALSA PCM.
Definition alsa.c:421
static av_cold int audio_read_header(AVFormatContext *s1)
Definition alsa_dec.c:61
static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
Definition alsa_dec.c:106
static const AVClass alsa_demuxer_class
Definition alsa_dec.c:157
static int audio_get_device_list(AVFormatContext *h, AVDeviceInfoList *device_list)
Definition alsa_dec.c:146
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition avformat.h:488
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:578
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static av_cold int read_close(AVFormatContext *ctx)
Definition libcdio.c:143

Definition at line 165 of file alsa_dec.c.