mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
RTC: Refine static cast for RTC connection
This commit is contained in:
parent
a5b21c159f
commit
e17d20c8fa
2 changed files with 10 additions and 13 deletions
|
@ -415,8 +415,11 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// A RTC Peer Connection, SDP level object.
|
// A RTC Peer Connection, SDP level object.
|
||||||
class SrsRtcConnection : virtual public ISrsHourGlass, virtual public ISrsResource
|
//
|
||||||
, virtual public ISrsDisposingHandler
|
// For performance, we use non-virtual public from resource,
|
||||||
|
// see https://stackoverflow.com/questions/3747066/c-cannot-convert-from-base-a-to-derived-type-b-via-virtual-base-a
|
||||||
|
class SrsRtcConnection : public ISrsResource
|
||||||
|
, virtual public ISrsHourGlass, virtual public ISrsDisposingHandler
|
||||||
{
|
{
|
||||||
friend class SrsSecurityTransport;
|
friend class SrsSecurityTransport;
|
||||||
friend class SrsRtcPlayStream;
|
friend class SrsRtcPlayStream;
|
||||||
|
|
|
@ -303,18 +303,12 @@ srs_error_t SrsRtcServer::on_udp_packet(SrsUdpMuxSocket* skt)
|
||||||
string peer_id = skt->peer_id();
|
string peer_id = skt->peer_id();
|
||||||
char* data = skt->data(); int size = skt->size();
|
char* data = skt->data(); int size = skt->size();
|
||||||
|
|
||||||
SrsRtcConnection* session = NULL;
|
SrsRtcConnection* session = (SrsRtcConnection*)_srs_rtc_manager->find_by_id(peer_id);
|
||||||
if (true) {
|
if (session) {
|
||||||
ISrsResource* conn = _srs_rtc_manager->find_by_id(peer_id);
|
|
||||||
if (conn) {
|
|
||||||
// Switch to the session to write logs to the context.
|
// Switch to the session to write logs to the context.
|
||||||
session = dynamic_cast<SrsRtcConnection*>(conn);
|
|
||||||
session->switch_to_context();
|
session->switch_to_context();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// When got any packet, the session is alive now.
|
// When got any packet, the session is alive now.
|
||||||
if (session) {
|
|
||||||
session->alive();
|
session->alive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue