diff options
author | Diego Biurrun <diego@biurrun.de> | 2017-09-23 16:26:28 +0200 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2017-10-13 23:57:01 +0200 |
commit | 8e7e042d41ac42f01d5573a4b0f7d9060356bd46 (patch) | |
tree | c0efbf4c61414a76e8a475ad909b05d99fe09927 /libavdevice | |
parent | eb3c1a94adbc28411610167d3dac583436e50125 (diff) |
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.
Diffstat (limited to 'libavdevice')
-rw-r--r-- | libavdevice/Makefile | 5 | ||||
-rw-r--r-- | libavdevice/alldevices.c | 39 | ||||
-rw-r--r-- | libavdevice/alsa.c | 16 | ||||
-rw-r--r-- | libavdevice/alsa.h | 2 | ||||
-rw-r--r-- | libavdevice/alsa_enc.c | 117 | ||||
-rw-r--r-- | libavdevice/oss_enc.c | 108 | ||||
-rw-r--r-- | libavdevice/sndio_enc.c | 95 | ||||
-rw-r--r-- | libavdevice/version.h | 2 |
8 files changed, 17 insertions, 367 deletions
diff --git a/libavdevice/Makefile b/libavdevice/Makefile index ab8931c639..69542020d3 100644 --- a/libavdevice/Makefile +++ b/libavdevice/Makefile @@ -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 diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c index cdbca4c8e8..47d7421a06 100644 --- a/libavdevice/alldevices.c +++ b/libavdevice/alldevices.c @@ -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); } diff --git a/libavdevice/alsa.c b/libavdevice/alsa.c index d394e4377d..81c94049cb 100644 --- a/libavdevice/alsa.c +++ b/libavdevice/alsa.c @@ -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; -} diff --git a/libavdevice/alsa.h b/libavdevice/alsa.h index 590b354053..773cd2faf8 100644 --- a/libavdevice/alsa.h +++ b/libavdevice/alsa.h @@ -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 */ diff --git a/libavdevice/alsa_enc.c b/libavdevice/alsa_enc.c deleted file mode 100644 index 3094b5043e..0000000000 --- a/libavdevice/alsa_enc.c +++ /dev/null @@ -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, -}; diff --git a/libavdevice/oss_enc.c b/libavdevice/oss_enc.c deleted file mode 100644 index eb6432ced0..0000000000 --- a/libavdevice/oss_enc.c +++ /dev/null @@ -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, -}; diff --git a/libavdevice/sndio_enc.c b/libavdevice/sndio_enc.c deleted file mode 100644 index 97b1827f82..0000000000 --- a/libavdevice/sndio_enc.c +++ /dev/null @@ -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, -}; diff --git a/libavdevice/version.h b/libavdevice/version.h index 1bcb32c4c9..e09a23cf67 100644 --- a/libavdevice/version.h +++ b/libavdevice/version.h @@ -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, \ |