Index: remoting/host/cast_extension_session.cc |
diff --git a/remoting/host/cast_extension_session.cc b/remoting/host/cast_extension_session.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..96250f4a08881947b718767d0f72dad149baff1c |
--- /dev/null |
+++ b/remoting/host/cast_extension_session.cc |
@@ -0,0 +1,615 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "remoting/host/cast_extension_session.h" |
+ |
+#include "base/bind.h" |
+#include "base/callback.h" |
+#include "base/json/json_reader.h" |
+#include "base/json/json_writer.h" |
+#include "base/logging.h" |
+#include "base/message_loop/message_loop.h" |
+#include "base/synchronization/waitable_event.h" |
+#include "net/url_request/url_request_context_getter.h" |
+#include "remoting/host/chromium_port_allocator_factory.h" |
+// #include "remoting/host/cast_video_capturer.h" |
+#include "remoting/host/client_session.h" |
+#include "remoting/proto/control.pb.h" |
+#include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h" |
+#include "third_party/libjingle/source/talk/app/webrtc/test/fakeconstraints.h" |
+#include "third_party/libjingle/source/talk/app/webrtc/videosourceinterface.h" |
+#include "third_party/webrtc/modules/desktop_capture/mouse_cursor_shape.h" |
+ |
+namespace remoting { |
+ |
+// Constant keys used in JSON messages to the host. |
+// Must keep synced with webapp. |
+const char kMessageData[] = "data"; // Use chromoting_data for CC v2. |
+const char kMessageSubject[] = "subject"; |
+const char kMessageType[] = "cast_message"; |
+ |
+const char kSubjectNewCandidate[] = "webrtc_candidate"; |
+const char kSubjectReady[] = "ready"; |
+const char kSubjectSDP[] = "webrtc_sdp"; |
+const char kSubjectTest[] = "test"; |
+ |
+const char kWebRtcPrefix[] = "webrtc_"; |
+ |
+// WebRTC Headers inside cast extension messages. |
+const char kWebRtcCandidate[] = "candidate"; |
+const char kWebRtcSessionDescType[] = "type"; |
+const char kWebRtcSessionDescSDP[] = "sdp"; |
+const char kWebRtcSDPMid[] = "sdpMid"; |
+const char kWebRtcSDPMLineIndex[] = "sdpMLineIndex"; |
+ |
+// Constants used by PeerConnection. |
+const char kVideoLabel[] = "cast_video_label"; |
+const char kStreamLabel[] = "stream_label"; |
+const char kDefaultStunURI[] = "stun:stun.l.google.com:19302"; |
+ |
+//------------------------------------------------------------------------------ |
+ |
+// webrtc::SetSessionDescriptionObserver implementation. |
+class CastSetSessionDescriptionObserver |
+ : public webrtc::SetSessionDescriptionObserver { |
+ public: |
+ static CastSetSessionDescriptionObserver* Create() { |
+ return new talk_base::RefCountedObject<CastSetSessionDescriptionObserver>(); |
+ } |
+ virtual void OnSuccess() OVERRIDE { |
+ VLOG(1) << "SetSessionDescriptionObserver success."; |
+ } |
+ virtual void OnFailure(const std::string& error) OVERRIDE { |
+ LOG(ERROR) << "CastSetSessionDescriptionObserver" << __FUNCTION__ << " " |
+ << error; |
+ } |
+ |
+ protected: |
+ CastSetSessionDescriptionObserver() {} |
+ virtual ~CastSetSessionDescriptionObserver() {} |
+}; |
+ |
+// webrtc::CreateSessionDescriptionObserver implementation. |
+class CastCreateSessionDescriptionObserver |
+ : public webrtc::CreateSessionDescriptionObserver { |
+ public: |
+ static CastCreateSessionDescriptionObserver* Create( |
+ CastExtensionSession* session) { |
+ return new talk_base::RefCountedObject< |
+ CastCreateSessionDescriptionObserver>(session); |
+ } |
+ virtual void OnSuccess(webrtc::SessionDescriptionInterface* desc) OVERRIDE { |
+ if (session_ == NULL) { |
+ LOG(ERROR) << "No Session, cannot create session description."; |
+ return; |
+ } |
+ session_->OnSuccess(desc); |
+ } |
+ virtual void OnFailure(const std::string& error) OVERRIDE { |
+ if (session_ == NULL) { |
+ LOG(ERROR) << "No Session, cannot create session description."; |
+ return; |
+ } |
+ session_->OnFailure(error); |
+ } |
+ |
+ protected: |
+ explicit CastCreateSessionDescriptionObserver(CastExtensionSession* session) |
+ : session_(session) {} |
+ virtual ~CastCreateSessionDescriptionObserver() {} |
+ |
+ private: |
+ CastExtensionSession* session_; |
+}; |
+ |
+// webrtc::StatsObserver implementation. |
+class CastStatsObserver : public webrtc::StatsObserver { |
+ public: |
+ static CastStatsObserver* Create() { |
+ return new talk_base::RefCountedObject<CastStatsObserver>(); |
+ } |
+ |
+ virtual void OnComplete( |
+ const std::vector<webrtc::StatsReport>& reports) OVERRIDE { |
+ if (reports.empty()) { |
+ VLOG(1) << "Received 0 StatsReports."; |
+ } |
+ VLOG(1) << "Received " << reports.size() << " new StatsReports."; |
+ std::vector<webrtc::StatsReport>::const_iterator it; |
+ for (it = reports.begin(); it != reports.end(); ++it) { |
+ LogStatsReport(*it); |
+ } |
+ } |
+ |
+ protected: |
+ CastStatsObserver() {} |
+ virtual ~CastStatsObserver() {} |
+ |
+ void LogStatsReport(const webrtc::StatsReport& report) { |
+ typedef webrtc::StatsReport StatsReport; |
+ typedef webrtc::StatsReport::Values::iterator ValuesIterator; |
+ webrtc::StatsReport::Values v = report.values; |
+ for (ValuesIterator it = v.begin(); it != v.end(); ++it) { |
+ VLOG(1) << "Param: " << it->name << "; Value: " << it->value << "."; |
+ } |
+ } |
+}; |
+ |
+//------------------------------------------------------------------------------ |
+ |
+// static |
+CastExtensionSession* CastExtensionSession::Create( |
+ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
+ scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, |
+ scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, |
+ const protocol::NetworkSettings& network_settings, |
+ ClientSession* client_session) { |
+ scoped_ptr<CastExtensionSession> cast_extension_session( |
+ new CastExtensionSession(network_task_runner, |
+ video_capture_task_runner, |
+ url_request_context_getter, |
+ network_settings, |
+ client_session)); |
+ bool success = cast_extension_session->WrapTasksAndSave(); |
+ success = cast_extension_session->InitializePeerConnection(); |
+ return (success ? cast_extension_session.release() : NULL); |
+} |
+ |
+CastExtensionSession::CastExtensionSession( |
+ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
+ scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, |
+ scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, |
+ const protocol::NetworkSettings& network_settings, |
+ ClientSession* client_session) |
+ : network_task_runner_(network_task_runner), |
+ capture_task_runner_(video_capture_task_runner), |
+ network_thread_wrapper_(NULL), |
+ capture_thread_wrapper_(NULL), |
+ url_request_context_getter_(url_request_context_getter), |
+ network_settings_(network_settings), |
+ client_session_(client_session), |
+ stats_observer_(CastStatsObserver::Create()) { |
+ DCHECK(network_task_runner_.get() != NULL); |
+ DCHECK(capture_task_runner_.get() != NULL); |
+ DCHECK(url_request_context_getter_.get() != NULL); |
+ DCHECK(client_session_); |
+} |
+ |
+CastExtensionSession::~CastExtensionSession() { |
+ DeletePeerConnection(); |
+} |
+ |
+std::string append_path(const char* first, const char* second) { |
+ std::string path(first); |
+ path.append("."); |
+ path.append(second); |
+ return path; |
+} |
+ |
+// Returns true if the ExtensionMessage was of type |kMessageType|, even if |
+// it was badly formed or a resulting action failed. This is done so that |
+// the host does not continue to attempt to pass |message| to other |
+// HostExtensionSessions. |
+bool CastExtensionSession::OnExtensionMessage( |
+ ClientSession* client_session, |
+ const protocol::ExtensionMessage& message) { |
+ if (!message.has_type() || message.type().compare(kMessageType) != 0) { |
+ return false; |
+ } |
+ |
+ scoped_ptr<base::Value> value(base::JSONReader::Read(message.data())); |
+ base::DictionaryValue* client_message; |
+ |
+ if (!(value && value->GetAsDictionary(&client_message))) { |
+ LOG(ERROR) << "Could not read cast extension message."; |
+ return true; |
+ } |
+ |
+ std::string subject; |
+ if (!client_message->GetString(kMessageSubject, &subject)) { |
+ LOG(ERROR) << "Invalid Cast Extension Message (missing subject header)."; |
+ return true; |
+ } |
+ |
+ if (subject == kSubjectSDP) { |
+ std::string webrtc_type; |
+ std::string sdp; |
+ if (!client_message->GetString( |
+ append_path(kMessageData, kWebRtcSessionDescType), &webrtc_type)) { |
+ LOG(ERROR) |
+ << "Invalid Cast Extension Message (missing webrtc type header)."; |
+ return true; |
+ } |
+ if (!client_message->GetString( |
+ append_path(kMessageData, kWebRtcSessionDescSDP), &sdp)) { |
+ LOG(ERROR) |
+ << "Invalid Cast Extension Message (missing webrtc sdp header)."; |
+ return true; |
+ } |
+ webrtc::SdpParseError error; |
+ webrtc::SessionDescriptionInterface* session_description( |
+ webrtc::CreateSessionDescription(webrtc_type, sdp, &error)); |
+ |
+ if (!session_description) { |
+ LOG(ERROR) << "Invalid Cast Extension Message (could not parse sdp)."; |
+ VLOG(1) << "SdpParseError was: " << error.line << "; " |
+ << error.description + ". (Ignore if empty)."; |
+ return true; |
+ } |
+ |
+ // Save the type because session_description is going to be given off to |
+ // PeerConnection. |
+ std::string sdp_type = session_description->type(); |
+ VLOG(1) << "Setting Remote Description."; |
+ peer_connection_->SetRemoteDescription( |
+ CastSetSessionDescriptionObserver::Create(), session_description); |
+ if (sdp_type == webrtc::SessionDescriptionInterface::kOffer) { |
+ // Setup MediaStream in PeerConnection because client has made an offer. |
+ // TODO(aiguha): Notify client of failure. |
+ if (!InitializeAndAddMediaStream()) { |
+ LOG(ERROR) << "InitializeAndAddMediaStream failed."; |
+ return true; |
+ } |
+ |
+ VLOG(1) << "Received Offer. Creating Answer."; |
+ peer_connection_->CreateAnswer( |
+ CastCreateSessionDescriptionObserver::Create(this), NULL); |
+ } |
+ return true; |
+ } else if (subject == kSubjectNewCandidate) { |
+ std::string candidate_str; |
+ std::string sdp_mid; |
+ int sdp_mlineindex = 0; |
+ if (!client_message->GetString(append_path(kMessageData, kWebRtcSDPMid), |
+ &sdp_mid) || |
+ !client_message->GetInteger( |
+ append_path(kMessageData, kWebRtcSDPMLineIndex), &sdp_mlineindex) || |
+ !client_message->GetString(append_path(kMessageData, kWebRtcCandidate), |
+ &candidate_str)) { |
+ LOG(ERROR) << "Invalid Cast Extension Message (could not parse)."; |
+ return true; |
+ } |
+ talk_base::scoped_ptr<webrtc::IceCandidateInterface> candidate( |
+ webrtc::CreateIceCandidate(sdp_mid, sdp_mlineindex, candidate_str)); |
+ if (!candidate.get()) { |
+ LOG(ERROR) |
+ << "Invalid Cast Extension Message (could not create candidate)."; |
+ return true; |
+ } |
+ if (!peer_connection_->AddIceCandidate(candidate.get())) { |
+ LOG(ERROR) << "Failed to apply received ICE Candidate to PeerConnection."; |
+ return true; |
+ } |
+ VLOG(1) << "Received ICE Candidate: " << candidate_str; |
+ } else { |
+ VLOG(1) << "Unexpected CastExtension Message: " << message.data(); |
+ } |
+ return true; |
+} |
+ |
+// Private Methods ------------------------------------------------------------- |
+ |
+bool CastExtensionSession::SendMessageToClient(const char* subject, |
+ const std::string& data) { |
+ DCHECK(network_task_runner_->BelongsToCurrentThread()); |
+ if (client_session_ == NULL) { |
+ LOG(ERROR) << "No Client Session. Cannot send message to client."; |
+ return false; |
+ } |
+ |
+ base::DictionaryValue message_dict; |
+ message_dict.SetString(kMessageSubject, subject); |
+ message_dict.SetString(kMessageData, data); |
+ std::string message_json; |
+ |
+ if (!base::JSONWriter::Write(&message_dict, &message_json)) { |
+ LOG(ERROR) << "Failed to create message json."; |
+ return false; |
+ } |
+ |
+ protocol::ExtensionMessage message; |
+ message.set_type(kMessageType); |
+ message.set_data(message_json); |
+ client_session_->connection()->client_stub()->DeliverHostMessage(message); |
+ return true; |
+} |
+ |
+void CastExtensionSession::SendCursorShape( |
+ scoped_ptr<protocol::CursorShapeInfo> cursor_shape) { |
+ DCHECK(network_task_runner_->BelongsToCurrentThread()); |
+ if (client_session_ == NULL) |
+ return; |
+ |
+ protocol::ClientStub* client_stub = |
+ client_session_->connection()->client_stub(); |
+ |
+ if (client_stub == NULL) |
+ return; |
+ |
+ client_stub->SetCursorShape(*cursor_shape); |
+} |
+ |
+void CastExtensionSession::EnsureTaskAndSetSend(talk_base::Thread** ptr, |
+ base::WaitableEvent* event) { |
+ jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); |
+ jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); |
+ *ptr = jingle_glue::JingleThreadWrapper::current(); |
+ |
+ if (event != NULL) |
+ event->Signal(); |
+} |
+ |
+bool CastExtensionSession::WrapTasksAndSave() { |
+ DCHECK(network_task_runner_->BelongsToCurrentThread()); |
+ EnsureTaskAndSetSend(&network_thread_wrapper_); |
+ |
+ if (network_thread_wrapper_ == NULL) |
+ return false; |
+ |
+ base::WaitableEvent wrap_capture_thread_event(true, false); |
+ capture_task_runner_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&CastExtensionSession::EnsureTaskAndSetSend, |
+ base::Unretained(this), |
+ &capture_thread_wrapper_, |
+ &wrap_capture_thread_event)); |
+ wrap_capture_thread_event.Wait(); |
+ |
+ return (capture_thread_wrapper_ != NULL); |
+} |
+ |
+bool CastExtensionSession::InitializePeerConnection() { |
+ DCHECK(network_task_runner_->BelongsToCurrentThread()); |
+ DCHECK(peer_conn_factory_.get() == NULL); |
+ DCHECK(peer_connection_.get() == NULL); |
+ DCHECK(capture_thread_wrapper_ != NULL); |
+ DCHECK(network_thread_wrapper_ != NULL); |
+ |
+ // TODO(aiguha): Confirm that worker and signalling threads are being |
+ // assigned appropriately. For the below configuration to work, |
+ // |capture_task_runner_| was changed to have a TYPE_IO MessageLoop. |
+ peer_conn_factory_ = webrtc::CreatePeerConnectionFactory( |
+ capture_thread_wrapper_, network_thread_wrapper_, NULL, NULL, NULL); |
+ |
+ if (!peer_conn_factory_.get()) { |
+ LOG(ERROR) << "Failed to initialize PeerConnectionFactory"; |
+ DeletePeerConnection(); |
+ return false; |
+ } |
+ |
+ VLOG(1) << "Created PeerConnectionFactory successfully."; |
+ |
+ webrtc::PeerConnectionInterface::IceServers servers; |
+ webrtc::PeerConnectionInterface::IceServer server; |
+ server.uri = kDefaultStunURI; |
+ servers.push_back(server); |
+ webrtc::PeerConnectionInterface::RTCConfiguration rtc_config; |
+ rtc_config.servers = servers; |
+ webrtc::FakeConstraints constraints; |
+ |
+ // DTLS-SRTP is the preferred encryption method. If set to kValueFalse, the |
+ // peer connection uses SDES. Disabling SDES as well will cause the peer |
+ // connection to fail to connect. |
+ // Note: For protection and unprotection of SRTP packets, the libjingle |
+ // ENABLE_EXTERNAL_AUTH flag must not be set. |
+ constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
+ webrtc::MediaConstraintsInterface::kValueTrue); |
+ |
+ peer_connection_ = peer_conn_factory_->CreatePeerConnection( |
+ rtc_config, |
+ &constraints, |
+ ChromiumPortAllocatorFactory::Create(network_settings_, |
+ url_request_context_getter_), |
+ NULL, |
+ this); |
+ |
+ if (!peer_connection_.get()) { |
+ LOG(ERROR) << "Failed to initialize PeerConnection."; |
+ DeletePeerConnection(); |
+ return false; |
+ } |
+ |
+ VLOG(1) << "Created PeerConnection successfully."; |
+ |
+ if (!SendMessageToClient(kSubjectTest, "Hello, client.")) { |
+ LOG(ERROR) << "Failed to send test message to client."; |
+ return false; |
+ } |
+ // Sending this message triggers the client to start the peer connection |
+ // offer/answer negotiation. |
+ if (!SendMessageToClient(kSubjectReady, "Host ready to receive offers.")) { |
+ LOG(ERROR) << "Failed to send ready message to client."; |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
+bool CastExtensionSession::InitializeAndAddMediaStream() { |
+ DCHECK(network_task_runner_->BelongsToCurrentThread()); |
+ |
+ if (stream_) { |
+ VLOG(1) << "Already added MediaStream."; |
+ return false; // Already added. |
+ } |
+ scoped_ptr<webrtc::ScreenCapturer> screen_capturer = |
+ client_session_->RequestScreenCapturer(); |
+ screen_capturer->SetMouseShapeObserver(this); |
+ // scoped_ptr<CastVideoCapturer> cast_video_capturer( |
+ // new CastVideoCapturer(capture_task_runner_, screen_capturer.Pass())); |
aiguha
2014/07/29 04:23:45
This is the only bit of code that relies on the ot
|
+ std::string minFrameRate = "3"; |
+ webrtc::FakeConstraints video_constraints; |
+ video_constraints.AddMandatory( |
+ webrtc::MediaConstraintsInterface::kMinFrameRate, minFrameRate); |
+ |
+ talk_base::scoped_refptr<webrtc::VideoTrackInterface> video_track = |
+ peer_conn_factory_->CreateVideoTrack( |
+ kVideoLabel, |
+ peer_conn_factory_->CreateVideoSource(NULL, |
+ &video_constraints)); |
+ |
+ VLOG(1) << "Created VideoTrack successfully."; |
+ stream_ = peer_conn_factory_->CreateLocalMediaStream(kStreamLabel); |
+ |
+ if (!stream_->AddTrack(video_track)) { |
+ LOG(ERROR) << "Failed to add VideoTrack to MediaStream."; |
+ return false; |
+ } else { |
+ VLOG(1) << "Added VideoTrack to MediaStream successfully."; |
+ } |
+ |
+ if (!peer_connection_->AddStream(stream_, NULL)) { |
+ VLOG(1) << "Failed to add MediaStream to PeerConnection."; |
+ return false; |
+ } else { |
+ VLOG(1) << "Added Stream to PeerConnection successfully."; |
+ } |
+ return true; |
+} |
+ |
+void CastExtensionSession::PollPeerConnectionStats() { |
+ if (!connection_active()) { |
+ VLOG(1) << "Cannot poll stats while PeerConnection is inactive."; |
+ } |
+ talk_base::scoped_refptr<webrtc::MediaStreamTrackInterface> video_track = |
+ stream_->FindVideoTrack(kVideoLabel); |
+ peer_connection_->GetStats( |
+ stats_observer_, |
+ video_track.release(), |
+ webrtc::PeerConnectionInterface::kStatsOutputLevelStandard); |
+} |
+ |
+void CastExtensionSession::DeletePeerConnection() { |
+ peer_connection_->Close(); |
+ // peer_connection_ = NULL; |
+ stream_ = NULL; |
+ peer_conn_factory_ = NULL; |
+} |
+ |
+bool CastExtensionSession::connection_active() const { |
+ return peer_connection_.get() != NULL; |
+} |
+ |
+// MouseShapeObserver implementation ------------------------------------------- |
+ |
+// TODO(aiguha): To reduce duplication, it would perhaps be |
+// better to create a single MouseShapeObserver outside of VideoScheduler |
+// that can be attached to the ScreenCapturer on its creation, in |
+// ClientSession. |
+void CastExtensionSession::OnCursorShapeChanged( |
+ webrtc::MouseCursorShape* cursor_shape) { |
+ DCHECK(capture_task_runner_->BelongsToCurrentThread()); |
+ VLOG(1) << __FUNCTION__ << " called."; |
+ scoped_ptr<webrtc::MouseCursorShape> owned_cursor(cursor_shape); |
+ |
+ scoped_ptr<protocol::CursorShapeInfo> cursor_proto( |
+ new protocol::CursorShapeInfo()); |
+ cursor_proto->set_width(cursor_shape->size.width()); |
+ cursor_proto->set_height(cursor_shape->size.height()); |
+ cursor_proto->set_hotspot_x(cursor_shape->hotspot.x()); |
+ cursor_proto->set_hotspot_y(cursor_shape->hotspot.y()); |
+ cursor_proto->set_data(cursor_shape->data); |
+ |
+ network_task_runner_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&CastExtensionSession::SendCursorShape, |
+ base::Unretained(this), |
+ base::Passed(&cursor_proto))); |
+} |
+ |
+// CreateSessionDescriptionObserver related methods ---------------------------- |
+ |
+void CastExtensionSession::OnSuccess( |
+ webrtc::SessionDescriptionInterface* desc) { |
+ if (!network_task_runner_->BelongsToCurrentThread()) { |
+ network_task_runner_->PostTask( |
+ FROM_HERE, |
+ base::Bind( |
+ &CastExtensionSession::OnSuccess, base::Unretained(this), desc)); |
+ return; |
+ } |
+ peer_connection_->SetLocalDescription( |
+ CastSetSessionDescriptionObserver::Create(), desc); |
+ scoped_ptr<base::DictionaryValue> json(new base::DictionaryValue()); |
+ json->SetString(kWebRtcSessionDescType, desc->type()); |
+ std::string subject = kWebRtcPrefix + desc->type(); |
+ std::string desc_str; |
+ desc->ToString(&desc_str); |
+ json->SetString(kWebRtcSessionDescSDP, desc_str); |
+ std::string json_str; |
+ base::JSONWriter::Write(json.get(), &json_str); |
+ SendMessageToClient(subject.c_str(), json_str); |
+} |
+ |
+void CastExtensionSession::OnFailure(const std::string& error) { |
+ VLOG(1) << __FUNCTION__ << " called with: " << error; |
+} |
+ |
+// PeerConnectionObserver implementation --------------------------------------- |
+ |
+void CastExtensionSession::OnError() { |
+ VLOG(1) << __FUNCTION__; |
+} |
+void CastExtensionSession::OnSignalingChange( |
+ webrtc::PeerConnectionInterface::SignalingState new_state) { |
+ VLOG(1) << "Function CastExtensionSession::OnSignalingChange called with " |
+ << new_state; |
+} |
+void CastExtensionSession::OnStateChange( |
+ webrtc::PeerConnectionObserver::StateType state_changed) { |
+ VLOG(1) << __FUNCTION__ << " called with input " << state_changed; |
+} |
+void CastExtensionSession::OnAddStream(webrtc::MediaStreamInterface* stream) { |
+ VLOG(1) << __FUNCTION__ << " " << stream->label(); |
+} |
+void CastExtensionSession::OnRemoveStream( |
+ webrtc::MediaStreamInterface* stream) { |
+ VLOG(1) << __FUNCTION__ << " " << stream->label(); |
+} |
+void CastExtensionSession::OnDataChannel( |
+ webrtc::DataChannelInterface* data_channel) { |
+ VLOG(1) << __FUNCTION__ << " called with " << data_channel->label(); |
+} |
+void CastExtensionSession::OnRenegotiationNeeded() { |
+ VLOG(1) << __FUNCTION__ << " called."; |
+} |
+void CastExtensionSession::OnIceConnectionChange( |
+ webrtc::PeerConnectionInterface::IceConnectionState new_state) { |
+ VLOG(1) << __FUNCTION__ << " called with new IceConnectionState " |
+ << new_state; |
+} |
+void CastExtensionSession::OnIceGatheringChange( |
+ webrtc::PeerConnectionInterface::IceGatheringState new_state) { |
+ VLOG(1) << __FUNCTION__ << " called with new IceGatheringState " << new_state; |
+} |
+ |
+void CastExtensionSession::OnIceComplete() { |
+ VLOG(1) << __FUNCTION__ << " called."; |
+ // TODO(aiguha): Maybe start timer only if enabled by command-line flag or |
+ // at a particular verbosity level. |
+ stats_polling_timer_.Start(FROM_HERE, |
+ base::TimeDelta::FromSeconds(10), |
+ this, |
+ &CastExtensionSession::PollPeerConnectionStats); |
+} |
+ |
+void CastExtensionSession::OnIceCandidate( |
+ const webrtc::IceCandidateInterface* candidate) { |
+ std::string candidate_str; |
+ if (!candidate->ToString(&candidate_str)) { |
+ LOG(ERROR) << __FUNCTION__ << " called, but could not serialize candidate."; |
+ return; |
+ } |
+ VLOG(1) << __FUNCTION__ << " called with " << candidate_str; |
+ scoped_ptr<base::DictionaryValue> json(new base::DictionaryValue()); |
+ json->SetString(kWebRtcSDPMid, candidate->sdp_mid()); |
+ json->SetInteger(kWebRtcSDPMLineIndex, candidate->sdp_mline_index()); |
+ json->SetString(kWebRtcCandidate, candidate_str); |
+ std::string json_str; |
+ base::JSONWriter::Write(json.get(), &json_str); |
+ SendMessageToClient(kSubjectNewCandidate, json_str); |
+} |
+ |
+} // namespace remoting |
+ |