]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Added meaningful labels to FWP contracts
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 25 Nov 2009 12:39:43 +0000 (13:39 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 25 Nov 2009 12:39:43 +0000 (13:39 +0100)
libavformat/rtpproto.c
libavformat/udp.c

index 9d80ddf0a7be7722006b2df0f38ca97b5af8f875..ca7af2f95f1b8222ec71b1c354e7e574a7d3a3e0 100644 (file)
@@ -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;
 
index f05d332b52c0aea7288f04c0a26f2f01967b1078..d45288e5e27b79588924428cb21db29590bc9d22 100644 (file)
@@ -35,6 +35,8 @@
 #include <sys/time.h>
 
 #include <frsh.h>
+#include <frsh_core_types.h>
+
 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 */