Skip to content

Commit

Permalink
Fix bug when rtc disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jun 13, 2024
1 parent f3fda03 commit 0e3a8c9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
2 changes: 2 additions & 0 deletions trunk/src/app/srs_app_rtc_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions trunk/src/app/srs_app_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SrsRtcTcpConn*>(resource);
if (raw_conn) {
Expand All @@ -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);
Expand Down
15 changes: 3 additions & 12 deletions trunk/src/app/srs_app_stream_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <srs_app_source.hpp>
#include <srs_protocol_format.hpp>
#include <srs_app_rtc_codec.hpp>
#include <srs_app_rtc_source.hpp>
#include <srs_app_config.hpp>
#include <srs_protocol_rtmp_stack.hpp>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
Expand All @@ -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()
{
Expand Down
6 changes: 5 additions & 1 deletion trunk/src/app/srs_app_stream_bridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class SrsLiveSource;
class SrsRtcSource;
class SrsRtmpFormat;
class SrsMetaCache;
class SrsAudioTranscoder;
class SrsRtpPacket;
class SrsRtcRtpBuilder;

Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions trunk/src/app/srs_app_threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0e3a8c9

Please sign in to comment.