gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/rtmp r9985: move where th cache size is de


From: rob
Subject: [Gnash-commit] /srv/bzr/gnash/rtmp r9985: move where th cache size is defined. add overload for sendMsg() to take a raw pointer and byte count.
Date: Sat, 14 Feb 2009 15:42:54 -0700
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9985
committer: address@hidden
branch nick: rtmp
timestamp: Sat 2009-02-14 15:42:54 -0700
message:
  move where th cache size is defined. add overload for sendMsg() to take a raw 
pointer and byte count.
modified:
  cygnal/README
  cygnal/rtmp_server.cpp
  cygnal/rtmp_server.h
  libnet/cache.h
  libnet/http.cpp
  libnet/rtmp.cpp
  libnet/rtmp.h
  testsuite/libnet.all/Makefile.am
  testsuite/libnet.all/test_http.cpp
  testsuite/libnet.all/test_rtmp.cpp
  utilities/flvdumper.cpp
=== modified file 'cygnal/README'
--- a/cygnal/README     2008-12-18 03:40:16 +0000
+++ b/cygnal/README     2009-02-14 22:42:54 +0000
@@ -139,5 +139,36 @@
 
 rtmp_handler - ditto.
 
+../../../rtmp-logs/red5-rtmpstream-test.log
+connect #3
+ping    #2
+_result #3
+createStream #3        -> streamid #2
+_result #3     -> streamid #2, #1
+_play   #8
+ping    #2
+onStatus #4    <- reset
+onStatus #4    <- play
+deleteStream #3
+
+.Reset 12 bytes
+.Play  8 bytes
+
+
+../../../rtmp-logs/ngrep-flowplayer-seek.log
+connect #3
+ping    #2
+_result #3
+createStream #3        -> streamid #3
+_result #3     -> streamid #d
+_play   #8
+ping    #2
+onStatus #4    <- reset -> streamid #1
+onStatus #5    <- play -> streamid #1
+onStatus #5    <- data start
+onMetaData #5  <- flv file
+
+.Reset 12 bytes
+.Play  8 bytes
 
 

=== modified file 'cygnal/rtmp_server.cpp'
--- a/cygnal/rtmp_server.cpp    2009-02-13 23:45:08 +0000
+++ b/cygnal/rtmp_server.cpp    2009-02-14 22:42:54 +0000
@@ -825,7 +825,7 @@
 //         cache.addFile(url, filestream);     FIXME: always reload from disk 
for now.
        
        // Oopen the file and read the first chunk into memory
