Remove all output devices

The libavformat API is not suitable for exporting output devices as muxers.
Some practical problems are e.g. lack of timing/synchronization mechanisms
or interaction with output-specific features.
pull/272/head
Diego Biurrun 7 years ago
parent eb3c1a94ad
commit 8e7e042d41
  1. 22
      configure
  2. 1
      doc/avconv.texi
  3. 1
      doc/avplay.texi
  4. 33
      doc/outdevs.texi
  5. 5
      libavdevice/Makefile
  6. 39
      libavdevice/alldevices.c
  7. 16
      libavdevice/alsa.c
  8. 2
      libavdevice/alsa.h
  9. 117
      libavdevice/alsa_enc.c
  10. 108
      libavdevice/oss_enc.c
  11. 95
      libavdevice/sndio_enc.c
  12. 2
      libavdevice/version.h

22
configure vendored

@ -73,7 +73,6 @@ Help options:
--list-protocols show all available protocols
--list-bsfs show all available bitstream filters
--list-indevs show all available input devices
--list-outdevs show all available output devices
--list-filters show all available filters
Standard options:
@ -163,9 +162,6 @@ Individual component options:
--enable-indev=NAME enable input device NAME
--disable-indev=NAME disable input device NAME
--disable-indevs disable input devices
--enable-outdev=NAME enable output device NAME
--disable-outdev=NAME disable output device NAME
--disable-outdevs disable output devices
--disable-devices disable all devices
--enable-filter=NAME enable filter NAME
--disable-filter=NAME disable filter NAME
@ -1224,7 +1220,6 @@ AVCODEC_COMPONENTS="
AVDEVICE_COMPONENTS="
indevs
outdevs
"
AVFILTER_COMPONENTS="
filters
@ -2433,9 +2428,8 @@ wtv_demuxer_select="mpegts_demuxer riffdec"
xmv_demuxer_select="riffdec"
xwma_demuxer_select="riffdec"
# indevs / outdevs
# indevs
alsa_indev_deps="alsa"
alsa_outdev_deps="alsa"
avfoundation_indev_deps="AVFoundation_AVFoundation_h objc_arc pthreads"
avfoundation_indev_extralibs="-framework Foundation -framework AVFoundation -framework CoreVideo -framework CoreMedia"
bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
@ -2447,10 +2441,8 @@ jack_indev_deps_any="sem_timedwait dispatch_dispatch_h"
libcdio_indev_deps="libcdio"
libdc1394_indev_deps="libdc1394"
oss_indev_deps_any="sys_soundcard_h"
oss_outdev_deps_any="sys_soundcard_h"
pulse_indev_deps="libpulse"
sndio_indev_deps="sndio"
sndio_outdev_deps="sndio"
v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
vfwcap_indev_deps="vfw32 vfwcap_defines"
xcbgrab_indev_deps="libxcb libxcb_shape"
@ -2715,7 +2707,6 @@ HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
@ -2739,7 +2730,6 @@ AVCODEC_COMPONENTS_LIST="
AVDEVICE_COMPONENTS_LIST="
$INDEV_LIST
$OUTDEV_LIST
"
AVFILTER_COMPONENTS_LIST="
@ -2800,7 +2790,7 @@ for opt do
add_extralibs $optval
;;
--disable-devices)
disable $INDEV_LIST $OUTDEV_LIST
disable $INDEV_LIST
;;
--enable-debug=*)
debuglevel="$optval"
@ -3906,7 +3896,6 @@ case $target_os in
netbsd)
disable symver
oss_indev_extralibs="-lossaudio"
oss_outdev_extralibs="-lossaudio"
;;
openbsd|bitrig)
disable symver
@ -3914,7 +3903,6 @@ case $target_os in
SLIB_INSTALL_NAME='$(SLIBNAME).$(LIBMAJOR).$(LIBMINOR)'
SLIB_INSTALL_LINKS=
oss_indev_extralibs="-lossaudio"
oss_outdev_extralibs="-lossaudio"
;;
dragonfly)
disable symver
@ -4789,13 +4777,13 @@ check_header "dev/bktr/ioctl_meteor.h dev/bktr/ioctl_bt848.h"
check_header sys/soundcard.h
enabled_any alsa_indev alsa_outdev &&
enabled alsa_indev &&
check_lib alsa alsa/asoundlib.h snd_pcm_htimestamp -lasound
enabled libjack &&
require_pkg_config libjack jack jack/jack.h jack_port_get_latency_range
enabled_any sndio_indev sndio_outdev && check_lib sndio sndio.h sio_open -lsndio
enabled sndio_indev && check_lib sndio sndio.h sio_open -lsndio
if enabled libcdio; then
check_lib libcdio "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
@ -5252,7 +5240,7 @@ echo "Programs:"
print_enabled '' $PROGRAM_LIST | print_3_columns
echo
for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev; do
echo "Enabled ${type}s:"
eval list=\$$(toupper $type)_LIST
print_enabled '_*' $list | print_3_columns

