diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index 66438e847..981a034b0 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -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"); } diff --git a/trunk/src/app/srs_app_rtc_conn.hpp b/trunk/src/app/srs_app_rtc_conn.hpp index 155536131..290d405c8 100644 --- a/trunk/src/app/srs_app_rtc_conn.hpp +++ b/trunk/src/app/srs_app_rtc_conn.hpp @@ -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);