gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/rtmp r10036: tweak logic of ending buffer


From: rob
Subject: [Gnash-commit] /srv/bzr/gnash/rtmp r10036: tweak logic of ending buffer so merging works for bigger Buffers.
Date: Wed, 25 Mar 2009 16:30:54 -0600
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10036
committer: address@hidden
branch nick: rtmp
timestamp: Wed 2009-03-25 16:30:54 -0600
message:
  tweak logic of ending buffer so merging works for bigger Buffers.
modified:
  libnet/cque.cpp
  libnet/cque.h
=== modified file 'libnet/cque.cpp'
--- a/libnet/cque.cpp   2009-02-25 22:33:03 +0000
+++ b/libnet/cque.cpp   2009-03-25 22:30:54 +0000
@@ -195,8 +195,17 @@
 // Merge sucessive buffers into one single larger buffer. This is for some
 // protocols, than have very long headers.
 boost::shared_ptr<amf::Buffer> 
+CQue::merge()
+{
+//     GNASH_REPORT_FUNCTION;
+    
+    return merge(_que.front());
+}
+
+boost::shared_ptr<amf::Buffer> 
 CQue::merge(boost::shared_ptr<amf::Buffer> start)
 {
+    GNASH_REPORT_FUNCTION;
     // Find iterator to first element to merge
     que_t::iterator from = std::find(_que.begin(), _que.end(), start); 
     if (from == _que.end()) {
@@ -211,27 +220,29 @@
     for (que_t::iterator e=_que.end(); to!=e; ++to) {
         size_t sz = (*to)->size();
         totalsize += sz;
-        if (sz < amf::NETBUFSIZE) break;
-    }
-    if (to == _que.end()) {
-        // Didn't find an element ending the merge
-        return start;          // FIXME:
-    }
-
+//     log_debug("%s: Totalsize is %s", __PRETTY_FUNCTION__, totalsize);
+        if (sz < amf::NETBUFSIZE) {
+           break;
+       }
+    }
+    totalsize += 24;
+//     log_debug("%s: Final Totalsize is %s", __PRETTY_FUNCTION__, totalsize);
+    
     // Merge all elements in a single buffer. We have totalsize now.
     boost::shared_ptr<amf::Buffer> newbuf(new Buffer(totalsize));
-    boost::uint8_t *tmp = newbuf->reference();
-    ++to;
     for (que_t::iterator i=from; i!=to; ++i) {
-        boost::shared_ptr<amf::Buffer> buf = *i;
-        size_t sz = buf->size();
-        std::copy(buf->reference(), buf->reference() + sz, tmp);
+//     log_debug("%s: copying %d bytes, space left is %d, totalsize is %d", 
__PRETTY_FUNCTION__,
+//               (*i)->allocated(), newbuf->spaceLeft(), totalsize);
+//     (*i)->dump();
+//     if (newbuf->spaceLeft() >= (*i)->allocated()) {
+           *newbuf += *i;
+//     }
+       
        //
        // NOTE: If we're the buffer owners, it is safe to delete
        //       the buffer now.
        // delete buf;
        //
-        tmp += sz;
     }
 
     // Finally erase all merged elements, and replace with the composite one

=== modified file 'libnet/cque.h'
--- a/libnet/cque.h     2009-03-16 23:34:13 +0000
+++ b/libnet/cque.h     2009-03-25 22:30:54 +0000
@@ -69,7 +69,8 @@
     void remove(boost::shared_ptr<amf::Buffer> it);
     // Merge sucessive buffers into one single larger buffer. This is for some
     // protocols, than have very long headers.
-    boost::shared_ptr<amf::Buffer> merge(boost::shared_ptr<amf::Buffer> begin);
+    boost::shared_ptr<amf::Buffer> DSOEXPORT 
merge(boost::shared_ptr<amf::Buffer> begin);
+    boost::shared_ptr<amf::Buffer> DSOEXPORT merge();
 
     boost::shared_ptr<amf::Buffer> operator[] (int index) { return 
_que[index]; };
     


reply via email to

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