]> rtime.felk.cvut.cz Git - frescor/streamer.git/commitdiff
Allow to select video4linux version 1 formant from commandline. adaptive
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Mon, 18 May 2009 18:09:35 +0000 (20:09 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Mon, 18 May 2009 18:09:35 +0000 (20:09 +0200)
Implemented -i v4l and -i v4l2 options.

Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
input.c
input.h
streamer.c

diff --git a/input.c b/input.c
index 14353b998172a17688cb50b0ea6b20ed2560b453..db09807257546e552dae7bd25e6b520561a7fb5b 100644 (file)
--- a/input.c
+++ b/input.c
@@ -35,7 +35,7 @@ static void time_base_convert(AVPacket *pkt, AVStream *st)
   }
 }
 
-AVFormatContext *open_input_stream(const char *fname, int w, int h, int fps)
+AVFormatContext *open_input_stream(const char *fname, int w, int h, int fps, const char *impform)
 {
     AVFormatContext *s;
     AVInputFormat *fmt;
@@ -49,7 +49,9 @@ AVFormatContext *open_input_stream(const char *fname, int w, int h, int fps)
     param.pix_fmt = PIX_FMT_YUV420P;
     param.time_base.den = fps;
     param.time_base.num = 1;
-    fmt = av_find_input_format("video4linux2");
+    if(impform == NULL)
+      impform = "video4linux2";
+    fmt = av_find_input_format(impform);
     res = av_open_input_file(&s, fname, fmt, 0, &param);
     if (res < 0) {
         fprintf(stderr, "Error opening %s: %d\n", fname, res);
diff --git a/input.h b/input.h
index a992b3415c756623db03c17c066fea93128e5de0..ad82b6b76a6efe9da203f03a051851015977dbec 100644 (file)
--- a/input.h
+++ b/input.h
@@ -3,6 +3,6 @@
  *
  *  This is free software; see GPL.txt
  */
-AVFormatContext *open_input_stream(const char *fname, int w, int h, int fps);
+AVFormatContext *open_input_stream(const char *fname, int w, int h, int fps, const char *impform);
 void close_input_stream(AVFormatContext *s);
 AVPacket *read_input_packet(AVFormatContext *s);
index 1a708cd81ea2de800cac22823fa166fc5f87e225..4185c1689f8e3808311de72c43ff158d8d1de3cf 100644 (file)
@@ -22,6 +22,7 @@ static int dport = 20000;
 static int width = 352;
 static int height = 288;
 int fps = 25;
+static const char *impform = "video4linux2";
 
 static void sdp_print(AVFormatContext *s, const char *fname)
 {
@@ -38,7 +39,7 @@ static int args_parse(int argc, char *argv[])
 {
   int v;
 
-  while ((v = getopt(argc, argv, "w:h:r:d:m:")) >= 0) {
+  while ((v = getopt(argc, argv, "w:h:r:d:m:i:")) >= 0) {
     switch (v) {
       case 'w':
         width = atoi(optarg);
@@ -55,6 +56,13 @@ static int args_parse(int argc, char *argv[])
       case 'm':
         dst = optarg;
         break;
+      case 'i':
+        impform = optarg;
+       if(!strcmp(impform, "v4l"))
+         impform = "video4linux";
+       else if(!strcmp(impform, "v4l2"))
+         impform = "video4linux2";
+        break;
       default: /* ’?’ */
         fprintf(stderr, "%s: illegal option %c\n", argv[0], v);
         exit(-1);
@@ -75,7 +83,7 @@ int main(int argc, char *argv[])
 
   args_parse(argc, argv);
 
-  s = open_input_stream(vdev, width, height, fps);
+  s = open_input_stream(vdev, width, height, fps, impform);
   if (s == NULL) {
     fprintf(stderr, "Cannot open input file %s\n", vdev);