mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Enable track of player when init done.
This commit is contained in:
parent
8aa20d390e
commit
0eae1bd493
6 changed files with 55 additions and 2 deletions
|
@ -525,6 +525,35 @@ void SrsRtcPlayStream::nack_fetch(vector<SrsRtpPacket2*>& pkts, uint32_t ssrc, u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsRtcPlayStream::set_track_status(bool status)
|
||||||
|
{
|
||||||
|
std::ostringstream merged_log;
|
||||||
|
|
||||||
|
// set video track status
|
||||||
|
if (true) {
|
||||||
|
std::map<uint32_t, SrsRtcVideoSendTrack*>::iterator it;
|
||||||
|
for (it = video_tracks_.begin(); it != video_tracks_.end(); ++it) {
|
||||||
|
SrsRtcVideoSendTrack* track = it->second;
|
||||||
|
|
||||||
|
bool previous = track->set_track_status(status);
|
||||||
|
merged_log << "{track: " << track->get_track_id() << ", is_active: " << previous << "=>" << status << "},";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set audio track status
|
||||||
|
if (true) {
|
||||||
|
std::map<uint32_t, SrsRtcAudioSendTrack*>::iterator it;
|
||||||
|
for (it = audio_tracks_.begin(); it != audio_tracks_.end(); ++it) {
|
||||||
|
SrsRtcAudioSendTrack* track = it->second;
|
||||||
|
|
||||||
|
bool previous = track->set_track_status(status);
|
||||||
|
merged_log << "{track: " << track->get_track_id() << ", is_active: " << previous << "=>" << status << "},";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
srs_trace("set status, %s", merged_log.str().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcPlayStream::notify(int type, srs_utime_t interval, srs_utime_t tick)
|
srs_error_t SrsRtcPlayStream::notify(int type, srs_utime_t interval, srs_utime_t tick)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
@ -2276,6 +2305,19 @@ srs_error_t SrsRtcConnection::do_send_packets(const std::vector<SrsRtpPacket2*>&
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
srs_error_t SrsRtcConnection::set_play_track_status(bool status)
|
||||||
|
{
|
||||||
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
if (!player_) {
|
||||||
|
return srs_error_new(ERROR_RTC_NO_PLAYER, "set play track status");
|
||||||
|
}
|
||||||
|
|
||||||
|
player_->set_track_status(status);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SRS_OSX
|
#ifdef SRS_OSX
|
||||||
// These functions are similar to the older byteorder(3) family of functions.
|
// These functions are similar to the older byteorder(3) family of functions.
|
||||||
// For example, be32toh() is identical to ntohl().
|
// For example, be32toh() is identical to ntohl().
|
||||||
|
|
|
@ -208,6 +208,8 @@ private:
|
||||||
srs_error_t send_packets(SrsRtcStream* source, const std::vector<SrsRtpPacket2*>& pkts, SrsRtcPlayStreamStatistic& info);
|
srs_error_t send_packets(SrsRtcStream* source, const std::vector<SrsRtpPacket2*>& pkts, SrsRtcPlayStreamStatistic& info);
|
||||||
public:
|
public:
|
||||||
void nack_fetch(std::vector<SrsRtpPacket2*>& pkts, uint32_t ssrc, uint16_t seq);
|
void nack_fetch(std::vector<SrsRtpPacket2*>& pkts, uint32_t ssrc, uint16_t seq);
|
||||||
|
// Directly set the status of track, generally for init to set the default value.
|
||||||
|
void set_track_status(bool status);
|
||||||
// interface ISrsHourGlass
|
// interface ISrsHourGlass
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t notify(int type, srs_utime_t interval, srs_utime_t tick);
|
virtual srs_error_t notify(int type, srs_utime_t interval, srs_utime_t tick);
|
||||||
|
@ -409,6 +411,8 @@ public:
|
||||||
void simulate_nack_drop(int nn);
|
void simulate_nack_drop(int nn);
|
||||||
void simulate_player_drop_packet(SrsRtpHeader* h, int nn_bytes);
|
void simulate_player_drop_packet(SrsRtpHeader* h, int nn_bytes);
|
||||||
srs_error_t do_send_packets(const std::vector<SrsRtpPacket2*>& pkts, SrsRtcPlayStreamStatistic& info);
|
srs_error_t do_send_packets(const std::vector<SrsRtpPacket2*>& pkts, SrsRtcPlayStreamStatistic& info);
|
||||||
|
// Directly set the status of play track, generally for init to set the default value.
|
||||||
|
srs_error_t set_play_track_status(bool status);
|
||||||
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
|
||||||
|
|
|
@ -413,6 +413,10 @@ srs_error_t SrsRtcServer::do_create_session(
|
||||||
if ((err = session->add_player(req, remote_sdp, local_sdp)) != srs_success) {
|
if ((err = session->add_player(req, remote_sdp, local_sdp)) != srs_success) {
|
||||||
return srs_error_wrap(err, "add player");
|
return srs_error_wrap(err, "add player");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: FIXME: Handle error.
|
||||||
|
// All tracks default as inactive, so we must enable them.
|
||||||
|
session->set_play_track_status(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string local_pwd = srs_random_str(32);
|
std::string local_pwd = srs_random_str(32);
|
||||||
|
|
|
@ -1756,9 +1756,11 @@ SrsRtpPacket2* SrsRtcSendTrack::fetch_rtp_packet(uint16_t seq)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: FIXME: Should refine logs, set tracks in a time.
|
// TODO: FIXME: Should refine logs, set tracks in a time.
|
||||||
void SrsRtcSendTrack::set_track_status(bool active)
|
bool SrsRtcSendTrack::set_track_status(bool active)
|
||||||
{
|
{
|
||||||
|
bool previous_status = track_desc_->is_active_;
|
||||||
track_desc_->is_active_ = active;
|
track_desc_->is_active_ = active;
|
||||||
|
return previous_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SrsRtcSendTrack::get_track_status()
|
bool SrsRtcSendTrack::get_track_status()
|
||||||
|
|
|
@ -510,7 +510,7 @@ public:
|
||||||
public:
|
public:
|
||||||
bool has_ssrc(uint32_t ssrc);
|
bool has_ssrc(uint32_t ssrc);
|
||||||
SrsRtpPacket2* fetch_rtp_packet(uint16_t seq);
|
SrsRtpPacket2* fetch_rtp_packet(uint16_t seq);
|
||||||
void set_track_status(bool active);
|
bool set_track_status(bool active);
|
||||||
bool get_track_status();
|
bool get_track_status();
|
||||||
std::string get_track_id();
|
std::string get_track_id();
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -356,6 +356,7 @@
|
||||||
#define ERROR_RTC_STREM_STARTED 5025
|
#define ERROR_RTC_STREM_STARTED 5025
|
||||||
#define ERROR_RTC_STREAM_DESC 5026
|
#define ERROR_RTC_STREAM_DESC 5026
|
||||||
#define ERROR_RTC_TRACK_CODEC 5027
|
#define ERROR_RTC_TRACK_CODEC 5027
|
||||||
|
#define ERROR_RTC_NO_PLAYER 5028
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
// GB28181 API error.
|
// GB28181 API error.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue