28 #include <pulse/simple.h>
29 #include <pulse/rtclock.h>
30 #include <pulse/error.h>
36 #define DEFAULT_CODEC_ID AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE)
65 default:
return PA_SAMPLE_INVALID;
82 pa_buffer_attr attr = { -1 };
130 if ((pa_simple_read(pd->
s, pkt->
data, pkt->
size, &res)) < 0) {
137 if ((latency = pa_simple_get_latency(pd->
s, &res)) == (pa_usec_t) -1) {
157 pa_simple_free(pd->
s);
161 #define OFFSET(a) offsetof(PulseData, a)
162 #define D AV_OPT_FLAG_DECODING_PARAM
168 {
"sample_rate",
"sample rate in Hz",
OFFSET(sample_rate),
AV_OPT_TYPE_INT, {.dbl = 48000}, 1, INT_MAX,
D },
170 {
"frame_size",
"number of bytes per frame",
OFFSET(frame_size),
AV_OPT_TYPE_INT, {.dbl = 1024}, 1, INT_MAX,
D },
171 {
"fragment_size",
"buffering size, affects latency and cpu usage",
OFFSET(fragment_size),
AV_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX,
D },
190 .priv_class = &pulse_demuxer_class,
static av_cold int pulse_read_header(AVFormatContext *s, AVFormatParameters *ap)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
static av_cold int pulse_close(AVFormatContext *s)
static pa_sample_format_t codec_id_to_pulse_format(int codec_id)
static const AVOption options[]
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static int read_header(FFV1Context *f)
void av_free_packet(AVPacket *pkt)
Free a packet.
static av_cold int read_close(AVFormatContext *ctx)
int av_get_bits_per_sample(enum CodecID codec_id)
Return codec bits per sample.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
AVCodecContext * codec
codec context
char filename[1024]
input or output filename
static int pulse_read_packet(AVFormatContext *s, AVPacket *pkt)
enum CodecID audio_codec_id
Forced audio codec_id.
enum AVMediaType codec_type
int sample_rate
samples per second
struct PulseData PulseData
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
AVInputFormat ff_pulse_demuxer
Describe the class of an AVClass context structure.
static const AVClass pulse_demuxer_class
CodecID
Identify the syntax and semantics of the bitstream.
int channels
number of audio channels
void * priv_data
Format private data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.