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

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

Issue 1905763002: Convert //media/cast from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« 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 <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <cmath> 9 #include <cmath>
10 #include <cstring> 10 #include <cstring>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // request to the encoder on receiving Pli messages. This is used to prevent 45 // request to the encoder on receiving Pli messages. This is used to prevent
46 // sending multiple requests while the sender is waiting for an encoded key 46 // sending multiple requests while the sender is waiting for an encoded key
47 // frame or receiving multiple Pli messages in a short period. 47 // frame or receiving multiple Pli messages in a short period.
48 const int64_t kMinKeyFrameRequestOnPliIntervalMs = 500; 48 const int64_t kMinKeyFrameRequestOnPliIntervalMs = 500;
49 49
50 // Extract capture begin/end timestamps from |video_frame|'s metadata and log 50 // Extract capture begin/end timestamps from |video_frame|'s metadata and log
51 // it. 51 // it.
52 void LogVideoCaptureTimestamps(CastEnvironment* cast_environment, 52 void LogVideoCaptureTimestamps(CastEnvironment* cast_environment,
53 const media::VideoFrame& video_frame, 53 const media::VideoFrame& video_frame,
54 RtpTimeTicks rtp_timestamp) { 54 RtpTimeTicks rtp_timestamp) {
55 scoped_ptr<FrameEvent> capture_begin_event(new FrameEvent()); 55 std::unique_ptr<FrameEvent> capture_begin_event(new FrameEvent());
56 capture_begin_event->type = FRAME_CAPTURE_BEGIN; 56 capture_begin_event->type = FRAME_CAPTURE_BEGIN;
57 capture_begin_event->media_type = VIDEO_EVENT; 57 capture_begin_event->media_type = VIDEO_EVENT;
58 capture_begin_event->rtp_timestamp = rtp_timestamp; 58 capture_begin_event->rtp_timestamp = rtp_timestamp;
59 59
60 scoped_ptr<FrameEvent> capture_end_event(new FrameEvent()); 60 std::unique_ptr<FrameEvent> capture_end_event(new FrameEvent());
61 capture_end_event->type = FRAME_CAPTURE_END; 61 capture_end_event->type = FRAME_CAPTURE_END;
62 capture_end_event->media_type = VIDEO_EVENT; 62 capture_end_event->media_type = VIDEO_EVENT;
63 capture_end_event->rtp_timestamp = rtp_timestamp; 63 capture_end_event->rtp_timestamp = rtp_timestamp;
64 capture_end_event->width = video_frame.visible_rect().width(); 64 capture_end_event->width = video_frame.visible_rect().width();
65 capture_end_event->height = video_frame.visible_rect().height(); 65 capture_end_event->height = video_frame.visible_rect().height();
66 66
67 if (!video_frame.metadata()->GetTimeTicks( 67 if (!video_frame.metadata()->GetTimeTicks(
68 media::VideoFrameMetadata::CAPTURE_BEGIN_TIME, 68 media::VideoFrameMetadata::CAPTURE_BEGIN_TIME,
69 &capture_begin_event->timestamp) || 69 &capture_begin_event->timestamp) ||
70 !video_frame.metadata()->GetTimeTicks( 70 !video_frame.metadata()->GetTimeTicks(
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 last_enqueued_frame_rtp_timestamp_ = rtp_timestamp; 293 last_enqueued_frame_rtp_timestamp_ = rtp_timestamp;
294 last_enqueued_frame_reference_time_ = reference_time; 294 last_enqueued_frame_reference_time_ = reference_time;
295 } else { 295 } else {
296 VLOG(1) << "Encoder rejected a frame. Skipping..."; 296 VLOG(1) << "Encoder rejected a frame. Skipping...";
297 TRACE_EVENT_INSTANT1("cast.stream", "Video Encode Reject", 297 TRACE_EVENT_INSTANT1("cast.stream", "Video Encode Reject",
298 TRACE_EVENT_SCOPE_THREAD, 298 TRACE_EVENT_SCOPE_THREAD,
299 "rtp_timestamp", rtp_timestamp.lower_32_bits()); 299 "rtp_timestamp", rtp_timestamp.lower_32_bits());
300 } 300 }
301 } 301 }
302 302
303 scoped_ptr<VideoFrameFactory> VideoSender::CreateVideoFrameFactory() { 303 std::unique_ptr<VideoFrameFactory> VideoSender::CreateVideoFrameFactory() {
304 return video_encoder_ ? video_encoder_->CreateVideoFrameFactory() : nullptr; 304 return video_encoder_ ? video_encoder_->CreateVideoFrameFactory() : nullptr;
305 } 305 }
306 306
307 int VideoSender::GetNumberOfFramesInEncoder() const { 307 int VideoSender::GetNumberOfFramesInEncoder() const {
308 return frames_in_encoder_; 308 return frames_in_encoder_;
309 } 309 }
310 310
311 base::TimeDelta VideoSender::GetInFlightMediaDuration() const { 311 base::TimeDelta VideoSender::GetInFlightMediaDuration() const {
312 if (GetUnacknowledgedFrameCount() > 0) { 312 if (GetUnacknowledgedFrameCount() > 0) {
313 const uint32_t oldest_unacked_frame_id = latest_acked_frame_id_ + 1; 313 const uint32_t oldest_unacked_frame_id = latest_acked_frame_id_ + 1;
314 return last_enqueued_frame_reference_time_ - 314 return last_enqueued_frame_reference_time_ -
315 GetRecordedReferenceTime(oldest_unacked_frame_id); 315 GetRecordedReferenceTime(oldest_unacked_frame_id);
316 } else { 316 } else {
317 return duration_in_encoder_; 317 return duration_in_encoder_;
318 } 318 }
319 } 319 }
320 320
321 void VideoSender::OnEncodedVideoFrame( 321 void VideoSender::OnEncodedVideoFrame(
322 const scoped_refptr<media::VideoFrame>& video_frame, 322 const scoped_refptr<media::VideoFrame>& video_frame,
323 int encoder_bitrate, 323 int encoder_bitrate,
324 scoped_ptr<SenderEncodedFrame> encoded_frame) { 324 std::unique_ptr<SenderEncodedFrame> encoded_frame) {
325 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 325 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
326 326
327 frames_in_encoder_--; 327 frames_in_encoder_--;
328 DCHECK_GE(frames_in_encoder_, 0); 328 DCHECK_GE(frames_in_encoder_, 0);
329 329
330 duration_in_encoder_ = 330 duration_in_encoder_ =
331 last_enqueued_frame_reference_time_ - encoded_frame->reference_time; 331 last_enqueued_frame_reference_time_ - encoded_frame->reference_time;
332 332
333 last_reported_deadline_utilization_ = encoded_frame->deadline_utilization; 333 last_reported_deadline_utilization_ = encoded_frame->deadline_utilization;
334 last_reported_lossy_utilization_ = encoded_frame->lossy_utilization; 334 last_reported_lossy_utilization_ = encoded_frame->lossy_utilization;
(...skipping 17 matching lines...) Expand all
352 media::VideoFrameMetadata::RESOURCE_UTILIZATION, 352 media::VideoFrameMetadata::RESOURCE_UTILIZATION,
353 encoded_frame->dependency == EncodedFrame::KEY ? 353 encoded_frame->dependency == EncodedFrame::KEY ?
354 std::min(1.0, attenuated_utilization) : attenuated_utilization); 354 std::min(1.0, attenuated_utilization) : attenuated_utilization);
355 } 355 }
356 356
357 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); 357 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame));
358 } 358 }
359 359
360 } // namespace cast 360 } // namespace cast
361 } // namespace media 361 } // 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