aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorRamiro Polla <ramiro@lisha.ufsc.br>2007-02-14 17:01:32 +0000
committerGuillaume Poirier <gpoirier@mplayerhq.hu>2007-02-14 17:01:32 +0000
commitcc58300e30e7aea6acfecd72a04a3886b285cfd8 (patch)
treee1060df29a65226dcdf1378538c920a1a544e2f8 /libavformat
parent20121213630a03001148f3ffdadac895dae8d7c5 (diff)
downloadffmpeg-cc58300e30e7aea6acfecd72a04a3886b285cfd8.tar.gz
implement new grabbing interface, as described here:
ttp://thread.gmane.org/gmane.comp.video.ffmpeg.devel/42920 patch by Ramiro Polla % ramiro A lisha P ufsc P br % Original thread: Date: Jan 31, 2007 8:56 PM Subject: [Ffmpeg-devel] [PATCH] New grabbing interface Originally committed as revision 7983 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/audio.c10
-rw-r--r--libavformat/avformat.h2
-rw-r--r--libavformat/beosaudio.cpp2
-rw-r--r--libavformat/dc1394.c2
-rw-r--r--libavformat/dv1394.c6
-rw-r--r--libavformat/grab.c8
-rw-r--r--libavformat/grab_bktr.c7
-rw-r--r--libavformat/v4l2.c13
-rw-r--r--libavformat/x11grab.c15
9 files changed, 15 insertions, 50 deletions
diff --git a/libavformat/audio.c b/libavformat/audio.c
index 52f74db391..a9e5bffd5f 100644
--- a/libavformat/audio.c
+++ b/libavformat/audio.c
@@ -53,14 +53,6 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
int tmp, err;
char *flip = getenv("AUDIO_FLIP_LEFT");
- /* open linux audio device */
- if (!audio_device)
-#ifdef __OpenBSD__
- audio_device = "/dev/sound";
-#else
- audio_device = "/dev/dsp";
-#endif
-
if (is_output)
audio_fd = open(audio_device, O_WRONLY);
else
@@ -229,7 +221,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, ap->device);
+ ret = audio_open(s, 0, s1->filename);
if (ret < 0) {
av_free(st);
return AVERROR_IO;
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 636748c6d1..dad18ced35 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -117,7 +117,9 @@ typedef struct AVFormatParameters {
int height;
enum PixelFormat pix_fmt;
int channel; /* used to select dv channel */
+#if LIBAVFORMAT_VERSION_INT < (52<<16)
const char *device; /* video, audio or DV device */
+#endif
const char *standard; /* tv standard, NTSC, PAL, SECAM */
int mpeg2ts_raw:1; /* force raw MPEG2 transport stream output, if possible */
int mpeg2ts_compute_pcr:1; /* compute exact PCR for each transport
diff --git a/libavformat/beosaudio.cpp b/libavformat/beosaudio.cpp
index ae77809747..6c16f0048c 100644
--- a/libavformat/beosaudio.cpp
+++ b/libavformat/beosaudio.cpp
@@ -361,7 +361,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, ap->device);
+ ret = audio_open(s, 0, s1->filename);
if (ret < 0) {
av_free(st);
return AVERROR(EIO);
diff --git a/libavformat/dc1394.c b/libavformat/dc1394.c
index 70bbf2e75a..bf140c4664 100644
--- a/libavformat/dc1394.c
+++ b/libavformat/dc1394.c
@@ -118,7 +118,7 @@ static int dc1394_read_header(AVFormatContext *c, AVFormatParameters * ap)
fmt->frame_size_id,
SPEED_400,
fps->frame_rate_id, 8, 1,
- ap->device,
+ c->filename,
&dc1394->camera);
dc1394_free_camera_nodes(camera_nodes);
if (res != DC1394_SUCCESS) {
diff --git a/libavformat/dv1394.c b/libavformat/dv1394.c
index c5795ca022..3a5f479c8e 100644
--- a/libavformat/dv1394.c
+++ b/libavformat/dv1394.c
@@ -83,7 +83,6 @@ static int dv1394_start(struct dv1394_data *dv)
static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap)
{
struct dv1394_data *dv = context->priv_data;
- const char *video_device;
dv->dv_demux = dv_init_demux(context);
if (!dv->dv_demux)
@@ -100,10 +99,7 @@ static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap
dv->channel = DV1394_DEFAULT_CHANNEL;
/* Open and initialize DV1394 device */
- video_device = ap->device;
- if (!video_device)
- video_device = "/dev/dv1394/0";
- dv->fd = open(video_device, O_RDONLY);
+ dv->fd = open(context->filename, O_RDONLY);
if (dv->fd < 0) {
perror("Failed to open DV interface");
goto failed;
diff --git a/libavformat/grab.c b/libavformat/grab.c
index 11acdac3b1..5e778ecc06 100644
--- a/libavformat/grab.c
+++ b/libavformat/grab.c
@@ -68,7 +68,6 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
struct video_tuner tuner;
struct video_audio audio;
struct video_picture pict;
- const char *video_device;
int j;
if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
@@ -100,12 +99,9 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
s->frame_rate = frame_rate;
s->frame_rate_base = frame_rate_base;
- video_device = ap->device;
- if (!video_device)
- video_device = "/dev/video";
- video_fd = open(video_device, O_RDWR);
+ video_fd = open(s1->filename, O_RDWR);
if (video_fd < 0) {
- perror(video_device);
+ perror(s1->filename);
goto fail;
}
diff --git a/libavformat/grab_bktr.c b/libavformat/grab_bktr.c
index 86348af5b1..100653db79 100644
--- a/libavformat/grab_bktr.c
+++ b/libavformat/grab_bktr.c
@@ -243,7 +243,6 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
int frame_rate;
int frame_rate_base;
int format = -1;
- const char *video_device;
if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0)
return -1;
@@ -253,10 +252,6 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
frame_rate = ap->time_base.den;
frame_rate_base = ap->time_base.num;
- video_device = ap->device;
- if (!video_device)
- video_device = "/dev/bktr0";
-
st = av_new_stream(s1, 0);
if (!st)
return AVERROR(ENOMEM);
@@ -285,7 +280,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
format = NTSC;
}
- if (bktr_init(video_device, width, height, format,
+ if (bktr_init(s1->filename, width, height, format,
&(s->video_fd), &(s->tuner_fd), -1, 0.0) < 0)
return AVERROR(EIO);
diff --git a/libavformat/v4l2.c b/libavformat/v4l2.c
index 5f669bd66c..ef661ae2ff 100644
--- a/libavformat/v4l2.c
+++ b/libavformat/v4l2.c
@@ -114,16 +114,16 @@ static struct fmt_map fmt_conversion_table[] = {
},
};
-static int device_open(AVFormatContext *ctx, const char *devname, uint32_t *capabilities)
+static int device_open(AVFormatContext *ctx, uint32_t *capabilities)
{
struct v4l2_capability cap;
int fd;
int res;
- fd = open(devname, O_RDWR /*| O_NONBLOCK*/, 0);
+ fd = open(ctx->filename, O_RDWR /*| O_NONBLOCK*/, 0);
if (fd < 0) {
av_log(ctx, AV_LOG_ERROR, "Cannot open video device %s : %s\n",
- devname, strerror(errno));
+ ctx->filename, strerror(errno));
return -1;
}
@@ -429,7 +429,6 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
int width, height;
int res, frame_rate, frame_rate_base;
uint32_t desired_format, capabilities;
- const char *video_device;
if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
av_log(s1, AV_LOG_ERROR, "Missing/Wrong parameters\n");
@@ -459,12 +458,8 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
s->frame_rate = frame_rate;
s->frame_rate_base = frame_rate_base;
- video_device = ap->device;
- if (!video_device) {
- video_device = "/dev/video";
- }
capabilities = 0;
- s->fd = device_open(s1, video_device, &capabilities);
+ s->fd = device_open(s1, &capabilities);
if (s->fd < 0) {
av_free(st);
diff --git a/libavformat/x11grab.c b/libavformat/x11grab.c
index 231c43da7e..8916d799a6 100644
--- a/libavformat/x11grab.c
+++ b/libavformat/x11grab.c
@@ -97,25 +97,14 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
int use_shm;
char *param, *offset;
- if (!ap->device) {
- av_log(s1, AV_LOG_ERROR, "AVParameters don't specify any device. Use -vd.\n");
- return AVERROR_IO;
- }
-
- param = strchr(ap->device, ':');
- if (!param) {
- av_free(st);
- return AVERROR_IO;
- }
-
- param = av_strdup(param);
+ param = av_strdup(s1->filename);
offset = strchr(param, '+');
if (offset) {
sscanf(offset, "%d,%d", &x_off, &y_off);
*offset= 0;
}
- av_log(s1, AV_LOG_INFO, "device: %s -> display: %s x: %d y: %d width: %d height: %d\n", ap->device, param, x_off, y_off, ap->width, ap->height);
+ av_log(s1, AV_LOG_INFO, "device: %s -> display: %s x: %d y: %d width: %d height: %d\n", s1->filename, param, x_off, y_off, ap->width, ap->height);
dpy = XOpenDisplay(param);
if(!dpy) {