grab device is in AVFormatParameter (at least better than global variable)

Originally committed as revision 1499 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Fabrice Bellard 22 years ago
parent 79a7c2683e
commit 7f172339fd
  1. 11
      libavformat/audio.c
  2. 6
      libavformat/avformat.h
  3. 3
      libavformat/beosaudio.cpp
  4. 7
      libavformat/dv1394.c
  5. 4
      libavformat/grab.c
  6. 2
      libavformat/utils.c

@ -28,8 +28,6 @@
#include <sys/mman.h>
#include <sys/time.h>
const char *audio_device = "/dev/dsp";
#define AUDIO_BLOCK_SIZE 4096
typedef struct {
@ -43,13 +41,16 @@ typedef struct {
int buffer_ptr;
} AudioData;
static int audio_open(AudioData *s, int is_output)
static int audio_open(AudioData *s, int is_output, const char *audio_device)
{
int audio_fd;
int tmp, err;
char *flip = getenv("AUDIO_FLIP_LEFT");
/* open linux audio device */
if (!audio_device)
audio_device = "/dev/dsp";
if (is_output)
audio_fd = open(audio_device, O_WRONLY);
else
@ -155,7 +156,7 @@ static int audio_write_header(AVFormatContext *s1)
st = s1->streams[0];
s->sample_rate = st->codec.sample_rate;
s->channels = st->codec.channels;
ret = audio_open(s, 1);
ret = audio_open(s, 1, NULL);
if (ret < 0) {
return -EIO;
} else {
@ -217,7 +218,7 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)
s->sample_rate = ap->sample_rate;
s->channels = ap->channels;
ret = audio_open(s, 0);
ret = audio_open(s, 0, ap->device);
if (ret < 0) {
av_free(st);
return -EIO;

@ -61,6 +61,8 @@ typedef struct AVFormatParameters {
int height;
enum PixelFormat pix_fmt;
struct AVImageFormat *image_format;
int channel; /* used to select dv channel */
const char *device; /* video4linux, audio or DV device */
} AVFormatParameters;
#define AVFMT_NOFILE 0x0001 /* no file should be opened */
@ -381,10 +383,6 @@ int audio_init(void);
/* DV1394 */
int dv1394_init(void);
extern int dv1394_channel;
extern const char *video_device;
extern const char *audio_device;
#ifdef HAVE_AV_CONFIG_H
int strstart(const char *str, const char *val, const char **ptr);

@ -34,9 +34,6 @@ extern "C" {
/* enable performance checks */
//#define PERF_CHECK
//const char *audio_device = "/dev/dsp";
const char *audio_device = "beosaudio:";
/* Pipes are 4k in BeOS IIRC */
#define AUDIO_BLOCK_SIZE 4096
//#define AUDIO_BLOCK_SIZE 2048

@ -76,6 +76,7 @@ static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap
{
struct dv1394_data *dv = context->priv_data;
AVStream *st;
const char *video_device;
st = av_new_stream(context, 0);
if (!st)
@ -83,14 +84,16 @@ static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap
dv->width = DV1394_WIDTH;
dv->height = DV1394_HEIGHT;
dv->channel = dv1394_channel;
dv->channel = ap->channel;
dv->frame_rate = 30;
dv->frame_size = DV1394_NTSC_FRAME_SIZE;
/* Open and initialize DV1394 device */
video_device = ap->device;
if (!video_device)
video_device = "/dev/dv1394/0";
dv->fd = open(video_device, O_RDONLY);
if (dv->fd < 0) {
perror("Failed to open DV interface");

@ -62,6 +62,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
int ret, frame_rate;
int desired_palette;
struct video_audio audio;
const char *video_device;
if (!ap || ap->width <= 0 || ap->height <= 0 || ap->frame_rate <= 0)
return -1;
@ -78,6 +79,9 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
s->height = height;
s->frame_rate = frame_rate;
video_device = ap->device;
if (!video_device)
video_device = "/dev/video";
video_fd = open(video_device, O_RDWR);
if (video_fd < 0) {
perror(video_device);

@ -41,8 +41,6 @@ AVInputFormat *first_iformat;
AVOutputFormat *first_oformat;
AVImageFormat *first_image_format;
const char *video_device = "none";
void av_register_input_format(AVInputFormat *format)
{
AVInputFormat **p;

Loading…
Cancel
Save