aboutsummaryrefslogtreecommitdiffstats
path: root/libav/grab.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2002-05-20 16:31:13 +0000
committerFabrice Bellard <fabrice@bellard.org>2002-05-20 16:31:13 +0000
commitc9a65ca8c306071b3c359b56a384a1594cd505df (patch)
treea33c4b156673f2c1404042501c1cebaae6a35457 /libav/grab.c
parentdb7f1f95acc050bb5ddf62b0008eab8c8305d369 (diff)
downloadffmpeg-c9a65ca8c306071b3c359b56a384a1594cd505df.tar.gz
converted to new API
Originally committed as revision 547 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libav/grab.c')
-rw-r--r--libav/grab.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/libav/grab.c b/libav/grab.c
index e456468c4e..48145c8b4f 100644
--- a/libav/grab.c
+++ b/libav/grab.c
@@ -48,7 +48,7 @@ static int gb_frame = 0;
static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
{
- VideoData *s;
+ VideoData *s = s1->priv_data;
AVStream *st;
int width, height;
int video_fd, frame_size;
@@ -62,17 +62,9 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
height = ap->height;
frame_rate = ap->frame_rate;
- s = av_mallocz(sizeof(VideoData));
- if (!s)
- return -ENOMEM;
- st = av_mallocz(sizeof(AVStream));
- if (!st) {
- av_free(s);
+ st = av_new_stream(s1, 0);
+ if (!st)
return -ENOMEM;
- }
- s1->priv_data = s;
- s1->nb_streams = 1;
- s1->streams[0] = st;
s->width = width;
s->height = height;
@@ -232,7 +224,6 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
if (video_fd >= 0)
close(video_fd);
av_free(st);
- av_free(s);
return -EIO;
}
@@ -327,24 +318,22 @@ static int grab_read_close(AVFormatContext *s1)
ioctl(s->fd, VIDIOCSAUDIO, &audio_saved);
close(s->fd);
- av_free(s);
return 0;
}
-AVFormat video_grab_device_format = {
+AVInputFormat video_grab_device_format = {
"video_grab_device",
"video grab",
- "",
- "",
- CODEC_ID_NONE,
- CODEC_ID_NONE,
+ sizeof(VideoData),
NULL,
- NULL,
- NULL,
-
grab_read_header,
grab_read_packet,
grab_read_close,
- NULL,
- AVFMT_NOFILE,
+ flags: AVFMT_NOFILE,
};
+
+int video_grab_init(void)
+{
+ av_register_input_format(&video_grab_device_format);
+ return 0;
+}