2 * Copyright (c) 2008 Luca Abeni
4 * This is free software; see GPL.txt
9 #include <libavformat/avformat.h>
10 #include <libavdevice/avdevice.h>
11 #include <libswscale/swscale.h>
18 #include "streamer_config.h"
20 #ifdef CONFIG_STREAMER_WITH_FRSH
24 extern long int udp_budget, udp_period;
26 static const char *sdp_file = "sdp.txt";
27 static const char *vdev = "/dev/video0";
28 static const char *dst = "127.0.0.1";
29 static int dport = 20000;
30 static int width = 352;
31 static int height = 288;
33 static const char *impform = "video4linux2";
35 static void sdp_print(AVFormatContext *s, const char *fname)
40 f = fopen(fname, "w");
41 avf_sdp_create(&s, 1, sdp, sizeof(sdp));
42 fprintf(f, "%s\n", sdp);
46 static int args_parse(int argc, char *argv[])
50 while ((v = getopt(argc, argv, "w:h:r:d:m:i:")) >= 0) {
56 height = atoi(optarg);
69 if(!strcmp(impform, "v4l"))
70 impform = "video4linux";
71 else if(!strcmp(impform, "v4l2"))
72 impform = "video4linux2";
75 fprintf(stderr, "%s: illegal option %c\n", argv[0], v);
83 int main(int argc, char *argv[])
85 AVFormatContext *s, *os;
88 #ifdef CONFIG_STREAMER_WITH_FRSH
90 if (ret) PERROR_AND_EXIT(ret, "frsh_init1");
91 #endif /*CONFIG_STREAMER_WITH_FRSH*/
96 avcodec_register_all();
98 avdevice_register_all();
100 args_parse(argc, argv);
102 s = open_input_stream(vdev, width, height, fps, impform);
104 fprintf(stderr, "Cannot open input file %s\n", vdev);
109 os = open_output_stream(dst, dport, CODEC_TYPE_VIDEO);
111 fprintf(stderr, "Cannot open output stream\n");
115 os->streams[0]->codec->width = s->streams[0]->codec->width;
116 os->streams[0]->codec->height = s->streams[0]->codec->height;
117 os->streams[0]->codec->time_base = s->streams[0]->codec->time_base;
118 codec_connect(s->streams[0]->codec, os->streams[0]->codec);
120 dump_format(os, 0, os->filename, 1);
121 sdp_print(os, sdp_file);
125 pkt = read_input_packet(s);
132 pkt->pts += s->streams[pkt->stream_index]->start_time;
133 //rt_job_start(pkt->pts);
134 f = pkt_decode(s, pkt);
136 opkt = pkt_encode(os, f);