gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/rtmp r9952: use a shared_ptr for the activ


From: rob
Subject: [Gnash-commit] /srv/bzr/gnash/rtmp r9952: use a shared_ptr for the active channels instead of a private data variabel.
Date: Sun, 04 Jan 2009 22:26:50 -0700
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9952
committer: address@hidden
branch nick: rtmp
timestamp: Sun 2009-01-04 22:26:50 -0700
message:
  use a shared_ptr for the active channels instead of a private data variabel.
modified:
  libnet/rtmp.cpp
  libnet/rtmp.h
=== modified file 'libnet/rtmp.cpp'
--- a/libnet/rtmp.cpp   2008-12-30 22:39:46 +0000
+++ b/libnet/rtmp.cpp   2009-01-05 05:26:50 +0000
@@ -197,6 +197,7 @@
 
         // each channel can have a different chunksize
            _chunksize[i] = RTMP_VIDEO_PACKET_SIZE;
+           _lastsize[i] = 0;
     }
 }
 
@@ -250,7 +251,7 @@
 boost::shared_ptr<RTMP::rtmp_head_t>
 RTMP::decodeHeader(boost::uint8_t *in)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
 
     boost::shared_ptr<RTMP::rtmp_head_t> head(new RTMP::rtmp_head_t);
     boost::uint8_t *tmpptr = in;
@@ -261,6 +262,11 @@
     head->head_size = headerSize(*tmpptr++);
     log_debug (_("The header size is %d"), head->head_size);
 
+    if (head->head_size > RTMP_MAX_HEADER_SIZE) {
+       head.reset();
+       return head;
+    }
+    
 //     cerr << "FIXME3: " << hexify(in, head->head_size, false) << endl;    
     
     if (head->head_size >= 4) {
@@ -358,7 +364,7 @@
                       size_t total_size, content_types_e type,
                       RTMPMsg::rtmp_source_e routing)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
 
     boost::shared_ptr<amf::Buffer> buf;
     switch(head_size) {
@@ -539,7 +545,7 @@
 boost::shared_ptr<RTMP::rtmp_ping_t>
 RTMP::decodePing(boost::uint8_t *data)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     
     boost::uint8_t *ptr = reinterpret_cast<boost::uint8_t *>(data);
     boost::shared_ptr<rtmp_ping_t> ping(new rtmp_ping_t);
@@ -566,7 +572,7 @@
 boost::shared_ptr<RTMP::rtmp_ping_t>
 RTMP::decodePing(amf::Buffer &buf)
 {
-    GNASH_REPORT_FUNCTION;
+//    GNASH_REPORT_FUNCTION;
     return decodePing(buf.reference());
 }
 
@@ -1042,7 +1048,7 @@
 boost::shared_ptr<amf::Buffer> 
 RTMP::recvMsg(int fd)
 {
-//    GNASH_REPORT_FUNCTION;
+    GNASH_REPORT_FUNCTION;
 
     int ret = 0;
     bool nopacket = true;
@@ -1087,14 +1093,14 @@
 // but RTMP uses a weird scheme of a standard header, and then every chunksize
 // bytes another 1 byte RTMP header. The header itself is not part of the byte
 // count.
-RTMP::queues_t *
+boost::shared_ptr<RTMP::queues_t>
 RTMP::split(amf::Buffer &buf)
 {
     GNASH_REPORT_FUNCTION;
     return split(buf.reference(), buf.allocated());
 }
 
-RTMP::queues_t *
+boost::shared_ptr<RTMP::queues_t>
 RTMP::split(boost::uint8_t *data, size_t size)
 {
     GNASH_REPORT_FUNCTION;
@@ -1102,7 +1108,9 @@
     if (data == 0) {
        log_error("Buffer pointer is invalid.");
     }
-    
+
+    boost::shared_ptr<RTMP::queues_t> channels(new RTMP::queues_t);
+       
     // split the buffer at the chunksize boundary
     boost::uint8_t *ptr = 0;
     boost::shared_ptr<rtmp_head_t> rthead(new rtmp_head_t);
@@ -1132,6 +1140,9 @@
            // Any packet with a header size greater than 1 is a
            // always a new RTMP message, so create a new Buffer to
            // hold all the data.
+           if (rthead->head_size <= 4) {
+               rthead->bodysize = _lastsize[rthead->channel];
+           }
            if ((rthead->head_size > 1)) {
                cerr << "New packet for channel #" << rthead->channel << " of 
size "
                     << (rthead->head_size + rthead->bodysize) << endl;
@@ -1142,6 +1153,7 @@
                // via the Buffer for processing later. All the data
                // goes in a queue for each channel.
                _queues[rthead->channel].push(chunk);
+//             rthead->head_size == 4
            } else {
                // Use the existing Buffer for this packet, as it's a
                // continuation messages for an existing packet. Leave
@@ -1210,12 +1222,13 @@
                }
                // This is a queue of channels with active messages. This is a
                // much smaller list to traverse when processing data than all 
64 channels.
-               _channels.push_back(&_queues[rthead->channel]);
+               channels->push_back(&_queues[rthead->channel]);
                if (pktsize < 0xffffff) {
 //                 cerr << "FIXME5: " << hexify(ptr, pktsize, true) << endl;
                    // If the packet size is in range, then append the
                    // data to the existing data to complete the message.
                    chunk->append(ptr, pktsize);
+                   _lastsize[rthead->channel] = rthead->bodysize;
                    cerr << "Adding data to existing packet for channel #" << 
rthead->channel
                         << ", read " << pktsize << " bytes." << endl;
                    ptr += pktsize;
@@ -1232,7 +1245,7 @@
        }
     }
 
-    return &_channels;
+    return channels;
 }
 
 

=== modified file 'libnet/rtmp.h'
--- a/libnet/rtmp.h     2008-12-28 19:06:41 +0000
+++ b/libnet/rtmp.h     2009-01-05 05:26:50 +0000
@@ -293,8 +293,8 @@
     // but RTMP uses a weird scheme of a standard header, and then every 
chunksize
     // bytes another 1 byte RTMP header. The header itself is not part of the 
byte
     // count.
-    queues_t *split(amf::Buffer &buf);
-    queues_t *split(boost::uint8_t *data, size_t size);
+    boost::shared_ptr<queues_t> split(amf::Buffer &buf);
+    boost::shared_ptr<queues_t> split(boost::uint8_t *data, size_t size);
 
     CQue &operator[] (size_t x) { return _queues[x]; }
     void dump();
@@ -306,9 +306,10 @@
     int         _packet_size;
     int         _mystery_word;
     size_t     _chunksize[MAX_AMF_INDEXES];
+    size_t     _lastsize[MAX_AMF_INDEXES];
     int                _timeout;
     CQue       _queues[MAX_AMF_INDEXES];
-    queues_t    _channels;
+//    queues_t    _channels;
     amf::Buffer        _buffer;
 };
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]