From dbf0971334b77a38d387152dc0afabbb5916c146 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Wed, 25 Nov 2009 13:39:43 +0100 Subject: [PATCH] Added meaningful labels to FWP contracts --- libavformat/rtpproto.c | 9 ++++++--- libavformat/udp.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index 9d80ddf0a..ca7af2f95 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -98,7 +98,8 @@ static void url_add_option(char *buf, int buf_size, const char *fmt, ...) static void build_udp_url(char *buf, int buf_size, const char *hostname, int port, int local_port, int ttl, - int max_packet_size) + int max_packet_size, + const char *label) { snprintf(buf, buf_size, "udp://%s:%d", hostname, port); if (local_port >= 0) @@ -107,6 +108,8 @@ static void build_udp_url(char *buf, int buf_size, url_add_option(buf, buf_size, "ttl=%d", ttl); if (max_packet_size >=0) url_add_option(buf, buf_size, "pkt_size=%d", max_packet_size); + if (label) + url_add_option(buf, buf_size, "contract_label=%s", label); } /** @@ -154,7 +157,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags) } build_udp_url(buf, sizeof(buf), - hostname, port, local_port, ttl, max_packet_size); + hostname, port, local_port, ttl, max_packet_size, "RTP"); if (url_open(&s->rtp_hd, buf, flags) < 0) goto fail; local_port = udp_get_local_port(s->rtp_hd); @@ -163,7 +166,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags) /* well, should suppress localport in path */ build_udp_url(buf, sizeof(buf), - hostname, port + 1, local_port + 1, ttl, max_packet_size); + hostname, port + 1, local_port + 1, ttl, max_packet_size, "RTCP"); if (url_open(&s->rtcp_hd, buf, flags) < 0) goto fail; diff --git a/libavformat/udp.c b/libavformat/udp.c index f05d332b5..d45288e5e 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -35,6 +35,8 @@ #include #include +#include + long int udp_budget, udp_period; typedef struct { @@ -52,6 +54,7 @@ typedef struct { frsh_vres_id_t vres; frsh_send_endpoint_protocol_info_t send_pinfo; frsh_contract_t contract; + frsh_contract_label_t label; frsh_rel_time_t budget, period; } UDPContext; @@ -127,9 +130,10 @@ udp_socket_create(UDPContext *s, struct sockaddr_in *addr, int *addr_len) FRSH_CT_REGULAR); //if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_basic_params"); if (ret) return -1; - snprintf(netcont_name, sizeof(netcont_name), "net_cont%d", ++netcont_num); + snprintf(netcont_name, sizeof(netcont_name), "ffmpeg%02d", ++netcont_num); ret = frsh_contract_set_resource_and_label(&s->contract,FRSH_RT_NETWORK, - FRSH_NETPF_FWP, netcont_name); + FRSH_NETPF_FWP, + s->label[0] ? s->label : netcont_name); //if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_resource_and_label"); if (ret) return -1; @@ -254,6 +258,10 @@ static int udp_open(URLContext *h, const char *uri, int flags) if (find_info_tag(buf, sizeof(buf), "buffer_size", p)) { s->buffer_size = strtol(buf, NULL, 10); } + if (!find_info_tag(s->label, sizeof(s->label), + "contract_label", p)) { + s->label[0]=0; + } } /* fill the dest addr */ -- 2.39.2