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

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

Issue 2782523003: [Remoting Host] Supporting WebRTC VP9 streaming (Closed)
Patch Set: Fix Feedback Created 3 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
« no previous file with comments | « remoting/protocol/webrtc_video_stream.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_video_stream.h" 5 #include "remoting/protocol/webrtc_video_stream.h"
6 6
7 #include <utility>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
9 #include "base/task_runner_util.h" 11 #include "base/task_runner_util.h"
10 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
11 #include "remoting/base/constants.h" 13 #include "remoting/base/constants.h"
12 #include "remoting/codec/webrtc_video_encoder_vpx.h" 14 #include "remoting/codec/webrtc_video_encoder_vpx.h"
13 #include "remoting/protocol/frame_stats.h" 15 #include "remoting/protocol/frame_stats.h"
14 #include "remoting/protocol/host_video_stats_dispatcher.h" 16 #include "remoting/protocol/host_video_stats_dispatcher.h"
15 #include "remoting/protocol/webrtc_dummy_video_capturer.h" 17 #include "remoting/protocol/webrtc_dummy_video_capturer.h"
16 #include "remoting/protocol/webrtc_frame_scheduler_simple.h" 18 #include "remoting/protocol/webrtc_frame_scheduler_simple.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 71
70 scoped_refptr<webrtc::PeerConnectionFactoryInterface> peer_connection_factory( 72 scoped_refptr<webrtc::PeerConnectionFactoryInterface> peer_connection_factory(
71 webrtc_transport->peer_connection_factory()); 73 webrtc_transport->peer_connection_factory());
72 peer_connection_ = webrtc_transport->peer_connection(); 74 peer_connection_ = webrtc_transport->peer_connection();
73 DCHECK(peer_connection_factory); 75 DCHECK(peer_connection_factory);
74 DCHECK(peer_connection_); 76 DCHECK(peer_connection_);
75 77
76 encode_task_runner_ = std::move(encode_task_runner); 78 encode_task_runner_ = std::move(encode_task_runner);
77 capturer_ = std::move(desktop_capturer); 79 capturer_ = std::move(desktop_capturer);
78 webrtc_transport_ = webrtc_transport; 80 webrtc_transport_ = webrtc_transport;
79 // TODO(isheriff): make this codec independent 81
80 encoder_ = WebrtcVideoEncoderVpx::CreateForVP8(); 82 webrtc_transport_->video_encoder_factory()->RegisterEncoderSelectedCallback(
83 base::Bind(&WebrtcVideoStream::OnEncoderCreated,
84 weak_factory_.GetWeakPtr()));
85
81 capturer_->Start(this); 86 capturer_->Start(this);
82 87
83 // Set video stream constraints. 88 // Set video stream constraints.
84 webrtc::FakeConstraints video_constraints; 89 webrtc::FakeConstraints video_constraints;
85 video_constraints.AddMandatory( 90 video_constraints.AddMandatory(
86 webrtc::MediaConstraintsInterface::kMinFrameRate, 5); 91 webrtc::MediaConstraintsInterface::kMinFrameRate, 5);
87 92
88 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> src = 93 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> src =
89 peer_connection_factory->CreateVideoSource(new WebrtcDummyVideoCapturer(), 94 peer_connection_factory->CreateVideoSource(new WebrtcDummyVideoCapturer(),
90 &video_constraints); 95 &video_constraints);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 : frame->dpi(); 162 : frame->dpi();
158 163
159 if (!frame_size_.equals(frame->size()) || !frame_dpi_.equals(dpi)) { 164 if (!frame_size_.equals(frame->size()) || !frame_dpi_.equals(dpi)) {
160 frame_size_ = frame->size(); 165 frame_size_ = frame->size();
161 frame_dpi_ = dpi; 166 frame_dpi_ = dpi;
162 if (observer_) 167 if (observer_)
163 observer_->OnVideoSizeChanged(this, frame_size_, frame_dpi_); 168 observer_->OnVideoSizeChanged(this, frame_size_, frame_dpi_);
164 } 169 }
165 } 170 }
166 171
172 DCHECK(encoder_);
173
167 base::PostTaskAndReplyWithResult( 174 base::PostTaskAndReplyWithResult(
168 encode_task_runner_.get(), FROM_HERE, 175 encode_task_runner_.get(), FROM_HERE,
169 base::Bind(&WebrtcVideoStream::EncodeFrame, encoder_.get(), 176 base::Bind(&WebrtcVideoStream::EncodeFrame, encoder_.get(),
170 base::Passed(std::move(frame)), frame_params, 177 base::Passed(std::move(frame)), frame_params,
171 base::Passed(std::move(captured_frame_stats_))), 178 base::Passed(std::move(captured_frame_stats_))),
172 base::Bind(&WebrtcVideoStream::OnFrameEncoded, 179 base::Bind(&WebrtcVideoStream::OnFrameEncoded,
173 weak_factory_.GetWeakPtr())); 180 weak_factory_.GetWeakPtr()));
174 } 181 }
175 182
176 void WebrtcVideoStream::OnChannelInitialized( 183 void WebrtcVideoStream::OnChannelInitialized(
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 261
255 stats.encode_delay = 262 stats.encode_delay =
256 frame.stats->encode_ended_time - frame.stats->encode_started_time; 263 frame.stats->encode_ended_time - frame.stats->encode_started_time;
257 264
258 stats.capturer_id = frame.stats->capturer_id; 265 stats.capturer_id = frame.stats->capturer_id;
259 266
260 video_stats_dispatcher_.OnVideoFrameStats(result.frame_id, stats); 267 video_stats_dispatcher_.OnVideoFrameStats(result.frame_id, stats);
261 } 268 }
262 } 269 }
263 270
271 void WebrtcVideoStream::OnEncoderCreated(webrtc::VideoCodecType codec_type) {
272 DCHECK(thread_checker_.CalledOnValidThread());
273 if (codec_type == webrtc::kVideoCodecVP8) {
274 encoder_ = WebrtcVideoEncoderVpx::CreateForVP8();
275 } else if (codec_type == webrtc::kVideoCodecVP9) {
276 encoder_ = WebrtcVideoEncoderVpx::CreateForVP9();
277 } else {
278 LOG(FATAL) << "Unknown codec type: " << codec_type;
279 }
280 }
281
264 } // namespace protocol 282 } // namespace protocol
265 } // namespace remoting 283 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/webrtc_video_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698