1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

SquashSRS4: Support WebRTC re-publish stream.

This commit is contained in:
winlin 2021-03-26 14:59:25 +08:00
parent aab54b2cf4
commit 4692e8b8ad
6 changed files with 95 additions and 20 deletions

View file

@ -75,6 +75,17 @@ public:
static uint64_t kMagicNtpFractionalUnit;
};
// When RTC stream publish and re-publish.
class ISrsRtcStreamChangeCallback
{
public:
ISrsRtcStreamChangeCallback();
virtual ~ISrsRtcStreamChangeCallback();
public:
virtual void on_stream_change(SrsRtcStreamDescription* desc) = 0;
};
// The RTC stream consumer, consume packets from RTC stream source.
class SrsRtcConsumer
{
private:
@ -87,6 +98,9 @@ private:
srs_cond_t mw_wait;
bool mw_waiting;
int mw_min_msgs;
private:
// The callback for stream change event.
ISrsRtcStreamChangeCallback* handler_;
public:
SrsRtcConsumer(SrsRtcStream* s);
virtual ~SrsRtcConsumer();
@ -100,6 +114,9 @@ public:
virtual srs_error_t dump_packet(SrsRtpPacket2** ppkt);
// Wait for at-least some messages incoming in queue.
virtual void wait(int nb_msgs);
public:
void set_handler(ISrsRtcStreamChangeCallback* h) { handler_ = h; } // SrsRtcConsumer::set_handler()
void on_stream_change(SrsRtcStreamDescription* desc);
};
class SrsRtcStreamManager
@ -154,7 +171,7 @@ private:
// For publish, it's the publish client id.
// For edge, it's the edge ingest id.
// when source id changed, for example, the edge reconnect,
// invoke the on_source_id_changed() to let all clients know.
// invoke the on_source_changed() to let all clients know.
SrsContextId _source_id;
// previous source id.
SrsContextId _pre_source_id;
@ -180,8 +197,10 @@ public:
virtual srs_error_t initialize(SrsRequest* r);
// Update the authentication information in request.
virtual void update_auth(SrsRequest* r);
// The source id changed.
virtual srs_error_t on_source_id_changed(SrsContextId id);
private:
// The stream source changed.
virtual srs_error_t on_source_changed();
public:
// Get current source id.
virtual SrsContextId source_id();
virtual SrsContextId pre_source_id();