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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 const char kWebRtcCandidate[] = "candidate"; | 42 const char kWebRtcCandidate[] = "candidate"; |
43 const char kWebRtcSessionDescType[] = "type"; | 43 const char kWebRtcSessionDescType[] = "type"; |
44 const char kWebRtcSessionDescSDP[] = "sdp"; | 44 const char kWebRtcSessionDescSDP[] = "sdp"; |
45 const char kWebRtcSDPMid[] = "sdpMid"; | 45 const char kWebRtcSDPMid[] = "sdpMid"; |
46 const char kWebRtcSDPMLineIndex[] = "sdpMLineIndex"; | 46 const char kWebRtcSDPMLineIndex[] = "sdpMLineIndex"; |
47 | 47 |
48 // Media labels used over the PeerConnection. | 48 // Media labels used over the PeerConnection. |
49 const char kVideoLabel[] = "cast_video_label"; | 49 const char kVideoLabel[] = "cast_video_label"; |
50 const char kStreamLabel[] = "stream_label"; | 50 const char kStreamLabel[] = "stream_label"; |
51 | 51 |
52 // Default STUN server used to construct | |
53 // ChromiumPortAllocator for the PeerConnection. | |
54 const char kDefaultStunHost[] = "stun.l.google.com"; | |
55 const int kDefaultStunPort = 19302; | |
56 | |
57 const char kWorkerThreadName[] = "CastExtensionSessionWorkerThread"; | 52 const char kWorkerThreadName[] = "CastExtensionSessionWorkerThread"; |
58 | 53 |
59 // Interval between each call to PollPeerConnectionStats(). | 54 // Interval between each call to PollPeerConnectionStats(). |
60 const int kStatsLogIntervalSec = 10; | 55 const int kStatsLogIntervalSec = 10; |
61 | 56 |
62 // Minimum frame rate for video streaming over the PeerConnection in frames per | 57 // Minimum frame rate for video streaming over the PeerConnection in frames per |
63 // second, added as a media constraint when constructing the video source for | 58 // second, added as a media constraint when constructing the video source for |
64 // the Peer Connection. | 59 // the Peer Connection. |
65 const int kMinFramesPerSecond = 5; | 60 const int kMinFramesPerSecond = 5; |
66 | 61 |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 | 479 |
485 // DTLS-SRTP is the preferred encryption method. If set to kValueFalse, the | 480 // DTLS-SRTP is the preferred encryption method. If set to kValueFalse, the |
486 // peer connection uses SDES. Disabling SDES as well will cause the peer | 481 // peer connection uses SDES. Disabling SDES as well will cause the peer |
487 // connection to fail to connect. | 482 // connection to fail to connect. |
488 // Note: For protection and unprotection of SRTP packets, the libjingle | 483 // Note: For protection and unprotection of SRTP packets, the libjingle |
489 // ENABLE_EXTERNAL_AUTH flag must not be set. | 484 // ENABLE_EXTERNAL_AUTH flag must not be set. |
490 webrtc::FakeConstraints constraints; | 485 webrtc::FakeConstraints constraints; |
491 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 486 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
492 webrtc::MediaConstraintsInterface::kValueTrue); | 487 webrtc::MediaConstraintsInterface::kValueTrue); |
493 | 488 |
494 rtc::scoped_ptr<protocol::ChromiumPortAllocator> port_allocator( | 489 scoped_ptr<cricket::PortAllocator> port_allocator = |
495 protocol::ChromiumPortAllocator::Create(url_request_context_getter_, | 490 protocol::ChromiumPortAllocator::Create(url_request_context_getter_); |
496 network_settings_) | |
497 .release()); | |
498 std::vector<rtc::SocketAddress> stun_hosts; | |
499 stun_hosts.push_back(rtc::SocketAddress(kDefaultStunHost, kDefaultStunPort)); | |
500 port_allocator->SetStunHosts(stun_hosts); | |
501 | 491 |
502 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config; | 492 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config; |
503 peer_connection_ = peer_conn_factory_->CreatePeerConnection( | 493 peer_connection_ = peer_conn_factory_->CreatePeerConnection( |
504 rtc_config, &constraints, port_allocator.Pass(), nullptr, this); | 494 rtc_config, &constraints, |
| 495 rtc::scoped_ptr<cricket::PortAllocator>(port_allocator.release()), |
| 496 nullptr, this); |
505 | 497 |
506 if (!peer_connection_.get()) { | 498 if (!peer_connection_.get()) { |
507 CleanupPeerConnection(); | 499 CleanupPeerConnection(); |
508 return false; | 500 return false; |
509 } | 501 } |
510 | 502 |
511 VLOG(1) << "Created PeerConnection successfully."; | 503 VLOG(1) << "Created PeerConnection successfully."; |
512 | 504 |
513 create_session_desc_observer_ = | 505 create_session_desc_observer_ = |
514 CastCreateSessionDescriptionObserver::Create(this); | 506 CastCreateSessionDescriptionObserver::Create(this); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 json.SetString(kWebRtcCandidate, candidate_str); | 644 json.SetString(kWebRtcCandidate, candidate_str); |
653 std::string json_str; | 645 std::string json_str; |
654 if (!base::JSONWriter::Write(json, &json_str)) { | 646 if (!base::JSONWriter::Write(json, &json_str)) { |
655 LOG(ERROR) << "Failed to serialize candidate message."; | 647 LOG(ERROR) << "Failed to serialize candidate message."; |
656 return; | 648 return; |
657 } | 649 } |
658 SendMessageToClient(kSubjectNewCandidate, json_str); | 650 SendMessageToClient(kSubjectNewCandidate, json_str); |
659 } | 651 } |
660 | 652 |
661 } // namespace remoting | 653 } // namespace remoting |
OLD | NEW |