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.h> | 7 #include <string.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h" | 33 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h" |
34 #include "content/renderer/media/webrtc_audio_device_impl.h" | 34 #include "content/renderer/media/webrtc_audio_device_impl.h" |
35 #include "content/renderer/media/webrtc_uma_histograms.h" | 35 #include "content/renderer/media/webrtc_uma_histograms.h" |
36 #include "content/renderer/render_thread_impl.h" | 36 #include "content/renderer/render_thread_impl.h" |
37 #include "media/base/media_switches.h" | 37 #include "media/base/media_switches.h" |
38 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 38 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
39 #include "third_party/WebKit/public/platform/WebRTCAnswerOptions.h" | 39 #include "third_party/WebKit/public/platform/WebRTCAnswerOptions.h" |
40 #include "third_party/WebKit/public/platform/WebRTCConfiguration.h" | 40 #include "third_party/WebKit/public/platform/WebRTCConfiguration.h" |
41 #include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h" | 41 #include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h" |
42 #include "third_party/WebKit/public/platform/WebRTCICECandidate.h" | 42 #include "third_party/WebKit/public/platform/WebRTCICECandidate.h" |
| 43 #include "third_party/WebKit/public/platform/WebRTCLegacyStats.h" |
43 #include "third_party/WebKit/public/platform/WebRTCOfferOptions.h" | 44 #include "third_party/WebKit/public/platform/WebRTCOfferOptions.h" |
44 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h" | 45 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h" |
45 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h" | 46 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h" |
46 #include "third_party/WebKit/public/platform/WebRTCStats.h" | |
47 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h" | 47 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h" |
48 #include "third_party/WebKit/public/platform/WebURL.h" | 48 #include "third_party/WebKit/public/platform/WebURL.h" |
49 #include "third_party/webrtc/pc/mediasession.h" | 49 #include "third_party/webrtc/pc/mediasession.h" |
50 | 50 |
51 using webrtc::DataChannelInterface; | 51 using webrtc::DataChannelInterface; |
52 using webrtc::IceCandidateInterface; | 52 using webrtc::IceCandidateInterface; |
53 using webrtc::MediaStreamInterface; | 53 using webrtc::MediaStreamInterface; |
54 using webrtc::PeerConnectionInterface; | 54 using webrtc::PeerConnectionInterface; |
55 using webrtc::PeerConnectionObserver; | 55 using webrtc::PeerConnectionObserver; |
56 using webrtc::StatsReport; | 56 using webrtc::StatsReport; |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 DLOG_IF(ERROR, !webkit_request_.isNull()) | 453 DLOG_IF(ERROR, !webkit_request_.isNull()) |
454 << "SetSessionDescriptionRequest not completed. Shutting down?"; | 454 << "SetSessionDescriptionRequest not completed. Shutting down?"; |
455 } | 455 } |
456 | 456 |
457 private: | 457 private: |
458 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_; | 458 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_; |
459 blink::WebRTCVoidRequest webkit_request_; | 459 blink::WebRTCVoidRequest webkit_request_; |
460 SessionDescriptionRequestTracker tracker_; | 460 SessionDescriptionRequestTracker tracker_; |
461 }; | 461 }; |
462 | 462 |
463 blink::WebRTCStatsType WebRTCStatsTypeFromStatsType( | 463 blink::WebRTCLegacyStatsMemberType |
464 webrtc::StatsReport::StatsType name) { | 464 WebRTCLegacyStatsMemberTypeFromStatsValueType( |
465 // TODO(hbos): Translate StatsType -> WebRTCStatsType. crbug.com/627816 | |
466 return blink::WebRTCStatsTypeUnknown; | |
467 } | |
468 | |
469 blink::WebRTCStatsMemberName WebRTCStatsMemberNameFromStatsValueName( | |
470 webrtc::StatsReport::StatsValueName name) { | |
471 // TODO(hbos): Translate StatsValueName -> WebRTCStatsMemberName. | |
472 // crbug.com/627816 | |
473 return blink::WebRTCStatsMemberNameUnknown; | |
474 } | |
475 | |
476 blink::WebRTCStatsMemberType WebRTCStatsMemberTypeFromStatsValueType( | |
477 webrtc::StatsReport::Value::Type type) { | 465 webrtc::StatsReport::Value::Type type) { |
478 switch (type) { | 466 switch (type) { |
479 case StatsReport::Value::kInt: | 467 case StatsReport::Value::kInt: |
480 return blink::WebRTCStatsMemberTypeInt; | 468 return blink::WebRTCLegacyStatsMemberTypeInt; |
481 case StatsReport::Value::kInt64: | 469 case StatsReport::Value::kInt64: |
482 return blink::WebRTCStatsMemberTypeInt64; | 470 return blink::WebRTCLegacyStatsMemberTypeInt64; |
483 case StatsReport::Value::kFloat: | 471 case StatsReport::Value::kFloat: |
484 return blink::WebRTCStatsMemberTypeFloat; | 472 return blink::WebRTCLegacyStatsMemberTypeFloat; |
485 case StatsReport::Value::kString: | 473 case StatsReport::Value::kString: |
486 case StatsReport::Value::kStaticString: | 474 case StatsReport::Value::kStaticString: |
487 return blink::WebRTCStatsMemberTypeString; | 475 return blink::WebRTCLegacyStatsMemberTypeString; |
488 case StatsReport::Value::kBool: | 476 case StatsReport::Value::kBool: |
489 return blink::WebRTCStatsMemberTypeBool; | 477 return blink::WebRTCLegacyStatsMemberTypeBool; |
490 case StatsReport::Value::kId: | 478 case StatsReport::Value::kId: |
491 return blink::WebRTCStatsMemberTypeId; | 479 return blink::WebRTCLegacyStatsMemberTypeId; |
492 } | 480 } |
493 NOTREACHED(); | 481 NOTREACHED(); |
494 return blink::WebRTCStatsMemberTypeInt; | 482 return blink::WebRTCLegacyStatsMemberTypeInt; |
495 } | 483 } |
496 | 484 |
497 // Class mapping responses from calls to libjingle | 485 // Class mapping responses from calls to libjingle |
498 // GetStats into a blink::WebRTCStatsCallback. | 486 // GetStats into a blink::WebRTCStatsCallback. |
499 class StatsResponse : public webrtc::StatsObserver { | 487 class StatsResponse : public webrtc::StatsObserver { |
500 public: | 488 public: |
501 explicit StatsResponse(const scoped_refptr<LocalRTCStatsRequest>& request) | 489 explicit StatsResponse(const scoped_refptr<LocalRTCStatsRequest>& request) |
502 : request_(request.get()), | 490 : request_(request.get()), |
503 main_thread_(base::ThreadTaskRunnerHandle::Get()) { | 491 main_thread_(base::ThreadTaskRunnerHandle::Get()) { |
504 // Measure the overall time it takes to satisfy a getStats request. | 492 // Measure the overall time it takes to satisfy a getStats request. |
(...skipping 12 matching lines...) Expand all Loading... |
517 report_copies->push_back(new Report(r)); | 505 report_copies->push_back(new Report(r)); |
518 | 506 |
519 main_thread_->PostTaskAndReply(FROM_HERE, | 507 main_thread_->PostTaskAndReply(FROM_HERE, |
520 base::Bind(&StatsResponse::DeliverCallback, this, | 508 base::Bind(&StatsResponse::DeliverCallback, this, |
521 base::Unretained(report_copies)), | 509 base::Unretained(report_copies)), |
522 base::Bind(&StatsResponse::DeleteReports, | 510 base::Bind(&StatsResponse::DeleteReports, |
523 base::Unretained(report_copies))); | 511 base::Unretained(report_copies))); |
524 } | 512 } |
525 | 513 |
526 private: | 514 private: |
527 class Report : public blink::WebRTCStats { | 515 class Report : public blink::WebRTCLegacyStats { |
528 public: | 516 public: |
529 class MemberIterator : public blink::WebRTCStatsMemberIterator { | 517 class MemberIterator : public blink::WebRTCLegacyStatsMemberIterator { |
530 public: | 518 public: |
531 MemberIterator(const StatsReport::Values::const_iterator& it, | 519 MemberIterator(const StatsReport::Values::const_iterator& it, |
532 const StatsReport::Values::const_iterator& end) | 520 const StatsReport::Values::const_iterator& end) |
533 : it_(it), end_(end) {} | 521 : it_(it), end_(end) {} |
534 | 522 |
535 // blink::WebRTCStatsMemberIterator | 523 // blink::WebRTCLegacyStatsMemberIterator |
536 bool isEnd() const override { return it_ == end_; } | 524 bool isEnd() const override { return it_ == end_; } |
537 void next() override { ++it_; } | 525 void next() override { ++it_; } |
538 blink::WebRTCStatsMemberName name() const override { | 526 blink::WebString name() const override { |
539 return WebRTCStatsMemberNameFromStatsValueName(it_->second->name); | |
540 } | |
541 blink::WebString displayName() const override { | |
542 return blink::WebString::fromUTF8(it_->second->display_name()); | 527 return blink::WebString::fromUTF8(it_->second->display_name()); |
543 } | 528 } |
544 blink::WebRTCStatsMemberType type() const override { | 529 blink::WebRTCLegacyStatsMemberType type() const override { |
545 return WebRTCStatsMemberTypeFromStatsValueType(it_->second->type()); | 530 return WebRTCLegacyStatsMemberTypeFromStatsValueType( |
| 531 it_->second->type()); |
546 } | 532 } |
547 int valueInt() const override { | 533 int valueInt() const override { |
548 return it_->second->int_val(); | 534 return it_->second->int_val(); |
549 } | 535 } |
550 int64_t valueInt64() const override { | 536 int64_t valueInt64() const override { |
551 return it_->second->int64_val(); | 537 return it_->second->int64_val(); |
552 } | 538 } |
553 float valueFloat() const override { | 539 float valueFloat() const override { |
554 return it_->second->float_val(); | 540 return it_->second->float_val(); |
555 } | 541 } |
(...skipping 28 matching lines...) Expand all Loading... |
584 type_name_(report->TypeToString()), | 570 type_name_(report->TypeToString()), |
585 timestamp_(report->timestamp()), | 571 timestamp_(report->timestamp()), |
586 values_(report->values()) {} | 572 values_(report->values()) {} |
587 | 573 |
588 ~Report() override { | 574 ~Report() override { |
589 // Since the values vector holds pointers to const objects that are bound | 575 // Since the values vector holds pointers to const objects that are bound |
590 // to the signaling thread, they must be released on the same thread. | 576 // to the signaling thread, they must be released on the same thread. |
591 DCHECK(thread_checker_.CalledOnValidThread()); | 577 DCHECK(thread_checker_.CalledOnValidThread()); |
592 } | 578 } |
593 | 579 |
594 // blink::WebRTCStats | 580 // blink::WebRTCLegacyStats |
595 blink::WebString id() const override { | 581 blink::WebString id() const override { |
596 return blink::WebString::fromUTF8(id_); | 582 return blink::WebString::fromUTF8(id_); |
597 } | 583 } |
598 blink::WebRTCStatsType type() const override { | 584 blink::WebString type() const override { |
599 return WebRTCStatsTypeFromStatsType(type_); | |
600 } | |
601 blink::WebString typeToString() const override { | |
602 return blink::WebString::fromUTF8(type_name_); | 585 return blink::WebString::fromUTF8(type_name_); |
603 } | 586 } |
604 double timestamp() const override { | 587 double timestamp() const override { |
605 return timestamp_; | 588 return timestamp_; |
606 } | 589 } |
607 blink::WebRTCStatsMemberIterator* iterator() const override { | 590 blink::WebRTCLegacyStatsMemberIterator* iterator() const override { |
608 return new MemberIterator(values_.cbegin(), values_.cend()); | 591 return new MemberIterator(values_.cbegin(), values_.cend()); |
609 } | 592 } |
610 | 593 |
611 bool HasValues() const { | 594 bool HasValues() const { |
612 return values_.size() > 0; | 595 return values_.size() > 0; |
613 } | 596 } |
614 | 597 |
615 private: | 598 private: |
616 const base::ThreadChecker thread_checker_; | 599 const base::ThreadChecker thread_checker_; |
617 const std::string id_; | 600 const std::string id_; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 void LocalRTCStatsRequest::requestSucceeded( | 840 void LocalRTCStatsRequest::requestSucceeded( |
858 const LocalRTCStatsResponse* response) { | 841 const LocalRTCStatsResponse* response) { |
859 impl_.requestSucceeded(response->webKitStatsResponse()); | 842 impl_.requestSucceeded(response->webKitStatsResponse()); |
860 } | 843 } |
861 | 844 |
862 // Implementation of LocalRTCStatsResponse. | 845 // Implementation of LocalRTCStatsResponse. |
863 blink::WebRTCStatsResponse LocalRTCStatsResponse::webKitStatsResponse() const { | 846 blink::WebRTCStatsResponse LocalRTCStatsResponse::webKitStatsResponse() const { |
864 return impl_; | 847 return impl_; |
865 } | 848 } |
866 | 849 |
867 void LocalRTCStatsResponse::addStats(const blink::WebRTCStats& stats) { | 850 void LocalRTCStatsResponse::addStats(const blink::WebRTCLegacyStats& stats) { |
868 impl_.addStats(stats); | 851 impl_.addStats(stats); |
869 } | 852 } |
870 | 853 |
871 // Receives notifications from a PeerConnection object about state changes, | 854 // Receives notifications from a PeerConnection object about state changes, |
872 // track addition/removal etc. The callbacks we receive here come on the | 855 // track addition/removal etc. The callbacks we receive here come on the |
873 // signaling thread, so this class takes care of delivering them to an | 856 // signaling thread, so this class takes care of delivering them to an |
874 // RTCPeerConnectionHandler instance on the main thread. | 857 // RTCPeerConnectionHandler instance on the main thread. |
875 // In order to do safe PostTask-ing, the class is reference counted and | 858 // In order to do safe PostTask-ing, the class is reference counted and |
876 // checks for the existence of the RTCPeerConnectionHandler instance before | 859 // checks for the existence of the RTCPeerConnectionHandler instance before |
877 // delivering callbacks on the main thread. | 860 // delivering callbacks on the main thread. |
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 } | 1889 } |
1907 | 1890 |
1908 void RTCPeerConnectionHandler::ResetUMAStats() { | 1891 void RTCPeerConnectionHandler::ResetUMAStats() { |
1909 DCHECK(thread_checker_.CalledOnValidThread()); | 1892 DCHECK(thread_checker_.CalledOnValidThread()); |
1910 num_local_candidates_ipv6_ = 0; | 1893 num_local_candidates_ipv6_ = 0; |
1911 num_local_candidates_ipv4_ = 0; | 1894 num_local_candidates_ipv4_ = 0; |
1912 ice_connection_checking_start_ = base::TimeTicks(); | 1895 ice_connection_checking_start_ = base::TimeTicks(); |
1913 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); | 1896 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); |
1914 } | 1897 } |
1915 } // namespace content | 1898 } // namespace content |
OLD | NEW |