From 5b199249d0f4a4baa8796bca4429388d0463773d Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 8 Jul 2020 19:01:33 +0800 Subject: [PATCH] RTC: Rename SrsRtcSource to SrsRtcStream --- trunk/src/app/srs_app_rtc_conn.cpp | 6 +-- trunk/src/app/srs_app_rtc_conn.hpp | 10 ++--- trunk/src/app/srs_app_rtc_server.cpp | 4 +- trunk/src/app/srs_app_rtc_source.cpp | 58 ++++++++++++++-------------- trunk/src/app/srs_app_rtc_source.hpp | 32 +++++++-------- trunk/src/app/srs_app_source.cpp | 2 +- 6 files changed, 56 insertions(+), 56 deletions(-) diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index eec8598c3..acae80ebd 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -378,7 +378,7 @@ srs_error_t SrsRtcPlayStream::cycle() { srs_error_t err = srs_success; - SrsRtcSource* source = NULL; + SrsRtcStream* source = NULL; SrsRequest* req = session_->req; if ((err = _srs_rtc_sources->fetch_or_create(req, &source)) != srs_success) { @@ -470,7 +470,7 @@ srs_error_t SrsRtcPlayStream::cycle() } } -srs_error_t SrsRtcPlayStream::send_packets(SrsRtcSource* source, const vector& pkts, SrsRtcOutgoingInfo& info) +srs_error_t SrsRtcPlayStream::send_packets(SrsRtcStream* source, const vector& pkts, SrsRtcOutgoingInfo& info) { srs_error_t err = srs_success; @@ -1864,7 +1864,7 @@ SrsContextId SrsRtcConnection::context_id() return cid; } -srs_error_t SrsRtcConnection::initialize(SrsRtcSource* source, SrsRequest* r, bool is_publisher, string username, SrsContextId context_id) +srs_error_t SrsRtcConnection::initialize(SrsRtcStream* source, SrsRequest* r, bool is_publisher, string username, SrsContextId context_id) { srs_error_t err = srs_success; diff --git a/trunk/src/app/srs_app_rtc_conn.hpp b/trunk/src/app/srs_app_rtc_conn.hpp index d20958347..880fdbc3f 100644 --- a/trunk/src/app/srs_app_rtc_conn.hpp +++ b/trunk/src/app/srs_app_rtc_conn.hpp @@ -50,7 +50,7 @@ class SrsStunPacket; class SrsRtcServer; class SrsRtcConnection; class SrsSharedPtrMessage; -class SrsRtcSource; +class SrsRtcStream; class SrsRtpPacket2; class ISrsCodec; class SrsRtpNackForReceiver; @@ -226,7 +226,7 @@ public: public: virtual srs_error_t cycle(); private: - srs_error_t send_packets(SrsRtcSource* source, const std::vector& pkts, SrsRtcOutgoingInfo& info); + srs_error_t send_packets(SrsRtcStream* source, const std::vector& pkts, SrsRtcOutgoingInfo& info); srs_error_t do_send_packets(const std::vector& pkts, SrsRtcOutgoingInfo& info); public: void nack_fetch(std::vector& pkts, uint32_t ssrc, uint16_t seq); @@ -264,7 +264,7 @@ private: SrsRtpNackForReceiver* audio_nack_; private: SrsRequest* req; - SrsRtcSource* source; + SrsRtcStream* source; // Simulators. int nn_simulate_nack_drop; private: @@ -347,7 +347,7 @@ private: // TODO: FIXME: Support reload. bool encrypt; SrsRequest* req; - SrsRtcSource* source_; + SrsRtcStream* source_; SrsSdp remote_sdp; SrsSdp local_sdp; public: @@ -378,7 +378,7 @@ public: SrsContextId context_id(); public: // Before initialize, user must set the local SDP, which is used to inititlize DTLS. - srs_error_t initialize(SrsRtcSource* source, SrsRequest* r, bool is_publisher, std::string username, SrsContextId context_id); + srs_error_t initialize(SrsRtcStream* source, SrsRequest* r, bool is_publisher, std::string username, SrsContextId context_id); // The peer address may change, we can identify that by STUN messages. srs_error_t on_stun(SrsUdpMuxSocket* skt, SrsStunPacket* r); srs_error_t on_dtls(char* data, int nb_data); diff --git a/trunk/src/app/srs_app_rtc_server.cpp b/trunk/src/app/srs_app_rtc_server.cpp index 348f8b46a..97ca437b3 100644 --- a/trunk/src/app/srs_app_rtc_server.cpp +++ b/trunk/src/app/srs_app_rtc_server.cpp @@ -300,7 +300,7 @@ srs_error_t SrsRtcServer::create_session( ) { srs_error_t err = srs_success; - SrsRtcSource* source = NULL; + SrsRtcStream* source = NULL; if ((err = _srs_rtc_sources->fetch_or_create(req, &source)) != srs_success) { return srs_error_wrap(err, "create source"); } @@ -393,7 +393,7 @@ srs_error_t SrsRtcServer::setup_session2(SrsRtcConnection* session, SrsRequest* return err; } - SrsRtcSource* source = NULL; + SrsRtcStream* source = NULL; if ((err = _srs_rtc_sources->fetch_or_create(req, &source)) != srs_success) { return srs_error_wrap(err, "create source"); } diff --git a/trunk/src/app/srs_app_rtc_source.cpp b/trunk/src/app/srs_app_rtc_source.cpp index 9711d14da..4e8e8fe35 100644 --- a/trunk/src/app/srs_app_rtc_source.cpp +++ b/trunk/src/app/srs_app_rtc_source.cpp @@ -90,7 +90,7 @@ srs_error_t aac_raw_append_adts_header(SrsSharedPtrMessage* shared_audio, SrsFor return err; } -SrsRtcConsumer::SrsRtcConsumer(SrsRtcSource* s) +SrsRtcConsumer::SrsRtcConsumer(SrsRtcStream* s) { source = s; should_update_source_id = false; @@ -165,21 +165,21 @@ void SrsRtcConsumer::wait(int nb_msgs) srs_cond_wait(mw_wait); } -SrsRtcSourceManager::SrsRtcSourceManager() +SrsRtcStreamManager::SrsRtcStreamManager() { lock = NULL; } -SrsRtcSourceManager::~SrsRtcSourceManager() +SrsRtcStreamManager::~SrsRtcStreamManager() { srs_mutex_destroy(lock); } -srs_error_t SrsRtcSourceManager::fetch_or_create(SrsRequest* r, SrsRtcSource** pps) +srs_error_t SrsRtcStreamManager::fetch_or_create(SrsRequest* r, SrsRtcStream** pps) { srs_error_t err = srs_success; - // Lazy create lock, because ST is not ready in SrsRtcSourceManager constructor. + // Lazy create lock, because ST is not ready in SrsRtcStreamManager constructor. if (!lock) { lock = srs_mutex_new(); } @@ -188,7 +188,7 @@ srs_error_t SrsRtcSourceManager::fetch_or_create(SrsRequest* r, SrsRtcSource** p // @bug https://github.com/ossrs/srs/issues/1230 SrsLocker(lock); - SrsRtcSource* source = NULL; + SrsRtcStream* source = NULL; if ((source = fetch(r)) != NULL) { *pps = source; return err; @@ -202,7 +202,7 @@ srs_error_t SrsRtcSourceManager::fetch_or_create(SrsRequest* r, SrsRtcSource** p srs_trace("new source, stream_url=%s", stream_url.c_str()); - source = new SrsRtcSource(); + source = new SrsRtcStream(); if ((err = source->initialize(r)) != srs_success) { return srs_error_wrap(err, "init source %s", r->get_stream_url().c_str()); } @@ -214,9 +214,9 @@ srs_error_t SrsRtcSourceManager::fetch_or_create(SrsRequest* r, SrsRtcSource** p return err; } -SrsRtcSource* SrsRtcSourceManager::fetch(SrsRequest* r) +SrsRtcStream* SrsRtcStreamManager::fetch(SrsRequest* r) { - SrsRtcSource* source = NULL; + SrsRtcStream* source = NULL; string stream_url = r->get_stream_url(); if (pool.find(stream_url) == pool.end()) { @@ -233,7 +233,7 @@ SrsRtcSource* SrsRtcSourceManager::fetch(SrsRequest* r) return source; } -SrsRtcSourceManager* _srs_rtc_sources = new SrsRtcSourceManager(); +SrsRtcStreamManager* _srs_rtc_sources = new SrsRtcStreamManager(); ISrsRtcPublishStream::ISrsRtcPublishStream() { @@ -243,7 +243,7 @@ ISrsRtcPublishStream::~ISrsRtcPublishStream() { } -SrsRtcSource::SrsRtcSource() +SrsRtcStream::SrsRtcStream() { _can_publish = true; publish_stream_ = NULL; @@ -256,7 +256,7 @@ SrsRtcSource::SrsRtcSource() #endif } -SrsRtcSource::~SrsRtcSource() +SrsRtcStream::~SrsRtcStream() { // never free the consumers, // for all consumers are auto free. @@ -266,7 +266,7 @@ SrsRtcSource::~SrsRtcSource() srs_freep(bridger_); } -srs_error_t SrsRtcSource::initialize(SrsRequest* r) +srs_error_t SrsRtcStream::initialize(SrsRequest* r) { srs_error_t err = srs_success; @@ -282,12 +282,12 @@ srs_error_t SrsRtcSource::initialize(SrsRequest* r) return err; } -void SrsRtcSource::update_auth(SrsRequest* r) +void SrsRtcStream::update_auth(SrsRequest* r) { req->update_auth(r); } -srs_error_t SrsRtcSource::on_source_id_changed(SrsContextId id) +srs_error_t SrsRtcStream::on_source_id_changed(SrsContextId id) { srs_error_t err = srs_success; @@ -313,22 +313,22 @@ srs_error_t SrsRtcSource::on_source_id_changed(SrsContextId id) return err; } -SrsContextId SrsRtcSource::source_id() +SrsContextId SrsRtcStream::source_id() { return _source_id; } -SrsContextId SrsRtcSource::pre_source_id() +SrsContextId SrsRtcStream::pre_source_id() { return _pre_source_id; } -ISrsSourceBridger* SrsRtcSource::bridger() +ISrsSourceBridger* SrsRtcStream::bridger() { return bridger_; } -srs_error_t SrsRtcSource::create_consumer(SrsRtcConsumer*& consumer) +srs_error_t SrsRtcStream::create_consumer(SrsRtcConsumer*& consumer) { srs_error_t err = srs_success; @@ -340,7 +340,7 @@ srs_error_t SrsRtcSource::create_consumer(SrsRtcConsumer*& consumer) return err; } -srs_error_t SrsRtcSource::consumer_dumps(SrsRtcConsumer* consumer, bool ds, bool dm, bool dg) +srs_error_t SrsRtcStream::consumer_dumps(SrsRtcConsumer* consumer, bool ds, bool dm, bool dg) { srs_error_t err = srs_success; @@ -350,7 +350,7 @@ srs_error_t SrsRtcSource::consumer_dumps(SrsRtcConsumer* consumer, bool ds, bool return err; } -void SrsRtcSource::on_consumer_destroy(SrsRtcConsumer* consumer) +void SrsRtcStream::on_consumer_destroy(SrsRtcConsumer* consumer) { std::vector::iterator it; it = std::find(consumers.begin(), consumers.end(), consumer); @@ -359,12 +359,12 @@ void SrsRtcSource::on_consumer_destroy(SrsRtcConsumer* consumer) } } -bool SrsRtcSource::can_publish(bool is_edge) +bool SrsRtcStream::can_publish(bool is_edge) { return _can_publish; } -srs_error_t SrsRtcSource::on_publish() +srs_error_t SrsRtcStream::on_publish() { srs_error_t err = srs_success; @@ -384,7 +384,7 @@ srs_error_t SrsRtcSource::on_publish() return err; } -void SrsRtcSource::on_unpublish() +void SrsRtcStream::on_unpublish() { // ignore when already unpublished. if (_can_publish) { @@ -399,17 +399,17 @@ void SrsRtcSource::on_unpublish() // TODO: FIXME: Handle by statistic. } -ISrsRtcPublishStream* SrsRtcSource::publish_stream() +ISrsRtcPublishStream* SrsRtcStream::publish_stream() { return publish_stream_; } -void SrsRtcSource::set_publish_stream(ISrsRtcPublishStream* v) +void SrsRtcStream::set_publish_stream(ISrsRtcPublishStream* v) { publish_stream_ = v; } -srs_error_t SrsRtcSource::on_rtp(SrsRtpPacket2* pkt) +srs_error_t SrsRtcStream::on_rtp(SrsRtpPacket2* pkt) { srs_error_t err = srs_success; @@ -424,7 +424,7 @@ srs_error_t SrsRtcSource::on_rtp(SrsRtpPacket2* pkt) } #ifdef SRS_FFMPEG_FIT -SrsRtcFromRtmpBridger::SrsRtcFromRtmpBridger(SrsRtcSource* source) +SrsRtcFromRtmpBridger::SrsRtcFromRtmpBridger(SrsRtcStream* source) { req = NULL; source_ = source; @@ -727,7 +727,7 @@ srs_error_t SrsRtcFromRtmpBridger::filter(SrsSharedPtrMessage* msg, SrsFormat* f return err; } -srs_error_t SrsRtcFromRtmpBridger::package_stap_a(SrsRtcSource* source, SrsSharedPtrMessage* msg, SrsRtpPacket2** ppkt) +srs_error_t SrsRtcFromRtmpBridger::package_stap_a(SrsRtcStream* source, SrsSharedPtrMessage* msg, SrsRtpPacket2** ppkt) { srs_error_t err = srs_success; diff --git a/trunk/src/app/srs_app_rtc_source.hpp b/trunk/src/app/srs_app_rtc_source.hpp index f66f69ea6..66215dbab 100644 --- a/trunk/src/app/srs_app_rtc_source.hpp +++ b/trunk/src/app/srs_app_rtc_source.hpp @@ -38,7 +38,7 @@ class SrsMetaCache; class SrsSharedPtrMessage; class SrsCommonMessage; class SrsMessageArray; -class SrsRtcSource; +class SrsRtcStream; class SrsRtcFromRtmpBridger; class SrsAudioRecode; class SrsRtpPacket2; @@ -47,7 +47,7 @@ class SrsSample; class SrsRtcConsumer { private: - SrsRtcSource* source; + SrsRtcStream* source; std::vector queue; // when source id changed, notice all consumers bool should_update_source_id; @@ -57,7 +57,7 @@ private: bool mw_waiting; int mw_min_msgs; public: - SrsRtcConsumer(SrsRtcSource* s); + SrsRtcConsumer(SrsRtcStream* s); virtual ~SrsRtcConsumer(); public: // When source id changed, notice client to print. @@ -71,27 +71,27 @@ public: virtual void wait(int nb_msgs); }; -class SrsRtcSourceManager +class SrsRtcStreamManager { private: srs_mutex_t lock; - std::map pool; + std::map pool; public: - SrsRtcSourceManager(); - virtual ~SrsRtcSourceManager(); + SrsRtcStreamManager(); + virtual ~SrsRtcStreamManager(); public: // create source when fetch from cache failed. // @param r the client request. // @param pps the matched source, if success never be NULL. - virtual srs_error_t fetch_or_create(SrsRequest* r, SrsRtcSource** pps); + virtual srs_error_t fetch_or_create(SrsRequest* r, SrsRtcStream** pps); private: // Get the exists source, NULL when not exists. // update the request and return the exists source. - virtual SrsRtcSource* fetch(SrsRequest* r); + virtual SrsRtcStream* fetch(SrsRequest* r); }; // Global singleton instance. -extern SrsRtcSourceManager* _srs_rtc_sources; +extern SrsRtcStreamManager* _srs_rtc_sources; // A publish stream interface, for source to callback with. class ISrsRtcPublishStream @@ -104,7 +104,7 @@ public: }; // A Source is a stream, to publish and to play with, binding to SrsRtcPublishStream and SrsRtcPlayStream. -class SrsRtcSource +class SrsRtcStream { private: // For publish, it's the publish client id. @@ -124,8 +124,8 @@ private: // Whether source is avaiable for publishing. bool _can_publish; public: - SrsRtcSource(); - virtual ~SrsRtcSource(); + SrsRtcStream(); + virtual ~SrsRtcStream(); public: virtual srs_error_t initialize(SrsRequest* r); // Update the authentication information in request. @@ -166,7 +166,7 @@ class SrsRtcFromRtmpBridger : public ISrsSourceBridger { private: SrsRequest* req; - SrsRtcSource* source_; + SrsRtcStream* source_; // The format, codec information. SrsRtmpFormat* format; // The metadata cache. @@ -180,7 +180,7 @@ private: uint16_t audio_sequence; uint16_t video_sequence; public: - SrsRtcFromRtmpBridger(SrsRtcSource* source); + SrsRtcFromRtmpBridger(SrsRtcStream* source); virtual ~SrsRtcFromRtmpBridger(); public: virtual srs_error_t initialize(SrsRequest* r); @@ -194,7 +194,7 @@ public: virtual srs_error_t on_video(SrsSharedPtrMessage* msg); private: srs_error_t filter(SrsSharedPtrMessage* msg, SrsFormat* format, bool& has_idr, std::vector& samples); - srs_error_t package_stap_a(SrsRtcSource* source, SrsSharedPtrMessage* msg, SrsRtpPacket2** ppkt); + srs_error_t package_stap_a(SrsRtcStream* source, SrsSharedPtrMessage* msg, SrsRtpPacket2** ppkt); srs_error_t package_nalus(SrsSharedPtrMessage* msg, const std::vector& samples, std::vector& pkts); srs_error_t package_single_nalu(SrsSharedPtrMessage* msg, SrsSample* sample, std::vector& pkts); srs_error_t package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, std::vector& pkts); diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index fd54a7aca..389156e9c 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -1728,7 +1728,7 @@ srs_error_t SrsSourceManager::fetch_or_create(SrsRequest* r, ISrsSourceHandler* bool rtc_enabled = _srs_config->get_rtc_enabled(r->vhost); // Get the RTC source and bridger. - SrsRtcSource* rtc = NULL; + SrsRtcStream* rtc = NULL; if (rtc_server_enabled && rtc_enabled) { if ((err = _srs_rtc_sources->fetch_or_create(r, &rtc)) != srs_success) { err = srs_error_wrap(err, "init rtc %s", r->get_stream_url().c_str());