diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl.cc b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl.cc index d60487eff..d57f5bf06 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl.cc @@ -285,10 +285,10 @@ bool PeerConnectionImpl::SignalingMessage_s(const std::string& msg) { return ret; } -WebRTCSession* PeerConnectionImpl::CreateMediaSession( +WebRtcSession* PeerConnectionImpl::CreateMediaSession( const std::string& id, const std::string& dir) { ASSERT(port_allocator_ != NULL); - WebRTCSession* session = new WebRTCSession(id, dir, + WebRtcSession* session = new WebRtcSession(id, dir, port_allocator_, channel_manager_.get(), signaling_thread_.get()); @@ -318,7 +318,7 @@ WebRTCSession* PeerConnectionImpl::CreateMediaSession( return session; } -void PeerConnectionImpl::SendRemoveSignal(WebRTCSession* session) { +void PeerConnectionImpl::SendRemoveSignal(WebRtcSession* session) { if (event_callback_) { std::string message; if (GetJSONSignalingMessage(session->remote_description(), diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl.h b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl.h index 39cf309c8..60c756ae2 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl.h @@ -53,7 +53,7 @@ namespace webrtc { class AudioDeviceModule; class ExternalRenderer; -class WebRTCSession; +class WebRtcSession; class PeerConnectionImpl : public PeerConnection, public talk_base::MessageHandler, @@ -114,8 +114,8 @@ class PeerConnectionImpl : public PeerConnection, bool ParseConfigString(const std::string& config, talk_base::SocketAddress* stun_addr); void WrapChromiumThread(); - void SendRemoveSignal(WebRTCSession* session); - WebRTCSession* CreateMediaSession(const std::string& id, + void SendRemoveSignal(WebRtcSession* session); + WebRtcSession* CreateMediaSession(const std::string& id, const std::string& dir); virtual void OnMessage(talk_base::Message* message); @@ -161,7 +161,7 @@ class PeerConnectionImpl : public PeerConnection, ServiceType service_type_; PeerConnectionObserver* event_callback_; - talk_base::scoped_ptr session_; + talk_base::scoped_ptr session_; // TODO(ronghua): There's no such concept as "incoming" and "outgoing" // according to the spec. This will be removed in the new PeerConnection. bool incoming_; diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.cc b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.cc index 6fadca033..096e3af51 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.cc @@ -36,12 +36,12 @@ bool PeerConnectionImpl::Init() { return true; } -WebRTCSession* PeerConnectionImpl::CreateSession() { - // TODO(ronghuawu): when we have the new WebRTCSession we don't need these +WebRtcSession* PeerConnectionImpl::CreateSession() { + // TODO(ronghuawu): when we have the new WebRtcSession we don't need these std::string id = ""; std::string direction = ""; - WebRTCSession* session = - new WebRTCSession(id, direction, port_allocator_, + WebRtcSession* session = + new WebRtcSession(id, direction, port_allocator_, channel_manager_, // TODO(ronghuawu): implement PeerConnectionImplCallbacks // this, diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.h b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.h index d5ec22c46..ec3aa09b6 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.h @@ -42,7 +42,7 @@ class Message; namespace webrtc { -class WebRTCSession; +class WebRtcSession; class PeerConnectionImpl : public PeerConnection { public: @@ -100,7 +100,7 @@ class PeerConnectionImpl : public PeerConnection { } private: - WebRTCSession* CreateSession(); + WebRtcSession* CreateSession(); virtual void OnMessage(talk_base::Message* msg); void AddStream_s(LocalStream* stream); void RemoveStream_s(LocalStream* stream); @@ -110,7 +110,7 @@ private: bool initialized_; ReadyState ready_state_; PeerConnectionObserver* observer_; - talk_base::scoped_ptr session_; + talk_base::scoped_ptr session_; talk_base::scoped_ptr signaling_thread_; cricket::ChannelManager* channel_manager_; cricket::PortAllocator* port_allocator_; diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnectiontransport.h b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnectiontransport.h index 4afd804d7..24a2b0cce 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnectiontransport.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnectiontransport.h @@ -53,7 +53,7 @@ class PeerConnectionTransport : public talk_base::MessageHandler, void ConnectChannels(); // methods to handle transport channels. These methods are relayed from - // WebRTCSessionImpl which implements cricket::BaseSession methods + // WebRtcSession which implements cricket::BaseSession methods cricket::TransportChannel* CreateChannel(const std::string& channel_name, const std::string& content_type); cricket::TransportChannel* GetChannel(const std::string& channel_name, diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession.cc b/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession.cc index ceedaf2fb..032d112fd 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession.cc @@ -64,10 +64,10 @@ typedef std::vector StreamMap; // not really a map (vector) static const char kVideoStream[] = "video_rtp"; static const char kAudioStream[] = "rtp"; -const char WebRTCSession::kOutgoingDirection[] = "s"; -const char WebRTCSession::kIncomingDirection[] = "r"; +const char WebRtcSession::kOutgoingDirection[] = "s"; +const char WebRtcSession::kIncomingDirection[] = "r"; -WebRTCSession::WebRTCSession( +WebRtcSession::WebRtcSession( const std::string& id, const std::string& direction, cricket::PortAllocator* allocator, @@ -76,7 +76,7 @@ WebRTCSession::WebRTCSession( : BaseSession(signaling_thread), transport_(NULL), channel_manager_(channelmgr), - all_transports_writable_(false), + transports_writable_(false), muted_(false), camera_muted_(false), setup_timeout_(kCallSetupTimeout), @@ -87,7 +87,7 @@ WebRTCSession::WebRTCSession( BaseSession::sid_ = id; } -WebRTCSession::~WebRTCSession() { +WebRtcSession::~WebRtcSession() { RemoveAllStreams(); if (state_ != STATE_RECEIVEDTERMINATE) { Terminate(); @@ -95,7 +95,7 @@ WebRTCSession::~WebRTCSession() { signaling_thread_->Send(this, MSG_WEBRTC_DELETE_TRANSPORT, NULL); } -bool WebRTCSession::Initiate() { +bool WebRtcSession::Initiate() { signaling_thread_->Send(this, MSG_WEBRTC_CREATE_TRANSPORT, NULL); if (transport_ == NULL) { return false; @@ -104,24 +104,24 @@ bool WebRTCSession::Initiate() { // start transports transport_->SignalRequestSignaling.connect( - this, &WebRTCSession::OnRequestSignaling); + this, &WebRtcSession::OnRequestSignaling); transport_->SignalCandidatesReady.connect( - this, &WebRTCSession::OnCandidatesReady); + this, &WebRtcSession::OnCandidatesReady); transport_->SignalWritableState.connect( - this, &WebRTCSession::OnWritableState); + this, &WebRtcSession::OnWritableState); // Limit the amount of time that setting up a call may take. StartTransportTimeout(kCallSetupTimeout); return true; } -cricket::Transport* WebRTCSession::CreateTransport() { +cricket::Transport* WebRtcSession::CreateTransport() { ASSERT(signaling_thread()->IsCurrent()); return new cricket::P2PTransport( talk_base::Thread::Current(), channel_manager_->worker_thread(), port_allocator()); } -bool WebRTCSession::CreateVoiceChannel(const std::string& stream_id) { +bool WebRtcSession::CreateVoiceChannel(const std::string& stream_id) { StreamInfo* stream_info = new StreamInfo(stream_id); stream_info->video = false; streams_.push_back(stream_info); @@ -138,7 +138,7 @@ bool WebRTCSession::CreateVoiceChannel(const std::string& stream_id) { return true; } -bool WebRTCSession::CreateVideoChannel(const std::string& stream_id) { +bool WebRtcSession::CreateVideoChannel(const std::string& stream_id) { StreamInfo* stream_info = new StreamInfo(stream_id); stream_info->video = true; streams_.push_back(stream_info); @@ -155,7 +155,7 @@ bool WebRTCSession::CreateVideoChannel(const std::string& stream_id) { return true; } -cricket::TransportChannel* WebRTCSession::CreateChannel( +cricket::TransportChannel* WebRtcSession::CreateChannel( const std::string& content_name, const std::string& name) { if (!transport_) { @@ -184,7 +184,7 @@ cricket::TransportChannel* WebRTCSession::CreateChannel( return transport_channel; } -cricket::TransportChannel* WebRTCSession::GetChannel( +cricket::TransportChannel* WebRtcSession::GetChannel( const std::string& content_name, const std::string& name) { if (!transport_) return NULL; @@ -198,7 +198,7 @@ cricket::TransportChannel* WebRTCSession::GetChannel( return NULL; } -void WebRTCSession::DestroyChannel( +void WebRtcSession::DestroyChannel( const std::string& content_name, const std::string& name) { if (!transport_) return; @@ -214,7 +214,7 @@ void WebRTCSession::DestroyChannel( } } -void WebRTCSession::OnMessage(talk_base::Message* message) { +void WebRtcSession::OnMessage(talk_base::Message* message) { switch (message->message_id) { case MSG_CANDIDATE_TIMEOUT: if (transport_->writable()) { @@ -239,7 +239,7 @@ void WebRTCSession::OnMessage(talk_base::Message* message) { } } -bool WebRTCSession::Connect() { +bool WebRtcSession::Connect() { if (streams_.empty()) { // nothing to initiate return false; @@ -259,7 +259,7 @@ bool WebRTCSession::Connect() { return true; } -bool WebRTCSession::SetVideoRenderer(const std::string& stream_id, +bool WebRtcSession::SetVideoRenderer(const std::string& stream_id, cricket::VideoRenderer* renderer) { bool ret = false; StreamMap::iterator iter; @@ -277,12 +277,12 @@ bool WebRTCSession::SetVideoRenderer(const std::string& stream_id, return ret; } -bool WebRTCSession::SetVideoCapture(bool capture) { +bool WebRtcSession::SetVideoCapture(bool capture) { channel_manager_->SetVideoCapture(capture); return true; } -bool WebRTCSession::RemoveStream(const std::string& stream_id) { +bool WebRtcSession::RemoveStream(const std::string& stream_id) { bool ret = false; StreamMap::iterator iter; for (iter = streams_.begin(); iter != streams_.end(); ++iter) { @@ -313,7 +313,7 @@ bool WebRTCSession::RemoveStream(const std::string& stream_id) { return ret; } -void WebRTCSession::DisableLocalCandidate(const std::string& name) { +void WebRtcSession::DisableLocalCandidate(const std::string& name) { for (size_t i = 0; i < local_candidates_.size(); ++i) { if (local_candidates_[i].name().compare(name) == 0) { talk_base::SocketAddress address(local_candidates_[i].address().ip(), 0); @@ -322,7 +322,7 @@ void WebRTCSession::DisableLocalCandidate(const std::string& name) { } } -void WebRTCSession::EnableAllStreams() { +void WebRtcSession::EnableAllStreams() { StreamMap::const_iterator i; for (i = streams_.begin(); i != streams_.end(); ++i) { cricket::BaseChannel* channel = (*i)->channel; @@ -331,7 +331,7 @@ void WebRTCSession::EnableAllStreams() { } } -void WebRTCSession::RemoveAllStreams() { +void WebRtcSession::RemoveAllStreams() { // signaling_thread_->Post(this, MSG_RTC_REMOVEALLSTREAMS); // First build a list of streams to remove and then remove them. // The reason we do this is that if we remove the streams inside the @@ -353,7 +353,7 @@ void WebRTCSession::RemoveAllStreams() { SignalRemoveStreamMessage(this); } -bool WebRTCSession::HasStream(const std::string& stream_id) const { +bool WebRtcSession::HasStream(const std::string& stream_id) const { StreamMap::const_iterator iter; for (iter = streams_.begin(); iter != streams_.end(); ++iter) { StreamInfo* sinfo = (*iter); @@ -364,7 +364,7 @@ bool WebRTCSession::HasStream(const std::string& stream_id) const { return false; } -bool WebRTCSession::HasStream(bool video) const { +bool WebRtcSession::HasStream(bool video) const { StreamMap::const_iterator iter; for (iter = streams_.begin(); iter != streams_.end(); ++iter) { StreamInfo* sinfo = (*iter); @@ -375,27 +375,27 @@ bool WebRTCSession::HasStream(bool video) const { return false; } -bool WebRTCSession::HasAudioStream() const { +bool WebRtcSession::HasAudioStream() const { return HasStream(false); } -bool WebRTCSession::HasVideoStream() const { +bool WebRtcSession::HasVideoStream() const { return HasStream(true); } -talk_base::Thread* WebRTCSession::worker_thread() { +talk_base::Thread* WebRtcSession::worker_thread() { return channel_manager_->worker_thread(); } -void WebRTCSession::OnRequestSignaling(cricket::Transport* transport) { +void WebRtcSession::OnRequestSignaling(cricket::Transport* transport) { transport->OnSignalingReady(); } -void WebRTCSession::OnWritableState(cricket::Transport* transport) { +void WebRtcSession::OnWritableState(cricket::Transport* transport) { ASSERT(transport == transport_); - const bool all_transports_writable = transport_->writable(); - if (all_transports_writable) { - if (all_transports_writable != all_transports_writable_) { + const bool transports_writable = transport_->writable(); + if (transports_writable) { + if (transports_writable != transports_writable_) { signaling_thread_->Clear(this, MSG_CANDIDATE_TIMEOUT); } else { // At one point all channels were writable and we had full connectivity, @@ -403,22 +403,22 @@ void WebRTCSession::OnWritableState(cricket::Transport* transport) { // doesn't come back. StartTransportTimeout(kCallLostTimeout); } - all_transports_writable_ = all_transports_writable; + transports_writable_ = transports_writable; } NotifyTransportState(); return; } -void WebRTCSession::StartTransportTimeout(int timeout) { +void WebRtcSession::StartTransportTimeout(int timeout) { talk_base::Thread::Current()->PostDelayed(timeout, this, MSG_CANDIDATE_TIMEOUT, NULL); } -void WebRTCSession::NotifyTransportState() { +void WebRtcSession::NotifyTransportState() { } -bool WebRTCSession::OnInitiateMessage( +bool WebRtcSession::OnInitiateMessage( cricket::SessionDescription* offer, const std::vector& candidates) { if (!offer) { @@ -480,7 +480,7 @@ bool WebRTCSession::OnInitiateMessage( return true; } -bool WebRTCSession::OnRemoteDescription( +bool WebRtcSession::OnRemoteDescription( cricket::SessionDescription* desc, const std::vector& candidates) { @@ -519,7 +519,7 @@ bool WebRTCSession::OnRemoteDescription( return true; } -void WebRTCSession::ProcessTerminateAccept(cricket::SessionDescription* desc) { +void WebRtcSession::ProcessTerminateAccept(cricket::SessionDescription* desc) { const cricket::ContentInfo* video_content = GetFirstVideoContent(desc); if (video_content) { SignalRemoveStream(video_content->name, true); @@ -531,7 +531,7 @@ void WebRTCSession::ProcessTerminateAccept(cricket::SessionDescription* desc) { } } -bool WebRTCSession::CheckForStreamDeleteMessage( +bool WebRtcSession::CheckForStreamDeleteMessage( const std::vector& candidates) { for (size_t i = 0; i < candidates.size(); ++i) { if (candidates[i].address().port() == 0) { @@ -541,7 +541,7 @@ bool WebRTCSession::CheckForStreamDeleteMessage( return false; } -bool WebRTCSession::OnStreamDeleteMessage( +bool WebRtcSession::OnStreamDeleteMessage( const cricket::SessionDescription* desc, const std::vector& candidates) { // This will be called when session is in connected state @@ -570,7 +570,7 @@ bool WebRTCSession::OnStreamDeleteMessage( return true; } -void WebRTCSession::RemoveStreamOnRequest( +void WebRtcSession::RemoveStreamOnRequest( const cricket::Candidate& candidate) { // 1. Get Transport corresponding to candidate name // 2. Get StreamInfo for the transport found in step 1 @@ -606,7 +606,7 @@ void WebRTCSession::RemoveStreamOnRequest( } } -cricket::SessionDescription* WebRTCSession::CreateOffer() { +cricket::SessionDescription* WebRtcSession::CreateOffer() { cricket::SessionDescription* offer = new cricket::SessionDescription(); StreamMap::iterator iter; for (iter = streams_.begin(); iter != streams_.end(); ++iter) { @@ -641,7 +641,7 @@ cricket::SessionDescription* WebRTCSession::CreateOffer() { return offer; } -cricket::SessionDescription* WebRTCSession::CreateAnswer( +cricket::SessionDescription* WebRtcSession::CreateAnswer( const cricket::SessionDescription* offer) { cricket::SessionDescription* answer = new cricket::SessionDescription(); @@ -699,35 +699,11 @@ cricket::SessionDescription* WebRTCSession::CreateAnswer( return answer; } -void WebRTCSession::OnMute(bool mute) { - StreamMap::iterator iter; - for (iter = streams_.begin(); iter != streams_.end(); ++iter) { - if (!(*iter)->video) { - cricket::VoiceChannel* voice_channel = - static_cast((*iter)->channel); - ASSERT(voice_channel != NULL); - voice_channel->Mute(mute); - } - } -} - -void WebRTCSession::OnCameraMute(bool mute) { - StreamMap::iterator iter; - for (iter = streams_.begin(); iter != streams_.end(); ++iter) { - if ((*iter)->video) { - cricket::VideoChannel* video_channel = - static_cast((*iter)->channel); - ASSERT(video_channel != NULL); - video_channel->Mute(mute); - } - } -} - -void WebRTCSession::SetError(Error error) { +void WebRtcSession::SetError(Error error) { BaseSession::SetError(error); } -void WebRTCSession::OnCandidatesReady( +void WebRtcSession::OnCandidatesReady( cricket::Transport* transport, const std::vector& candidates) { std::vector::const_iterator iter; diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession.h b/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession.h index 171441197..a551955a8 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession.h @@ -74,15 +74,15 @@ struct StreamInfo { typedef std::vector AudioCodecs; typedef std::vector VideoCodecs; -class WebRTCSession : public cricket::BaseSession { +class WebRtcSession : public cricket::BaseSession { public: - WebRTCSession(const std::string& id, + WebRtcSession(const std::string& id, const std::string& direction, cricket::PortAllocator* allocator, cricket::ChannelManager* channelmgr, talk_base::Thread* signaling_thread); - ~WebRTCSession(); + ~WebRtcSession(); bool Initiate(); bool Connect(); @@ -90,8 +90,6 @@ class WebRTCSession : public cricket::BaseSession { const std::vector& candidates); bool OnInitiateMessage(cricket::SessionDescription* sdp, const std::vector& candidates); - void OnMute(bool mute); - void OnCameraMute(bool mute); bool CreateVoiceChannel(const std::string& stream_id); bool CreateVideoChannel(const std::string& stream_id); bool RemoveStream(const std::string& stream_id); @@ -110,14 +108,31 @@ class WebRTCSession : public cricket::BaseSession { bool SetVideoRenderer(const std::string& stream_id, cricket::VideoRenderer* renderer); - sigslot::signal1 SignalRemoveStreamMessage; + // This signal occurs when all the streams have been removed. + // It is triggered by a successful call to the RemoveAllStream or + // the OnRemoteDescription with stream deleted signaling message with the + // candidates port equal to 0. + sigslot::signal1 SignalRemoveStreamMessage; + + // This signal indicates a stream has been added properly. + // It is triggered by a successful call to the OnInitiateMessage or + // the OnRemoteDescription and if it's going to the STATE_RECEIVEDACCEPT. sigslot::signal2 SignalAddStream; + + // This signal occurs when one stream is removed with the signaling + // message from the remote peer with the candidates port equal to 0. sigslot::signal2 SignalRemoveStream; + + // This signal occurs when audio/video channel has been created for the + // new added stream. sigslot::signal2 SignalRtcMediaChannelCreated; - // Triggered when the local candidate is ready + + // This signal occurs when the local candidate is ready sigslot::signal2&> SignalLocalDescription; - // This callback will trigger if setting up a call times out. + + // This signal triggers when setting up or resuming a call has not been + // successful before a certain time out. sigslot::signal0<> SignalFailedCall; bool muted() const { return muted_; } @@ -194,7 +209,7 @@ class WebRTCSession : public cricket::BaseSession { cricket::ChannelManager* channel_manager_; std::vector streams_; TransportChannelMap transport_channels_; - bool all_transports_writable_; + bool transports_writable_; bool muted_; bool camera_muted_; int setup_timeout_; diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession_unittest.cc b/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession_unittest.cc index ce0e03146..408c934d1 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession_unittest.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession_unittest.cc @@ -168,7 +168,7 @@ class OnSignalImpl enum CallbackId { kNone, kOnAddStream, - kOnRemoveStream2, + kOnRemoveStream, kOnRtcMediaChannelCreated, kOnLocalDescription, kOnFailedCall, @@ -190,8 +190,8 @@ class OnSignalImpl last_stream_id_ = stream_id; last_was_video_ = video; } - void OnRemoveStream2(const std::string& stream_id, bool video) { - callback_ids_.push_back(kOnRemoveStream2); + void OnRemoveStream(const std::string& stream_id, bool video) { + callback_ids_.push_back(kOnRemoveStream); last_stream_id_ = stream_id; last_was_video_ = video; } @@ -310,14 +310,14 @@ typedef ReturnBoolPassArgument< std::pair > ReturnBoolPassStringVideoRenderer; -class WebRTCSessionExtendedForTest : public webrtc::WebRTCSession { +class WebRtcSessionExtendedForTest : public webrtc::WebRtcSession { public: - WebRTCSessionExtendedForTest(const std::string& id, + WebRtcSessionExtendedForTest(const std::string& id, const std::string& direction, cricket::PortAllocator* allocator, cricket::ChannelManager* channelmgr, talk_base::Thread* signaling_thread) - : WebRTCSession(id, direction, allocator, channelmgr, signaling_thread), + : WebRtcSession(id, direction, allocator, channelmgr, signaling_thread), worker_thread_(channelmgr->worker_thread()) { } private: @@ -330,7 +330,7 @@ class WebRTCSessionExtendedForTest : public webrtc::WebRTCSession { talk_base::Thread* worker_thread_; }; -class WebRTCSessionTest : public OnSignalImpl, +class WebRtcSessionTest : public OnSignalImpl, public talk_base::MessageHandler { public: enum FunctionCallId { @@ -338,8 +338,6 @@ class WebRTCSessionTest : public OnSignalImpl, kCallConnect, kCallOnRemoteDescription, kCallOnInitiateMessage, - kCallOnMute, - kCallOnCameraMute, kCallMuted, kCallCameraMuted, kCallCreateVoiceChannel, @@ -356,9 +354,9 @@ class WebRTCSessionTest : public OnSignalImpl, enum {kInit = kCallLocalCandidates + 1}; enum {kTerminate = kInit + 1}; - static WebRTCSessionTest* CreateWebRTCSessionTest(bool receiving) { - WebRTCSessionTest* return_value = - new WebRTCSessionTest(); + static WebRtcSessionTest* CreateWebRtcSessionTest(bool receiving) { + WebRtcSessionTest* return_value = + new WebRtcSessionTest(); if (return_value == NULL) { return NULL; } @@ -436,16 +434,16 @@ class WebRTCSessionTest : public OnSignalImpl, talk_base::CreateRandomString(8, &id_); - session_ = new webrtc::WebRTCSession( + session_ = new webrtc::WebRtcSession( id_, DirectionAsString() , allocator_, channel_manager_, signaling_thread_); session_->SignalAddStream.connect( static_cast (this), &OnSignalImpl::OnAddStream); - session_->SignalRemoveStream2.connect( + session_->SignalRemoveStream.connect( static_cast (this), - &OnSignalImpl::OnRemoveStream2); + &OnSignalImpl::OnRemoveStream); session_->SignalRtcMediaChannelCreated.connect( static_cast (this), &OnSignalImpl::OnRtcMediaChannelCreated); @@ -466,7 +464,7 @@ class WebRTCSessionTest : public OnSignalImpl, delete allocator_; } - ~WebRTCSessionTest() { + ~WebRtcSessionTest() { if (signaling_thread_ != NULL) { signaling_thread_->Send(this, kTerminate, NULL); signaling_thread_->Stop(); @@ -509,28 +507,6 @@ class WebRTCSessionTest : public OnSignalImpl, return return_value.return_value_; } - void CallOnMute(bool mute) { - PassBool return_value(mute); - signaling_thread_->Send(this, kCallOnMute, &return_value); - } - - void CallOnCameraMute(bool mute) { - PassBool return_value(mute); - signaling_thread_->Send(this, kCallOnCameraMute, &return_value); - } - - bool CallMuted() { - ReturnBool return_value; - signaling_thread_->Send(this, kCallMuted, &return_value); - return return_value.return_value_; - } - - bool CallCameraMuted() { - ReturnBool return_value; - signaling_thread_->Send(this, kCallCameraMuted, &return_value); - return return_value.return_value_; - } - bool CallCreateVoiceChannel(const std::string& stream_id) { ReturnBoolPassString return_value(stream_id); signaling_thread_->Send(this, kCallCreateVoiceChannel, &return_value); @@ -641,16 +617,6 @@ class WebRTCSessionTest : public OnSignalImpl, return_value->return_value_ = true; } - void OnMute_s(talk_base::Message* message) { - PassBool* return_value = reinterpret_cast(message->pdata); - session_->OnMute(return_value->argument()); - } - - void OnCameraMute_s(talk_base::Message* message) { - PassBool* return_value = reinterpret_cast(message->pdata); - session_->OnCameraMute(return_value->argument()); - } - void Muted_s(talk_base::Message* message) { ReturnBool* return_value = reinterpret_cast(message->pdata); return_value->return_value_ = session_->muted(); @@ -747,12 +713,6 @@ class WebRTCSessionTest : public OnSignalImpl, case kCallOnInitiateMessage: OnInitiateMessage_s(message); return; - case kCallOnMute: - OnMute_s(message); - return; - case kCallOnCameraMute: - OnCameraMute_s(message); - return; case kCallMuted: Muted_s(message); return; @@ -802,7 +762,7 @@ class WebRTCSessionTest : public OnSignalImpl, } private: - WebRTCSessionTest() + WebRtcSessionTest() : session_(NULL), id_(), receiving_(false), @@ -812,7 +772,7 @@ class WebRTCSessionTest : public OnSignalImpl, signaling_thread_(NULL) { } - webrtc::WebRTCSession* session_; + webrtc::WebRtcSession* session_; std::string id_; bool receiving_; @@ -824,7 +784,7 @@ class WebRTCSessionTest : public OnSignalImpl, talk_base::Thread* signaling_thread_; }; -bool CallbackReceived(WebRTCSessionTest* session, int timeout) { +bool CallbackReceived(WebRtcSessionTest* session, int timeout) { talk_base::Thread::SleepMs(timeout); const OnSignalImpl::CallbackId peek_id = session->PeekOldestCallback(); @@ -837,8 +797,8 @@ void SleepMs(int timeout_ms) { TEST(WebRtcSessionTest, InitializationReceiveSanity) { const bool kReceiving = true; - talk_base::scoped_ptr my_session; - my_session.reset(WebRTCSessionTest::CreateWebRTCSessionTest(kReceiving)); + talk_base::scoped_ptr my_session; + my_session.reset(WebRtcSessionTest::CreateWebRtcSessionTest(kReceiving)); ASSERT_TRUE(my_session.get() != NULL); ASSERT_TRUE(my_session->CallInitiate()); @@ -854,10 +814,11 @@ TEST(WebRtcSessionTest, InitializationReceiveSanity) { my_session->PopOldestCallback()); } +// TODO(ronghuawu): Add tests for video calls and incoming calls. TEST(WebRtcSessionTest, SendCallSetUp) { const bool kReceiving = false; - talk_base::scoped_ptr my_session; - my_session.reset(WebRTCSessionTest::CreateWebRTCSessionTest(kReceiving)); + talk_base::scoped_ptr my_session; + my_session.reset(WebRtcSessionTest::CreateWebRtcSessionTest(kReceiving)); ASSERT_TRUE(my_session.get() != NULL); ASSERT_TRUE(my_session->CallInitiate());