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

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

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU 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/ice_connection_to_client.h" 5 #include "remoting/protocol/ice_connection_to_client.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/memory/ptr_util.h"
11 #include "net/base/io_buffer.h" 12 #include "net/base/io_buffer.h"
12 #include "remoting/codec/video_encoder.h" 13 #include "remoting/codec/video_encoder.h"
13 #include "remoting/codec/video_encoder_verbatim.h" 14 #include "remoting/codec/video_encoder_verbatim.h"
14 #include "remoting/codec/video_encoder_vpx.h" 15 #include "remoting/codec/video_encoder_vpx.h"
15 #include "remoting/protocol/audio_writer.h" 16 #include "remoting/protocol/audio_writer.h"
16 #include "remoting/protocol/clipboard_stub.h" 17 #include "remoting/protocol/clipboard_stub.h"
17 #include "remoting/protocol/host_control_dispatcher.h" 18 #include "remoting/protocol/host_control_dispatcher.h"
18 #include "remoting/protocol/host_event_dispatcher.h" 19 #include "remoting/protocol/host_event_dispatcher.h"
19 #include "remoting/protocol/host_stub.h" 20 #include "remoting/protocol/host_stub.h"
20 #include "remoting/protocol/host_video_dispatcher.h" 21 #include "remoting/protocol/host_video_dispatcher.h"
21 #include "remoting/protocol/input_stub.h" 22 #include "remoting/protocol/input_stub.h"
22 #include "remoting/protocol/transport_context.h" 23 #include "remoting/protocol/transport_context.h"
23 #include "remoting/protocol/video_frame_pump.h" 24 #include "remoting/protocol/video_frame_pump.h"
24 25
25 namespace remoting { 26 namespace remoting {
26 namespace protocol { 27 namespace protocol {
27 28
28 namespace { 29 namespace {
29 30
30 scoped_ptr<VideoEncoder> CreateVideoEncoder( 31 std::unique_ptr<VideoEncoder> CreateVideoEncoder(
31 const protocol::SessionConfig& config) { 32 const protocol::SessionConfig& config) {
32 const protocol::ChannelConfig& video_config = config.video_config(); 33 const protocol::ChannelConfig& video_config = config.video_config();
33 34
34 if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { 35 if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) {
35 return VideoEncoderVpx::CreateForVP8(); 36 return VideoEncoderVpx::CreateForVP8();
36 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP9) { 37 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP9) {
37 return VideoEncoderVpx::CreateForVP9(); 38 return VideoEncoderVpx::CreateForVP9();
38 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { 39 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) {
39 return make_scoped_ptr(new VideoEncoderVerbatim()); 40 return base::WrapUnique(new VideoEncoderVerbatim());
40 } 41 }
41 42
42 NOTREACHED(); 43 NOTREACHED();
43 return nullptr; 44 return nullptr;
44 } 45 }
45 46
46 } // namespace 47 } // namespace
47 48
48 IceConnectionToClient::IceConnectionToClient( 49 IceConnectionToClient::IceConnectionToClient(
49 scoped_ptr<protocol::Session> session, 50 std::unique_ptr<protocol::Session> session,
50 scoped_refptr<TransportContext> transport_context, 51 scoped_refptr<TransportContext> transport_context,
51 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner) 52 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner)
52 : event_handler_(nullptr), 53 : event_handler_(nullptr),
53 session_(std::move(session)), 54 session_(std::move(session)),
54 video_encode_task_runner_(video_encode_task_runner), 55 video_encode_task_runner_(video_encode_task_runner),
55 transport_(transport_context, this), 56 transport_(transport_context, this),
56 control_dispatcher_(new HostControlDispatcher()), 57 control_dispatcher_(new HostControlDispatcher()),
57 event_dispatcher_(new HostEventDispatcher()), 58 event_dispatcher_(new HostEventDispatcher()),
58 video_dispatcher_(new HostVideoDispatcher()) { 59 video_dispatcher_(new HostVideoDispatcher()) {
59 session_->SetEventHandler(this); 60 session_->SetEventHandler(this);
(...skipping 19 matching lines...) Expand all
79 // This should trigger OnConnectionClosed() event and this object 80 // This should trigger OnConnectionClosed() event and this object
80 // may be destroyed as the result. 81 // may be destroyed as the result.
81 session_->Close(error); 82 session_->Close(error);
82 } 83 }
83 84
84 void IceConnectionToClient::OnInputEventReceived(int64_t timestamp) { 85 void IceConnectionToClient::OnInputEventReceived(int64_t timestamp) {
85 DCHECK(thread_checker_.CalledOnValidThread()); 86 DCHECK(thread_checker_.CalledOnValidThread());
86 event_handler_->OnInputEventReceived(this, timestamp); 87 event_handler_->OnInputEventReceived(this, timestamp);
87 } 88 }
88 89
89 scoped_ptr<VideoStream> IceConnectionToClient::StartVideoStream( 90 std::unique_ptr<VideoStream> IceConnectionToClient::StartVideoStream(
90 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer) { 91 std::unique_ptr<webrtc::DesktopCapturer> desktop_capturer) {
91 DCHECK(thread_checker_.CalledOnValidThread()); 92 DCHECK(thread_checker_.CalledOnValidThread());
92 93
93 scoped_ptr<VideoEncoder> video_encoder = 94 std::unique_ptr<VideoEncoder> video_encoder =
94 CreateVideoEncoder(session_->config()); 95 CreateVideoEncoder(session_->config());
95 96
96 scoped_ptr<VideoFramePump> pump( 97 std::unique_ptr<VideoFramePump> pump(
97 new VideoFramePump(video_encode_task_runner_, std::move(desktop_capturer), 98 new VideoFramePump(video_encode_task_runner_, std::move(desktop_capturer),
98 std::move(video_encoder), video_dispatcher_.get())); 99 std::move(video_encoder), video_dispatcher_.get()));
99 video_dispatcher_->set_video_feedback_stub(pump->video_feedback_stub()); 100 video_dispatcher_->set_video_feedback_stub(pump->video_feedback_stub());
100 return std::move(pump); 101 return std::move(pump);
101 } 102 }
102 103
103 AudioStub* IceConnectionToClient::audio_stub() { 104 AudioStub* IceConnectionToClient::audio_stub() {
104 DCHECK(thread_checker_.CalledOnValidThread()); 105 DCHECK(thread_checker_.CalledOnValidThread());
105 return audio_writer_.get(); 106 return audio_writer_.get();
106 } 107 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 210
210 void IceConnectionToClient::CloseChannels() { 211 void IceConnectionToClient::CloseChannels() {
211 control_dispatcher_.reset(); 212 control_dispatcher_.reset();
212 event_dispatcher_.reset(); 213 event_dispatcher_.reset();
213 video_dispatcher_.reset(); 214 video_dispatcher_.reset();
214 audio_writer_.reset(); 215 audio_writer_.reset();
215 } 216 }
216 217
217 } // namespace protocol 218 } // namespace protocol
218 } // namespace remoting 219 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/ice_connection_to_client.h ('k') | remoting/protocol/ice_connection_to_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698