mirror of
				https://github.com/ossrs/srs.git
				synced 2025-03-09 15:49:59 +00:00 
			
		
		
		
	For #1339, Support HTTP-FLV params.
This commit is contained in:
		
						commit
						b9750baa52
					
				
					 5 changed files with 30 additions and 11 deletions
				
			
		
							
								
								
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -29,3 +29,5 @@
 | 
			
		|||
 | 
			
		||||
# Apple-specific garbage files.
 | 
			
		||||
.AppleDouble
 | 
			
		||||
 | 
			
		||||
.idea
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -213,6 +213,7 @@ Please select according to languages:
 | 
			
		|||
 | 
			
		||||
### V2 changes
 | 
			
		||||
 | 
			
		||||
* v2.0, 2019-04-05, Merge [#1339][bug #1339], Support HTTP-FLV params. 2.0.262
 | 
			
		||||
* v2.0, 2018-12-01, Merge [#1274][bug #1274], Upgrade to FFMPEG 4.1 and X264 157. 2.0.261
 | 
			
		||||
* v2.0, 2018-11-11, Merge [#1261][bug #1261], Support `_definst_` for Wowza. 2.0.260
 | 
			
		||||
* v2.0, 2018-11-11, Merge [#1263][bug #1263], Fix string trim bug. 2.0.259
 | 
			
		||||
| 
						 | 
				
			
			@ -1446,6 +1447,7 @@ Winlin
 | 
			
		|||
[bug #1263]: https://github.com/ossrs/srs/issues/1263
 | 
			
		||||
[bug #1261]: https://github.com/ossrs/srs/issues/1261
 | 
			
		||||
[bug #1274]: https://github.com/ossrs/srs/pull/1274
 | 
			
		||||
[bug #1339]: https://github.com/ossrs/srs/pull/1339
 | 
			
		||||
[bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx
 | 
			
		||||
 | 
			
		||||
[bug #735]: https://github.com/ossrs/srs/issues/735
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -489,13 +489,13 @@ srs_error_t SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage
 | 
			
		|||
{
 | 
			
		||||
    srs_error_t err = srs_success;
 | 
			
		||||
    
 | 
			
		||||
    if ((err = http_hooks_on_play()) != srs_success) {
 | 
			
		||||
    if ((err = http_hooks_on_play(r)) != srs_success) {
 | 
			
		||||
        return srs_error_wrap(err, "http hook");
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    err = do_serve_http(w, r);
 | 
			
		||||
    
 | 
			
		||||
    http_hooks_on_stop();
 | 
			
		||||
    http_hooks_on_stop(r);
 | 
			
		||||
    
 | 
			
		||||
    return err;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -658,13 +658,18 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
 | 
			
		|||
    return err;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
srs_error_t SrsLiveStream::http_hooks_on_play()
 | 
			
		||||
srs_error_t SrsLiveStream::http_hooks_on_play(ISrsHttpMessage* r)
 | 
			
		||||
{
 | 
			
		||||
    srs_error_t err = srs_success;
 | 
			
		||||
    
 | 
			
		||||
    if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
 | 
			
		||||
        return err;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Create request to report for the specified connection.
 | 
			
		||||
    SrsHttpMessage* hr = dynamic_cast<SrsHttpMessage*>(r);
 | 
			
		||||
    SrsRequest* nreq = hr->to_request(req->vhost);
 | 
			
		||||
    SrsAutoFree(SrsRequest, nreq);
 | 
			
		||||
    
 | 
			
		||||
    // the http hooks will cause context switch,
 | 
			
		||||
    // so we must copy all hooks for the on_connect may freed.
 | 
			
		||||
| 
						 | 
				
			
			@ -672,7 +677,7 @@ srs_error_t SrsLiveStream::http_hooks_on_play()
 | 
			
		|||
    vector<string> hooks;
 | 
			
		||||
    
 | 
			
		||||
    if (true) {
 | 
			
		||||
        SrsConfDirective* conf = _srs_config->get_vhost_on_play(req->vhost);
 | 
			
		||||
        SrsConfDirective* conf = _srs_config->get_vhost_on_play(nreq->vhost);
 | 
			
		||||
        
 | 
			
		||||
        if (!conf) {
 | 
			
		||||
            return err;
 | 
			
		||||
| 
						 | 
				
			
			@ -683,19 +688,24 @@ srs_error_t SrsLiveStream::http_hooks_on_play()
 | 
			
		|||
    
 | 
			
		||||
    for (int i = 0; i < (int)hooks.size(); i++) {
 | 
			
		||||
        std::string url = hooks.at(i);
 | 
			
		||||
        if ((err = SrsHttpHooks::on_play(url, req)) != srs_success) {
 | 
			
		||||
            return srs_error_wrap(err, "rtmp on_play %s", url.c_str());
 | 
			
		||||
        if ((err = SrsHttpHooks::on_play(url, nreq)) != srs_success) {
 | 
			
		||||
            return srs_error_wrap(err, "http on_play %s", url.c_str());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    return err;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SrsLiveStream::http_hooks_on_stop()
 | 
			
		||||
void SrsLiveStream::http_hooks_on_stop(ISrsHttpMessage* r)
 | 
			
		||||
{
 | 
			
		||||
    if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Create request to report for the specified connection.
 | 
			
		||||
    SrsHttpMessage* hr = dynamic_cast<SrsHttpMessage*>(r);
 | 
			
		||||
    SrsRequest* nreq = hr->to_request(req->vhost);
 | 
			
		||||
    SrsAutoFree(SrsRequest, nreq);
 | 
			
		||||
    
 | 
			
		||||
    // the http hooks will cause context switch,
 | 
			
		||||
    // so we must copy all hooks for the on_connect may freed.
 | 
			
		||||
| 
						 | 
				
			
			@ -703,7 +713,7 @@ void SrsLiveStream::http_hooks_on_stop()
 | 
			
		|||
    vector<string> hooks;
 | 
			
		||||
    
 | 
			
		||||
    if (true) {
 | 
			
		||||
        SrsConfDirective* conf = _srs_config->get_vhost_on_stop(req->vhost);
 | 
			
		||||
        SrsConfDirective* conf = _srs_config->get_vhost_on_stop(nreq->vhost);
 | 
			
		||||
        
 | 
			
		||||
        if (!conf) {
 | 
			
		||||
            srs_info("ignore the empty http callback: on_stop");
 | 
			
		||||
| 
						 | 
				
			
			@ -715,7 +725,7 @@ void SrsLiveStream::http_hooks_on_stop()
 | 
			
		|||
    
 | 
			
		||||
    for (int i = 0; i < (int)hooks.size(); i++) {
 | 
			
		||||
        std::string url = hooks.at(i);
 | 
			
		||||
        SrsHttpHooks::on_stop(url, req);
 | 
			
		||||
        SrsHttpHooks::on_stop(url, nreq);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    return;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -229,8 +229,8 @@ public:
 | 
			
		|||
    virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
 | 
			
		||||
private:
 | 
			
		||||
    virtual srs_error_t do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
 | 
			
		||||
    virtual srs_error_t http_hooks_on_play();
 | 
			
		||||
    virtual void http_hooks_on_stop();
 | 
			
		||||
    virtual srs_error_t http_hooks_on_play(ISrsHttpMessage* r);
 | 
			
		||||
    virtual void http_hooks_on_stop(ISrsHttpMessage* r);
 | 
			
		||||
    virtual srs_error_t streaming_send_messages(ISrsBufferEncoder* enc, SrsSharedPtrMessage** msgs, int nb_msgs);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -593,6 +593,11 @@ SrsRequest* SrsHttpMessage::to_request(string vhost)
 | 
			
		|||
    req->tcUrl = "rtmp://" + vhost + "/" + req->app;
 | 
			
		||||
    req->pageUrl = get_request_header("Referer");
 | 
			
		||||
    req->objectEncoding = 0;
 | 
			
		||||
 | 
			
		||||
    std::string query = _uri->get_query();
 | 
			
		||||
    if (!query.empty()) {
 | 
			
		||||
        req->tcUrl = req->tcUrl + "?" + query;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    srs_discovery_tc_url(req->tcUrl, req->schema, req->host, req->vhost, req->app, req->stream, req->port, req->param);
 | 
			
		||||
    req->strip();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue