OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/protocol/webrtc_transport.h" | 5 #include "remoting/protocol/webrtc_transport.h" |
6 | 6 |
7 #include <string> | |
7 #include <utility> | 8 #include <utility> |
8 | 9 |
9 #include "base/base64.h" | 10 #include "base/base64.h" |
10 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
15 #include "base/task_runner_util.h" | 16 #include "base/task_runner_util.h" |
16 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
17 #include "jingle/glue/thread_wrapper.h" | 18 #include "jingle/glue/thread_wrapper.h" |
19 #include "remoting/codec/webrtc_video_encoder.h" | |
18 #include "remoting/protocol/authenticator.h" | 20 #include "remoting/protocol/authenticator.h" |
19 #include "remoting/protocol/port_allocator_factory.h" | 21 #include "remoting/protocol/port_allocator_factory.h" |
20 #include "remoting/protocol/stream_message_pipe_adapter.h" | 22 #include "remoting/protocol/stream_message_pipe_adapter.h" |
21 #include "remoting/protocol/transport_context.h" | 23 #include "remoting/protocol/transport_context.h" |
22 #include "third_party/webrtc/api/test/fakeconstraints.h" | 24 #include "third_party/webrtc/api/test/fakeconstraints.h" |
25 #include "third_party/webrtc/base/stringutils.h" | |
23 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 26 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
24 #include "third_party/webrtc/modules/audio_device/include/fake_audio_device.h" | 27 #include "third_party/webrtc/modules/audio_device/include/fake_audio_device.h" |
25 | 28 |
26 using buzz::QName; | 29 using buzz::QName; |
27 using buzz::XmlElement; | 30 using buzz::XmlElement; |
28 | 31 |
29 namespace remoting { | 32 namespace remoting { |
30 namespace protocol { | 33 namespace protocol { |
31 | 34 |
32 namespace { | 35 namespace { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 | 98 |
96 void OnSuccess() override { | 99 void OnSuccess() override { |
97 base::ResetAndReturn(&result_callback_).Run(true, std::string()); | 100 base::ResetAndReturn(&result_callback_).Run(true, std::string()); |
98 } | 101 } |
99 | 102 |
100 void OnFailure(const std::string& error) override { | 103 void OnFailure(const std::string& error) override { |
101 base::ResetAndReturn(&result_callback_).Run(false, error); | 104 base::ResetAndReturn(&result_callback_).Run(false, error); |
102 } | 105 } |
103 | 106 |
104 protected: | 107 protected: |
105 SetSessionDescriptionObserver(const ResultCallback& result_callback) | 108 explicit SetSessionDescriptionObserver(const ResultCallback& result_callback) |
106 : result_callback_(result_callback) {} | 109 : result_callback_(result_callback) {} |
107 ~SetSessionDescriptionObserver() override {} | 110 ~SetSessionDescriptionObserver() override {} |
108 | 111 |
109 private: | 112 private: |
110 ResultCallback result_callback_; | 113 ResultCallback result_callback_; |
111 | 114 |
112 DISALLOW_COPY_AND_ASSIGN(SetSessionDescriptionObserver); | 115 DISALLOW_COPY_AND_ASSIGN(SetSessionDescriptionObserver); |
113 }; | 116 }; |
114 | 117 |
115 | 118 |
(...skipping 30 matching lines...) Expand all Loading... | |
146 // TODO(sergeyu): Investigate if it's possible to avoid Send(). | 149 // TODO(sergeyu): Investigate if it's possible to avoid Send(). |
147 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); | 150 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); |
148 | 151 |
149 send_transport_info_callback_ = std::move(send_transport_info_callback); | 152 send_transport_info_callback_ = std::move(send_transport_info_callback); |
150 | 153 |
151 if (!handshake_hmac_.Init(authenticator->GetAuthKey())) { | 154 if (!handshake_hmac_.Init(authenticator->GetAuthKey())) { |
152 LOG(FATAL) << "HMAC::Init() failed."; | 155 LOG(FATAL) << "HMAC::Init() failed."; |
153 } | 156 } |
154 | 157 |
155 fake_audio_device_module_.reset(new webrtc::FakeAudioDeviceModule()); | 158 fake_audio_device_module_.reset(new webrtc::FakeAudioDeviceModule()); |
159 video_encoder_factory_ = new remoting::WebRtcVideoEncoderFactory(); | |
156 | 160 |
161 // Takes ownership of video_encoder_factory_ | |
157 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( | 162 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( |
158 worker_thread_, rtc::Thread::Current(), | 163 worker_thread_, rtc::Thread::Current(), fake_audio_device_module_.get(), |
159 fake_audio_device_module_.get(), nullptr, nullptr); | 164 video_encoder_factory_, nullptr); |
160 | 165 |
161 webrtc::PeerConnectionInterface::IceServer stun_server; | 166 webrtc::PeerConnectionInterface::IceServer stun_server; |
162 stun_server.urls.push_back("stun:stun.l.google.com:19302"); | 167 stun_server.urls.push_back("stun:stun.l.google.com:19302"); |
163 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config; | 168 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config; |
164 rtc_config.servers.push_back(stun_server); | 169 rtc_config.servers.push_back(stun_server); |
165 | 170 |
166 webrtc::FakeConstraints constraints; | 171 webrtc::FakeConstraints constraints; |
167 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 172 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
168 webrtc::MediaConstraintsInterface::kValueTrue); | 173 webrtc::MediaConstraintsInterface::kValueTrue); |
169 | 174 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 #if !defined(NDEBUG) | 227 #if !defined(NDEBUG) |
223 ignore_error = base::CommandLine::ForCurrentProcess()->HasSwitch( | 228 ignore_error = base::CommandLine::ForCurrentProcess()->HasSwitch( |
224 kDisableAuthenticationSwitchName); | 229 kDisableAuthenticationSwitchName); |
225 #endif | 230 #endif |
226 if (!ignore_error) { | 231 if (!ignore_error) { |
227 Close(AUTHENTICATION_FAILED); | 232 Close(AUTHENTICATION_FAILED); |
228 return true; | 233 return true; |
229 } | 234 } |
230 } | 235 } |
231 | 236 |
237 // TODO(isheriff): The need for this should go away once we have a proper | |
238 // API to provide max bitrate for the case of handing over encoded | |
239 // frames to webrtc. | |
240 // Increase max bitrate from 600 kbps to 5 Mbps. | |
241 std::string vp8line = "a=rtpmap:100 VP8/90000\n"; | |
Sergey Ulanov
2016/03/31 22:06:19
I think webrtc generates SDP with '\r\n' at the en
Irfan
2016/04/05 21:23:28
It was working for me.
| |
242 std::string vp8line_with_bitrate = | |
243 vp8line + "a=fmtp:100 x-google-max-bitrate=5000\n"; | |
244 rtc::replace_substrs(vp8line.c_str(), vp8line.length(), | |
Sergey Ulanov
2016/03/31 22:06:19
Please use base::ReplaceSubstringsAfterOffset:
ba
Irfan
2016/04/05 21:23:28
Done.
| |
245 vp8line_with_bitrate.c_str(), | |
246 vp8line_with_bitrate.length(), &sdp); | |
247 | |
232 webrtc::SdpParseError error; | 248 webrtc::SdpParseError error; |
233 scoped_ptr<webrtc::SessionDescriptionInterface> session_description( | 249 scoped_ptr<webrtc::SessionDescriptionInterface> session_description( |
234 webrtc::CreateSessionDescription(type, sdp, &error)); | 250 webrtc::CreateSessionDescription(type, sdp, &error)); |
235 if (!session_description) { | 251 if (!session_description) { |
236 LOG(ERROR) << "Failed to parse the session description: " | 252 LOG(ERROR) << "Failed to parse the session description: " |
237 << error.description << " line: " << error.line; | 253 << error.description << " line: " << error.line; |
238 return false; | 254 return false; |
239 } | 255 } |
240 | 256 |
241 peer_connection_->SetRemoteDescription( | 257 peer_connection_->SetRemoteDescription( |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
529 peer_connection_->Close(); | 545 peer_connection_->Close(); |
530 peer_connection_ = nullptr; | 546 peer_connection_ = nullptr; |
531 peer_connection_factory_ = nullptr; | 547 peer_connection_factory_ = nullptr; |
532 | 548 |
533 if (error != OK) | 549 if (error != OK) |
534 event_handler_->OnWebrtcTransportError(error); | 550 event_handler_->OnWebrtcTransportError(error); |
535 } | 551 } |
536 | 552 |
537 } // namespace protocol | 553 } // namespace protocol |
538 } // namespace remoting | 554 } // namespace remoting |
OLD | NEW |