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

Side by Side Diff: media/cast/sender/video_sender.cc

Issue 688423003: [Cast] VideoFrameFactory interface to vend frames with encoder affinity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final patch cleanup. Created 6 years, 1 month 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 | « media/cast/sender/video_sender.h ('k') | media/cast/sender/video_sender_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "media/cast/sender/video_sender.h" 5 #include "media/cast/sender/video_sender.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "media/cast/cast_defines.h" 14 #include "media/cast/cast_defines.h"
15 #include "media/cast/net/cast_transport_config.h" 15 #include "media/cast/net/cast_transport_config.h"
16 #include "media/cast/sender/external_video_encoder.h" 16 #include "media/cast/sender/external_video_encoder.h"
17 #include "media/cast/sender/video_encoder_impl.h" 17 #include "media/cast/sender/video_encoder_impl.h"
18 #include "media/cast/sender/video_frame_factory.h"
18 19
19 namespace media { 20 namespace media {
20 namespace cast { 21 namespace cast {
21 22
22 namespace { 23 namespace {
23 24
24 // The following two constants are used to adjust the target 25 // The following two constants are used to adjust the target
25 // playout delay (when allowed). They were calculated using 26 // playout delay (when allowed). They were calculated using
26 // a combination of cast_benchmark runs and manual testing. 27 // a combination of cast_benchmark runs and manual testing.
27 // 28 //
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 bitrate))) { 187 bitrate))) {
187 frames_in_encoder_++; 188 frames_in_encoder_++;
188 duration_in_encoder_ += duration_added_by_next_frame; 189 duration_in_encoder_ += duration_added_by_next_frame;
189 last_enqueued_frame_rtp_timestamp_ = rtp_timestamp; 190 last_enqueued_frame_rtp_timestamp_ = rtp_timestamp;
190 last_enqueued_frame_reference_time_ = reference_time; 191 last_enqueued_frame_reference_time_ = reference_time;
191 } else { 192 } else {
192 VLOG(1) << "Encoder rejected a frame. Skipping..."; 193 VLOG(1) << "Encoder rejected a frame. Skipping...";
193 } 194 }
194 } 195 }
195 196
197 scoped_ptr<VideoFrameFactory> VideoSender::CreateVideoFrameFactory() {
198 DCHECK(cast_initialization_status_ == STATUS_VIDEO_INITIALIZED);
199 DCHECK(video_encoder_.get()) << "Invalid state";
200 return video_encoder_->CreateVideoFrameFactory();
201 }
202
196 int VideoSender::GetNumberOfFramesInEncoder() const { 203 int VideoSender::GetNumberOfFramesInEncoder() const {
197 return frames_in_encoder_; 204 return frames_in_encoder_;
198 } 205 }
199 206
200 base::TimeDelta VideoSender::GetInFlightMediaDuration() const { 207 base::TimeDelta VideoSender::GetInFlightMediaDuration() const {
201 if (GetUnacknowledgedFrameCount() > 0) { 208 if (GetUnacknowledgedFrameCount() > 0) {
202 const uint32 oldest_unacked_frame_id = latest_acked_frame_id_ + 1; 209 const uint32 oldest_unacked_frame_id = latest_acked_frame_id_ + 1;
203 return last_enqueued_frame_reference_time_ - 210 return last_enqueued_frame_reference_time_ -
204 GetRecordedReferenceTime(oldest_unacked_frame_id); 211 GetRecordedReferenceTime(oldest_unacked_frame_id);
205 } else { 212 } else {
(...skipping 21 matching lines...) Expand all
227 DCHECK_GE(frames_in_encoder_, 0); 234 DCHECK_GE(frames_in_encoder_, 0);
228 235
229 duration_in_encoder_ = 236 duration_in_encoder_ =
230 last_enqueued_frame_reference_time_ - encoded_frame->reference_time; 237 last_enqueued_frame_reference_time_ - encoded_frame->reference_time;
231 238
232 SendEncodedFrame(encoder_bitrate, encoded_frame.Pass()); 239 SendEncodedFrame(encoder_bitrate, encoded_frame.Pass());
233 } 240 }
234 241
235 } // namespace cast 242 } // namespace cast
236 } // namespace media 243 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/video_sender.h ('k') | media/cast/sender/video_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698