From 0e3a8c95d4263e000126616b1042a9610449b3c4 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jun 2024 15:01:26 +0800 Subject: [PATCH] Fix bug when rtc disabled. --- trunk/src/app/srs_app_rtc_source.cpp | 2 ++ trunk/src/app/srs_app_server.cpp | 2 ++ trunk/src/app/srs_app_stream_bridge.cpp | 15 +++------------ trunk/src/app/srs_app_stream_bridge.hpp | 6 +++++- trunk/src/app/srs_app_threads.cpp | 3 +-- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/trunk/src/app/srs_app_rtc_source.cpp b/trunk/src/app/srs_app_rtc_source.cpp index 9e3e466f0e..9e70ea7a69 100644 --- a/trunk/src/app/srs_app_rtc_source.cpp +++ b/trunk/src/app/srs_app_rtc_source.cpp @@ -59,6 +59,7 @@ const int kVideoSamplerate = 90000; using namespace std; +#ifdef SRS_FFMPEG_FIT // The RTP payload max size, reserved some paddings for SRTP as such: // kRtpPacketSize = kRtpMaxPayloadSize + paddings // For example, if kRtpPacketSize is 1500, recommend to set kRtpMaxPayloadSize to 1400, @@ -68,6 +69,7 @@ using namespace std; // so we set kRtpMaxPayloadSize = 1200. // see @doc https://groups.google.com/g/discuss-webrtc/c/gH5ysR3SoZI const int kRtpMaxPayloadSize = kRtpPacketSize - 300; +#endif // TODO: Add this function into SrsRtpMux class. srs_error_t aac_raw_append_adts_header(SrsSharedPtrMessage* shared_audio, SrsFormat* format, char** pbuf, int* pnn_buf) diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 6ac1f39af7..d485ed885d 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -1226,6 +1226,7 @@ srs_error_t SrsServer::do_on_tcp_client(ISrsListener* listener, srs_netfd_t& stf } } +#ifdef SRS_RTC // For RTC TCP connection, use resource executor to manage the resource. SrsRtcTcpConn* raw_conn = dynamic_cast(resource); if (raw_conn) { @@ -1238,6 +1239,7 @@ srs_error_t SrsServer::do_on_tcp_client(ISrsListener* listener, srs_netfd_t& stf } return err; } +#endif // Use connection manager to manage all the resources. srs_assert(resource); diff --git a/trunk/src/app/srs_app_stream_bridge.cpp b/trunk/src/app/srs_app_stream_bridge.cpp index 1c391dd83e..543cd91f37 100644 --- a/trunk/src/app/srs_app_stream_bridge.cpp +++ b/trunk/src/app/srs_app_stream_bridge.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -63,13 +62,12 @@ srs_error_t SrsFrameToRtmpBridge::on_frame(SrsSharedPtrMessage* frame) return source_->on_frame(frame); } +#ifdef SRS_RTC SrsFrameToRtcBridge::SrsFrameToRtcBridge(SrsRtcSource* source) { -#ifdef SRS_RTC source_ = source; -#endif -#if defined(SRS_RTC) && defined(SRS_FFMPEG_FIT) +#if defined(SRS_FFMPEG_FIT) uint32_t audio_ssrc = 0; uint8_t audio_payload_type = 0; uint32_t video_ssrc = 0; @@ -119,12 +117,10 @@ srs_error_t SrsFrameToRtcBridge::on_publish() { srs_error_t err = srs_success; -#ifdef SRS_RTC // TODO: FIXME: Should sync with bridge? if ((err = source_->on_publish()) != srs_success) { return srs_error_wrap(err, "source publish"); } -#endif #ifdef SRS_FFMPEG_FIT if ((err = rtp_builder_->on_publish()) != srs_success) { @@ -141,11 +137,9 @@ void SrsFrameToRtcBridge::on_unpublish() rtp_builder_->on_unpublish(); #endif -#ifdef SRS_RTC // @remark This bridge might be disposed here, so never use it. // TODO: FIXME: Should sync with bridge? source_->on_unpublish(); -#endif } srs_error_t SrsFrameToRtcBridge::on_frame(SrsSharedPtrMessage* frame) @@ -159,12 +153,9 @@ srs_error_t SrsFrameToRtcBridge::on_frame(SrsSharedPtrMessage* frame) srs_error_t SrsFrameToRtcBridge::on_rtp(SrsRtpPacket* pkt) { -#ifdef SRS_RTC return source_->on_rtp(pkt); -#else - return srs_success; -#endif } +#endif SrsCompositeBridge::SrsCompositeBridge() { diff --git a/trunk/src/app/srs_app_stream_bridge.hpp b/trunk/src/app/srs_app_stream_bridge.hpp index 6b85bb7a55..bbf42d3295 100644 --- a/trunk/src/app/srs_app_stream_bridge.hpp +++ b/trunk/src/app/srs_app_stream_bridge.hpp @@ -19,7 +19,6 @@ class SrsLiveSource; class SrsRtcSource; class SrsRtmpFormat; class SrsMetaCache; -class SrsAudioTranscoder; class SrsRtpPacket; class SrsRtcRtpBuilder; @@ -55,12 +54,16 @@ class SrsFrameToRtmpBridge : public ISrsStreamBridge virtual srs_error_t on_frame(SrsSharedPtrMessage* frame); }; +#ifdef SRS_RTC // A bridge to covert AV frame to WebRTC stream. class SrsFrameToRtcBridge : public ISrsStreamBridge { private: SrsRtcSource* source_; +private: +#if defined(SRS_FFMPEG_FIT) SrsRtcRtpBuilder* rtp_builder_; +#endif public: SrsFrameToRtcBridge(SrsRtcSource* source); virtual ~SrsFrameToRtcBridge(); @@ -71,6 +74,7 @@ class SrsFrameToRtcBridge : public ISrsStreamBridge virtual srs_error_t on_frame(SrsSharedPtrMessage* frame); srs_error_t on_rtp(SrsRtpPacket* pkt); }; +#endif // A bridge chain, a set of bridges. class SrsCompositeBridge : public ISrsStreamBridge diff --git a/trunk/src/app/srs_app_threads.cpp b/trunk/src/app/srs_app_threads.cpp index d5c6e42297..3aa39d124d 100644 --- a/trunk/src/app/srs_app_threads.cpp +++ b/trunk/src/app/srs_app_threads.cpp @@ -268,10 +268,9 @@ srs_error_t SrsCircuitBreaker::on_timer(srs_utime_t interval) // The hybrid thread cpu and memory. float thread_percent = stat->percent * 100; - static char buf[128]; - string snk_desc; #ifdef SRS_RTC + static char buf[128]; if (_srs_pps_snack2->r10s()) { snprintf(buf, sizeof(buf), ", snk=%d,%d,%d", _srs_pps_snack2->r10s(), _srs_pps_snack3->r10s(), _srs_pps_snack4->r10s() // NACK packet,seqs sent.