@ -1264,7 +1264,6 @@ avconv -i src.ext -lmax 21*QP2LAMBDA dst.ext
@include demuxers.texi
@include muxers.texi
@include indevs.texi
@include outdevs.texi
@include protocols.texi
@include bitstream_filters.texi
@include filters.texi

@ -164,7 +164,6 @@ Seek to percentage in file corresponding to fraction of width.
@include demuxers.texi
@include muxers.texi
@include indevs.texi
@include outdevs.texi
@include protocols.texi
@include filters.texi

@ -1,33 +0,0 @@
@chapter Output Devices
@c man begin OUTPUT DEVICES
Output devices are configured elements in Libav which allow to write
multimedia data to an output device attached to your system.
When you configure your Libav build, all the supported output devices
are enabled by default. You can list all available ones using the
configure option "--list-outdevs".
You can disable all the output devices using the configure option
"--disable-outdevs", and selectively enable an output device using the
option "--enable-outdev=@var{OUTDEV}", or you can disable a particular
input device using the option "--disable-outdev=@var{OUTDEV}".
The option "-formats" of the av* tools will display the list of
enabled output devices (amongst the muxers).
A description of the currently available output devices follows.
@section alsa
ALSA (Advanced Linux Sound Architecture) output device.
@section oss
OSS (Open Sound System) output device.
@section sndio
sndio audio output device.
@c man end OUTPUT DEVICES

@ -9,19 +9,16 @@ OBJS = alldevices.o \
OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o
# input/output devices
# input devices
OBJS-$(CONFIG_ALSA_INDEV) += alsa_dec.o alsa.o
OBJS-$(CONFIG_ALSA_OUTDEV) += alsa_enc.o alsa.o
OBJS-$(CONFIG_AVFOUNDATION_INDEV) += avfoundation_dec.o
OBJS-$(CONFIG_BKTR_INDEV) += bktr.o
OBJS-$(CONFIG_DV1394_INDEV) += dv1394.o
OBJS-$(CONFIG_FBDEV_INDEV) += fbdev.o
OBJS-$(CONFIG_JACK_INDEV) += jack.o timefilter.o
OBJS-$(CONFIG_OSS_INDEV) += oss_dec.o oss.o
OBJS-$(CONFIG_OSS_OUTDEV) += oss_enc.o oss.o
OBJS-$(CONFIG_PULSE_INDEV) += pulse.o
OBJS-$(CONFIG_SNDIO_INDEV) += sndio_dec.o sndio.o
OBJS-$(CONFIG_SNDIO_OUTDEV) += sndio_enc.o sndio.o
OBJS-$(CONFIG_V4L2_INDEV) += v4l2.o
OBJS-$(CONFIG_VFWCAP_INDEV) += vfwcap.o
OBJS-$(CONFIG_XCBGRAB_INDEV) += xcbgrab.o

