}
}
-AVFormatContext *open_input_stream(const char *fname)
+AVFormatContext *open_input_stream(const char *fname, int w, int h, int fps)
{
AVFormatContext *s;
AVInputFormat *fmt;
memset(¶m, 0, sizeof(AVFormatParameters));
/* FIXME: Set these!!! */
- param.width = 352;
- param.height = 288;
+ param.width = w;
+ param.height = h;
param.pix_fmt = PIX_FMT_YUV420P;
- param.time_base.den = 25;
+ param.time_base.den = fps;
param.time_base.num = 1;
fmt = av_find_input_format("video4linux2");
res = av_open_input_file(&s, fname, fmt, 0, ¶m);
-AVFormatContext *open_input_stream(const char *fname);
+AVFormatContext *open_input_stream(const char *fname, int w, int h, int fps);
void close_input_stream(AVFormatContext *s);
AVPacket *read_input_packet(AVFormatContext *s);
+#include <unistd.h>
+#include <stdlib.h>
+
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "codec.h"
#include "rt.h"
+static const char *vdev = "/dev/video0";
+static const char *dst = "224.10.20.30";
+static int dport = 20000;
+static int width = 352;
+static int height = 288;
+static int fps = 25;
+
static void sdp_print(AVFormatContext *s)
{
char sdp[2048];
fclose(f);
}
+static int args_parse(int argc, char *argv[])
+{
+ int v;
+
+ while ((v = getopt(argc, argv, "w:h:r:d:")) >= 0) {
+ switch (v) {
+ case 'w':
+ width = atoi(optarg);
+ break;
+ case 'h':
+ height = atoi(optarg);
+ break;
+ case 'r':
+ fps = atoi(optarg);
+ break;
+ case 'd':
+ vdev = optarg;
+ break;
+ case 'm':
+ dst = optarg;
+ break;
+ default: /* ’?’ */
+ fprintf(stderr, "%s: illegal option %c\n", argv[0], v);
+ exit(-1);
+ }
+ }
+
+ return 0;
+}
int main(int argc, char *argv[])
{
av_register_all();
avdevice_register_all();
- s = open_input_stream(argv[1]);
+ args_parse(argc, argv);
+
+ s = open_input_stream(vdev, width, height, fps);
if (s == NULL) {
- fprintf(stderr, "Cannot open input file %s\n", argv[1]);
+ fprintf(stderr, "Cannot open input file %s\n", vdev);
return -1;
}
codec_open(s);
- os = open_output_stream("224.10.20.30", 20000, CODEC_TYPE_VIDEO);
+ os = open_output_stream(dst, dport, CODEC_TYPE_VIDEO);
if (os == NULL) {
fprintf(stderr, "Cannot open output stream\n");