mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
Refactor RTC session API
This commit is contained in:
parent
5fb7c4efbc
commit
157bc713a9
2 changed files with 17 additions and 13 deletions
|
@ -2247,17 +2247,16 @@ srs_error_t SrsRtcPublisher::notify(int type, srs_utime_t interval, srs_utime_t
|
|||
return err;
|
||||
}
|
||||
|
||||
SrsRtcSession::SrsRtcSession(SrsRtcServer* s, SrsSource* source, SrsRequest* r, bool is_publisher, const std::string& un, int context_id)
|
||||
SrsRtcSession::SrsRtcSession(SrsRtcServer* s)
|
||||
{
|
||||
username = un;
|
||||
req = r->copy();
|
||||
cid = context_id;
|
||||
req = NULL;
|
||||
cid = 0;
|
||||
is_publisher_ = false;
|
||||
encrypt = true;
|
||||
|
||||
source_ = source;
|
||||
source_ = NULL;
|
||||
publisher = NULL;
|
||||
sender = NULL;
|
||||
is_publisher_ = is_publisher;
|
||||
sendonly_skt = NULL;
|
||||
rtc_server = s;
|
||||
dtls_session = new SrsDtlsSession(this);
|
||||
|
@ -2343,10 +2342,16 @@ int SrsRtcSession::context_id()
|
|||
return cid;
|
||||
}
|
||||
|
||||
srs_error_t SrsRtcSession::initialize()
|
||||
srs_error_t SrsRtcSession::initialize(SrsSource* source, SrsRequest* r, bool is_publisher, const std::string& un, int context_id)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
username = un;
|
||||
req = r->copy();
|
||||
cid = context_id;
|
||||
is_publisher_ = is_publisher;
|
||||
source_ = source;
|
||||
|
||||
if ((err = dtls_session->initialize(req)) != srs_success) {
|
||||
return srs_error_wrap(err, "init");
|
||||
}
|
||||
|
@ -2786,7 +2791,6 @@ srs_error_t SrsRtcSession::on_rtcp_ps_feedback(char* buf, int nb_buf)
|
|||
//uint8_t padding = first & 0x20;
|
||||
uint8_t fmt = first & 0x1F;
|
||||
|
||||
// TODO: FIXME: Dead code?
|
||||
/*uint8_t payload_type = */stream->read_1bytes();
|
||||
/*uint16_t length = */stream->read_2bytes();
|
||||
/*uint32_t ssrc_of_sender = */stream->read_4bytes();
|
||||
|
@ -2797,8 +2801,8 @@ srs_error_t SrsRtcSession::on_rtcp_ps_feedback(char* buf, int nb_buf)
|
|||
SrsRtcPublisher* publisher = source_->rtc_publisher();
|
||||
if (publisher) {
|
||||
publisher->request_keyframe();
|
||||
srs_trace("RTC request PLI");
|
||||
}
|
||||
srs_trace("RTC request PLI");
|
||||
break;
|
||||
}
|
||||
case kSLI: {
|
||||
|
@ -3371,8 +3375,8 @@ srs_error_t SrsRtcServer::create_rtc_session(
|
|||
}
|
||||
|
||||
int cid = _srs_context->get_id();
|
||||
SrsRtcSession* session = new SrsRtcSession(this, source, req, publish, username, cid);
|
||||
if ((err = session->initialize()) != srs_success) {
|
||||
SrsRtcSession* session = new SrsRtcSession(this);
|
||||
if ((err = session->initialize(source, req, publish, username, cid)) != srs_success) {
|
||||
srs_freep(session);
|
||||
return srs_error_wrap(err, "init");
|
||||
}
|
||||
|
|
|
@ -337,7 +337,7 @@ private:
|
|||
sockaddr_in* blackhole_addr;
|
||||
srs_netfd_t blackhole_stfd;
|
||||
public:
|
||||
SrsRtcSession(SrsRtcServer* s, SrsSource* source, SrsRequest* r, bool is_publisher, const std::string& un, int context_id);
|
||||
SrsRtcSession(SrsRtcServer* s);
|
||||
virtual ~SrsRtcSession();
|
||||
public:
|
||||
SrsSdp* get_local_sdp();
|
||||
|
@ -353,7 +353,7 @@ public:
|
|||
void switch_to_context();
|
||||
int context_id();
|
||||
public:
|
||||
srs_error_t initialize();
|
||||
srs_error_t initialize(SrsSource* source, SrsRequest* r, bool is_publisher, const std::string& un, int context_id);
|
||||
// The peer address may change, we can identify that by STUN messages.
|
||||
srs_error_t on_stun(SrsUdpMuxSocket* skt, SrsStunPacket* r);
|
||||
srs_error_t on_dtls(char* data, int nb_data);
|
||||
|
|
Loading…
Reference in a new issue