@ -22,13 +22,6 @@
#include "libavformat/avformat.h"
#include "avdevice.h"
#define REGISTER_OUTDEV(X, x) \
{ \
extern AVOutputFormat ff_##x##_muxer; \
if (CONFIG_##X##_OUTDEV) \
av_register_output_format(&ff_##x##_muxer); \
}
#define REGISTER_INDEV(X, x) \
{ \
extern AVInputFormat ff_##x##_demuxer; \
@ -36,8 +29,6 @@
av_register_input_format(&ff_##x##_demuxer); \
}
#define REGISTER_INOUTDEV(X, x) REGISTER_OUTDEV(X, x); REGISTER_INDEV(X, x)
void avdevice_register_all(void)
{
static int initialized;
@ -46,21 +37,21 @@ void avdevice_register_all(void)
return;
initialized = 1;
/* devices */
REGISTER_INOUTDEV(ALSA, alsa);
REGISTER_INDEV (AVFOUNDATION, avfoundation);
REGISTER_INDEV (BKTR, bktr);
REGISTER_INDEV (DV1394, dv1394);
REGISTER_INDEV (FBDEV, fbdev);
REGISTER_INDEV (JACK, jack);
REGISTER_INOUTDEV(OSS, oss);
REGISTER_INDEV (PULSE, pulse);
REGISTER_INOUTDEV(SNDIO, sndio);
REGISTER_INDEV (V4L2, v4l2);
REGISTER_INDEV (VFWCAP, vfwcap);
REGISTER_INDEV (XCBGRAB, xcbgrab);
/* input devices */
REGISTER_INDEV(ALSA, alsa);
REGISTER_INDEV(AVFOUNDATION, avfoundation);
REGISTER_INDEV(BKTR, bktr);
REGISTER_INDEV(DV1394, dv1394);
REGISTER_INDEV(FBDEV, fbdev);
REGISTER_INDEV(JACK, jack);
REGISTER_INDEV(OSS, oss);
REGISTER_INDEV(PULSE, pulse);
REGISTER_INDEV(SNDIO, sndio);
REGISTER_INDEV(V4L2, v4l2);
REGISTER_INDEV(VFWCAP, vfwcap);
REGISTER_INDEV(XCBGRAB, xcbgrab);
/* external libraries */
REGISTER_INDEV (LIBCDIO, libcdio);
REGISTER_INDEV (LIBDC1394, libdc1394);
REGISTER_INDEV(LIBCDIO, libcdio);
REGISTER_INDEV(LIBDC1394, libdc1394);
}

@ -344,19 +344,3 @@ int ff_alsa_xrun_recover(AVFormatContext *s1, int err)
}
return err;
}
int ff_alsa_extend_reorder_buf(AlsaData *s, int min_size)
{
int size = s->reorder_buf_size;
void *r;
av_assert0(size != 0);
while (size < min_size)
size *= 2;
r = av_realloc(s->reorder_buf, size * s->frame_size);
if (!r)
return AVERROR(ENOMEM);
s->reorder_buf = r;
s->reorder_buf_size = size;
return 0;
}

@ -91,6 +91,4 @@ int ff_alsa_close(AVFormatContext *s1);
*/
int ff_alsa_xrun_recover(AVFormatContext *s1, int err);
int ff_alsa_extend_reorder_buf(AlsaData *s, int size);
#endif /* AVDEVICE_ALSA_H */

@ -1,117 +0,0 @@
/*
* ALSA input and output
* Copyright (c) 2007 Luca Abeni ( lucabe72 email it )
* Copyright (c) 2007 Benoit Fouet ( benoit fouet free fr )
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* ALSA input and output: output
* @author Luca Abeni ( lucabe72 email it )
* @author Benoit Fouet ( benoit fouet free fr )
*
* This avdevice encoder allows to play audio to 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 playback period is set to the lower value available for the device,
* which gives a low latency suitable for real-time playback.
*/
#include <alsa/asoundlib.h>
#include "libavutil/internal.h"
#include "libavformat/avformat.h"
#include "alsa.h"
static av_cold int audio_write_header(AVFormatContext *s1)
{
AlsaData *s = s1->priv_data;
AVStream *st;
unsigned int sample_rate;
enum AVCodecID codec_id;
int res;
st = s1->streams[0];
sample_rate = st->codecpar->sample_rate;
codec_id = st->codecpar->codec_id;
res = ff_alsa_open(s1, SND_PCM_STREAM_PLAYBACK, &sample_rate,
st->codecpar->channels, &codec_id);
if (sample_rate != st->codecpar->sample_rate) {
av_log(s1, AV_LOG_ERROR,
"sample rate %d not available, nearest is %d\n",
st->codecpar->sample_rate, sample_rate);
goto fail;
}
return res;
fail:
snd_pcm_close(s->h);
return AVERROR(EIO);
}
static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
{
AlsaData *s = s1->priv_data;
int res;
int size = pkt->size;
uint8_t *buf = pkt->data;
size /= s->frame_size;
if (s->reorder_func) {
if (size > s->reorder_buf_size)
if (ff_alsa_extend_reorder_buf(s, size))
return AVERROR(ENOMEM);
s->reorder_func(buf, s->reorder_buf, size);
buf = s->reorder_buf;
}
while ((res = snd_pcm_writei(s->h, buf, size)) < 0) {
if (res == -EAGAIN) {
return AVERROR(EAGAIN);
}
if (ff_alsa_xrun_recover(s1, res) < 0) {
av_log(s1, AV_LOG_ERROR, "ALSA write error: %s\n",
snd_strerror(res));
return AVERROR(EIO);
}
}
return 0;
}
AVOutputFormat ff_alsa_muxer = {
.name = "alsa",
.long_name = NULL_IF_CONFIG_SMALL("ALSA audio output"),
.priv_data_size = sizeof(AlsaData),
.audio_codec = DEFAULT_CODEC_ID,
.video_codec = AV_CODEC_ID_NONE,
.write_header = audio_write_header,
.write_packet = audio_write_packet,
.write_trailer = ff_alsa_close,
.flags = AVFMT_NOFILE,
};

@ -1,108 +0,0 @@
/*
* Linux audio grab interface
* Copyright (c) 2000, 2001 Fabrice Bellard
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#if HAVE_SOUNDCARD_H
#include <soundcard.h>
#else
#include <sys/soundcard.h>
#endif
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "libavutil/internal.h"
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libavformat/internal.h"
#include "oss.h"
static int audio_write_header(AVFormatContext *s1)
{
OSSAudioData *s = s1->priv_data;
AVStream *st;
int ret;
st = s1->streams[0];
s->sample_rate = st->codecpar->sample_rate;
s->channels = st->codecpar->channels;
ret = ff_oss_audio_open(s1, 1, s1->filename);
if (ret < 0) {
return AVERROR(EIO);
} else {
return 0;
}
}
static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
{
OSSAudioData *s = s1->priv_data;
int len, ret;
int size= pkt->size;
uint8_t *buf= pkt->data;
while (size > 0) {
len = FFMIN(OSS_AUDIO_BLOCK_SIZE - s->buffer_ptr, size);
memcpy(s->buffer + s->buffer_ptr, buf, len);
s->buffer_ptr += len;
if (s->buffer_ptr >= OSS_AUDIO_BLOCK_SIZE) {
for(;;) {
ret = write(s->fd, s->buffer, OSS_AUDIO_BLOCK_SIZE);
if (ret > 0)
break;
if (ret < 0 && (errno != EAGAIN && errno != EINTR))
return AVERROR(EIO);
}
s->buffer_ptr = 0;
}
buf += len;
size -= len;
}
return 0;
}
static int audio_write_trailer(AVFormatContext *s1)
{
OSSAudioData *s = s1->priv_data;
ff_oss_audio_close(s);
return 0;
}
AVOutputFormat ff_oss_muxer = {
.name = "oss",
.long_name = NULL_IF_CONFIG_SMALL("OSS (Open Sound System) playback"),
.priv_data_size = sizeof(OSSAudioData),
/* XXX: we make the assumption that the soundcard accepts this format */
/* XXX: find better solution with "preinit" method, needed also in
other formats */
.audio_codec = AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE),
.video_codec = AV_CODEC_ID_NONE,
.write_header = audio_write_header,
.write_packet = audio_write_packet,
.write_trailer = audio_write_trailer,
.flags = AVFMT_NOFILE,
};

