mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Rename SrsRtcStream* to SrsRtcSource*. 4.0.113
This commit is contained in:
parent
2dd58665fa
commit
dae6dc5395
11 changed files with 126 additions and 125 deletions
|
@ -176,6 +176,7 @@ The ports used by SRS:
|
||||||
|
|
||||||
## V4 changes
|
## V4 changes
|
||||||
|
|
||||||
|
* v4.0, 2021-05-15, Rename SrsRtcStream* to SrsRtcSource*. 4.0.113
|
||||||
* v4.0, 2021-05-15, Rename SrsSource* to SrsLiveSource*. 4.0.112
|
* v4.0, 2021-05-15, Rename SrsSource* to SrsLiveSource*. 4.0.112
|
||||||
* v4.0, 2021-05-15, Rename SrsRtpPacket2 to SrsRtpPacket. 4.0.111
|
* v4.0, 2021-05-15, Rename SrsRtpPacket2 to SrsRtpPacket. 4.0.111
|
||||||
* v4.0, 2021-05-14, RTC: Remove [Object Cache Pool](https://github.com/ossrs/srs/commit/14bfc98122bba369572417c19ebb2a61b373fc45#commitcomment-47655008), no effect. 4.0.110
|
* v4.0, 2021-05-14, RTC: Remove [Object Cache Pool](https://github.com/ossrs/srs/commit/14bfc98122bba369572417c19ebb2a61b373fc45#commitcomment-47655008), no effect. 4.0.110
|
||||||
|
|
|
@ -463,7 +463,7 @@ srs_error_t SrsRtcPlayStream::initialize(SrsRequest* req, std::map<uint32_t, Srs
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtcPlayStream::on_stream_change(SrsRtcStreamDescription* desc)
|
void SrsRtcPlayStream::on_stream_change(SrsRtcSourceDescription* desc)
|
||||||
{
|
{
|
||||||
// Refresh the relation for audio.
|
// Refresh the relation for audio.
|
||||||
// TODO: FIMXE: Match by label?
|
// TODO: FIMXE: Match by label?
|
||||||
|
@ -555,7 +555,7 @@ srs_error_t SrsRtcPlayStream::cycle()
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
SrsRtcStream* source = source_;
|
SrsRtcSource* source = source_;
|
||||||
|
|
||||||
SrsRtcConsumer* consumer = NULL;
|
SrsRtcConsumer* consumer = NULL;
|
||||||
SrsAutoFree(SrsRtcConsumer, consumer);
|
SrsAutoFree(SrsRtcConsumer, consumer);
|
||||||
|
@ -1009,7 +1009,7 @@ SrsRtcPublishStream::~SrsRtcPublishStream()
|
||||||
srs_freep(req);
|
srs_freep(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcPublishStream::initialize(SrsRequest* r, SrsRtcStreamDescription* stream_desc)
|
srs_error_t SrsRtcPublishStream::initialize(SrsRequest* r, SrsRtcSourceDescription* stream_desc)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -1848,8 +1848,8 @@ srs_error_t SrsRtcConnection::add_publisher(SrsRtcUserConfig* ruc, SrsSdp& local
|
||||||
|
|
||||||
SrsRequest* req = ruc->req_;
|
SrsRequest* req = ruc->req_;
|
||||||
|
|
||||||
SrsRtcStreamDescription* stream_desc = new SrsRtcStreamDescription();
|
SrsRtcSourceDescription* stream_desc = new SrsRtcSourceDescription();
|
||||||
SrsAutoFree(SrsRtcStreamDescription, stream_desc);
|
SrsAutoFree(SrsRtcSourceDescription, stream_desc);
|
||||||
|
|
||||||
// TODO: FIXME: Change to api of stream desc.
|
// TODO: FIXME: Change to api of stream desc.
|
||||||
if ((err = negotiate_publish_capability(ruc, stream_desc)) != srs_success) {
|
if ((err = negotiate_publish_capability(ruc, stream_desc)) != srs_success) {
|
||||||
|
@ -1860,7 +1860,7 @@ srs_error_t SrsRtcConnection::add_publisher(SrsRtcUserConfig* ruc, SrsSdp& local
|
||||||
return srs_error_wrap(err, "generate local sdp");
|
return srs_error_wrap(err, "generate local sdp");
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcStream* source = NULL;
|
SrsRtcSource* source = NULL;
|
||||||
if ((err = _srs_rtc_sources->fetch_or_create(req, &source)) != srs_success) {
|
if ((err = _srs_rtc_sources->fetch_or_create(req, &source)) != srs_success) {
|
||||||
return srs_error_wrap(err, "create source");
|
return srs_error_wrap(err, "create source");
|
||||||
}
|
}
|
||||||
|
@ -1905,8 +1905,8 @@ srs_error_t SrsRtcConnection::add_player(SrsRtcUserConfig* ruc, SrsSdp& local_sd
|
||||||
return srs_error_new(ERROR_RTC_SDP_EXCHANGE, "no play relations");
|
return srs_error_new(ERROR_RTC_SDP_EXCHANGE, "no play relations");
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcStreamDescription* stream_desc = new SrsRtcStreamDescription();
|
SrsRtcSourceDescription* stream_desc = new SrsRtcSourceDescription();
|
||||||
SrsAutoFree(SrsRtcStreamDescription, stream_desc);
|
SrsAutoFree(SrsRtcSourceDescription, stream_desc);
|
||||||
std::map<uint32_t, SrsRtcTrackDescription*>::iterator it = play_sub_relations.begin();
|
std::map<uint32_t, SrsRtcTrackDescription*>::iterator it = play_sub_relations.begin();
|
||||||
while (it != play_sub_relations.end()) {
|
while (it != play_sub_relations.end()) {
|
||||||
SrsRtcTrackDescription* track_desc = it->second;
|
SrsRtcTrackDescription* track_desc = it->second;
|
||||||
|
@ -2701,7 +2701,7 @@ bool srs_sdp_has_h264_profile(const SrsSdp& sdp, const string& profile)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcConnection::negotiate_publish_capability(SrsRtcUserConfig* ruc, SrsRtcStreamDescription* stream_desc)
|
srs_error_t SrsRtcConnection::negotiate_publish_capability(SrsRtcUserConfig* ruc, SrsRtcSourceDescription* stream_desc)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -2939,7 +2939,7 @@ srs_error_t SrsRtcConnection::negotiate_publish_capability(SrsRtcUserConfig* ruc
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcConnection::generate_publish_local_sdp(SrsRequest* req, SrsSdp& local_sdp, SrsRtcStreamDescription* stream_desc, bool unified_plan)
|
srs_error_t SrsRtcConnection::generate_publish_local_sdp(SrsRequest* req, SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, bool unified_plan)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -3056,7 +3056,7 @@ srs_error_t SrsRtcConnection::negotiate_play_capability(SrsRtcUserConfig* ruc, s
|
||||||
// TODO: FIME: Should check packetization-mode=1 also.
|
// TODO: FIME: Should check packetization-mode=1 also.
|
||||||
bool has_42e01f = srs_sdp_has_h264_profile(remote_sdp, "42e01f");
|
bool has_42e01f = srs_sdp_has_h264_profile(remote_sdp, "42e01f");
|
||||||
|
|
||||||
SrsRtcStream* source = NULL;
|
SrsRtcSource* source = NULL;
|
||||||
if ((err = _srs_rtc_sources->fetch_or_create(req, &source)) != srs_success) {
|
if ((err = _srs_rtc_sources->fetch_or_create(req, &source)) != srs_success) {
|
||||||
return srs_error_wrap(err, "fetch rtc source");
|
return srs_error_wrap(err, "fetch rtc source");
|
||||||
}
|
}
|
||||||
|
@ -3177,7 +3177,7 @@ srs_error_t SrsRtcConnection::fetch_source_capability(SrsRequest* req, std::map<
|
||||||
bool nack_enabled = _srs_config->get_rtc_nack_enabled(req->vhost);
|
bool nack_enabled = _srs_config->get_rtc_nack_enabled(req->vhost);
|
||||||
bool twcc_enabled = _srs_config->get_rtc_twcc_enabled(req->vhost);
|
bool twcc_enabled = _srs_config->get_rtc_twcc_enabled(req->vhost);
|
||||||
|
|
||||||
SrsRtcStream* source = NULL;
|
SrsRtcSource* source = NULL;
|
||||||
if ((err = _srs_rtc_sources->fetch_or_create(req, &source)) != srs_success) {
|
if ((err = _srs_rtc_sources->fetch_or_create(req, &source)) != srs_success) {
|
||||||
return srs_error_wrap(err, "fetch rtc source");
|
return srs_error_wrap(err, "fetch rtc source");
|
||||||
}
|
}
|
||||||
|
@ -3274,7 +3274,7 @@ void video_track_generate_play_offer(SrsRtcTrackDescription* track, string mid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcConnection::generate_play_local_sdp(SrsRequest* req, SrsSdp& local_sdp, SrsRtcStreamDescription* stream_desc, bool unified_plan)
|
srs_error_t SrsRtcConnection::generate_play_local_sdp(SrsRequest* req, SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, bool unified_plan)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -3468,7 +3468,7 @@ srs_error_t SrsRtcConnection::create_player(SrsRequest* req, std::map<uint32_t,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcConnection::create_publisher(SrsRequest* req, SrsRtcStreamDescription* stream_desc)
|
srs_error_t SrsRtcConnection::create_publisher(SrsRequest* req, SrsRtcSourceDescription* stream_desc)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ class SrsStunPacket;
|
||||||
class SrsRtcServer;
|
class SrsRtcServer;
|
||||||
class SrsRtcConnection;
|
class SrsRtcConnection;
|
||||||
class SrsSharedPtrMessage;
|
class SrsSharedPtrMessage;
|
||||||
class SrsRtcStream;
|
class SrsRtcSource;
|
||||||
class SrsRtpPacket;
|
class SrsRtpPacket;
|
||||||
class ISrsCodec;
|
class ISrsCodec;
|
||||||
class SrsRtpNackForReceiver;
|
class SrsRtpNackForReceiver;
|
||||||
|
@ -214,7 +214,7 @@ public:
|
||||||
|
|
||||||
// A RTC play stream, client pull and play stream from SRS.
|
// A RTC play stream, client pull and play stream from SRS.
|
||||||
class SrsRtcPlayStream : public ISrsCoroutineHandler, public ISrsReloadHandler
|
class SrsRtcPlayStream : public ISrsCoroutineHandler, public ISrsReloadHandler
|
||||||
, public ISrsRtcPLIWorkerHandler, public ISrsRtcStreamChangeCallback
|
, public ISrsRtcPLIWorkerHandler, public ISrsRtcSourceChangeCallback
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
|
@ -223,7 +223,7 @@ private:
|
||||||
SrsRtcPLIWorker* pli_worker_;
|
SrsRtcPLIWorker* pli_worker_;
|
||||||
private:
|
private:
|
||||||
SrsRequest* req_;
|
SrsRequest* req_;
|
||||||
SrsRtcStream* source_;
|
SrsRtcSource* source_;
|
||||||
// key: publish_ssrc, value: send track to process rtp/rtcp
|
// key: publish_ssrc, value: send track to process rtp/rtcp
|
||||||
std::map<uint32_t, SrsRtcAudioSendTrack*> audio_tracks_;
|
std::map<uint32_t, SrsRtcAudioSendTrack*> audio_tracks_;
|
||||||
std::map<uint32_t, SrsRtcVideoSendTrack*> video_tracks_;
|
std::map<uint32_t, SrsRtcVideoSendTrack*> video_tracks_;
|
||||||
|
@ -252,9 +252,9 @@ public:
|
||||||
virtual ~SrsRtcPlayStream();
|
virtual ~SrsRtcPlayStream();
|
||||||
public:
|
public:
|
||||||
srs_error_t initialize(SrsRequest* request, std::map<uint32_t, SrsRtcTrackDescription*> sub_relations);
|
srs_error_t initialize(SrsRequest* request, std::map<uint32_t, SrsRtcTrackDescription*> sub_relations);
|
||||||
// Interface ISrsRtcStreamChangeCallback
|
// Interface ISrsRtcSourceChangeCallback
|
||||||
public:
|
public:
|
||||||
void on_stream_change(SrsRtcStreamDescription* desc);
|
void on_stream_change(SrsRtcSourceDescription* desc);
|
||||||
// interface ISrsReloadHandler
|
// interface ISrsReloadHandler
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_reload_vhost_play(std::string vhost);
|
virtual srs_error_t on_reload_vhost_play(std::string vhost);
|
||||||
|
@ -335,7 +335,7 @@ private:
|
||||||
SrsErrorPithyPrint* pli_epp;
|
SrsErrorPithyPrint* pli_epp;
|
||||||
private:
|
private:
|
||||||
SrsRequest* req;
|
SrsRequest* req;
|
||||||
SrsRtcStream* source;
|
SrsRtcSource* source;
|
||||||
// Simulators.
|
// Simulators.
|
||||||
int nn_simulate_nack_drop;
|
int nn_simulate_nack_drop;
|
||||||
private:
|
private:
|
||||||
|
@ -353,7 +353,7 @@ public:
|
||||||
SrsRtcPublishStream(SrsRtcConnection* session, const SrsContextId& cid);
|
SrsRtcPublishStream(SrsRtcConnection* session, const SrsContextId& cid);
|
||||||
virtual ~SrsRtcPublishStream();
|
virtual ~SrsRtcPublishStream();
|
||||||
public:
|
public:
|
||||||
srs_error_t initialize(SrsRequest* req, SrsRtcStreamDescription* stream_desc);
|
srs_error_t initialize(SrsRequest* req, SrsRtcSourceDescription* stream_desc);
|
||||||
srs_error_t start();
|
srs_error_t start();
|
||||||
// Directly set the status of track, generally for init to set the default value.
|
// Directly set the status of track, generally for init to set the default value.
|
||||||
void set_all_tracks_status(bool status);
|
void set_all_tracks_status(bool status);
|
||||||
|
@ -553,15 +553,15 @@ public:
|
||||||
private:
|
private:
|
||||||
srs_error_t on_binding_request(SrsStunPacket* r);
|
srs_error_t on_binding_request(SrsStunPacket* r);
|
||||||
// publish media capabilitiy negotiate
|
// publish media capabilitiy negotiate
|
||||||
srs_error_t negotiate_publish_capability(SrsRtcUserConfig* ruc, SrsRtcStreamDescription* stream_desc);
|
srs_error_t negotiate_publish_capability(SrsRtcUserConfig* ruc, SrsRtcSourceDescription* stream_desc);
|
||||||
srs_error_t generate_publish_local_sdp(SrsRequest* req, SrsSdp& local_sdp, SrsRtcStreamDescription* stream_desc, bool unified_plan);
|
srs_error_t generate_publish_local_sdp(SrsRequest* req, SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, bool unified_plan);
|
||||||
// play media capabilitiy negotiate
|
// play media capabilitiy negotiate
|
||||||
//TODO: Use StreamDescription to negotiate and remove first negotiate_play_capability function
|
//TODO: Use StreamDescription to negotiate and remove first negotiate_play_capability function
|
||||||
srs_error_t negotiate_play_capability(SrsRtcUserConfig* ruc, std::map<uint32_t, SrsRtcTrackDescription*>& sub_relations);
|
srs_error_t negotiate_play_capability(SrsRtcUserConfig* ruc, std::map<uint32_t, SrsRtcTrackDescription*>& sub_relations);
|
||||||
srs_error_t fetch_source_capability(SrsRequest* req, std::map<uint32_t, SrsRtcTrackDescription*>& sub_relations);
|
srs_error_t fetch_source_capability(SrsRequest* req, std::map<uint32_t, SrsRtcTrackDescription*>& sub_relations);
|
||||||
srs_error_t generate_play_local_sdp(SrsRequest* req, SrsSdp& local_sdp, SrsRtcStreamDescription* stream_desc, bool unified_plan);
|
srs_error_t generate_play_local_sdp(SrsRequest* req, SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, bool unified_plan);
|
||||||
srs_error_t create_player(SrsRequest* request, std::map<uint32_t, SrsRtcTrackDescription*> sub_relations);
|
srs_error_t create_player(SrsRequest* request, std::map<uint32_t, SrsRtcTrackDescription*> sub_relations);
|
||||||
srs_error_t create_publisher(SrsRequest* request, SrsRtcStreamDescription* stream_desc);
|
srs_error_t create_publisher(SrsRequest* request, SrsRtcSourceDescription* stream_desc);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ISrsRtcHijacker
|
class ISrsRtcHijacker
|
||||||
|
|
|
@ -469,7 +469,7 @@ srs_error_t SrsRtcServer::create_session(SrsRtcUserConfig* ruc, SrsSdp& local_sd
|
||||||
|
|
||||||
SrsRequest* req = ruc->req_;
|
SrsRequest* req = ruc->req_;
|
||||||
|
|
||||||
SrsRtcStream* source = NULL;
|
SrsRtcSource* source = NULL;
|
||||||
if ((err = _srs_rtc_sources->fetch_or_create(req, &source)) != srs_success) {
|
if ((err = _srs_rtc_sources->fetch_or_create(req, &source)) != srs_success) {
|
||||||
return srs_error_wrap(err, "create source");
|
return srs_error_wrap(err, "create source");
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class SrsHourGlass;
|
||||||
class SrsRtcConnection;
|
class SrsRtcConnection;
|
||||||
class SrsRequest;
|
class SrsRequest;
|
||||||
class SrsSdp;
|
class SrsSdp;
|
||||||
class SrsRtcStream;
|
class SrsRtcSource;
|
||||||
class SrsResourceManager;
|
class SrsResourceManager;
|
||||||
|
|
||||||
// The UDP black hole, for developer to use wireshark to catch plaintext packets.
|
// The UDP black hole, for developer to use wireshark to catch plaintext packets.
|
||||||
|
|
|
@ -152,15 +152,15 @@ SrsNtp SrsNtp::to_time_ms(uint64_t ntp)
|
||||||
return srs_ntp;
|
return srs_ntp;
|
||||||
}
|
}
|
||||||
|
|
||||||
ISrsRtcStreamChangeCallback::ISrsRtcStreamChangeCallback()
|
ISrsRtcSourceChangeCallback::ISrsRtcSourceChangeCallback()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ISrsRtcStreamChangeCallback::~ISrsRtcStreamChangeCallback()
|
ISrsRtcSourceChangeCallback::~ISrsRtcSourceChangeCallback()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcConsumer::SrsRtcConsumer(SrsRtcStream* s)
|
SrsRtcConsumer::SrsRtcConsumer(SrsRtcSource* s)
|
||||||
{
|
{
|
||||||
source = s;
|
source = s;
|
||||||
should_update_source_id = false;
|
should_update_source_id = false;
|
||||||
|
@ -240,24 +240,24 @@ void SrsRtcConsumer::wait(int nb_msgs)
|
||||||
srs_cond_wait(mw_wait);
|
srs_cond_wait(mw_wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtcConsumer::on_stream_change(SrsRtcStreamDescription* desc)
|
void SrsRtcConsumer::on_stream_change(SrsRtcSourceDescription* desc)
|
||||||
{
|
{
|
||||||
if (handler_) {
|
if (handler_) {
|
||||||
handler_->on_stream_change(desc);
|
handler_->on_stream_change(desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcStreamManager::SrsRtcStreamManager()
|
SrsRtcSourceManager::SrsRtcSourceManager()
|
||||||
{
|
{
|
||||||
lock = srs_mutex_new();
|
lock = srs_mutex_new();
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcStreamManager::~SrsRtcStreamManager()
|
SrsRtcSourceManager::~SrsRtcSourceManager()
|
||||||
{
|
{
|
||||||
srs_mutex_destroy(lock);
|
srs_mutex_destroy(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcStreamManager::fetch_or_create(SrsRequest* r, SrsRtcStream** pps)
|
srs_error_t SrsRtcSourceManager::fetch_or_create(SrsRequest* r, SrsRtcSource** pps)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ srs_error_t SrsRtcStreamManager::fetch_or_create(SrsRequest* r, SrsRtcStream** p
|
||||||
// @bug https://github.com/ossrs/srs/issues/1230
|
// @bug https://github.com/ossrs/srs/issues/1230
|
||||||
SrsLocker(lock);
|
SrsLocker(lock);
|
||||||
|
|
||||||
SrsRtcStream* source = NULL;
|
SrsRtcSource* source = NULL;
|
||||||
if ((source = fetch(r)) != NULL) {
|
if ((source = fetch(r)) != NULL) {
|
||||||
*pps = source;
|
*pps = source;
|
||||||
return err;
|
return err;
|
||||||
|
@ -279,7 +279,7 @@ srs_error_t SrsRtcStreamManager::fetch_or_create(SrsRequest* r, SrsRtcStream** p
|
||||||
|
|
||||||
srs_trace("new source, stream_url=%s", stream_url.c_str());
|
srs_trace("new source, stream_url=%s", stream_url.c_str());
|
||||||
|
|
||||||
source = new SrsRtcStream();
|
source = new SrsRtcSource();
|
||||||
if ((err = source->initialize(r)) != srs_success) {
|
if ((err = source->initialize(r)) != srs_success) {
|
||||||
return srs_error_wrap(err, "init source %s", r->get_stream_url().c_str());
|
return srs_error_wrap(err, "init source %s", r->get_stream_url().c_str());
|
||||||
}
|
}
|
||||||
|
@ -291,9 +291,9 @@ srs_error_t SrsRtcStreamManager::fetch_or_create(SrsRequest* r, SrsRtcStream** p
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcStream* SrsRtcStreamManager::fetch(SrsRequest* r)
|
SrsRtcSource* SrsRtcSourceManager::fetch(SrsRequest* r)
|
||||||
{
|
{
|
||||||
SrsRtcStream* source = NULL;
|
SrsRtcSource* source = NULL;
|
||||||
|
|
||||||
string stream_url = r->get_stream_url();
|
string stream_url = r->get_stream_url();
|
||||||
if (pool.find(stream_url) == pool.end()) {
|
if (pool.find(stream_url) == pool.end()) {
|
||||||
|
@ -310,7 +310,7 @@ SrsRtcStream* SrsRtcStreamManager::fetch(SrsRequest* r)
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcStreamManager* _srs_rtc_sources = NULL;
|
SrsRtcSourceManager* _srs_rtc_sources = NULL;
|
||||||
|
|
||||||
ISrsRtcPublishStream::ISrsRtcPublishStream()
|
ISrsRtcPublishStream::ISrsRtcPublishStream()
|
||||||
{
|
{
|
||||||
|
@ -320,11 +320,11 @@ ISrsRtcPublishStream::~ISrsRtcPublishStream()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ISrsRtcStreamEventHandler::ISrsRtcStreamEventHandler()
|
ISrsRtcSourceEventHandler::ISrsRtcSourceEventHandler()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ISrsRtcStreamEventHandler::~ISrsRtcStreamEventHandler()
|
ISrsRtcSourceEventHandler::~ISrsRtcSourceEventHandler()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ ISrsRtcSourceBridger::~ISrsRtcSourceBridger()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcStream::SrsRtcStream()
|
SrsRtcSource::SrsRtcSource()
|
||||||
{
|
{
|
||||||
is_created_ = false;
|
is_created_ = false;
|
||||||
is_delivering_packets_ = false;
|
is_delivering_packets_ = false;
|
||||||
|
@ -350,7 +350,7 @@ SrsRtcStream::SrsRtcStream()
|
||||||
pli_for_rtmp_ = pli_elapsed_ = 0;
|
pli_for_rtmp_ = pli_elapsed_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcStream::~SrsRtcStream()
|
SrsRtcSource::~SrsRtcSource()
|
||||||
{
|
{
|
||||||
// never free the consumers,
|
// never free the consumers,
|
||||||
// for all consumers are auto free.
|
// for all consumers are auto free.
|
||||||
|
@ -361,7 +361,7 @@ SrsRtcStream::~SrsRtcStream()
|
||||||
srs_freep(stream_desc_);
|
srs_freep(stream_desc_);
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcStream::initialize(SrsRequest* r)
|
srs_error_t SrsRtcSource::initialize(SrsRequest* r)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -370,12 +370,12 @@ srs_error_t SrsRtcStream::initialize(SrsRequest* r)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtcStream::update_auth(SrsRequest* r)
|
void SrsRtcSource::update_auth(SrsRequest* r)
|
||||||
{
|
{
|
||||||
req->update_auth(r);
|
req->update_auth(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcStream::on_source_changed()
|
srs_error_t SrsRtcSource::on_source_changed()
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -408,23 +408,23 @@ srs_error_t SrsRtcStream::on_source_changed()
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsContextId SrsRtcStream::source_id()
|
SrsContextId SrsRtcSource::source_id()
|
||||||
{
|
{
|
||||||
return _source_id;
|
return _source_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsContextId SrsRtcStream::pre_source_id()
|
SrsContextId SrsRtcSource::pre_source_id()
|
||||||
{
|
{
|
||||||
return _pre_source_id;
|
return _pre_source_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtcStream::set_bridger(ISrsRtcSourceBridger *bridger)
|
void SrsRtcSource::set_bridger(ISrsRtcSourceBridger *bridger)
|
||||||
{
|
{
|
||||||
srs_freep(bridger_);
|
srs_freep(bridger_);
|
||||||
bridger_ = bridger;
|
bridger_ = bridger;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcStream::create_consumer(SrsRtcConsumer*& consumer)
|
srs_error_t SrsRtcSource::create_consumer(SrsRtcConsumer*& consumer)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ srs_error_t SrsRtcStream::create_consumer(SrsRtcConsumer*& consumer)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcStream::consumer_dumps(SrsRtcConsumer* consumer, bool ds, bool dm, bool dg)
|
srs_error_t SrsRtcSource::consumer_dumps(SrsRtcConsumer* consumer, bool ds, bool dm, bool dg)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ srs_error_t SrsRtcStream::consumer_dumps(SrsRtcConsumer* consumer, bool ds, bool
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtcStream::on_consumer_destroy(SrsRtcConsumer* consumer)
|
void SrsRtcSource::on_consumer_destroy(SrsRtcConsumer* consumer)
|
||||||
{
|
{
|
||||||
std::vector<SrsRtcConsumer*>::iterator it;
|
std::vector<SrsRtcConsumer*>::iterator it;
|
||||||
it = std::find(consumers.begin(), consumers.end(), consumer);
|
it = std::find(consumers.begin(), consumers.end(), consumer);
|
||||||
|
@ -457,26 +457,26 @@ void SrsRtcStream::on_consumer_destroy(SrsRtcConsumer* consumer)
|
||||||
// When all consumers finished, notify publisher to handle it.
|
// When all consumers finished, notify publisher to handle it.
|
||||||
if (publish_stream_ && consumers.empty()) {
|
if (publish_stream_ && consumers.empty()) {
|
||||||
for (size_t i = 0; i < event_handlers_.size(); i++) {
|
for (size_t i = 0; i < event_handlers_.size(); i++) {
|
||||||
ISrsRtcStreamEventHandler* h = event_handlers_.at(i);
|
ISrsRtcSourceEventHandler* h = event_handlers_.at(i);
|
||||||
h->on_consumers_finished();
|
h->on_consumers_finished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SrsRtcStream::can_publish()
|
bool SrsRtcSource::can_publish()
|
||||||
{
|
{
|
||||||
// TODO: FIXME: Should check the status of bridger.
|
// TODO: FIXME: Should check the status of bridger.
|
||||||
|
|
||||||
return !is_created_;
|
return !is_created_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtcStream::set_stream_created()
|
void SrsRtcSource::set_stream_created()
|
||||||
{
|
{
|
||||||
srs_assert(!is_created_ && !is_delivering_packets_);
|
srs_assert(!is_created_ && !is_delivering_packets_);
|
||||||
is_created_ = true;
|
is_created_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcStream::on_publish()
|
srs_error_t SrsRtcSource::on_publish()
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -502,7 +502,7 @@ srs_error_t SrsRtcStream::on_publish()
|
||||||
// The PLI interval for RTC2RTMP.
|
// The PLI interval for RTC2RTMP.
|
||||||
pli_for_rtmp_ = _srs_config->get_rtc_pli_for_rtmp(req->vhost);
|
pli_for_rtmp_ = _srs_config->get_rtc_pli_for_rtmp(req->vhost);
|
||||||
|
|
||||||
// @see SrsRtcStream::on_timer()
|
// @see SrsRtcSource::on_timer()
|
||||||
_srs_hybrid->timer100ms()->subscribe(this);
|
_srs_hybrid->timer100ms()->subscribe(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,7 +511,7 @@ srs_error_t SrsRtcStream::on_publish()
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtcStream::on_unpublish()
|
void SrsRtcSource::on_unpublish()
|
||||||
{
|
{
|
||||||
// ignore when already unpublished.
|
// ignore when already unpublished.
|
||||||
if (!is_created_) {
|
if (!is_created_) {
|
||||||
|
@ -529,13 +529,13 @@ void SrsRtcStream::on_unpublish()
|
||||||
_source_id = SrsContextId();
|
_source_id = SrsContextId();
|
||||||
|
|
||||||
for (size_t i = 0; i < event_handlers_.size(); i++) {
|
for (size_t i = 0; i < event_handlers_.size(); i++) {
|
||||||
ISrsRtcStreamEventHandler* h = event_handlers_.at(i);
|
ISrsRtcSourceEventHandler* h = event_handlers_.at(i);
|
||||||
h->on_unpublish();
|
h->on_unpublish();
|
||||||
}
|
}
|
||||||
|
|
||||||
//free bridger resource
|
//free bridger resource
|
||||||
if (bridger_) {
|
if (bridger_) {
|
||||||
// For SrsRtcStream::on_timer()
|
// For SrsRtcSource::on_timer()
|
||||||
_srs_hybrid->timer100ms()->unsubscribe(this);
|
_srs_hybrid->timer100ms()->unsubscribe(this);
|
||||||
|
|
||||||
bridger_->on_unpublish();
|
bridger_->on_unpublish();
|
||||||
|
@ -548,33 +548,33 @@ void SrsRtcStream::on_unpublish()
|
||||||
// TODO: FIXME: Handle by statistic.
|
// TODO: FIXME: Handle by statistic.
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtcStream::subscribe(ISrsRtcStreamEventHandler* h)
|
void SrsRtcSource::subscribe(ISrsRtcSourceEventHandler* h)
|
||||||
{
|
{
|
||||||
if (std::find(event_handlers_.begin(), event_handlers_.end(), h) == event_handlers_.end()) {
|
if (std::find(event_handlers_.begin(), event_handlers_.end(), h) == event_handlers_.end()) {
|
||||||
event_handlers_.push_back(h);
|
event_handlers_.push_back(h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtcStream::unsubscribe(ISrsRtcStreamEventHandler* h)
|
void SrsRtcSource::unsubscribe(ISrsRtcSourceEventHandler* h)
|
||||||
{
|
{
|
||||||
std::vector<ISrsRtcStreamEventHandler*>::iterator it;
|
std::vector<ISrsRtcSourceEventHandler*>::iterator it;
|
||||||
it = std::find(event_handlers_.begin(), event_handlers_.end(), h);
|
it = std::find(event_handlers_.begin(), event_handlers_.end(), h);
|
||||||
if (it != event_handlers_.end()) {
|
if (it != event_handlers_.end()) {
|
||||||
event_handlers_.erase(it);
|
event_handlers_.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ISrsRtcPublishStream* SrsRtcStream::publish_stream()
|
ISrsRtcPublishStream* SrsRtcSource::publish_stream()
|
||||||
{
|
{
|
||||||
return publish_stream_;
|
return publish_stream_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtcStream::set_publish_stream(ISrsRtcPublishStream* v)
|
void SrsRtcSource::set_publish_stream(ISrsRtcPublishStream* v)
|
||||||
{
|
{
|
||||||
publish_stream_ = v;
|
publish_stream_ = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcStream::on_rtp(SrsRtpPacket* pkt)
|
srs_error_t SrsRtcSource::on_rtp(SrsRtpPacket* pkt)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -598,12 +598,12 @@ srs_error_t SrsRtcStream::on_rtp(SrsRtpPacket* pkt)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SrsRtcStream::has_stream_desc()
|
bool SrsRtcSource::has_stream_desc()
|
||||||
{
|
{
|
||||||
return stream_desc_;
|
return stream_desc_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtcStream::set_stream_desc(SrsRtcStreamDescription* stream_desc)
|
void SrsRtcSource::set_stream_desc(SrsRtcSourceDescription* stream_desc)
|
||||||
{
|
{
|
||||||
srs_freep(stream_desc_);
|
srs_freep(stream_desc_);
|
||||||
|
|
||||||
|
@ -612,7 +612,7 @@ void SrsRtcStream::set_stream_desc(SrsRtcStreamDescription* stream_desc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<SrsRtcTrackDescription*> SrsRtcStream::get_track_desc(std::string type, std::string media_name)
|
std::vector<SrsRtcTrackDescription*> SrsRtcSource::get_track_desc(std::string type, std::string media_name)
|
||||||
{
|
{
|
||||||
std::vector<SrsRtcTrackDescription*> track_descs;
|
std::vector<SrsRtcTrackDescription*> track_descs;
|
||||||
if (!stream_desc_) {
|
if (!stream_desc_) {
|
||||||
|
@ -636,7 +636,7 @@ std::vector<SrsRtcTrackDescription*> SrsRtcStream::get_track_desc(std::string ty
|
||||||
return track_descs;
|
return track_descs;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcStream::on_timer(srs_utime_t interval)
|
srs_error_t SrsRtcSource::on_timer(srs_utime_t interval)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -662,7 +662,7 @@ srs_error_t SrsRtcStream::on_timer(srs_utime_t interval)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SRS_FFMPEG_FIT
|
#ifdef SRS_FFMPEG_FIT
|
||||||
SrsRtcFromRtmpBridger::SrsRtcFromRtmpBridger(SrsRtcStream* source)
|
SrsRtcFromRtmpBridger::SrsRtcFromRtmpBridger(SrsRtcSource* source)
|
||||||
{
|
{
|
||||||
req = NULL;
|
req = NULL;
|
||||||
source_ = source;
|
source_ = source;
|
||||||
|
@ -675,8 +675,8 @@ SrsRtcFromRtmpBridger::SrsRtcFromRtmpBridger(SrsRtcStream* source)
|
||||||
audio_sequence = 0;
|
audio_sequence = 0;
|
||||||
video_sequence = 0;
|
video_sequence = 0;
|
||||||
|
|
||||||
SrsRtcStreamDescription* stream_desc = new SrsRtcStreamDescription();
|
SrsRtcSourceDescription* stream_desc = new SrsRtcSourceDescription();
|
||||||
SrsAutoFree(SrsRtcStreamDescription, stream_desc);
|
SrsAutoFree(SrsRtcSourceDescription, stream_desc);
|
||||||
|
|
||||||
// audio track description
|
// audio track description
|
||||||
if (true) {
|
if (true) {
|
||||||
|
@ -989,7 +989,7 @@ srs_error_t SrsRtcFromRtmpBridger::filter(SrsSharedPtrMessage* msg, SrsFormat* f
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcFromRtmpBridger::package_stap_a(SrsRtcStream* source, SrsSharedPtrMessage* msg, SrsRtpPacket* pkt)
|
srs_error_t SrsRtcFromRtmpBridger::package_stap_a(SrsRtcSource* source, SrsSharedPtrMessage* msg, SrsRtpPacket* pkt)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -2130,12 +2130,12 @@ SrsRtcTrackDescription* SrsRtcTrackDescription::copy()
|
||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcStreamDescription::SrsRtcStreamDescription()
|
SrsRtcSourceDescription::SrsRtcSourceDescription()
|
||||||
{
|
{
|
||||||
audio_track_desc_ = NULL;
|
audio_track_desc_ = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcStreamDescription::~SrsRtcStreamDescription()
|
SrsRtcSourceDescription::~SrsRtcSourceDescription()
|
||||||
{
|
{
|
||||||
srs_freep(audio_track_desc_);
|
srs_freep(audio_track_desc_);
|
||||||
|
|
||||||
|
@ -2145,9 +2145,9 @@ SrsRtcStreamDescription::~SrsRtcStreamDescription()
|
||||||
video_track_descs_.clear();
|
video_track_descs_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcStreamDescription* SrsRtcStreamDescription::copy()
|
SrsRtcSourceDescription* SrsRtcSourceDescription::copy()
|
||||||
{
|
{
|
||||||
SrsRtcStreamDescription* stream_desc = new SrsRtcStreamDescription();
|
SrsRtcSourceDescription* stream_desc = new SrsRtcSourceDescription();
|
||||||
|
|
||||||
if (audio_track_desc_) {
|
if (audio_track_desc_) {
|
||||||
stream_desc->audio_track_desc_ = audio_track_desc_->copy();
|
stream_desc->audio_track_desc_ = audio_track_desc_->copy();
|
||||||
|
@ -2160,7 +2160,7 @@ SrsRtcStreamDescription* SrsRtcStreamDescription::copy()
|
||||||
return stream_desc;
|
return stream_desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcTrackDescription* SrsRtcStreamDescription::find_track_description_by_ssrc(uint32_t ssrc)
|
SrsRtcTrackDescription* SrsRtcSourceDescription::find_track_description_by_ssrc(uint32_t ssrc)
|
||||||
{
|
{
|
||||||
if (audio_track_desc_ && audio_track_desc_->has_ssrc(ssrc)) {
|
if (audio_track_desc_ && audio_track_desc_->has_ssrc(ssrc)) {
|
||||||
return audio_track_desc_;
|
return audio_track_desc_;
|
||||||
|
@ -2328,7 +2328,7 @@ void SrsRtcAudioRecvTrack::on_before_decode_payload(SrsRtpPacket* pkt, SrsBuffer
|
||||||
*ppt = SrsRtspPacketPayloadTypeRaw;
|
*ppt = SrsRtspPacketPayloadTypeRaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcAudioRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket* pkt)
|
srs_error_t SrsRtcAudioRecvTrack::on_rtp(SrsRtcSource* source, SrsRtpPacket* pkt)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
@ -2384,7 +2384,7 @@ void SrsRtcVideoRecvTrack::on_before_decode_payload(SrsRtpPacket* pkt, SrsBuffer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcVideoRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket* pkt)
|
srs_error_t SrsRtcVideoRecvTrack::on_rtp(SrsRtcSource* source, SrsRtpPacket* pkt)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
|
|
@ -43,12 +43,12 @@ class SrsMetaCache;
|
||||||
class SrsSharedPtrMessage;
|
class SrsSharedPtrMessage;
|
||||||
class SrsCommonMessage;
|
class SrsCommonMessage;
|
||||||
class SrsMessageArray;
|
class SrsMessageArray;
|
||||||
class SrsRtcStream;
|
class SrsRtcSource;
|
||||||
class SrsRtcFromRtmpBridger;
|
class SrsRtcFromRtmpBridger;
|
||||||
class SrsAudioTranscoder;
|
class SrsAudioTranscoder;
|
||||||
class SrsRtpPacket;
|
class SrsRtpPacket;
|
||||||
class SrsSample;
|
class SrsSample;
|
||||||
class SrsRtcStreamDescription;
|
class SrsRtcSourceDescription;
|
||||||
class SrsRtcTrackDescription;
|
class SrsRtcTrackDescription;
|
||||||
class SrsRtcConnection;
|
class SrsRtcConnection;
|
||||||
class SrsRtpRingBuffer;
|
class SrsRtpRingBuffer;
|
||||||
|
@ -74,20 +74,20 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// When RTC stream publish and re-publish.
|
// When RTC stream publish and re-publish.
|
||||||
class ISrsRtcStreamChangeCallback
|
class ISrsRtcSourceChangeCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ISrsRtcStreamChangeCallback();
|
ISrsRtcSourceChangeCallback();
|
||||||
virtual ~ISrsRtcStreamChangeCallback();
|
virtual ~ISrsRtcSourceChangeCallback();
|
||||||
public:
|
public:
|
||||||
virtual void on_stream_change(SrsRtcStreamDescription* desc) = 0;
|
virtual void on_stream_change(SrsRtcSourceDescription* desc) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The RTC stream consumer, consume packets from RTC stream source.
|
// The RTC stream consumer, consume packets from RTC stream source.
|
||||||
class SrsRtcConsumer
|
class SrsRtcConsumer
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsRtcStream* source;
|
SrsRtcSource* source;
|
||||||
std::vector<SrsRtpPacket*> queue;
|
std::vector<SrsRtpPacket*> queue;
|
||||||
// when source id changed, notice all consumers
|
// when source id changed, notice all consumers
|
||||||
bool should_update_source_id;
|
bool should_update_source_id;
|
||||||
|
@ -98,9 +98,9 @@ private:
|
||||||
int mw_min_msgs;
|
int mw_min_msgs;
|
||||||
private:
|
private:
|
||||||
// The callback for stream change event.
|
// The callback for stream change event.
|
||||||
ISrsRtcStreamChangeCallback* handler_;
|
ISrsRtcSourceChangeCallback* handler_;
|
||||||
public:
|
public:
|
||||||
SrsRtcConsumer(SrsRtcStream* s);
|
SrsRtcConsumer(SrsRtcSource* s);
|
||||||
virtual ~SrsRtcConsumer();
|
virtual ~SrsRtcConsumer();
|
||||||
public:
|
public:
|
||||||
// When source id changed, notice client to print.
|
// When source id changed, notice client to print.
|
||||||
|
@ -113,31 +113,31 @@ public:
|
||||||
// Wait for at-least some messages incoming in queue.
|
// Wait for at-least some messages incoming in queue.
|
||||||
virtual void wait(int nb_msgs);
|
virtual void wait(int nb_msgs);
|
||||||
public:
|
public:
|
||||||
void set_handler(ISrsRtcStreamChangeCallback* h) { handler_ = h; } // SrsRtcConsumer::set_handler()
|
void set_handler(ISrsRtcSourceChangeCallback* h) { handler_ = h; } // SrsRtcConsumer::set_handler()
|
||||||
void on_stream_change(SrsRtcStreamDescription* desc);
|
void on_stream_change(SrsRtcSourceDescription* desc);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsRtcStreamManager
|
class SrsRtcSourceManager
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
srs_mutex_t lock;
|
srs_mutex_t lock;
|
||||||
std::map<std::string, SrsRtcStream*> pool;
|
std::map<std::string, SrsRtcSource*> pool;
|
||||||
public:
|
public:
|
||||||
SrsRtcStreamManager();
|
SrsRtcSourceManager();
|
||||||
virtual ~SrsRtcStreamManager();
|
virtual ~SrsRtcSourceManager();
|
||||||
public:
|
public:
|
||||||
// create source when fetch from cache failed.
|
// create source when fetch from cache failed.
|
||||||
// @param r the client request.
|
// @param r the client request.
|
||||||
// @param pps the matched source, if success never be NULL.
|
// @param pps the matched source, if success never be NULL.
|
||||||
virtual srs_error_t fetch_or_create(SrsRequest* r, SrsRtcStream** pps);
|
virtual srs_error_t fetch_or_create(SrsRequest* r, SrsRtcSource** pps);
|
||||||
private:
|
private:
|
||||||
// Get the exists source, NULL when not exists.
|
// Get the exists source, NULL when not exists.
|
||||||
// update the request and return the exists source.
|
// update the request and return the exists source.
|
||||||
virtual SrsRtcStream* fetch(SrsRequest* r);
|
virtual SrsRtcSource* fetch(SrsRequest* r);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Global singleton instance.
|
// Global singleton instance.
|
||||||
extern SrsRtcStreamManager* _srs_rtc_sources;
|
extern SrsRtcSourceManager* _srs_rtc_sources;
|
||||||
|
|
||||||
// A publish stream interface, for source to callback with.
|
// A publish stream interface, for source to callback with.
|
||||||
class ISrsRtcPublishStream
|
class ISrsRtcPublishStream
|
||||||
|
@ -150,11 +150,11 @@ public:
|
||||||
virtual void request_keyframe(uint32_t ssrc) = 0;
|
virtual void request_keyframe(uint32_t ssrc) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ISrsRtcStreamEventHandler
|
class ISrsRtcSourceEventHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ISrsRtcStreamEventHandler();
|
ISrsRtcSourceEventHandler();
|
||||||
virtual ~ISrsRtcStreamEventHandler();
|
virtual ~ISrsRtcSourceEventHandler();
|
||||||
public:
|
public:
|
||||||
// stream unpublish, sync API.
|
// stream unpublish, sync API.
|
||||||
virtual void on_unpublish() = 0;
|
virtual void on_unpublish() = 0;
|
||||||
|
@ -162,7 +162,7 @@ public:
|
||||||
virtual void on_consumers_finished() = 0;
|
virtual void on_consumers_finished() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// SrsRtcStream bridge to SrsLiveSource
|
// SrsRtcSource bridge to SrsLiveSource
|
||||||
class ISrsRtcSourceBridger
|
class ISrsRtcSourceBridger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -175,7 +175,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// A Source is a stream, to publish and to play with, binding to SrsRtcPublishStream and SrsRtcPlayStream.
|
// A Source is a stream, to publish and to play with, binding to SrsRtcPublishStream and SrsRtcPlayStream.
|
||||||
class SrsRtcStream : public ISrsFastTimer
|
class SrsRtcSource : public ISrsFastTimer
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// For publish, it's the publish client id.
|
// For publish, it's the publish client id.
|
||||||
|
@ -188,7 +188,7 @@ private:
|
||||||
SrsRequest* req;
|
SrsRequest* req;
|
||||||
ISrsRtcPublishStream* publish_stream_;
|
ISrsRtcPublishStream* publish_stream_;
|
||||||
// Steam description for this steam.
|
// Steam description for this steam.
|
||||||
SrsRtcStreamDescription* stream_desc_;
|
SrsRtcSourceDescription* stream_desc_;
|
||||||
// The Source bridger, bridger stream to other source.
|
// The Source bridger, bridger stream to other source.
|
||||||
ISrsRtcSourceBridger* bridger_;
|
ISrsRtcSourceBridger* bridger_;
|
||||||
private:
|
private:
|
||||||
|
@ -199,14 +199,14 @@ private:
|
||||||
// Whether stream is delivering data, that is, DTLS is done.
|
// Whether stream is delivering data, that is, DTLS is done.
|
||||||
bool is_delivering_packets_;
|
bool is_delivering_packets_;
|
||||||
// Notify stream event to event handler
|
// Notify stream event to event handler
|
||||||
std::vector<ISrsRtcStreamEventHandler*> event_handlers_;
|
std::vector<ISrsRtcSourceEventHandler*> event_handlers_;
|
||||||
private:
|
private:
|
||||||
// The PLI for RTC2RTMP.
|
// The PLI for RTC2RTMP.
|
||||||
srs_utime_t pli_for_rtmp_;
|
srs_utime_t pli_for_rtmp_;
|
||||||
srs_utime_t pli_elapsed_;
|
srs_utime_t pli_elapsed_;
|
||||||
public:
|
public:
|
||||||
SrsRtcStream();
|
SrsRtcSource();
|
||||||
virtual ~SrsRtcStream();
|
virtual ~SrsRtcSource();
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t initialize(SrsRequest* r);
|
virtual srs_error_t initialize(SrsRequest* r);
|
||||||
// Update the authentication information in request.
|
// Update the authentication information in request.
|
||||||
|
@ -241,8 +241,8 @@ public:
|
||||||
virtual void on_unpublish();
|
virtual void on_unpublish();
|
||||||
public:
|
public:
|
||||||
// For event handler
|
// For event handler
|
||||||
void subscribe(ISrsRtcStreamEventHandler* h);
|
void subscribe(ISrsRtcSourceEventHandler* h);
|
||||||
void unsubscribe(ISrsRtcStreamEventHandler* h);
|
void unsubscribe(ISrsRtcSourceEventHandler* h);
|
||||||
public:
|
public:
|
||||||
// Get and set the publisher, passed to consumer to process requests such as PLI.
|
// Get and set the publisher, passed to consumer to process requests such as PLI.
|
||||||
ISrsRtcPublishStream* publish_stream();
|
ISrsRtcPublishStream* publish_stream();
|
||||||
|
@ -251,7 +251,7 @@ public:
|
||||||
srs_error_t on_rtp(SrsRtpPacket* pkt);
|
srs_error_t on_rtp(SrsRtpPacket* pkt);
|
||||||
// Set and get stream description for souce
|
// Set and get stream description for souce
|
||||||
bool has_stream_desc();
|
bool has_stream_desc();
|
||||||
void set_stream_desc(SrsRtcStreamDescription* stream_desc);
|
void set_stream_desc(SrsRtcSourceDescription* stream_desc);
|
||||||
std::vector<SrsRtcTrackDescription*> get_track_desc(std::string type, std::string media_type);
|
std::vector<SrsRtcTrackDescription*> get_track_desc(std::string type, std::string media_type);
|
||||||
// interface ISrsFastTimer
|
// interface ISrsFastTimer
|
||||||
private:
|
private:
|
||||||
|
@ -263,7 +263,7 @@ class SrsRtcFromRtmpBridger : public ISrsLiveSourceBridger
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsRequest* req;
|
SrsRequest* req;
|
||||||
SrsRtcStream* source_;
|
SrsRtcSource* source_;
|
||||||
// The format, codec information.
|
// The format, codec information.
|
||||||
SrsRtmpFormat* format;
|
SrsRtmpFormat* format;
|
||||||
// The metadata cache.
|
// The metadata cache.
|
||||||
|
@ -278,7 +278,7 @@ private:
|
||||||
uint32_t audio_ssrc;
|
uint32_t audio_ssrc;
|
||||||
uint32_t video_ssrc;
|
uint32_t video_ssrc;
|
||||||
public:
|
public:
|
||||||
SrsRtcFromRtmpBridger(SrsRtcStream* source);
|
SrsRtcFromRtmpBridger(SrsRtcSource* source);
|
||||||
virtual ~SrsRtcFromRtmpBridger();
|
virtual ~SrsRtcFromRtmpBridger();
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t initialize(SrsRequest* r);
|
virtual srs_error_t initialize(SrsRequest* r);
|
||||||
|
@ -292,7 +292,7 @@ public:
|
||||||
virtual srs_error_t on_video(SrsSharedPtrMessage* msg);
|
virtual srs_error_t on_video(SrsSharedPtrMessage* msg);
|
||||||
private:
|
private:
|
||||||
srs_error_t filter(SrsSharedPtrMessage* msg, SrsFormat* format, bool& has_idr, std::vector<SrsSample*>& samples);
|
srs_error_t filter(SrsSharedPtrMessage* msg, SrsFormat* format, bool& has_idr, std::vector<SrsSample*>& samples);
|
||||||
srs_error_t package_stap_a(SrsRtcStream* source, SrsSharedPtrMessage* msg, SrsRtpPacket* pkt);
|
srs_error_t package_stap_a(SrsRtcSource* source, SrsSharedPtrMessage* msg, SrsRtpPacket* pkt);
|
||||||
srs_error_t package_nalus(SrsSharedPtrMessage* msg, const std::vector<SrsSample*>& samples, std::vector<SrsRtpPacket*>& pkts);
|
srs_error_t package_nalus(SrsSharedPtrMessage* msg, const std::vector<SrsSample*>& samples, std::vector<SrsRtpPacket*>& pkts);
|
||||||
srs_error_t package_single_nalu(SrsSharedPtrMessage* msg, SrsSample* sample, std::vector<SrsRtpPacket*>& pkts);
|
srs_error_t package_single_nalu(SrsSharedPtrMessage* msg, SrsSample* sample, std::vector<SrsRtpPacket*>& pkts);
|
||||||
srs_error_t package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, std::vector<SrsRtpPacket*>& pkts);
|
srs_error_t package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, std::vector<SrsRtpPacket*>& pkts);
|
||||||
|
@ -504,7 +504,7 @@ public:
|
||||||
SrsRtcTrackDescription* copy();
|
SrsRtcTrackDescription* copy();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsRtcStreamDescription
|
class SrsRtcSourceDescription
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// the id for this stream;
|
// the id for this stream;
|
||||||
|
@ -513,11 +513,11 @@ public:
|
||||||
SrsRtcTrackDescription* audio_track_desc_;
|
SrsRtcTrackDescription* audio_track_desc_;
|
||||||
std::vector<SrsRtcTrackDescription*> video_track_descs_;
|
std::vector<SrsRtcTrackDescription*> video_track_descs_;
|
||||||
public:
|
public:
|
||||||
SrsRtcStreamDescription();
|
SrsRtcSourceDescription();
|
||||||
virtual ~SrsRtcStreamDescription();
|
virtual ~SrsRtcSourceDescription();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SrsRtcStreamDescription* copy();
|
SrsRtcSourceDescription* copy();
|
||||||
SrsRtcTrackDescription* find_track_description_by_ssrc(uint32_t ssrc);
|
SrsRtcTrackDescription* find_track_description_by_ssrc(uint32_t ssrc);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -556,7 +556,7 @@ public:
|
||||||
// set to NULL, nack nerver copy it but set the pkt to NULL.
|
// set to NULL, nack nerver copy it but set the pkt to NULL.
|
||||||
srs_error_t on_nack(SrsRtpPacket** ppkt);
|
srs_error_t on_nack(SrsRtpPacket** ppkt);
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket* pkt) = 0;
|
virtual srs_error_t on_rtp(SrsRtcSource* source, SrsRtpPacket* pkt) = 0;
|
||||||
virtual srs_error_t check_send_nacks() = 0;
|
virtual srs_error_t check_send_nacks() = 0;
|
||||||
protected:
|
protected:
|
||||||
virtual srs_error_t do_check_send_nacks(uint32_t& timeout_nacks);
|
virtual srs_error_t do_check_send_nacks(uint32_t& timeout_nacks);
|
||||||
|
@ -570,7 +570,7 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual void on_before_decode_payload(SrsRtpPacket* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtspPacketPayloadType* ppt);
|
virtual void on_before_decode_payload(SrsRtpPacket* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtspPacketPayloadType* ppt);
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket* pkt);
|
virtual srs_error_t on_rtp(SrsRtcSource* source, SrsRtpPacket* pkt);
|
||||||
virtual srs_error_t check_send_nacks();
|
virtual srs_error_t check_send_nacks();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -582,7 +582,7 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual void on_before_decode_payload(SrsRtpPacket* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtspPacketPayloadType* ppt);
|
virtual void on_before_decode_payload(SrsRtpPacket* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtspPacketPayloadType* ppt);
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket* pkt);
|
virtual srs_error_t on_rtp(SrsRtcSource* source, SrsRtpPacket* pkt);
|
||||||
virtual srs_error_t check_send_nacks();
|
virtual srs_error_t check_send_nacks();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -963,7 +963,7 @@ srs_error_t SrsRtmpConn::acquire_publish(SrsLiveSource* source)
|
||||||
|
|
||||||
// Check whether RTC stream is busy.
|
// Check whether RTC stream is busy.
|
||||||
#ifdef SRS_RTC
|
#ifdef SRS_RTC
|
||||||
SrsRtcStream *rtc = NULL;
|
SrsRtcSource *rtc = NULL;
|
||||||
bool rtc_server_enabled = _srs_config->get_rtc_server_enabled();
|
bool rtc_server_enabled = _srs_config->get_rtc_server_enabled();
|
||||||
bool rtc_enabled = _srs_config->get_rtc_enabled(req->vhost);
|
bool rtc_enabled = _srs_config->get_rtc_enabled(req->vhost);
|
||||||
if (rtc_server_enabled && rtc_enabled && !info->edge) {
|
if (rtc_server_enabled && rtc_enabled && !info->edge) {
|
||||||
|
|
|
@ -487,7 +487,7 @@ public:
|
||||||
// Global singleton instance.
|
// Global singleton instance.
|
||||||
extern SrsLiveSourceManager* _srs_sources;
|
extern SrsLiveSourceManager* _srs_sources;
|
||||||
|
|
||||||
// For RTMP2RTC, bridge SrsLiveSource to SrsRtcStream
|
// For RTMP2RTC, bridge SrsLiveSource to SrsRtcSource
|
||||||
class ISrsLiveSourceBridger
|
class ISrsLiveSourceBridger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -291,7 +291,7 @@ srs_error_t srs_thread_initialize()
|
||||||
|
|
||||||
// The global objects which depends on ST.
|
// The global objects which depends on ST.
|
||||||
_srs_hybrid = new SrsHybridServer();
|
_srs_hybrid = new SrsHybridServer();
|
||||||
_srs_rtc_sources = new SrsRtcStreamManager();
|
_srs_rtc_sources = new SrsRtcSourceManager();
|
||||||
_srs_sources = new SrsLiveSourceManager();
|
_srs_sources = new SrsLiveSourceManager();
|
||||||
_srs_stages = new SrsStageManager();
|
_srs_stages = new SrsStageManager();
|
||||||
_srs_blackhole = new SrsRtcBlackhole();
|
_srs_blackhole = new SrsRtcBlackhole();
|
||||||
|
|
|
@ -26,6 +26,6 @@
|
||||||
|
|
||||||
#define VERSION_MAJOR 4
|
#define VERSION_MAJOR 4
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 112
|
#define VERSION_REVISION 113
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue