From 267b62db50e78e2f380ee4715574f8f1e896c614 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Sat, 28 Nov 2009 19:30:05 +0100 Subject: [PATCH] Contract parameters are based on encoding bitrate --- streamer.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/streamer.c b/streamer.c index 3f0646c..128a154 100644 --- a/streamer.c +++ b/streamer.c @@ -28,7 +28,7 @@ #include /*temporrary solution to pass network parameters */ -extern long int avformat_frsh_budget, avformat_frsh_period; +extern long int frsh_rtp_budget, frsh_rtp_period_ms, frsh_rtp_deadline_ms; #endif /*CONFIG_STREAMER_WITH_FRSH*/ static const char *sdp_file = "sdp.txt"; @@ -37,6 +37,7 @@ static const char *dst = "127.0.0.1"; static int dport = 20000; static int width = 320; static int height = 240; +static int bitrate = 1000000; int fps = 15; static const char *impform = "video4linux2"; AVFormatContext *s, *os; @@ -62,11 +63,8 @@ usage(void) printf(" -r video device [%s]\n", vdev); printf(" -m destination IP address\n"); printf(" -i input video device format [%s]\n", impform); - printf(" -o destination port [%d]\n", dport); - #ifdef CONFIG_STREAMER_WITH_FRSH - printf(" -b network budget\n"); - printf(" -p network period for given budget\n"); - #endif /*CONFIG_STREAMER_WITH_FRSH*/ + printf(" -p destination port [%d]\n", dport); + printf(" -b bitrate in b/s [%d]\n", bitrate); #ifdef CONFIG_OC_ULUT printf(" -l |=,...\n"); #endif /*CONFIG_OC_ULUT*/ @@ -76,9 +74,9 @@ static int args_parse(int argc, char *argv[]) { int v; - while ((v = getopt(argc, argv, "o:w:h:r:d:m:i:l:b:p:")) >= 0) { + while ((v = getopt(argc, argv, "w:h:r:d:m:i:l:b:p:")) >= 0) { switch (v) { - case 'o': + case 'p': dport = atoi(optarg); break; case 'w': @@ -90,6 +88,9 @@ static int args_parse(int argc, char *argv[]) case 'r': fps = atoi(optarg); break; + case 'b': + bitrate = atoi(optarg); + break; case 'd': vdev = optarg; break; @@ -103,15 +104,6 @@ static int args_parse(int argc, char *argv[]) else if(!strcmp(impform, "v4l2")) impform = "video4linux2"; break; - #ifdef CONFIG_STREAMER_WITH_FRSH - case 'b': - udp_budget = atol(optarg); - break; - case 'p': - udp_period = atol(optarg); - break; - #endif /*CONFIG_STREAMER_WITH_FRSH*/ - #ifdef CONFIG_OC_ULUT case 'l': ul_log_domain_arg2levels(optarg); @@ -241,8 +233,9 @@ int main(int argc, char *argv[]) if (ret) PERROR_AND_EXIT(ret, "frsh_init1"); /* fill default network contract params */ - avformat_frsh_budget = 50000; - avformat_frsh_period = 500; + frsh_rtp_budget = bitrate/8; + frsh_rtp_period_ms = 1000; + frsh_rtp_deadline_ms = 1000/fps; #endif /*CONFIG_FFMPEG_WITH_FRSH*/ avcodec_register_all(); @@ -267,7 +260,7 @@ int main(int argc, char *argv[]) os->streams[0]->codec->width = s->streams[0]->codec->width; os->streams[0]->codec->height = s->streams[0]->codec->height; os->streams[0]->codec->time_base = s->streams[0]->codec->time_base; - os->streams[0]->codec->bit_rate = 1000000; + os->streams[0]->codec->bit_rate = bitrate; codec_connect(s->streams[0]->codec, os->streams[0]->codec); out_codec_open(os); dump_format(os, 0, os->filename, 1); -- 2.39.2