]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Reworked assignment of FRSH contract parameters
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 28 Nov 2009 18:26:09 +0000 (19:26 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 28 Nov 2009 18:26:09 +0000 (19:26 +0100)
Now we can specify also deadline. The assigned values differ for RTCP and
RTP streams because RCP needs much less bandwidth.

Sending was changed to sync. When async was used, the packets would
be queued and delivered with delay, which is not what we want. In future,
we might add an endpoint parameter to specify the size of queue and use
async again.

libavformat/frsh.c
libavformat/rtpproto.c

index 90e6f6020d3676e4258fa470b823f1590ca6571b..d4fae188a2fcc5fa2a390b7c4b75832d99c61cee 100644 (file)
@@ -36,8 +36,6 @@
 #include <frsh.h>
 #include <frsh_core_types.h>
 
-long int avformat_frsh_budget, avformat_frsh_period;
-
 typedef struct {
     int frsh_fd;
     int ttl;
@@ -54,7 +52,7 @@ typedef struct {
        frsh_send_endpoint_protocol_info_t send_pinfo;
        frsh_contract_t contract;
        frsh_contract_label_t label;
-       frsh_rel_time_t budget, period;
+       frsh_rel_time_t budget, period, deadline;
 } FRSHContext;
 
 #define FRSH_TX_BUF_SIZE 32768
@@ -91,8 +89,6 @@ frsh_output_socket_create(FRSHContext *s)
     addr_len = sizeof(addr);
 
        /* set params for contract */
-       frsh_network_bytes_to_budget(FRSH_NETPF_FWP, avformat_frsh_budget, &s->budget);
-       s->period = fosa_msec_to_rel_time(avformat_frsh_period);
        s->send_pinfo.body = NULL;              
        
        frsh_fd = frsh_send_endpoint_create(FRSH_NETPF_FWP, 
@@ -123,6 +119,11 @@ frsh_output_socket_create(FRSHContext *s)
        //if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_resource_and_label");
        if (ret) return -1;
 
+       if (frsh_rel_time_to_nsec(s->deadline) > 0) {
+               ret = frsh_contract_set_timing_reqs(&s->contract, false, &s->deadline);
+               if (ret) return -1;
+       }
+
        ret = frsh_contract_negotiate(&s->contract, &s->vres);
        //if (ret) PERROR_AND_EXIT(ret, "frsh_contract_negotiate");
        if (ret) return -1;
@@ -260,6 +261,15 @@ static int frsh_open(URLContext *h, const char *uri, int flags)
                          "contract_label", p)) {
                s->label[0]=0;
         }
+        if (find_info_tag(buf, sizeof(buf), "budget", p)) {
+               frsh_network_bytes_to_budget(FRSH_NETPF_FWP, strtol(buf, NULL, 10), &s->budget);
+        }
+        if (find_info_tag(buf, sizeof(buf), "period", p)) {
+               s->period=frsh_msec_to_rel_time(strtol(buf, NULL, 10));
+        }
+        if (find_info_tag(buf, sizeof(buf), "deadline", p)) {
+               s->deadline=frsh_msec_to_rel_time(strtol(buf, NULL, 10));
+        }
     }
 
     /* fill the dest addr */
@@ -336,7 +346,7 @@ static int frsh_write(URLContext *h, uint8_t *buf, int size)
     FRSHContext *s = h->priv_data;
     int ret;
        
-       ret = frsh_send_async(s->sepoint, buf, size);
+       ret = frsh_send_sync(s->sepoint, buf, size);
        return ret;
 }
 
@@ -347,6 +357,7 @@ static int frsh_close(URLContext *h)
        
        frsh_send_endpoint_unbind(s->sepoint);
        ret = frsh_contract_cancel(s->vres);
+       frsh_contract_destroy(s->contract);
        return ret;
 }
 
index 727c799619801d4104b29f6151a153353d21e8b0..a18bf558557fe6ea09512846a4db8400d070bd3d 100644 (file)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+int frsh_rtp_budget=0, frsh_rtp_period_ms=0, frsh_rtp_deadline_ms=0;
+
 /**
  * @file libavformat/rtpproto.c
  * RTP protocol
@@ -109,7 +111,7 @@ static void build_udp_url(char *buf, int buf_size,
                           const char *hostname, int port,
                           int local_port, int ttl,
                           int max_packet_size,
-                         const char *label)
+                         const char *label, int budget, int period_ms, int deadline_ms)
 {
     snprintf(buf, buf_size, URL_PROTO"://%s:%d", hostname, port);
     if (local_port >= 0)
@@ -120,6 +122,12 @@ static void build_udp_url(char *buf, int buf_size,
         url_add_option(buf, buf_size, "pkt_size=%d", max_packet_size);
     if (label)
         url_add_option(buf, buf_size, "contract_label=%s", label);
+    if (budget >=0)
+        url_add_option(buf, buf_size, "budget=%d", budget);
+    if (period_ms >=0)
+        url_add_option(buf, buf_size, "period=%d", period_ms);
+    if (deadline_ms >=0)
+        url_add_option(buf, buf_size, "deadline=%d", deadline_ms);
 }
 
 /**
@@ -167,7 +175,8 @@ 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, "RTP");
+                  hostname, port, local_port, ttl, max_packet_size, "RTP",
+                 frsh_rtp_budget, frsh_rtp_period_ms, frsh_rtp_deadline_ms);
     if (url_open(&s->rtp_hd, buf, flags) < 0)
         goto fail;
     local_port = udp_get_local_port(s->rtp_hd);
@@ -176,7 +185,8 @@ 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, "RTCP");
+                  hostname, port + 1, local_port + 1, ttl, max_packet_size, "RTCP",
+                 1000, 100*1000, 0);
     if (url_open(&s->rtcp_hd, buf, flags) < 0)
         goto fail;