winlin

support push flv stream over HTTP POST to SRS.

@@ -522,6 +522,8 @@ Supported operating systems and hardware: @@ -522,6 +522,8 @@ Supported operating systems and hardware:
522 [#250](https://github.com/simple-rtmp-server/srs/issues/250). 522 [#250](https://github.com/simple-rtmp-server/srs/issues/250).
523 1. [experiment] Support push RTSP to SRS, read 523 1. [experiment] Support push RTSP to SRS, read
524 [#133](https://github.com/simple-rtmp-server/srs/issues/133). 524 [#133](https://github.com/simple-rtmp-server/srs/issues/133).
  525 +1. [experiment] Support push flv stream over HTTP POST to SRS, read
  526 +[wiki](https://github.com/simple-rtmp-server/srs/wiki/v2_CN_Streamer#push-http-flv-to-srs).
525 1. Start [2.0release branch](https://github.com/simple-rtmp-server/srs/tree/2.0release). 527 1. Start [2.0release branch](https://github.com/simple-rtmp-server/srs/tree/2.0release).
526 1. [no-plan] Support <500ms latency, FRSC(Fast RTMP-compatible Stream Channel tech). 528 1. [no-plan] Support <500ms latency, FRSC(Fast RTMP-compatible Stream Channel tech).
527 1. [no-plan] Support RTMP 302 redirect [#92](https://github.com/simple-rtmp-server/srs/issues/92). 529 1. [no-plan] Support RTMP 302 redirect [#92](https://github.com/simple-rtmp-server/srs/issues/92).
@@ -560,6 +562,7 @@ Supported operating systems and hardware: @@ -560,6 +562,7 @@ Supported operating systems and hardware:
560 562
561 ### SRS 2.0 history 563 ### SRS 2.0 history
562 564
  565 +* v2.0, 2015-05-10, support push flv stream over HTTP POST to SRS.
563 * v2.0, 2015-04-20, support ingest hls live stream to RTMP. 566 * v2.0, 2015-04-20, support ingest hls live stream to RTMP.
564 * v2.0, 2015-04-15, for [#383](https://github.com/simple-rtmp-server/srs/issues/383), support mix_correct algorithm. 2.0.161. 567 * v2.0, 2015-04-15, for [#383](https://github.com/simple-rtmp-server/srs/issues/383), support mix_correct algorithm. 2.0.161.
565 * v2.0, 2015-04-13, for [#381](https://github.com/simple-rtmp-server/srs/issues/381), support reap hls/ts by gop or not. 2.0.160. 568 * v2.0, 2015-04-13, for [#381](https://github.com/simple-rtmp-server/srs/issues/381), support reap hls/ts by gop or not. 2.0.160.
@@ -175,6 +175,17 @@ int SrsDynamicHttpConn::proxy(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std: @@ -175,6 +175,17 @@ int SrsDynamicHttpConn::proxy(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std:
175 return ret; 175 return ret;
176 } 176 }
177 177
  178 + ret = do_proxy(rr, &dec);
  179 + close();
  180 +
  181 + return ret;
  182 +}
  183 +
  184 +int SrsDynamicHttpConn::do_proxy(ISrsHttpResponseReader* rr, SrsFlvDecoder* dec)
  185 +{
  186 + int ret = ERROR_SUCCESS;
  187 +
  188 + char pps[4];
178 while (!rr->eof()) { 189 while (!rr->eof()) {
179 pprint->elapse(); 190 pprint->elapse();
180 191
@@ -185,7 +196,7 @@ int SrsDynamicHttpConn::proxy(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std: @@ -185,7 +196,7 @@ int SrsDynamicHttpConn::proxy(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std:
185 char type; 196 char type;
186 int32_t size; 197 int32_t size;
187 u_int32_t time; 198 u_int32_t time;
188 - if ((ret = dec.read_tag_header(&type, &size, &time)) != ERROR_SUCCESS) { 199 + if ((ret = dec->read_tag_header(&type, &size, &time)) != ERROR_SUCCESS) {
189 if (!srs_is_client_gracefully_close(ret)) { 200 if (!srs_is_client_gracefully_close(ret)) {
190 srs_error("flv: proxy tag header failed. ret=%d", ret); 201 srs_error("flv: proxy tag header failed. ret=%d", ret);
191 } 202 }
@@ -193,7 +204,7 @@ int SrsDynamicHttpConn::proxy(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std: @@ -193,7 +204,7 @@ int SrsDynamicHttpConn::proxy(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std:
193 } 204 }
194 205
195 char* data = new char[size]; 206 char* data = new char[size];
196 - if ((ret = dec.read_tag_data(data, size)) != ERROR_SUCCESS) { 207 + if ((ret = dec->read_tag_data(data, size)) != ERROR_SUCCESS) {
197 srs_freep(data); 208 srs_freep(data);
198 if (!srs_is_client_gracefully_close(ret)) { 209 if (!srs_is_client_gracefully_close(ret)) {
199 srs_error("flv: proxy tag data failed. ret=%d", ret); 210 srs_error("flv: proxy tag data failed. ret=%d", ret);
@@ -208,7 +219,7 @@ int SrsDynamicHttpConn::proxy(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std: @@ -208,7 +219,7 @@ int SrsDynamicHttpConn::proxy(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std:
208 return ret; 219 return ret;
209 } 220 }
210 221
211 - if ((ret = dec.read_previous_tag_size(pps)) != ERROR_SUCCESS) { 222 + if ((ret = dec->read_previous_tag_size(pps)) != ERROR_SUCCESS) {
212 if (!srs_is_client_gracefully_close(ret)) { 223 if (!srs_is_client_gracefully_close(ret)) {
213 srs_error("flv: proxy tag header pps failed. ret=%d", ret); 224 srs_error("flv: proxy tag header pps failed. ret=%d", ret);
214 } 225 }
@@ -42,6 +42,8 @@ class SrsRtmpClient; @@ -42,6 +42,8 @@ class SrsRtmpClient;
42 class SrsStSocket; 42 class SrsStSocket;
43 class SrsRequest; 43 class SrsRequest;
44 class SrsPithyPrint; 44 class SrsPithyPrint;
  45 +class ISrsHttpResponseReader;
  46 +class SrsFlvDecoder;
45 47
46 #include <srs_app_st.hpp> 48 #include <srs_app_st.hpp>
47 #include <srs_app_listener.hpp> 49 #include <srs_app_listener.hpp>
@@ -98,6 +100,7 @@ public: @@ -98,6 +100,7 @@ public:
98 public: 100 public:
99 virtual int proxy(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std::string o); 101 virtual int proxy(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std::string o);
100 private: 102 private:
  103 + virtual int do_proxy(ISrsHttpResponseReader* rr, SrsFlvDecoder* dec);
101 virtual int rtmp_write_packet(char type, u_int32_t timestamp, char* data, int size); 104 virtual int rtmp_write_packet(char type, u_int32_t timestamp, char* data, int size);
102 private: 105 private:
103 // connect to rtmp output url. 106 // connect to rtmp output url.
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR 2 32 #define VERSION_MAJOR 2
33 #define VERSION_MINOR 0 33 #define VERSION_MINOR 0
34 -#define VERSION_REVISION 161 34 +#define VERSION_REVISION 162
35 35
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"