#include #include "api/video/video_frame.h" #include "remote.pb.h" #include "peer_connection.h" #include "socket_remote.h" CPeerConnection::CPeerConnection(SocketRemote* c):_client(c) { } CPeerConnection::~CPeerConnection() { if (_nativeHandle != nullptr) { } } bool CPeerConnection::CreateOffer() { // std::cout<<__FUNCTION__<<","<<__LINE__<(user_data); lhs->OnLocalSdpReadytoSend(peer, view, type, sdp_data); } void CPeerConnection::OnLocalSdpReadytoSend(int32_t peer, int32_t view, const char* type, const char* sdp) { //std::string newsdp = ForceSdpCodecs(sdp, PreferredAudioCodec, PreferredAudioCodecExtraParamsRemote, PreferredVideoCodec, PreferredVideoCodecExtraParamsRemote); //std::cout<WriteOffer(peer, view, type, sdp); } else if (kAnswer == type) { _client->WriteAnswer(peer, view, type, sdp); } //mrsWe } void CPeerConnection::IceCandidateReadytoSendCallback(void* user_data, int32_t peer, int32_t index, const char* sdp, int32_t sdp_mline_index, const char* sdp_mid) { auto lhs = static_cast(user_data); lhs->OnIceCandidateReadytoSend(peer, index, sdp, sdp_mline_index, sdp_mid); } void CPeerConnection::OnIceCandidateReadytoSend(int32_t peer, int32_t index, const char* candidate, int32_t sdp_mline_index, const char* sdp_mid) { _client->WriteCandidate(peer, index, candidate, sdp_mline_index, sdp_mid); } void CPeerConnection::Close() { //std::lock_guard l(_lock); if (_nativeHandle == nullptr) return; mrsPeerConnectionRegisterLocalSdpReadytoSendCallback(_nativeHandle, 0, 0, nullptr, nullptr); mrsPeerConnectionRegisterIceCandidateReadytoSendCallback(_nativeHandle, 0, 0, nullptr, nullptr); mrsPeerConnectionClose(&_nativeHandle); _nativeHandle = nullptr; }