OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/cast_extension_session.h" | 5 #include "remoting/host/cast_extension_session.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 const int kMinFramesPerSecond = 5; | 64 const int kMinFramesPerSecond = 5; |
65 | 65 |
66 // A webrtc::SetSessionDescriptionObserver implementation used to receive the | 66 // A webrtc::SetSessionDescriptionObserver implementation used to receive the |
67 // results of setting local and remote descriptions of the PeerConnection. | 67 // results of setting local and remote descriptions of the PeerConnection. |
68 class CastSetSessionDescriptionObserver | 68 class CastSetSessionDescriptionObserver |
69 : public webrtc::SetSessionDescriptionObserver { | 69 : public webrtc::SetSessionDescriptionObserver { |
70 public: | 70 public: |
71 static CastSetSessionDescriptionObserver* Create() { | 71 static CastSetSessionDescriptionObserver* Create() { |
72 return new rtc::RefCountedObject<CastSetSessionDescriptionObserver>(); | 72 return new rtc::RefCountedObject<CastSetSessionDescriptionObserver>(); |
73 } | 73 } |
74 virtual void OnSuccess() OVERRIDE { | 74 virtual void OnSuccess() override { |
75 VLOG(1) << "Setting session description succeeded."; | 75 VLOG(1) << "Setting session description succeeded."; |
76 } | 76 } |
77 virtual void OnFailure(const std::string& error) OVERRIDE { | 77 virtual void OnFailure(const std::string& error) override { |
78 LOG(ERROR) << "Setting session description failed: " << error; | 78 LOG(ERROR) << "Setting session description failed: " << error; |
79 } | 79 } |
80 | 80 |
81 protected: | 81 protected: |
82 CastSetSessionDescriptionObserver() {} | 82 CastSetSessionDescriptionObserver() {} |
83 virtual ~CastSetSessionDescriptionObserver() {} | 83 virtual ~CastSetSessionDescriptionObserver() {} |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(CastSetSessionDescriptionObserver); | 85 DISALLOW_COPY_AND_ASSIGN(CastSetSessionDescriptionObserver); |
86 }; | 86 }; |
87 | 87 |
88 // A webrtc::CreateSessionDescriptionObserver implementation used to receive the | 88 // A webrtc::CreateSessionDescriptionObserver implementation used to receive the |
89 // results of creating descriptions for this end of the PeerConnection. | 89 // results of creating descriptions for this end of the PeerConnection. |
90 class CastCreateSessionDescriptionObserver | 90 class CastCreateSessionDescriptionObserver |
91 : public webrtc::CreateSessionDescriptionObserver { | 91 : public webrtc::CreateSessionDescriptionObserver { |
92 public: | 92 public: |
93 static CastCreateSessionDescriptionObserver* Create( | 93 static CastCreateSessionDescriptionObserver* Create( |
94 CastExtensionSession* session) { | 94 CastExtensionSession* session) { |
95 return new rtc::RefCountedObject<CastCreateSessionDescriptionObserver>( | 95 return new rtc::RefCountedObject<CastCreateSessionDescriptionObserver>( |
96 session); | 96 session); |
97 } | 97 } |
98 virtual void OnSuccess(webrtc::SessionDescriptionInterface* desc) OVERRIDE { | 98 virtual void OnSuccess(webrtc::SessionDescriptionInterface* desc) override { |
99 if (cast_extension_session_ == NULL) { | 99 if (cast_extension_session_ == NULL) { |
100 LOG(ERROR) | 100 LOG(ERROR) |
101 << "No CastExtensionSession. Creating session description succeeded."; | 101 << "No CastExtensionSession. Creating session description succeeded."; |
102 return; | 102 return; |
103 } | 103 } |
104 cast_extension_session_->OnCreateSessionDescription(desc); | 104 cast_extension_session_->OnCreateSessionDescription(desc); |
105 } | 105 } |
106 virtual void OnFailure(const std::string& error) OVERRIDE { | 106 virtual void OnFailure(const std::string& error) override { |
107 if (cast_extension_session_ == NULL) { | 107 if (cast_extension_session_ == NULL) { |
108 LOG(ERROR) | 108 LOG(ERROR) |
109 << "No CastExtensionSession. Creating session description failed."; | 109 << "No CastExtensionSession. Creating session description failed."; |
110 return; | 110 return; |
111 } | 111 } |
112 cast_extension_session_->OnCreateSessionDescriptionFailure(error); | 112 cast_extension_session_->OnCreateSessionDescriptionFailure(error); |
113 } | 113 } |
114 void SetCastExtensionSession(CastExtensionSession* cast_extension_session) { | 114 void SetCastExtensionSession(CastExtensionSession* cast_extension_session) { |
115 cast_extension_session_ = cast_extension_session; | 115 cast_extension_session_ = cast_extension_session; |
116 } | 116 } |
(...skipping 11 matching lines...) Expand all Loading... |
128 | 128 |
129 // A webrtc::StatsObserver implementation used to receive statistics about the | 129 // A webrtc::StatsObserver implementation used to receive statistics about the |
130 // current PeerConnection. | 130 // current PeerConnection. |
131 class CastStatsObserver : public webrtc::StatsObserver { | 131 class CastStatsObserver : public webrtc::StatsObserver { |
132 public: | 132 public: |
133 static CastStatsObserver* Create() { | 133 static CastStatsObserver* Create() { |
134 return new rtc::RefCountedObject<CastStatsObserver>(); | 134 return new rtc::RefCountedObject<CastStatsObserver>(); |
135 } | 135 } |
136 | 136 |
137 virtual void OnComplete( | 137 virtual void OnComplete( |
138 const std::vector<webrtc::StatsReport>& reports) OVERRIDE { | 138 const std::vector<webrtc::StatsReport>& reports) override { |
139 typedef webrtc::StatsReport::Values::iterator ValuesIterator; | 139 typedef webrtc::StatsReport::Values::iterator ValuesIterator; |
140 | 140 |
141 VLOG(1) << "Received " << reports.size() << " new StatsReports."; | 141 VLOG(1) << "Received " << reports.size() << " new StatsReports."; |
142 | 142 |
143 int index; | 143 int index; |
144 std::vector<webrtc::StatsReport>::const_iterator it; | 144 std::vector<webrtc::StatsReport>::const_iterator it; |
145 for (it = reports.begin(), index = 0; it != reports.end(); ++it, ++index) { | 145 for (it = reports.begin(), index = 0; it != reports.end(); ++it, ++index) { |
146 webrtc::StatsReport::Values v = it->values; | 146 webrtc::StatsReport::Values v = it->values; |
147 VLOG(1) << "Report " << index << ":"; | 147 VLOG(1) << "Report " << index << ":"; |
148 for (ValuesIterator vIt = v.begin(); vIt != v.end(); ++vIt) { | 148 for (ValuesIterator vIt = v.begin(); vIt != v.end(); ++vIt) { |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 json->SetString(kWebRtcCandidate, candidate_str); | 661 json->SetString(kWebRtcCandidate, candidate_str); |
662 std::string json_str; | 662 std::string json_str; |
663 if (!base::JSONWriter::Write(json.get(), &json_str)) { | 663 if (!base::JSONWriter::Write(json.get(), &json_str)) { |
664 LOG(ERROR) << "Failed to serialize candidate message."; | 664 LOG(ERROR) << "Failed to serialize candidate message."; |
665 return; | 665 return; |
666 } | 666 } |
667 SendMessageToClient(kSubjectNewCandidate, json_str); | 667 SendMessageToClient(kSubjectNewCandidate, json_str); |
668 } | 668 } |
669 | 669 |
670 } // namespace remoting | 670 } // namespace remoting |
OLD | NEW |