diff --git a/trunk/src/app/srs_app_rtc_conn.hpp b/trunk/src/app/srs_app_rtc_conn.hpp index 509616495..e5e6bb5a8 100644 --- a/trunk/src/app/srs_app_rtc_conn.hpp +++ b/trunk/src/app/srs_app_rtc_conn.hpp @@ -415,8 +415,11 @@ public: }; // 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 SrsRtcPlayStream; diff --git a/trunk/src/app/srs_app_rtc_server.cpp b/trunk/src/app/srs_app_rtc_server.cpp index 3e60d0782..24fe1e721 100644 --- a/trunk/src/app/srs_app_rtc_server.cpp +++ b/trunk/src/app/srs_app_rtc_server.cpp @@ -303,18 +303,12 @@ srs_error_t SrsRtcServer::on_udp_packet(SrsUdpMuxSocket* skt) string peer_id = skt->peer_id(); char* data = skt->data(); int size = skt->size(); - SrsRtcConnection* session = NULL; - if (true) { - ISrsResource* conn = _srs_rtc_manager->find_by_id(peer_id); - if (conn) { - // Switch to the session to write logs to the context. - session = dynamic_cast(conn); - session->switch_to_context(); - } - } - - // When got any packet, the session is alive now. + SrsRtcConnection* session = (SrsRtcConnection*)_srs_rtc_manager->find_by_id(peer_id); if (session) { + // Switch to the session to write logs to the context. + session->switch_to_context(); + + // When got any packet, the session is alive now. session->alive(); }