~ubuntu-branches/ubuntu/raring/gpac/raring

« back to all changes in this revision

Viewing changes to src/ietf/rtsp_session.c

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2007-01-24 23:34:57 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070124233457-zzlls8afkt0nyakj
Tags: 0.4.2~rc2-0ubuntu1
* New upstream release
  * Most notably MP4 tagging support via MP4Box -itags
* debian/patches/01_64bits.dpatch: dropped; included upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
GF_Err RTSP_UnpackURL(char *sURL, char *Server, u16 *Port, char *Service, Bool *useTCP)
36
36
{
37
37
        char schema[10], *test, text[1024], *retest;
38
 
        u32 i;
 
38
        u32 i, len;
 
39
        Bool is_ipv6;
39
40
        if (!sURL) return GF_BAD_PARAM;
40
41
 
41
42
        strcpy(Server, "");
69
70
        if (!stricmp(schema, "rtsp")) *useTCP = 1;
70
71
 
71
72
        //check for port
72
 
        retest = strstr(test, ":");
 
73
        retest = strrchr(test, ':');
 
74
        /*IPV6 address*/
 
75
        if (retest && strchr(retest, ']')) retest = NULL;
 
76
 
73
77
        if (retest && strstr(retest, "/")) {
74
78
                retest += 1;
75
79
                i=0;
82
86
                *Port = atoi(text);
83
87
        }
84
88
        //get the server name
85
 
        strcpy(text, test);
 
89
        is_ipv6 = 0;
 
90
        len = strlen(test);
86
91
        i=0;
87
 
        while (i<strlen(text)) {
88
 
                if ( (text[i] == '/') || (text[i] == ':') ) break;
 
92
        while (i<len) {
 
93
                if (test[i]=='[') is_ipv6 = 1;
 
94
                else if (test[i]==']') is_ipv6 = 0;
 
95
                if ( (test[i] == '/') || (!is_ipv6 && (test[i] == ':')) ) break;
89
96
                text[i] = test[i];
90
97
                i += 1;
91
98
        }
278
285
        if (!sess->connection) {
279
286
                sess->connection = gf_sk_new(sess->ConnectionType);
280
287
                if (!sess->connection) return GF_OUT_OF_MEM;
281
 
                if (sess->SockBufferSize) gf_sk_set_buffer_size(sess->connection, 0, sess->SockBufferSize);
282
288
        }
283
289
        //the session is down, reconnect
284
290
        e = gf_sk_connect(sess->connection, sess->Server, sess->Port);
285
291
        if (e) return e;
286
292
 
 
293
        if (sess->SockBufferSize) gf_sk_set_buffer_size(sess->connection, 0, sess->SockBufferSize);
 
294
 
287
295
        if (!sess->http && sess->HasTunnel) {
288
296
                e = gf_rtsp_http_tunnel_start(sess, "toto is the king of RTSP");
289
297
                if (e) return e;
318
326
static GF_TCPChan *GetTCPChannel(GF_RTSPSession *sess, u8 rtpID, u8 rtcpID, Bool RemoveIt)
319
327
{
320
328
        GF_TCPChan *ptr;
321
 
        u32 i;
322
 
        for (i=0; i<gf_list_count(sess->TCPChannels); i++) {
 
329
        u32 i, count = gf_list_count(sess->TCPChannels);
 
330
        for (i=0; i<count; i++) {
323
331
                ptr = gf_list_get(sess->TCPChannels, i);
324
332
                if (ptr->rtpID == rtpID) goto exit;;
325
333
                if (ptr->rtcpID == rtcpID) goto exit;
644
652
                gf_sk_del(new_conn);
645
653
                return NULL;
646
654
        }
647
 
        e = gf_sk_set_blocking(new_conn, 1);
 
655
        e = gf_sk_set_block_mode(new_conn, 1);
648
656
        if (e) {
649
657
                gf_sk_del(new_conn);
650
658
                return NULL;
737
745
        u32 i;
738
746
        u8 id;
739
747
        GF_TCPChan *ch;
740
 
 
741
748
        id = 0;
742
 
        for (i=0; i<gf_list_count(sess->TCPChannels); i++) {
743
 
                ch = gf_list_get(sess->TCPChannels, i);
 
749
        i=0;
 
750
        while ((ch = gf_list_enum(sess->TCPChannels, &i))) {
744
751
                if (ch->rtpID >= id) id = ch->rtpID + 1;
745
752
                if (ch->rtcpID >= id) id = ch->rtcpID + 1;
746
753
        }