* Linux audio play and grab interface
* Copyright (c) 2000, 2001 Fabrice Bellard
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * 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.
*
- * FFmpeg is distributed in the hope that it will be useful,
+ * 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 FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <sys/select.h>
#include "libavutil/log.h"
+#include "libavutil/opt.h"
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#define AUDIO_BLOCK_SIZE 4096
typedef struct {
+ AVClass *class;
int fd;
int sample_rate;
int channels;
AVStream *st;
int ret;
- if (ap->sample_rate <= 0 || ap->channels <= 0)
- return -1;
+#if FF_API_FORMAT_PARAMETERS
+ if (ap->sample_rate > 0)
+ s->sample_rate = ap->sample_rate;
+ if (ap->channels > 0)
+ s->channels = ap->channels;
+#endif
st = av_new_stream(s1, 0);
if (!st) {
return AVERROR(ENOMEM);
}
- s->sample_rate = ap->sample_rate;
- s->channels = ap->channels;
ret = audio_open(s1, 0, s1->filename);
if (ret < 0) {
}
/* take real parameters */
- st->codec->codec_type = CODEC_TYPE_AUDIO;
+ st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = s->codec_id;
st->codec->sample_rate = s->sample_rate;
st->codec->channels = s->channels;
if ((ret=av_new_packet(pkt, s->frame_size)) < 0)
return ret;
- ret = read(s->fd, pkt->data, pkt->size);
+ ret = read(s->fd, pkt->data, pkt->size);
if (ret <= 0){
av_free_packet(pkt);
pkt->size = 0;
if (ret<0) return AVERROR(errno);
- else return AVERROR(EOF);
+ else return AVERROR_EOF;
}
pkt->size = ret;
}
#if CONFIG_OSS_INDEV
-AVInputFormat oss_demuxer = {
+static const AVOption options[] = {
+ { "sample_rate", "", offsetof(AudioData, sample_rate), FF_OPT_TYPE_INT, {.dbl = 48000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+ { "channels", "", offsetof(AudioData, channels), FF_OPT_TYPE_INT, {.dbl = 2}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+ { NULL },
+};
+
+static const AVClass oss_demuxer_class = {
+ .class_name = "OSS demuxer",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+AVInputFormat ff_oss_demuxer = {
"oss",
NULL_IF_CONFIG_SMALL("Open Sound System capture"),
sizeof(AudioData),
audio_read_packet,
audio_read_close,
.flags = AVFMT_NOFILE,
+ .priv_class = &oss_demuxer_class,
};
#endif
#if CONFIG_OSS_OUTDEV
-AVOutputFormat oss_muxer = {
+AVOutputFormat ff_oss_muxer = {
"oss",
NULL_IF_CONFIG_SMALL("Open Sound System playback"),
"",
/* XXX: we make the assumption that the soundcard accepts this format */
/* XXX: find better solution with "preinit" method, needed also in
other formats */
-#if HAVE_BIGENDIAN
- CODEC_ID_PCM_S16BE,
-#else
- CODEC_ID_PCM_S16LE,
-#endif
+ AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE),
CODEC_ID_NONE,
audio_write_header,
audio_write_packet,