@ -1,95 +0,0 @@
/*
* sndio play and grab interface
* Copyright (c) 2010 Jacob Meuser
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdint.h>
#include <sndio.h>
#include "libavutil/internal.h"
#include "libavformat/avformat.h"
#include "libavdevice/sndio.h"
static av_cold int audio_write_header(AVFormatContext *s1)
{
SndioData *s = s1->priv_data;
AVStream *st;
int ret;
st = s1->streams[0];
s->sample_rate = st->codecpar->sample_rate;
s->channels = st->codecpar->channels;
ret = ff_sndio_open(s1, 1, s1->filename);
return ret;
}
static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
{
SndioData *s = s1->priv_data;
uint8_t *buf= pkt->data;
int size = pkt->size;
int len, ret;
while (size > 0) {
len = FFMIN(s->buffer_size - s->buffer_offset, size);
memcpy(s->buffer + s->buffer_offset, buf, len);
buf += len;
size -= len;
s->buffer_offset += len;
if (s->buffer_offset >= s->buffer_size) {
ret = sio_write(s->hdl, s->buffer, s->buffer_size);
if (ret == 0 || sio_eof(s->hdl))
return AVERROR(EIO);
s->softpos += ret;
s->buffer_offset = 0;
}
}
return 0;
}
static int audio_write_trailer(AVFormatContext *s1)
{
SndioData *s = s1->priv_data;
sio_write(s->hdl, s->buffer, s->buffer_offset);
ff_sndio_close(s);
return 0;
}
AVOutputFormat ff_sndio_muxer = {
.name = "sndio",
.long_name = NULL_IF_CONFIG_SMALL("sndio audio playback"),
.priv_data_size = sizeof(SndioData),
/* XXX: we make the assumption that the soundcard accepts this format */
/* XXX: find better solution with "preinit" method, needed also in
other formats */
.audio_codec = AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE),
.video_codec = AV_CODEC_ID_NONE,
.write_header = audio_write_header,
.write_packet = audio_write_packet,
.write_trailer = audio_write_trailer,
.flags = AVFMT_NOFILE,
};

@ -29,7 +29,7 @@
#define LIBAVDEVICE_VERSION_MAJOR 57
#define LIBAVDEVICE_VERSION_MINOR 0
#define LIBAVDEVICE_VERSION_MICRO 0
#define LIBAVDEVICE_VERSION_MICRO 1
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
LIBAVDEVICE_VERSION_MINOR, \

Loading…
Cancel
Save