changeset 30:90fd30dd68b3 libavformat

grab device is in AVFormatParameter (at least better than global variable)
author bellard
date Thu, 23 Jan 2003 10:33:16 +0000
parents 86a085c19c7f
children 36dd902f98d2
files audio.c avformat.h beosaudio.cpp dv1394.c grab.c utils.c
diffstat 6 files changed, 17 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/audio.c	Thu Jan 23 09:55:19 2003 +0000
+++ b/audio.c	Thu Jan 23 10:33:16 2003 +0000
@@ -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 @@
     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 @@
     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 @@
     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;
--- a/avformat.h	Thu Jan 23 09:55:19 2003 +0000
+++ b/avformat.h	Thu Jan 23 10:33:16 2003 +0000
@@ -61,6 +61,8 @@
     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 @@
 
 /* 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);
--- a/beosaudio.cpp	Thu Jan 23 09:55:19 2003 +0000
+++ b/beosaudio.cpp	Thu Jan 23 10:33:16 2003 +0000
@@ -34,9 +34,6 @@
 /* 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
--- a/dv1394.c	Thu Jan 23 09:55:19 2003 +0000
+++ b/dv1394.c	Thu Jan 23 10:33:16 2003 +0000
@@ -76,6 +76,7 @@
 {
     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 @@
 
     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");
--- a/grab.c	Thu Jan 23 09:55:19 2003 +0000
+++ b/grab.c	Thu Jan 23 10:33:16 2003 +0000
@@ -62,6 +62,7 @@
     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 @@
     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);
--- a/utils.c	Thu Jan 23 09:55:19 2003 +0000
+++ b/utils.c	Thu Jan 23 10:33:16 2003 +0000
@@ -41,8 +41,6 @@
 AVOutputFormat *first_oformat;
 AVImageFormat *first_image_format;
 
-const char *video_device = "none";
-
 void av_register_input_format(AVInputFormat *format)
 {
     AVInputFormat **p;