winlin

read the http flv stream.

@@ -35,6 +35,7 @@ using namespace std; @@ -35,6 +35,7 @@ using namespace std;
35 #include <srs_app_pithy_print.hpp> 35 #include <srs_app_pithy_print.hpp>
36 #include <srs_app_http.hpp> 36 #include <srs_app_http.hpp>
37 #include <srs_app_http_conn.hpp> 37 #include <srs_app_http_conn.hpp>
  38 +#include <srs_core_autofree.hpp>
38 39
39 SrsAppCasterFlv::SrsAppCasterFlv(SrsConfDirective* c) 40 SrsAppCasterFlv::SrsAppCasterFlv(SrsConfDirective* c)
40 { 41 {
@@ -78,12 +79,24 @@ void SrsAppCasterFlv::remove(SrsConnection* c) @@ -78,12 +79,24 @@ void SrsAppCasterFlv::remove(SrsConnection* c)
78 conns.erase(it); 79 conns.erase(it);
79 } 80 }
80 } 81 }
81 - 82 +#define SRS_HTTP_FLV_STREAM_BUFFER 4096
82 int SrsAppCasterFlv::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) 83 int SrsAppCasterFlv::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
83 { 84 {
84 int ret = ERROR_SUCCESS; 85 int ret = ERROR_SUCCESS;
85 86
86 - srs_trace("flv: handle request at %s", r->path().c_str()); 87 + srs_info("flv: handle request at %s", r->path().c_str());
  88 +
  89 + char* buffer = new char[SRS_HTTP_FLV_STREAM_BUFFER];
  90 + SrsAutoFree(char, buffer);
  91 +
  92 + ISrsHttpResponseReader* rr = r->body_reader();
  93 + while (!rr->eof()) {
  94 + int nb_read = 0;
  95 + if ((ret = rr->read(buffer, SRS_HTTP_FLV_STREAM_BUFFER, &nb_read)) != ERROR_SUCCESS) {
  96 + return ret;
  97 + }
  98 + srs_trace("flv: read %dB from %s", nb_read, r->path().c_str());
  99 + }
87 100
88 return ret; 101 return ret;
89 } 102 }