FFmpeg
Data Structures | Macros | Functions | Variables
pulse_audio_enc.c File Reference
#include <math.h>
#include <pulse/pulseaudio.h>
#include <pulse/error.h>
#include "libavformat/avformat.h"
#include "libavformat/internal.h"
#include "libavformat/mux.h"
#include "libavformat/version.h"
#include "libavutil/channel_layout.h"
#include "libavutil/frame.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/time.h"
#include "libavutil/log.h"
#include "libavutil/attributes.h"
#include "pulse_audio_common.h"

Go to the source code of this file.

Data Structures

struct  PulseData
 

Macros

#define OFFSET(a)   offsetof(PulseData, a)
 
#define E   AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static void pulse_audio_sink_device_cb (pa_context *ctx, const pa_sink_info *dev, int eol, void *userdata)
 
static int pulse_update_sink_info (AVFormatContext *h)
 
static void pulse_audio_sink_input_cb (pa_context *ctx, const pa_sink_input_info *i, int eol, void *userdata)
 
static int pulse_update_sink_input_info (AVFormatContext *h)
 
static void pulse_event (pa_context *ctx, pa_subscription_event_type_t t, uint32_t idx, void *userdata)
 
static void pulse_stream_writable (pa_stream *stream, size_t nbytes, void *userdata)
 
static void pulse_overflow (pa_stream *stream, void *userdata)
 
static void pulse_underflow (pa_stream *stream, void *userdata)
 
static void pulse_stream_state (pa_stream *stream, void *userdata)
 
static int pulse_stream_wait (PulseData *s)
 
static void pulse_context_state (pa_context *ctx, void *userdata)
 
static int pulse_context_wait (PulseData *s)
 
static void pulse_stream_result (pa_stream *stream, int success, void *userdata)
 
static int pulse_finish_stream_operation (PulseData *s, pa_operation *op, const char *name)
 
static int pulse_set_pause (PulseData *s, int pause)
 
static int pulse_flash_stream (PulseData *s)
 
static void pulse_context_result (pa_context *ctx, int success, void *userdata)
 
static int pulse_finish_context_operation (PulseData *s, pa_operation *op, const char *name)
 
static int pulse_set_mute (PulseData *s)
 
static int pulse_set_volume (PulseData *s, double volume)
 
static int pulse_subscribe_events (PulseData *s)
 
static void pulse_map_channels_to_pulse (const AVChannelLayout *channel_layout, pa_channel_map *channel_map)
 
static av_cold int pulse_write_trailer (AVFormatContext *h)
 
static av_cold int pulse_write_header (AVFormatContext *h)
 
static int pulse_write_packet (AVFormatContext *h, AVPacket *pkt)
 
static int pulse_write_frame (AVFormatContext *h, int stream_index, AVFrame **frame, unsigned flags)
 
static void pulse_get_output_timestamp (AVFormatContext *h, int stream, int64_t *dts, int64_t *wall)
 
static int pulse_get_device_list (AVFormatContext *h, AVDeviceInfoList *device_list)
 
static int pulse_control_message (AVFormatContext *h, int type, void *data, size_t data_size)
 

Variables

static const AVOption options []
 
static const AVClass pulse_muxer_class
 
const FFOutputFormat ff_pulse_muxer
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   a)    offsetof(PulseData, a)

Definition at line 764 of file pulse_audio_enc.c.

◆ E

Definition at line 765 of file pulse_audio_enc.c.

Function Documentation

◆ pulse_audio_sink_device_cb()

static void pulse_audio_sink_device_cb ( pa_context *  ctx,
const pa_sink_info *  dev,
int  eol,
void *  userdata 
)
static

Definition at line 58 of file pulse_audio_enc.c.

Referenced by pulse_update_sink_info().

◆ pulse_update_sink_info()

static int pulse_update_sink_info ( AVFormatContext h)
static

Definition at line 78 of file pulse_audio_enc.c.

Referenced by pulse_write_header().

◆ pulse_audio_sink_input_cb()

static void pulse_audio_sink_input_cb ( pa_context *  ctx,
const pa_sink_input_info *  i,
int  eol,
void *  userdata 
)
static

Definition at line 93 of file pulse_audio_enc.c.

Referenced by pulse_update_sink_input_info().

◆ pulse_update_sink_input_info()

static int pulse_update_sink_input_info ( AVFormatContext h)
static

Definition at line 121 of file pulse_audio_enc.c.

Referenced by pulse_control_message(), pulse_event(), and pulse_write_header().

◆ pulse_event()

static void pulse_event ( pa_context *  ctx,
pa_subscription_event_type_t  t,
uint32_t  idx,
void *  userdata 
)
static

