OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/media/rtc_peer_connection_handler.h" | 5 #include "content/renderer/media/rtc_peer_connection_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 33 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
34 #include "third_party/WebKit/public/platform/WebRTCConfiguration.h" | 34 #include "third_party/WebKit/public/platform/WebRTCConfiguration.h" |
35 #include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h" | 35 #include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h" |
36 #include "third_party/WebKit/public/platform/WebRTCICECandidate.h" | 36 #include "third_party/WebKit/public/platform/WebRTCICECandidate.h" |
37 #include "third_party/WebKit/public/platform/WebRTCOfferOptions.h" | 37 #include "third_party/WebKit/public/platform/WebRTCOfferOptions.h" |
38 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h" | 38 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h" |
39 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h" | 39 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h" |
40 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h" | 40 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h" |
41 #include "third_party/WebKit/public/platform/WebURL.h" | 41 #include "third_party/WebKit/public/platform/WebURL.h" |
42 | 42 |
| 43 using webrtc::StatsReport; |
| 44 using webrtc::StatsReports; |
| 45 |
43 namespace content { | 46 namespace content { |
44 | 47 |
45 // Converter functions from libjingle types to WebKit types. | 48 // Converter functions from libjingle types to WebKit types. |
46 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState | 49 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState |
47 GetWebKitIceGatheringState( | 50 GetWebKitIceGatheringState( |
48 webrtc::PeerConnectionInterface::IceGatheringState state) { | 51 webrtc::PeerConnectionInterface::IceGatheringState state) { |
49 using blink::WebRTCPeerConnectionHandlerClient; | 52 using blink::WebRTCPeerConnectionHandlerClient; |
50 switch (state) { | 53 switch (state) { |
51 case webrtc::PeerConnectionInterface::kIceGatheringNew: | 54 case webrtc::PeerConnectionInterface::kIceGatheringNew: |
52 return WebRTCPeerConnectionHandlerClient::ICEGatheringStateNew; | 55 return WebRTCPeerConnectionHandlerClient::ICEGatheringStateNew; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 // Class mapping responses from calls to libjingle | 251 // Class mapping responses from calls to libjingle |
249 // GetStats into a blink::WebRTCStatsCallback. | 252 // GetStats into a blink::WebRTCStatsCallback. |
250 class StatsResponse : public webrtc::StatsObserver { | 253 class StatsResponse : public webrtc::StatsObserver { |
251 public: | 254 public: |
252 explicit StatsResponse(const scoped_refptr<LocalRTCStatsRequest>& request) | 255 explicit StatsResponse(const scoped_refptr<LocalRTCStatsRequest>& request) |
253 : request_(request.get()), response_(request_->createResponse().get()) { | 256 : request_(request.get()), response_(request_->createResponse().get()) { |
254 // Measure the overall time it takes to satisfy a getStats request. | 257 // Measure the overall time it takes to satisfy a getStats request. |
255 TRACE_EVENT_ASYNC_BEGIN0("webrtc", "getStats_Native", this); | 258 TRACE_EVENT_ASYNC_BEGIN0("webrtc", "getStats_Native", this); |
256 } | 259 } |
257 | 260 |
258 virtual void OnComplete( | 261 virtual void OnComplete(const StatsReports& reports) OVERRIDE { |
259 const std::vector<webrtc::StatsReport>& reports) OVERRIDE { | |
260 TRACE_EVENT0("webrtc", "StatsResponse::OnComplete") | 262 TRACE_EVENT0("webrtc", "StatsResponse::OnComplete") |
261 for (std::vector<webrtc::StatsReport>::const_iterator it = reports.begin(); | 263 for (StatsReports::const_iterator it = reports.begin(); |
262 it != reports.end(); ++it) { | 264 it != reports.end(); ++it) { |
263 if (it->values.size() > 0) { | 265 if ((*it)->values.size() > 0) { |
264 AddReport(*it); | 266 AddReport(*(*it)); |
265 } | 267 } |
266 } | 268 } |
267 | 269 |
268 // Record the getSync operation as done before calling into Blink so that | 270 // Record the getSync operation as done before calling into Blink so that |
269 // we don't skew the perf measurements of the native code with whatever the | 271 // we don't skew the perf measurements of the native code with whatever the |
270 // callback might be doing. | 272 // callback might be doing. |
271 TRACE_EVENT_ASYNC_END0("webrtc", "getStats_Native", this); | 273 TRACE_EVENT_ASYNC_END0("webrtc", "getStats_Native", this); |
272 | 274 |
273 request_->requestSucceeded(response_); | 275 request_->requestSucceeded(response_); |
274 } | 276 } |
275 | 277 |
276 private: | 278 private: |
277 void AddReport(const webrtc::StatsReport& report) { | 279 void AddReport(const StatsReport& report) { |
278 int idx = response_->addReport(blink::WebString::fromUTF8(report.id), | 280 int idx = response_->addReport(blink::WebString::fromUTF8(report.id), |
279 blink::WebString::fromUTF8(report.type), | 281 blink::WebString::fromUTF8(report.type), |
280 report.timestamp); | 282 report.timestamp); |
281 for (webrtc::StatsReport::Values::const_iterator value_it = | 283 for (StatsReport::Values::const_iterator value_it = report.values.begin(); |
282 report.values.begin(); | |
283 value_it != report.values.end(); ++value_it) { | 284 value_it != report.values.end(); ++value_it) { |
284 AddStatistic(idx, value_it->display_name(), value_it->value); | 285 AddStatistic(idx, value_it->display_name(), value_it->value); |
285 } | 286 } |
286 } | 287 } |
287 | 288 |
288 void AddStatistic(int idx, const char* name, const std::string& value) { | 289 void AddStatistic(int idx, const char* name, const std::string& value) { |
289 response_->addStatistic(idx, | 290 response_->addStatistic(idx, |
290 blink::WebString::fromUTF8(name), | 291 blink::WebString::fromUTF8(name), |
291 blink::WebString::fromUTF8(value)); | 292 blink::WebString::fromUTF8(value)); |
292 } | 293 } |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 track = | 752 track = |
752 native_peer_connection_->local_streams()->FindVideoTrack(track_id); | 753 native_peer_connection_->local_streams()->FindVideoTrack(track_id); |
753 if (!track) { | 754 if (!track) { |
754 track = | 755 track = |
755 native_peer_connection_->remote_streams()->FindVideoTrack(track_id); | 756 native_peer_connection_->remote_streams()->FindVideoTrack(track_id); |
756 } | 757 } |
757 } | 758 } |
758 if (!track) { | 759 if (!track) { |
759 DVLOG(1) << "GetStats: Track not found."; | 760 DVLOG(1) << "GetStats: Track not found."; |
760 // TODO(hta): Consider how to get an error back. | 761 // TODO(hta): Consider how to get an error back. |
761 std::vector<webrtc::StatsReport> no_reports; | 762 observer->OnComplete(StatsReports()); |
762 observer->OnComplete(no_reports); | |
763 return; | 763 return; |
764 } | 764 } |
765 } | 765 } |
766 GetStats(observer, | 766 GetStats(observer, |
767 track, | 767 track, |
768 webrtc::PeerConnectionInterface::kStatsOutputLevelStandard); | 768 webrtc::PeerConnectionInterface::kStatsOutputLevelStandard); |
769 } | 769 } |
770 | 770 |
771 void RTCPeerConnectionHandler::GetStats( | 771 void RTCPeerConnectionHandler::GetStats( |
772 webrtc::StatsObserver* observer, | 772 webrtc::StatsObserver* observer, |
773 webrtc::MediaStreamTrackInterface* track, | 773 webrtc::MediaStreamTrackInterface* track, |
774 webrtc::PeerConnectionInterface::StatsOutputLevel level) { | 774 webrtc::PeerConnectionInterface::StatsOutputLevel level) { |
775 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::GetStats"); | 775 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::GetStats"); |
776 if (!native_peer_connection_->GetStats(observer, track, level)) { | 776 if (!native_peer_connection_->GetStats(observer, track, level)) { |
777 DVLOG(1) << "GetStats failed."; | 777 DVLOG(1) << "GetStats failed."; |
778 // TODO(hta): Consider how to get an error back. | 778 // TODO(hta): Consider how to get an error back. |
779 std::vector<webrtc::StatsReport> no_reports; | 779 observer->OnComplete(StatsReports()); |
780 observer->OnComplete(no_reports); | |
781 return; | 780 return; |
782 } | 781 } |
783 } | 782 } |
784 | 783 |
785 blink::WebRTCDataChannelHandler* RTCPeerConnectionHandler::createDataChannel( | 784 blink::WebRTCDataChannelHandler* RTCPeerConnectionHandler::createDataChannel( |
786 const blink::WebString& label, const blink::WebRTCDataChannelInit& init) { | 785 const blink::WebString& label, const blink::WebRTCDataChannelInit& init) { |
787 DVLOG(1) << "createDataChannel label " << base::UTF16ToUTF8(label); | 786 DVLOG(1) << "createDataChannel label " << base::UTF16ToUTF8(label); |
788 | 787 |
789 webrtc::DataChannelInit config; | 788 webrtc::DataChannelInit config; |
790 // TODO(jiayl): remove the deprecated reliable field once Libjingle is updated | 789 // TODO(jiayl): remove the deprecated reliable field once Libjingle is updated |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 webrtc::SessionDescriptionInterface* native_desc = | 996 webrtc::SessionDescriptionInterface* native_desc = |
998 dependency_factory_->CreateSessionDescription(type, sdp, error); | 997 dependency_factory_->CreateSessionDescription(type, sdp, error); |
999 | 998 |
1000 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." | 999 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." |
1001 << " Type: " << type << " SDP: " << sdp; | 1000 << " Type: " << type << " SDP: " << sdp; |
1002 | 1001 |
1003 return native_desc; | 1002 return native_desc; |
1004 } | 1003 } |
1005 | 1004 |
1006 } // namespace content | 1005 } // namespace content |
OLD | NEW |