Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: remoting/protocol/webrtc_transport.cc

Issue 1846893002: Interface with webrtc through encoded frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed sergeyu comments and rebased Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
9 #include <vector>
8 10
9 #include "base/base64.h" 11 #include "base/base64.h"
10 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
11 #include "base/command_line.h" 13 #include "base/command_line.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
14 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_split.h" 18 #include "base/strings/string_split.h"
17 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
18 #include "base/task_runner_util.h" 20 #include "base/task_runner_util.h"
19 #include "base/thread_task_runner_handle.h" 21 #include "base/thread_task_runner_handle.h"
20 #include "jingle/glue/thread_wrapper.h" 22 #include "jingle/glue/thread_wrapper.h"
21 #include "remoting/protocol/authenticator.h" 23 #include "remoting/protocol/authenticator.h"
22 #include "remoting/protocol/port_allocator_factory.h" 24 #include "remoting/protocol/port_allocator_factory.h"
23 #include "remoting/protocol/stream_message_pipe_adapter.h" 25 #include "remoting/protocol/stream_message_pipe_adapter.h"
24 #include "remoting/protocol/transport_context.h" 26 #include "remoting/protocol/transport_context.h"
27 #include "remoting/protocol/webrtc_video_encoder.h"
25 #include "third_party/webrtc/api/test/fakeconstraints.h" 28 #include "third_party/webrtc/api/test/fakeconstraints.h"
26 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" 29 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
27 #include "third_party/webrtc/modules/audio_device/include/fake_audio_device.h" 30 #include "third_party/webrtc/modules/audio_device/include/fake_audio_device.h"
28 31
29 using buzz::QName; 32 using buzz::QName;
30 using buzz::XmlElement; 33 using buzz::XmlElement;
31 34
32 namespace remoting { 35 namespace remoting {
33 namespace protocol { 36 namespace protocol {
34 37
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 118
116 void OnSuccess() override { 119 void OnSuccess() override {
117 base::ResetAndReturn(&result_callback_).Run(true, std::string()); 120 base::ResetAndReturn(&result_callback_).Run(true, std::string());
118 } 121 }
119 122
120 void OnFailure(const std::string& error) override { 123 void OnFailure(const std::string& error) override {
121 base::ResetAndReturn(&result_callback_).Run(false, error); 124 base::ResetAndReturn(&result_callback_).Run(false, error);
122 } 125 }
123 126
124 protected: 127 protected:
125 SetSessionDescriptionObserver(const ResultCallback& result_callback) 128 explicit SetSessionDescriptionObserver(const ResultCallback& result_callback)
126 : result_callback_(result_callback) {} 129 : result_callback_(result_callback) {}
127 ~SetSessionDescriptionObserver() override {} 130 ~SetSessionDescriptionObserver() override {}
128 131
129 private: 132 private:
130 ResultCallback result_callback_; 133 ResultCallback result_callback_;
131 134
132 DISALLOW_COPY_AND_ASSIGN(SetSessionDescriptionObserver); 135 DISALLOW_COPY_AND_ASSIGN(SetSessionDescriptionObserver);
133 }; 136 };
134 137
135 138
(...skipping 30 matching lines...) Expand all
166 // TODO(sergeyu): Investigate if it's possible to avoid Send(). 169 // TODO(sergeyu): Investigate if it's possible to avoid Send().
167 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); 170 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true);
168 171
169 send_transport_info_callback_ = std::move(send_transport_info_callback); 172 send_transport_info_callback_ = std::move(send_transport_info_callback);
170 173
171 if (!handshake_hmac_.Init(authenticator->GetAuthKey())) { 174 if (!handshake_hmac_.Init(authenticator->GetAuthKey())) {
172 LOG(FATAL) << "HMAC::Init() failed."; 175 LOG(FATAL) << "HMAC::Init() failed.";
173 } 176 }
174 177
175 fake_audio_device_module_.reset(new webrtc::FakeAudioDeviceModule()); 178 fake_audio_device_module_.reset(new webrtc::FakeAudioDeviceModule());
179 video_encoder_factory_ = new remoting::WebRtcVideoEncoderFactory();
176 180
181 // Takes ownership of video_encoder_factory_
177 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( 182 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory(
178 worker_thread_, rtc::Thread::Current(), 183 worker_thread_, rtc::Thread::Current(), fake_audio_device_module_.get(),
179 fake_audio_device_module_.get(), nullptr, nullptr); 184 video_encoder_factory_, nullptr);
180 185
181 webrtc::PeerConnectionInterface::IceServer stun_server; 186 webrtc::PeerConnectionInterface::IceServer stun_server;
182 stun_server.urls.push_back("stun:stun.l.google.com:19302"); 187 stun_server.urls.push_back("stun:stun.l.google.com:19302");
183 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config; 188 webrtc::PeerConnectionInterface::RTCConfiguration rtc_config;
184 rtc_config.servers.push_back(stun_server); 189 rtc_config.servers.push_back(stun_server);
185 190
186 webrtc::FakeConstraints constraints; 191 webrtc::FakeConstraints constraints;
187 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 192 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
188 webrtc::MediaConstraintsInterface::kValueTrue); 193 webrtc::MediaConstraintsInterface::kValueTrue);
189 194
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 #if !defined(NDEBUG) 248 #if !defined(NDEBUG)
244 ignore_error = base::CommandLine::ForCurrentProcess()->HasSwitch( 249 ignore_error = base::CommandLine::ForCurrentProcess()->HasSwitch(
245 kDisableAuthenticationSwitchName); 250 kDisableAuthenticationSwitchName);
246 #endif 251 #endif
247 if (!ignore_error) { 252 if (!ignore_error) {
248 Close(AUTHENTICATION_FAILED); 253 Close(AUTHENTICATION_FAILED);
249 return true; 254 return true;
250 } 255 }
251 } 256 }
252 257
258 // TODO(isheriff): The need for this should go away once we have a proper
259 // API to provide max bitrate for the case of handing over encoded
260 // frames to webrtc.
261 // Increase max bitrate from 600 kbps to 5 Mbps.
262 std::string vp8line = "a=rtpmap:100 VP8/90000\n";
263 std::string vp8line_with_bitrate =
264 vp8line + "a=fmtp:100 x-google-max-bitrate=5000\n";
265 base::ReplaceSubstringsAfterOffset(&sdp, 0, vp8line, vp8line_with_bitrate);
266
253 webrtc::SdpParseError error; 267 webrtc::SdpParseError error;
254 std::unique_ptr<webrtc::SessionDescriptionInterface> session_description( 268 std::unique_ptr<webrtc::SessionDescriptionInterface> session_description(
255 webrtc::CreateSessionDescription(type, sdp, &error)); 269 webrtc::CreateSessionDescription(type, sdp, &error));
256 if (!session_description) { 270 if (!session_description) {
257 LOG(ERROR) << "Failed to parse the session description: " 271 LOG(ERROR) << "Failed to parse the session description: "
258 << error.description << " line: " << error.line; 272 << error.description << " line: " << error.line;
259 return false; 273 return false;
260 } 274 }
261 275
262 peer_connection_->SetRemoteDescription( 276 peer_connection_->SetRemoteDescription(
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 peer_connection_->Close(); 565 peer_connection_->Close();
552 peer_connection_ = nullptr; 566 peer_connection_ = nullptr;
553 peer_connection_factory_ = nullptr; 567 peer_connection_factory_ = nullptr;
554 568
555 if (error != OK) 569 if (error != OK)
556 event_handler_->OnWebrtcTransportError(error); 570 event_handler_->OnWebrtcTransportError(error);
557 } 571 }
558 572
559 } // namespace protocol 573 } // namespace protocol
560 } // namespace remoting 574 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698