Definition at line 154 of file pulse_audio_enc.c.

Referenced by pulse_write_header().

◆ pulse_stream_writable()

static void pulse_stream_writable ( pa_stream *  stream,
size_t  nbytes,
void *  userdata 
)
static

Definition at line 170 of file pulse_audio_enc.c.

Referenced by pulse_write_header().

◆ pulse_overflow()

static void pulse_overflow ( pa_stream *  stream,
void *  userdata 
)
static

Definition at line 183 of file pulse_audio_enc.c.

Referenced by pulse_write_header().

◆ pulse_underflow()

static void pulse_underflow ( pa_stream *  stream,
void *  userdata 
)
static

Definition at line 189 of file pulse_audio_enc.c.

Referenced by pulse_write_header().

◆ pulse_stream_state()

static void pulse_stream_state ( pa_stream *  stream,
void *  userdata 
)
static

Definition at line 195 of file pulse_audio_enc.c.

Referenced by pulse_write_header().

◆ pulse_stream_wait()

static int pulse_stream_wait ( PulseData s)
static

Definition at line 212 of file pulse_audio_enc.c.

Referenced by pulse_write_header().

◆ pulse_context_state()

static void pulse_context_state ( pa_context *  ctx,
void *  userdata 
)
static

Definition at line 224 of file pulse_audio_enc.c.

Referenced by pulse_write_header().

◆ pulse_context_wait()

static int pulse_context_wait ( PulseData s)
static

Definition at line 241 of file pulse_audio_enc.c.

Referenced by pulse_write_header().

◆ pulse_stream_result()

static void pulse_stream_result ( pa_stream *  stream,
int  success,
void *  userdata 
)
static

Definition at line 253 of file pulse_audio_enc.c.

Referenced by pulse_flash_stream(), and pulse_set_pause().

◆ pulse_finish_stream_operation()

static int pulse_finish_stream_operation ( PulseData s,
pa_operation *  op,
const char *  name 
)
static

Definition at line 264 of file pulse_audio_enc.c.

Referenced by pulse_flash_stream(), and pulse_set_pause().

◆ pulse_set_pause()

static int pulse_set_pause ( PulseData s,
int  pause 
)
static

Definition at line 281 of file pulse_audio_enc.c.

Referenced by pulse_control_message().

◆ pulse_flash_stream()

static int pulse_flash_stream ( PulseData s)
static

Definition at line 289 of file pulse_audio_enc.c.

Referenced by pulse_write_packet().

◆ pulse_context_result()

static void pulse_context_result ( pa_context *  ctx,
int  success,
void *  userdata 
)
static

Definition at line 297 of file pulse_audio_enc.c.

Referenced by pulse_set_mute(), pulse_set_volume(), and pulse_subscribe_events().

◆ pulse_finish_context_operation()

static int pulse_finish_context_operation ( PulseData s,
pa_operation *  op,
const char *  name 
)
static

Definition at line 308 of file pulse_audio_enc.c.

Referenced by pulse_set_mute(), pulse_set_volume(), and pulse_subscribe_events().

◆ pulse_set_mute()

static int pulse_set_mute ( PulseData s)
static

Definition at line 325 of file pulse_audio_enc.c.

Referenced by pulse_control_message().

◆ pulse_set_volume()

static int pulse_set_volume ( PulseData s,
double  volume 
)
static

Definition at line 334 of file pulse_audio_enc.c.

Referenced by pulse_control_message().

◆ pulse_subscribe_events()

static int pulse_subscribe_events ( PulseData s)
static

Definition at line 350 of file pulse_audio_enc.c.

Referenced by pulse_write_header().

◆ pulse_map_channels_to_pulse()

static void pulse_map_channels_to_pulse ( const AVChannelLayout channel_layout,
pa_channel_map *  channel_map 
)
static

Definition at line 359 of file pulse_audio_enc.c.

Referenced by pulse_write_header().

◆ pulse_write_trailer()

static av_cold int pulse_write_trailer ( AVFormatContext h)
static

Definition at line 414 of file pulse_audio_enc.c.

Referenced by pulse_write_header().

◆ pulse_write_header()

static av_cold int pulse_write_header ( AVFormatContext h)
static

Definition at line 445 of file pulse_audio_enc.c.

◆ pulse_write_packet()

static int pulse_write_packet ( AVFormatContext h,
AVPacket pkt 
)
static

Definition at line 629 of file pulse_audio_enc.c.

Referenced by pulse_write_frame().

◆ pulse_write_frame()

static int pulse_write_frame ( AVFormatContext h,
int  stream_index,
AVFrame **  frame,
unsigned  flags 
)
static

Definition at line 678 of file pulse_audio_enc.c.

