]> rtime.felk.cvut.cz Git - frescor/streamer.git/blobdiff - streamer.c
Allow to select video4linux version 1 formant from commandline.
[frescor/streamer.git] / streamer.c
index 84a320f153353439261e4dd1c5285c318e7115b0..4185c1689f8e3808311de72c43ff158d8d1de3cf 100644 (file)
@@ -6,8 +6,9 @@
 #include <unistd.h>
 #include <stdlib.h>
 
-#include <avformat.h>
-//#include <avdevice.h>
+#include <libavformat/avformat.h>
+#include <libavdevice/avdevice.h>
+#include <libswscale/swscale.h>
 
 #include "input.h"
 #include "output.h"
 
 static const char *sdp_file = "sdp.txt";
 static const char *vdev = "/dev/video0";
-static const char *dst = "224.10.20.30";
+static const char *dst = "127.0.0.1";
 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)
 {
@@ -37,7 +39,7 @@ static int args_parse(int argc, char *argv[])
 {
   int v;
 
-  while ((v = getopt(argc, argv, "w:h:r:d:")) >= 0) {
+  while ((v = getopt(argc, argv, "w:h:r:d:m:i:")) >= 0) {
     switch (v) {
       case 'w':
         width = atoi(optarg);
@@ -54,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);
@@ -74,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);
 
@@ -105,7 +114,7 @@ int main(int argc, char *argv[])
       AVPacket *opkt;
 
       pkt->pts += s->streams[pkt->stream_index]->start_time;
-      rt_job_start(pkt->pts);
+      //rt_job_start(pkt->pts);
       f = pkt_decode(s, pkt);
       if (f) {
         opkt = pkt_encode(os, f);
@@ -113,7 +122,7 @@ int main(int argc, char *argv[])
           pkt_send(os, opkt);
         }
       }
-      rt_job_end();
+      //rt_job_end();
       av_free_packet(pkt);
     }
   }