diff --git a/trunk/src/app/srs_app_rtc_source.cpp b/trunk/src/app/srs_app_rtc_source.cpp index 47af65645..9e08bcb15 100644 --- a/trunk/src/app/srs_app_rtc_source.cpp +++ b/trunk/src/app/srs_app_rtc_source.cpp @@ -344,8 +344,8 @@ SrsRtcSource::~SrsRtcSource() // for all consumers are auto free. consumers.clear(); - srs_freep(req); srs_freep(bridge_); + srs_freep(req); srs_freep(stream_desc_); } diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index 687644968..e3d9901bf 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -39,7 +39,6 @@ using namespace std; #include #include #include -#include // the timeout in srs_utime_t to wait encoder to republish // if timeout, close the connection. diff --git a/trunk/src/app/srs_app_source.hpp b/trunk/src/app/srs_app_source.hpp index 6bfc246c6..5ebdb4614 100644 --- a/trunk/src/app/srs_app_source.hpp +++ b/trunk/src/app/srs_app_source.hpp @@ -468,23 +468,6 @@ public: // Global singleton instance. extern SrsLiveSourceManager* _srs_sources; -// Destination type. -enum SrsBridgeDestType { - SrsBridgeDestTypeRtmp = 1, - SrsBridgeDestTypeRTC = 2, - SrsBridgeDestTypeSRT = 3, -}; - -class ISrsBridge { -public: - ISrsBridge(SrsBridgeDestType type); - virtual ~ISrsBridge(); -public: - SrsBridgeDestType get_type() const; -protected: - SrsBridgeDestType type_; -}; - // For RTMP2RTC, bridge SrsLiveSource to SrsRtcSource class ISrsLiveSourceBridge { diff --git a/trunk/src/app/srs_app_srt_source.cpp b/trunk/src/app/srs_app_srt_source.cpp index 4d4f68a31..37b5e993d 100644 --- a/trunk/src/app/srs_app_srt_source.cpp +++ b/trunk/src/app/srs_app_srt_source.cpp @@ -234,7 +234,7 @@ void SrsSrtConsumer::wait(int nb_msgs, srs_utime_t timeout) srs_cond_timedwait(mw_wait, timeout); } -ISrsSrtSourceBridge::ISrsSrtSourceBridge(SrsBridgeDestType type) : ISrsBridge(type) +ISrsSrtSourceBridge::ISrsSrtSourceBridge() { } @@ -242,8 +242,7 @@ ISrsSrtSourceBridge::~ISrsSrtSourceBridge() { } -SrsRtmpFromSrtBridge::SrsRtmpFromSrtBridge(SrsLiveSource* source) - : ISrsSrtSourceBridge(SrsBridgeDestTypeRtmp) +SrsRtmpFromSrtBridge::SrsRtmpFromSrtBridge(SrsLiveSource* source) : ISrsSrtSourceBridge() { ts_ctx_ = new SrsTsContext(); @@ -645,6 +644,7 @@ SrsSrtSource::SrsSrtSource() { req = NULL; can_publish_ = true; + bridge_ = NULL; } SrsSrtSource::~SrsSrtSource() @@ -653,11 +653,7 @@ SrsSrtSource::~SrsSrtSource() // for all consumers are auto free. consumers.clear(); - for (vector::iterator iter = bridgers_.begin(); iter != bridgers_.end(); ++iter) { - ISrsSrtSourceBridge* bridge = *iter; - srs_freep(bridge); - } - bridgers_.clear(); + srs_freep(bridge_); } srs_error_t SrsSrtSource::initialize(SrsRequest* r) @@ -707,18 +703,10 @@ void SrsSrtSource::update_auth(SrsRequest* r) req->update_auth(r); } -void SrsSrtSource::set_bridger(ISrsSrtSourceBridge *bridger) +void SrsSrtSource::set_bridge(ISrsSrtSourceBridge* bridge) { - for (vector::iterator iter = bridgers_.begin(); iter != bridgers_.end(); ++iter) { - ISrsSrtSourceBridge* b = *iter; - if (b->get_type() == bridger->get_type()) { - srs_freep(b); - *iter = bridger; - return; - } - } - - bridgers_.push_back(bridger); + srs_freep(bridge_); + bridge_ = bridge; } srs_error_t SrsSrtSource::create_consumer(SrsSrtConsumer*& consumer) @@ -765,11 +753,8 @@ srs_error_t SrsSrtSource::on_publish() return srs_error_wrap(err, "source id change"); } - for (vector::iterator iter = bridgers_.begin(); iter != bridgers_.end(); ++iter) { - ISrsSrtSourceBridge* bridge = *iter; - if ((err = bridge->on_publish()) != srs_success) { - return srs_error_wrap(err, "bridger on publish"); - } + if ((err = bridge_->on_publish()) != srs_success) { + return srs_error_wrap(err, "bridge on publish"); } SrsStatistic* stat = SrsStatistic::instance(); @@ -787,12 +772,8 @@ void SrsSrtSource::on_unpublish() can_publish_ = true; - for (vector::iterator iter = bridgers_.begin(); iter != bridgers_.end(); ++iter) { - ISrsSrtSourceBridge* bridge = *iter; - bridge->on_unpublish(); - srs_freep(bridge); - } - bridgers_.clear(); + bridge_->on_unpublish(); + srs_freep(bridge_); } srs_error_t SrsSrtSource::on_packet(SrsSrtPacket* packet) @@ -806,11 +787,8 @@ srs_error_t SrsSrtSource::on_packet(SrsSrtPacket* packet) } } - for (vector::iterator iter = bridgers_.begin(); iter != bridgers_.end(); ++iter) { - ISrsSrtSourceBridge* bridge = *iter; - if ((err = bridge->on_packet(packet)) != srs_success) { - return srs_error_wrap(err, "bridger consume message"); - } + if ((err = bridge_->on_packet(packet)) != srs_success) { + return srs_error_wrap(err, "bridge consume message"); } return err; diff --git a/trunk/src/app/srs_app_srt_source.hpp b/trunk/src/app/srs_app_srt_source.hpp index 7a4b06b3b..e916067f6 100644 --- a/trunk/src/app/srs_app_srt_source.hpp +++ b/trunk/src/app/srs_app_srt_source.hpp @@ -90,10 +90,10 @@ public: virtual void wait(int nb_msgs, srs_utime_t timeout); }; -class ISrsSrtSourceBridge : public ISrsBridge +class ISrsSrtSourceBridge { public: - ISrsSrtSourceBridge(SrsBridgeDestType type); + ISrsSrtSourceBridge(); virtual ~ISrsSrtSourceBridge(); public: virtual srs_error_t on_publish() = 0; @@ -179,7 +179,7 @@ private: // To delivery packets to clients. std::vector consumers; bool can_publish_; - std::vector bridgers_; + ISrsSrtSourceBridge* bridge_; }; #endif