◆ pulse_get_output_timestamp()

static void pulse_get_output_timestamp ( AVFormatContext h,
int  stream,
int64_t dts,
int64_t wall 
)
static

Definition at line 696 of file pulse_audio_enc.c.

◆ pulse_get_device_list()

static int pulse_get_device_list ( AVFormatContext h,
AVDeviceInfoList device_list 
)
static

Definition at line 710 of file pulse_audio_enc.c.

◆ pulse_control_message()

static int pulse_control_message ( AVFormatContext h,
int  type,
void *  data,
size_t  data_size 
)
static

Definition at line 716 of file pulse_audio_enc.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "server", "set PulseAudio server", OFFSET(server), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E },
{ "name", "set application name", OFFSET(name), AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, E },
{ "stream_name", "set stream description", OFFSET(stream_name), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E },
{ "device", "set device name", OFFSET(device), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E },
{ "buffer_size", "set buffer size in bytes", OFFSET(buffer_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E },
{ "buffer_duration", "set buffer duration in millisecs", OFFSET(buffer_duration), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E },
{ "prebuf", "set pre-buffering size", OFFSET(prebuf), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E },
{ "minreq", "set minimum request size", OFFSET(minreq), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E },
{ NULL }
}

Definition at line 766 of file pulse_audio_enc.c.

◆ pulse_muxer_class

const AVClass pulse_muxer_class
static
Initial value:
= {
.class_name = "PulseAudio outdev",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 778 of file pulse_audio_enc.c.

◆ ff_pulse_muxer

const FFOutputFormat ff_pulse_muxer
Initial value:
= {
.p.name = "pulse",
.p.long_name = NULL_IF_CONFIG_SMALL("Pulse audio output"),
.priv_data_size = sizeof(PulseData),
.p.video_codec = AV_CODEC_ID_NONE,
.write_header = pulse_write_header,
.write_packet = pulse_write_packet,
.write_uncoded_frame = pulse_write_frame,
.write_trailer = pulse_write_trailer,
.get_output_timestamp = pulse_get_output_timestamp,
.get_device_list = pulse_get_device_list,
.control_message = pulse_control_message,
.p.flags = AVFMT_NOFILE,
.p.priv_class = &pulse_muxer_class,
.flags_internal = FF_OFMT_FLAG_ALLOW_FLUSH,
}

Definition at line 786 of file pulse_audio_enc.c.

AV_CODEC_ID_PCM_S16LE
@ AV_CODEC_ID_PCM_S16LE
Definition: codec_id.h:328
pulse_write_packet
static int pulse_write_packet(AVFormatContext *h, AVPacket *pkt)
Definition: pulse_audio_enc.c:629
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
LIBAVFORMAT_IDENT
#define LIBAVFORMAT_IDENT
Definition: version.h:45
pulse_write_frame
static int pulse_write_frame(AVFormatContext *h, int stream_index, AVFrame **frame, unsigned flags)
Definition: pulse_audio_enc.c:678
pulse_write_header
static av_cold int pulse_write_header(AVFormatContext *h)
Definition: pulse_audio_enc.c:445
pulse_muxer_class
static const AVClass pulse_muxer_class
Definition: pulse_audio_enc.c:778
E
#define E
Definition: pulse_audio_enc.c:765
PulseData
Definition: pulse_audio_dec.c:40
AV_CODEC_ID_PCM_S16BE
@ AV_CODEC_ID_PCM_S16BE
Definition: codec_id.h:329
AV_NE
#define AV_NE(be, le)
Definition: macros.h:33
pulse_get_output_timestamp
static void pulse_get_output_timestamp(AVFormatContext *h, int stream, int64_t *dts, int64_t *wall)
Definition: pulse_audio_enc.c:696
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
pulse_control_message
static int pulse_control_message(AVFormatContext *h, int type, void *data, size_t data_size)
Definition: pulse_audio_enc.c:716
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
FF_OFMT_FLAG_ALLOW_FLUSH
#define FF_OFMT_FLAG_ALLOW_FLUSH
This flag indicates that the muxer stores data internally and supports flushing it.
Definition: mux.h:38
AVFMT_NOFILE
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:468
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:50
AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT
@ AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT
Definition: log.h:42
OFFSET
#define OFFSET(a)
Definition: pulse_audio_enc.c:764
pulse_write_trailer
static av_cold int pulse_write_trailer(AVFormatContext *h)
Definition: pulse_audio_enc.c:414
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
pulse_get_device_list
static int pulse_get_device_list(AVFormatContext *h, AVDeviceInfoList *device_list)
Definition: pulse_audio_enc.c:710
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
options
static const AVOption options[]
Definition: pulse_audio_enc.c:766