winlin

refine code, rename SrsRtmp to SrsRtmpServer.

@@ -43,7 +43,7 @@ SrsBandwidth::~SrsBandwidth() @@ -43,7 +43,7 @@ SrsBandwidth::~SrsBandwidth()
43 { 43 {
44 } 44 }
45 45
46 -int SrsBandwidth::bandwidth_test(SrsRequest* _req, st_netfd_t stfd, SrsRtmp* _rtmp) 46 +int SrsBandwidth::bandwidth_test(SrsRequest* _req, st_netfd_t stfd, SrsRtmpServer* _rtmp)
47 { 47 {
48 int ret = ERROR_SUCCESS; 48 int ret = ERROR_SUCCESS;
49 49
@@ -32,7 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -32,7 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #include <srs_core_st.hpp> 32 #include <srs_core_st.hpp>
33 33
34 class SrsRequest; 34 class SrsRequest;
35 -class SrsRtmp; 35 +class SrsRtmpServer;
36 36
37 /** 37 /**
38 * bandwidth test agent which provides the interfaces for bandwidth check. 38 * bandwidth test agent which provides the interfaces for bandwidth check.
@@ -74,7 +74,7 @@ class SrsBandwidth @@ -74,7 +74,7 @@ class SrsBandwidth
74 { 74 {
75 private: 75 private:
76 SrsRequest* req; 76 SrsRequest* req;
77 - SrsRtmp* rtmp; 77 + SrsRtmpServer* rtmp;
78 public: 78 public:
79 SrsBandwidth(); 79 SrsBandwidth();
80 virtual ~SrsBandwidth(); 80 virtual ~SrsBandwidth();
@@ -82,7 +82,7 @@ public: @@ -82,7 +82,7 @@ public:
82 /** 82 /**
83 * do the bandwidth test. 83 * do the bandwidth test.
84 */ 84 */
85 - virtual int bandwidth_test(SrsRequest* _req, st_netfd_t stfd, SrsRtmp* _rtmp); 85 + virtual int bandwidth_test(SrsRequest* _req, st_netfd_t stfd, SrsRtmpServer* _rtmp);
86 private: 86 private:
87 virtual int get_local_ip(st_netfd_t stfd, char *&local_ip); 87 virtual int get_local_ip(st_netfd_t stfd, char *&local_ip);
88 /** 88 /**
@@ -50,7 +50,7 @@ SrsClient::SrsClient(SrsServer* srs_server, st_netfd_t client_stfd) @@ -50,7 +50,7 @@ SrsClient::SrsClient(SrsServer* srs_server, st_netfd_t client_stfd)
50 req = new SrsRequest(); 50 req = new SrsRequest();
51 res = new SrsResponse(); 51 res = new SrsResponse();
52 skt = new SrsSocket(client_stfd); 52 skt = new SrsSocket(client_stfd);
53 - rtmp = new SrsRtmp(skt); 53 + rtmp = new SrsRtmpServer(skt);
54 refer = new SrsRefer(); 54 refer = new SrsRefer();
55 #ifdef SRS_HTTP 55 #ifdef SRS_HTTP
56 http_hooks = new SrsHttpHooks(); 56 http_hooks = new SrsHttpHooks();
@@ -34,7 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -34,7 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 #include <srs_core_conn.hpp> 34 #include <srs_core_conn.hpp>
35 #include <srs_core_reload.hpp> 35 #include <srs_core_reload.hpp>
36 36
37 -class SrsRtmp; 37 +class SrsRtmpServer;
38 class SrsRequest; 38 class SrsRequest;
39 class SrsResponse; 39 class SrsResponse;
40 class SrsSource; 40 class SrsSource;
@@ -57,7 +57,7 @@ private: @@ -57,7 +57,7 @@ private:
57 SrsRequest* req; 57 SrsRequest* req;
58 SrsResponse* res; 58 SrsResponse* res;
59 SrsSocket* skt; 59 SrsSocket* skt;
60 - SrsRtmp* rtmp; 60 + SrsRtmpServer* rtmp;
61 SrsRefer* refer; 61 SrsRefer* refer;
62 #ifdef SRS_HTTP 62 #ifdef SRS_HTTP
63 SrsHttpHooks* http_hooks; 63 SrsHttpHooks* http_hooks;
@@ -206,7 +206,23 @@ int srs_complex_handshake(srs_rtmp_t rtmp) @@ -206,7 +206,23 @@ int srs_complex_handshake(srs_rtmp_t rtmp)
206 206
207 int srs_connect_app(srs_rtmp_t rtmp) 207 int srs_connect_app(srs_rtmp_t rtmp)
208 { 208 {
209 - return ERROR_SUCCESS; 209 + int ret = ERROR_SUCCESS;
  210 +
  211 + srs_assert(rtmp != NULL);
  212 + Context* context = (Context*)rtmp;
  213 +
  214 + string tcUrl = "rtmp://";
  215 + tcUrl += context->vhost;
  216 + tcUrl += ":";
  217 + tcUrl += context->port;
  218 + tcUrl += "/";
  219 + tcUrl += context->app;
  220 +
  221 + if ((ret = context->rtmp->connect_app(context->app, tcUrl)) != ERROR_SUCCESS) {
  222 + return ret;
  223 + }
  224 +
  225 + return ret;
210 } 226 }
211 227
212 int srs_play_stream(srs_rtmp_t rtmp) 228 int srs_play_stream(srs_rtmp_t rtmp)
@@ -441,73 +441,73 @@ int SrsRtmpClient::publish(string stream, int stream_id) @@ -441,73 +441,73 @@ int SrsRtmpClient::publish(string stream, int stream_id)
441 return ret; 441 return ret;
442 } 442 }
443 443
444 -SrsRtmp::SrsRtmp(ISrsProtocolReaderWriter* skt) 444 +SrsRtmpServer::SrsRtmpServer(ISrsProtocolReaderWriter* skt)
445 { 445 {
446 io = skt; 446 io = skt;
447 protocol = new SrsProtocol(skt); 447 protocol = new SrsProtocol(skt);
448 } 448 }
449 449
450 -SrsRtmp::~SrsRtmp() 450 +SrsRtmpServer::~SrsRtmpServer()
451 { 451 {
452 srs_freep(protocol); 452 srs_freep(protocol);
453 } 453 }
454 454
455 -SrsProtocol* SrsRtmp::get_protocol() 455 +SrsProtocol* SrsRtmpServer::get_protocol()
456 { 456 {
457 return protocol; 457 return protocol;
458 } 458 }
459 459
460 -void SrsRtmp::set_recv_timeout(int64_t timeout_us) 460 +void SrsRtmpServer::set_recv_timeout(int64_t timeout_us)
461 { 461 {
462 protocol->set_recv_timeout(timeout_us); 462 protocol->set_recv_timeout(timeout_us);
463 } 463 }
464 464
465 -int64_t SrsRtmp::get_recv_timeout() 465 +int64_t SrsRtmpServer::get_recv_timeout()
466 { 466 {
467 return protocol->get_recv_timeout(); 467 return protocol->get_recv_timeout();
468 } 468 }
469 469
470 -void SrsRtmp::set_send_timeout(int64_t timeout_us) 470 +void SrsRtmpServer::set_send_timeout(int64_t timeout_us)
471 { 471 {
472 protocol->set_send_timeout(timeout_us); 472 protocol->set_send_timeout(timeout_us);
473 } 473 }
474 474
475 -int64_t SrsRtmp::get_send_timeout() 475 +int64_t SrsRtmpServer::get_send_timeout()
476 { 476 {
477 return protocol->get_send_timeout(); 477 return protocol->get_send_timeout();
478 } 478 }
479 479
480 -int64_t SrsRtmp::get_recv_bytes() 480 +int64_t SrsRtmpServer::get_recv_bytes()
481 { 481 {
482 return protocol->get_recv_bytes(); 482 return protocol->get_recv_bytes();
483 } 483 }
484 484
485 -int64_t SrsRtmp::get_send_bytes() 485 +int64_t SrsRtmpServer::get_send_bytes()
486 { 486 {
487 return protocol->get_send_bytes(); 487 return protocol->get_send_bytes();
488 } 488 }
489 489
490 -int SrsRtmp::get_recv_kbps() 490 +int SrsRtmpServer::get_recv_kbps()
491 { 491 {
492 return protocol->get_recv_kbps(); 492 return protocol->get_recv_kbps();
493 } 493 }
494 494
495 -int SrsRtmp::get_send_kbps() 495 +int SrsRtmpServer::get_send_kbps()
496 { 496 {
497 return protocol->get_send_kbps(); 497 return protocol->get_send_kbps();
498 } 498 }
499 499
500 -int SrsRtmp::recv_message(SrsCommonMessage** pmsg) 500 +int SrsRtmpServer::recv_message(SrsCommonMessage** pmsg)
501 { 501 {
502 return protocol->recv_message(pmsg); 502 return protocol->recv_message(pmsg);
503 } 503 }
504 504
505 -int SrsRtmp::send_message(ISrsMessage* msg) 505 +int SrsRtmpServer::send_message(ISrsMessage* msg)
506 { 506 {
507 return protocol->send_message(msg); 507 return protocol->send_message(msg);
508 } 508 }
509 509
510 -int SrsRtmp::handshake() 510 +int SrsRtmpServer::handshake()
511 { 511 {
512 int ret = ERROR_SUCCESS; 512 int ret = ERROR_SUCCESS;
513 513
@@ -520,7 +520,7 @@ int SrsRtmp::handshake() @@ -520,7 +520,7 @@ int SrsRtmp::handshake()
520 return ret; 520 return ret;
521 } 521 }
522 522
523 -int SrsRtmp::connect_app(SrsRequest* req) 523 +int SrsRtmpServer::connect_app(SrsRequest* req)
524 { 524 {
525 int ret = ERROR_SUCCESS; 525 int ret = ERROR_SUCCESS;
526 526
@@ -559,7 +559,7 @@ int SrsRtmp::connect_app(SrsRequest* req) @@ -559,7 +559,7 @@ int SrsRtmp::connect_app(SrsRequest* req)
559 return req->discovery_app(); 559 return req->discovery_app();
560 } 560 }
561 561
562 -int SrsRtmp::set_window_ack_size(int ack_size) 562 +int SrsRtmpServer::set_window_ack_size(int ack_size)
563 { 563 {
564 int ret = ERROR_SUCCESS; 564 int ret = ERROR_SUCCESS;
565 565
@@ -578,7 +578,7 @@ int SrsRtmp::set_window_ack_size(int ack_size) @@ -578,7 +578,7 @@ int SrsRtmp::set_window_ack_size(int ack_size)
578 return ret; 578 return ret;
579 } 579 }
580 580
581 -int SrsRtmp::set_peer_bandwidth(int bandwidth, int type) 581 +int SrsRtmpServer::set_peer_bandwidth(int bandwidth, int type)
582 { 582 {
583 int ret = ERROR_SUCCESS; 583 int ret = ERROR_SUCCESS;
584 584
@@ -599,7 +599,7 @@ int SrsRtmp::set_peer_bandwidth(int bandwidth, int type) @@ -599,7 +599,7 @@ int SrsRtmp::set_peer_bandwidth(int bandwidth, int type)
599 return ret; 599 return ret;
600 } 600 }
601 601
602 -int SrsRtmp::response_connect_app(SrsRequest *req, const char* server_ip) 602 +int SrsRtmpServer::response_connect_app(SrsRequest *req, const char* server_ip)
603 { 603 {
604 int ret = ERROR_SUCCESS; 604 int ret = ERROR_SUCCESS;
605 605
@@ -644,7 +644,7 @@ int SrsRtmp::response_connect_app(SrsRequest *req, const char* server_ip) @@ -644,7 +644,7 @@ int SrsRtmp::response_connect_app(SrsRequest *req, const char* server_ip)
644 return ret; 644 return ret;
645 } 645 }
646 646
647 -void SrsRtmp::response_connect_reject(SrsRequest *req, const char* desc) 647 +void SrsRtmpServer::response_connect_reject(SrsRequest *req, const char* desc)
648 { 648 {
649 int ret = ERROR_SUCCESS; 649 int ret = ERROR_SUCCESS;
650 650
@@ -665,7 +665,7 @@ void SrsRtmp::response_connect_reject(SrsRequest *req, const char* desc) @@ -665,7 +665,7 @@ void SrsRtmp::response_connect_reject(SrsRequest *req, const char* desc)
665 return; 665 return;
666 } 666 }
667 667
668 -int SrsRtmp::on_bw_done() 668 +int SrsRtmpServer::on_bw_done()
669 { 669 {
670 int ret = ERROR_SUCCESS; 670 int ret = ERROR_SUCCESS;
671 671
@@ -683,7 +683,7 @@ int SrsRtmp::on_bw_done() @@ -683,7 +683,7 @@ int SrsRtmp::on_bw_done()
683 return ret; 683 return ret;
684 } 684 }
685 685
686 -int SrsRtmp::identify_client(int stream_id, SrsClientType& type, string& stream_name) 686 +int SrsRtmpServer::identify_client(int stream_id, SrsClientType& type, string& stream_name)
687 { 687 {
688 type = SrsClientUnknown; 688 type = SrsClientUnknown;
689 int ret = ERROR_SUCCESS; 689 int ret = ERROR_SUCCESS;
@@ -728,7 +728,7 @@ int SrsRtmp::identify_client(int stream_id, SrsClientType& type, string& stream_ @@ -728,7 +728,7 @@ int SrsRtmp::identify_client(int stream_id, SrsClientType& type, string& stream_
728 return ret; 728 return ret;
729 } 729 }
730 730
731 -int SrsRtmp::set_chunk_size(int chunk_size) 731 +int SrsRtmpServer::set_chunk_size(int chunk_size)
732 { 732 {
733 int ret = ERROR_SUCCESS; 733 int ret = ERROR_SUCCESS;
734 734
@@ -747,7 +747,7 @@ int SrsRtmp::set_chunk_size(int chunk_size) @@ -747,7 +747,7 @@ int SrsRtmp::set_chunk_size(int chunk_size)
747 return ret; 747 return ret;
748 } 748 }
749 749
750 -int SrsRtmp::start_play(int stream_id) 750 +int SrsRtmpServer::start_play(int stream_id)
751 { 751 {
752 int ret = ERROR_SUCCESS; 752 int ret = ERROR_SUCCESS;
753 753
@@ -842,7 +842,7 @@ int SrsRtmp::start_play(int stream_id) @@ -842,7 +842,7 @@ int SrsRtmp::start_play(int stream_id)
842 return ret; 842 return ret;
843 } 843 }
844 844
845 -int SrsRtmp::on_play_client_pause(int stream_id, bool is_pause) 845 +int SrsRtmpServer::on_play_client_pause(int stream_id, bool is_pause)
846 { 846 {
847 int ret = ERROR_SUCCESS; 847 int ret = ERROR_SUCCESS;
848 848
@@ -917,7 +917,7 @@ int SrsRtmp::on_play_client_pause(int stream_id, bool is_pause) @@ -917,7 +917,7 @@ int SrsRtmp::on_play_client_pause(int stream_id, bool is_pause)
917 return ret; 917 return ret;
918 } 918 }
919 919
920 -int SrsRtmp::start_fmle_publish(int stream_id) 920 +int SrsRtmpServer::start_fmle_publish(int stream_id)
921 { 921 {
922 int ret = ERROR_SUCCESS; 922 int ret = ERROR_SUCCESS;
923 923
@@ -1030,7 +1030,7 @@ int SrsRtmp::start_fmle_publish(int stream_id) @@ -1030,7 +1030,7 @@ int SrsRtmp::start_fmle_publish(int stream_id)
1030 return ret; 1030 return ret;
1031 } 1031 }
1032 1032
1033 -int SrsRtmp::fmle_unpublish(int stream_id, double unpublish_tid) 1033 +int SrsRtmpServer::fmle_unpublish(int stream_id, double unpublish_tid)
1034 { 1034 {
1035 int ret = ERROR_SUCCESS; 1035 int ret = ERROR_SUCCESS;
1036 1036
@@ -1088,7 +1088,7 @@ int SrsRtmp::fmle_unpublish(int stream_id, double unpublish_tid) @@ -1088,7 +1088,7 @@ int SrsRtmp::fmle_unpublish(int stream_id, double unpublish_tid)
1088 return ret; 1088 return ret;
1089 } 1089 }
1090 1090
1091 -int SrsRtmp::start_flash_publish(int stream_id) 1091 +int SrsRtmpServer::start_flash_publish(int stream_id)
1092 { 1092 {
1093 int ret = ERROR_SUCCESS; 1093 int ret = ERROR_SUCCESS;
1094 1094
@@ -1116,7 +1116,7 @@ int SrsRtmp::start_flash_publish(int stream_id) @@ -1116,7 +1116,7 @@ int SrsRtmp::start_flash_publish(int stream_id)
1116 return ret; 1116 return ret;
1117 } 1117 }
1118 1118
1119 -int SrsRtmp::identify_create_stream_client(SrsCreateStreamPacket* req, int stream_id, SrsClientType& type, string& stream_name) 1119 +int SrsRtmpServer::identify_create_stream_client(SrsCreateStreamPacket* req, int stream_id, SrsClientType& type, string& stream_name)
1120 { 1120 {
1121 int ret = ERROR_SUCCESS; 1121 int ret = ERROR_SUCCESS;
1122 1122
@@ -1169,7 +1169,7 @@ int SrsRtmp::identify_create_stream_client(SrsCreateStreamPacket* req, int strea @@ -1169,7 +1169,7 @@ int SrsRtmp::identify_create_stream_client(SrsCreateStreamPacket* req, int strea
1169 return ret; 1169 return ret;
1170 } 1170 }
1171 1171
1172 -int SrsRtmp::identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsClientType& type, string& stream_name) 1172 +int SrsRtmpServer::identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsClientType& type, string& stream_name)
1173 { 1173 {
1174 int ret = ERROR_SUCCESS; 1174 int ret = ERROR_SUCCESS;
1175 1175
@@ -1193,7 +1193,7 @@ int SrsRtmp::identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsClientType @@ -1193,7 +1193,7 @@ int SrsRtmp::identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsClientType
1193 return ret; 1193 return ret;
1194 } 1194 }
1195 1195
1196 -int SrsRtmp::identify_flash_publish_client(SrsPublishPacket* req, SrsClientType& type, string& stream_name) 1196 +int SrsRtmpServer::identify_flash_publish_client(SrsPublishPacket* req, SrsClientType& type, string& stream_name)
1197 { 1197 {
1198 int ret = ERROR_SUCCESS; 1198 int ret = ERROR_SUCCESS;
1199 1199
@@ -1203,7 +1203,7 @@ int SrsRtmp::identify_flash_publish_client(SrsPublishPacket* req, SrsClientType& @@ -1203,7 +1203,7 @@ int SrsRtmp::identify_flash_publish_client(SrsPublishPacket* req, SrsClientType&
1203 return ret; 1203 return ret;
1204 } 1204 }
1205 1205
1206 -int SrsRtmp::identify_play_client(SrsPlayPacket* req, SrsClientType& type, string& stream_name) 1206 +int SrsRtmpServer::identify_play_client(SrsPlayPacket* req, SrsClientType& type, string& stream_name)
1207 { 1207 {
1208 int ret = ERROR_SUCCESS; 1208 int ret = ERROR_SUCCESS;
1209 1209
@@ -146,14 +146,14 @@ public: @@ -146,14 +146,14 @@ public:
146 * such as connect to vhost/app, play stream, get audio/video data. 146 * such as connect to vhost/app, play stream, get audio/video data.
147 */ 147 */
148 // TODO: FIXME: rename to SrsRtmpServer 148 // TODO: FIXME: rename to SrsRtmpServer
149 -class SrsRtmp 149 +class SrsRtmpServer
150 { 150 {
151 private: 151 private:
152 SrsProtocol* protocol; 152 SrsProtocol* protocol;
153 ISrsProtocolReaderWriter* io; 153 ISrsProtocolReaderWriter* io;
154 public: 154 public:
155 - SrsRtmp(ISrsProtocolReaderWriter* skt);  
156 - virtual ~SrsRtmp(); 155 + SrsRtmpServer(ISrsProtocolReaderWriter* skt);
  156 + virtual ~SrsRtmpServer();
157 public: 157 public:
158 virtual SrsProtocol* get_protocol(); 158 virtual SrsProtocol* get_protocol();
159 virtual void set_recv_timeout(int64_t timeout_us); 159 virtual void set_recv_timeout(int64_t timeout_us);