-       if (filestream->open(filespec)) {
+       if (!filestream->open(filespec)) {
            return false;
        } else {
            // Get the file size for the HTTP header
@@ -853,18 +853,31 @@
            getbytes = filestream->getPagesize();
        }
        if (filesize >= CACHE_LIMIT) {
+           if (sendMsg(fd, getChannel(), RTMP::HEADER_12, filesize,
+                       RTMP::NOTIFY, RTMPMsg::FROM_SERVER, filestream->get(),
+                       filesize)) {
+           }
            do {
                filestream->loadToMem(page);
-               ret = writeNet(fd, filestream->get(), getbytes);
-               if (ret <= 0) {
-                   break;
+//             ret = writeNet(fd, filestream->get(), getbytes);
+//             if (ret <= 0) {
+//                 break;
+//             }
+               if (sendMsg(fd, getChannel(), RTMP::HEADER_4, filesize,
+                           RTMP::NOTIFY, RTMPMsg::FROM_SERVER, 
filestream->get(),
+                           getbytes)) {
                }
                bytes_read += ret;
                page += filestream->getPagesize();
            } while (bytes_read <= filesize);
        } else {
            filestream->loadToMem(filesize, 0);
-           ret = writeNet(fd, filestream->get(), filesize);
+//         ret = writeNet(fd, filestream->get(), filesize);
+           if (sendMsg(fd, getChannel(), RTMP::HEADER_12, filesize,
+                       RTMP::NOTIFY, RTMPMsg::FROM_SERVER, 
filestream->get()+24,
+                       filesize-24)) {
+           }
+                                       
        }
        filestream->close();
 #ifdef USE_STATS_CACHE
@@ -894,7 +907,7 @@
     RTMPMsg *body = 0;
     static bool initialize = true;
     static bool echo = false;
-    
+    bool sendfile = false;
     log_debug(_("Starting RTMP Handler for fd #%d, tid %ld"),
              args->netfd, get_thread_id());
     
@@ -911,6 +924,8 @@
     boost::shared_ptr<amf::Element> swfurl;
     boost::shared_ptr<amf::Buffer> response;
 
+    string basepath = docroot;
+
     RTMP::rtmp_headersize_e response_head_size = RTMP::HEADER_12;
     
     // This handler is called everytime there is RTMP data on a socket to 
process the
@@ -1044,6 +1059,16 @@
                                        tcurl  = body->findProperty("tcUrl");
                                        if (tcurl) {
                                            log_debug("Client request for 
remote file is: %s", tcurl->to_string());
+                                           string path = tcurl->to_string();
+                                           string::size_type start = 
path.find("://", 0) + 4;
+                                           if (start != string::npos) {
+                                               string::size_type end = 
path.find("/", start);
+                                               if (end != string::npos) {
+                                                   basepath += 
path.substr(end, path.size());
+                                               }
+                                           }
+                                           log_debug("Base path to files from 
connect is: %s", basepath);
+                                                                               
                                        }
                                        swfurl = body->findProperty("swfUrl");
                                        if (swfurl) {
@@ -1095,16 +1120,15 @@
                                        response_head_size = RTMP::HEADER_8;
                                        double clientid = 
rtmp->createClientID();
 //                                     response = 
rtmp->encodeResult(RTMPMsg::NS_PLAY_RESET, filespec);
-// //                                  body->setChannel(4);
+                                       body->setChannel(4);
 //                                     rtmp->sendMsg(args->netfd, 
body->getChannel(), response_head_size, response->allocated(),
 //                                                       RTMP::INVOKE, 
RTMPMsg::FROM_SERVER, *response);
 //                                     response.reset();
-//                                     body->setChannel(4);
+//                                     rtmp->setChannel(4);
+//                                     rtmp->sendMsg(args->netfd, 
body->getChannel(), response_head_size, response->allocated(),
                                        response = 
rtmp->encodeResult(RTMPMsg::NS_PLAY_START, filespec, clientid);
-                                       rtmp->sendMsg(args->netfd, 
body->getChannel(), response_head_size, response->allocated(),
-                                                     RTMP::INVOKE, 
RTMPMsg::FROM_SERVER, *response);
-                                       rtmp->sendFile(args->netfd, filespec);
 //                                     body->dump();
+                                       sendfile = true;
                                    }
                                    if (body->getMethodName() == "recData") {
                                    }
@@ -1116,6 +1140,12 @@
                                    } else {
                                        log_error("Couldn't send response to 
client!");
                                    }
+                                   if (sendfile) {
+                                       string fullspec = basepath;
+                                       fullspec += filespec;
+                                       rtmp->sendFile(args->netfd, fullspec);
+                                       sendfile = false;
+                                   } 
                                }
                            }
                        }
@@ -1179,7 +1209,8 @@
                                if (body) {
                                    if (body->getMethodName() == "connect") {
                                        response = 
rtmp->encodeResult(RTMPMsg::NC_CONNECT_SUCCESS);
-                                   } else if (body->getMethodName() == 
"createStream") {
+                                   } else if (body->getMethodName() == "createS
+tream") {
                                        response = 
rtmp->encodeResult(RTMPMsg::NS_DATA_START);
                                    } else {
                                        response = 
rtmp->encodeResult(RTMPMsg::NS_FAILED);

=== modified file 'cygnal/rtmp_server.h'
--- a/cygnal/rtmp_server.h      2009-02-13 23:45:08 +0000
+++ b/cygnal/rtmp_server.h      2009-02-14 22:42:54 +0000
@@ -76,6 +76,7 @@
     typedef boost::char_separator<char> Sep;
     typedef boost::tokenizer<Sep> Tok;
     gnash::DiskStream::filetype_e  _filetype;
+    std::string                _docroot;
     std::string                _filespec;
     boost::uint32_t     _filesize;
     std::map<boost::uint16_t, amf::Element> _references;

=== modified file 'libnet/cache.h'
--- a/libnet/cache.h    2008-11-20 20:58:49 +0000
+++ b/libnet/cache.h    2009-02-14 22:42:54 +0000
@@ -36,6 +36,9 @@
 ///    This is the main namespace for Gnash and it's libraries.
 namespace gnash {
 
+// max size of files to map enirely into the cache
+static const size_t CACHE_LIMIT = 102400000;
+
 // forward instatiate
 //class DiskStream;
 

=== modified file 'libnet/http.cpp'
--- a/libnet/http.cpp   2009-02-02 02:07:06 +0000
+++ b/libnet/http.cpp   2009-02-14 22:42:54 +0000
@@ -79,9 +79,6 @@
 // FIXME, this seems too small to me.  --gnu
 static const int readsize = 1024;
 
-// max size of files to map enirely into the cache
-static const size_t CACHE_LIMIT = 102400000;
-
 static Cache& cache = Cache::getDefaultInstance();
 
 HTTP::HTTP() 

=== modified file 'libnet/rtmp.cpp'
--- a/libnet/rtmp.cpp   2009-02-05 00:42:44 +0000
+++ b/libnet/rtmp.cpp   2009-02-14 22:42:54 +0000
@@ -831,6 +831,15 @@
              RTMPMsg::rtmp_source_e routing, amf::Buffer &data)
 {
 //    GNASH_REPORT_FUNCTION;
+    return sendMsg(fd, channel, head_size, total_size, type, routing, 
data.reference(), data.allocated());
+}
+
+bool
+RTMP::sendMsg(int fd, int channel, rtmp_headersize_e head_size,
+             size_t total_size, content_types_e type,
+             RTMPMsg::rtmp_source_e routing, boost::uint8_t *data, size_t size)
+{
+//  GNASH_REPORT_FUNCTION;
     int ret = 0;
     
     // We got some bogus parameters
@@ -859,11 +868,11 @@
     }    
 
     // now send the data
-    while (nbytes <= data.allocated()) {
+    while (nbytes <= size) {
        // The last bit of data is usually less than the packet size,
        // so we write less data of course.
-       if ((data.allocated() - nbytes) < static_cast<signed 
int>(_chunksize[channel])) {
-           partial = data.allocated() - nbytes;
+       if ((size - nbytes) < static_cast<signed int>(_chunksize[channel])) {
+           partial = size - nbytes;
        }
        // After the first packet, only send the single byte
        // continuation packet.
@@ -871,7 +880,7 @@
            int ret = writeNet(fd, *cont_head);
        }
        // write the data to the client
-       ret = writeNet(fd, data.reference() + nbytes, partial);
+       ret = writeNet(fd, data + nbytes, partial);
        if (ret == -1) {
            log_error("Couldn't write the RTMP body!");
            return false;
@@ -1099,14 +1108,14 @@
 boost::shared_ptr<RTMP::queues_t>
 RTMP::split(amf::Buffer &buf)
 {
-//    GNASH_REPORT_FUNCTION;
+    GNASH_REPORT_FUNCTION;
     return split(buf.reference(), buf.allocated());
 }
 
 boost::shared_ptr<RTMP::queues_t>
 RTMP::split(boost::uint8_t *data, size_t size)
 {
-//    GNASH_REPORT_FUNCTION;
+    GNASH_REPORT_FUNCTION;
 
     if (data == 0) {
        log_error("Buffer pointer is invalid.");
@@ -1225,7 +1234,6 @@
                }
                // 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]);
                if (pktsize < 0xffffff) {
 //                 cerr << "FIXME5: " << hexify(ptr, pktsize, true) << endl;
                    // If the packet size is in range, then append the
@@ -1238,6 +1246,13 @@
                } else {
                    log_error("Packet size out of range! %d, %d", 
rthead->bodysize, pktsize);
                }
+               // add this packet to the list of active channels if we've 
gotten
+               // all the data.
+//             if (chunk->allocated() - 5 >= rthead->bodysize) {
+//                 cerr << "Bodysize: " << rthead->bodysize 
+//                      << " Allocated Chunksize: " << chunk->allocated() << 
endl;
+               channels->push_back(&_queues[rthead->channel]);
+//             }
            } else {
                log_error("RTMP packet size is out of range! %d, %d", 
rthead->bodysize, pktsize);
                break;

=== modified file 'libnet/rtmp.h'
--- a/libnet/rtmp.h     2009-02-04 21:20:09 +0000
+++ b/libnet/rtmp.h     2009-02-14 22:42:54 +0000
@@ -281,6 +281,9 @@
     bool sendMsg(int fd, int channel, rtmp_headersize_e head_size,
              size_t total_size, content_types_e type,
              RTMPMsg::rtmp_source_e routing, amf::Buffer &data);
+    bool sendMsg(int fd, int channel, rtmp_headersize_e head_size,
+             size_t total_size, content_types_e type,
+                RTMPMsg::rtmp_source_e routing, boost::uint8_t *data, size_t 
size);
     
 #if 0
     // Send a Msg, and expect a response back of some kind.

=== modified file 'testsuite/libnet.all/Makefile.am'
--- a/testsuite/libnet.all/Makefile.am  2009-01-02 01:11:48 +0000
+++ b/testsuite/libnet.all/Makefile.am  2009-02-14 22:42:54 +0000
@@ -49,11 +49,11 @@
 
 check_PROGRAMS = \
        test_cque \
-       test_handler \
        test_http \
        test_diskstream \
        test_cache \
        test_rtmp 
+#      test_handler
 
 generate_amfbins_SOURCES = generate_amfbins.cpp
 generate_amfbins_LDADD = $(AM_LDFLAGS) 

=== modified file 'testsuite/libnet.all/test_http.cpp'
--- a/testsuite/libnet.all/test_http.cpp        2009-01-18 07:01:34 +0000
+++ b/testsuite/libnet.all/test_http.cpp        2009-02-14 22:42:54 +0000
@@ -363,8 +363,11 @@
 
 // User Agent: Lynx/2.8.6rel.2 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.8b
 
-    boost::uint8_t *field1 = (boost::uint8_t *)"GET /index.html HTTP/1.1";
+    Buffer field1;
+    field1 = "GET /index.html HTTP/1.1";
+    //    boost::uint8_t *field1 = (boost::uint8_t *)"GET /index.html 
HTTP/1.1";
     HTTP http1;
+    //    http1.extractCommand(field1);
     http1.extractCommand(field1);
     if ((http1.getVersion()->minor == 1) && (http1.getFilespec() == 
"/index.html")) {
         runtest.pass ("HTTP::extractCommand(HTTP/1.1)");
@@ -372,19 +375,26 @@
         runtest.fail ("HTTP::extractCommand(HTTP/1.1)");
     }
 
-    boost::uint8_t *field2 = (boost::uint8_t *)"GET /index.html HTTP/1.0";
+    Buffer field2;
+    field2 = "GET /index.html HTTP/1.0";
     HTTP http2;
     http2.extractCommand(field2);
-    if ((http1.getVersion()->minor == 0) && (http1.getFilespec() == 
"/index.html")) {
+    if ((http2.getVersion()->minor == 0) && (http2.getFilespec() == 
"/index.html")) {
         runtest.pass ("HTTP::extractCommand(HTTP/1.0)");
     } else {
         runtest.fail ("HTTP::extractCommand(HTTP/1.0)");
     }
 
-    boost::uint8_t *field3 = (boost::uint8_t *)"GET 
/software/gnash/tests/flvplayer.swf?file=http://localhost/software/gnash/tests/Ouray_Ice_Festival_Climbing_Competition.flv
 HTTP/1.1\r\n";
+    Buffer field3;
+    field3 = "GET 
/software/gnash/tests/flvplayer.swf?file=http://localhost/software/gnash/tests/Ouray_Ice_Festival_Climbing_Competition.flv
 HTTP/1.1\r\n";
     HTTP http3;
     http3.extractCommand(field3);
-    if ((http1.getVersion()->minor == 1) && (http1.getFilespec() == 
"/software/gnash/tests/flvplayer.swf") && (http1.getParams() == 
"file=http://localhost/software/gnash/tests/Ouray_Ice_Festival_Climbing_Competition.flv";))
 {
+    if (http3.getFilespec() == "/software/gnash/tests/flvplayer.swf") {
+        runtest.pass ("HTTP::extractCommand(filespec)");
+    } else {
+        runtest.fail ("HTTP::extractCommand(params)");
+    }
+    if (http3.getParams() == 
"file=http://localhost/software/gnash/tests/Ouray_Ice_Festival_Climbing_Competition.flv";)
 {
         runtest.pass ("HTTP::extractCommand(params)");
     } else {
         runtest.fail ("HTTP::extractCommand(params)");

=== modified file 'testsuite/libnet.all/test_rtmp.cpp'
--- a/testsuite/libnet.all/test_rtmp.cpp        2009-01-05 05:25:42 +0000
+++ b/testsuite/libnet.all/test_rtmp.cpp        2009-02-14 22:42:54 +0000
@@ -679,7 +679,7 @@
 //         dsLgYohb
     boost::shared_ptr<amf::Buffer> hex4(new Buffer("02 00 08 6f 6e 53 74 61 74 
75 73 00 00 00 00 00 00 00 00 00 05 03 00 05 6c 65 76 65 6c 02 00 06 73 74 61 
74 75 73 00 04 63 6f 64 65 02 00 14 4e 65 74 53 74 72 65 61 6d 2e 50 6c 61 79 
2e 52 65 73 65 74 00 0b 64 65 73 63 72 69 70 74 69 6f 6e 02 00 2a 50 6c 61 79 
69 6e 67 20 61 6e 64 20 72 65 73 65 74 74 69 6e 67 20 50 44 5f 45 6e 67 6c 69 
73 68 5f 4c 6f 77 40 32 30 30 31 2e 00 07 64 65 74 61 69 6c 73 02 00 13 50 44 
5f 45 6e 67 6c 69 73 68 5f 4c 6f 77 40 32 30 30 31 00 08 63 6c 69 65 6e 74 69 
64 02 00 08 64 73 4c 67 59 6f 68 62 00 00 09"));
     RTMPMsg *msg4 = rtmp.decodeMsgBody(*hex4);
-//    msg4->dump();
+    msg4->dump();
 //    std::vector<amf::Element *> hell4 = msg4->getElements();
     if ((msg4->getStatus() ==  RTMPMsg::NS_PLAY_RESET)
         && (msg4->getMethodName() == "onStatus")
@@ -697,7 +697,7 @@
 // Data.Start
     boost::shared_ptr<amf::Buffer> hex5(new Buffer("02 00 08 6f 6e 53 74 61 74 
75 73 03 00 04 63 6f 64 65 02 00 14 4e 65 74 53 74 72 65 61 6d 2e 44 61 74 61 
2e 53 74 61 72 74 00 00 09"));
     RTMPMsg *msg5 = rtmp.decodeMsgBody(*hex5);
-//    msg5->dump();
+    msg5->dump();
 //    cout << msg5->getStreamID() << endl;
 //    std::vector<amf::Element *> hell4 = msg4->getElements();
     if ((msg5->getStatus() ==  RTMPMsg::NS_DATA_START)

=== modified file 'utilities/flvdumper.cpp'
--- a/utilities/flvdumper.cpp   2008-12-20 17:11:55 +0000
+++ b/utilities/flvdumper.cpp   2009-02-14 22:42:54 +0000
@@ -223,7 +223,7 @@
                 }
                 ifs.read(reinterpret_cast<char *>(buf->reference()), 
sizeof(Flv::flv_tag_t));
                 tag  = flv.decodeTagHeader(buf);
-                
+                flv.dump();
                 total -= sizeof(Flv::previous_size_t);
                 size_t bodysize = flv.convert24(tag->bodysize);
                 if (bodysize == 0) {


reply via email to

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