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

Side by Side Diff: webrtc/media/base/videocapturer.cc

Issue 1728503002: Replace scoped_ptr with unique_ptr in webrtc/media/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@up1
Patch Set: Created 4 years, 10 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 | « webrtc/media/base/videocapturer.h ('k') | webrtc/media/base/videoengine_unittest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 if (capture_state() == CS_PAUSED) { 161 if (capture_state() == CS_PAUSED) {
162 return true; 162 return true;
163 } 163 }
164 bool is_running = capture_state() == CS_STARTING || 164 bool is_running = capture_state() == CS_STARTING ||
165 capture_state() == CS_RUNNING; 165 capture_state() == CS_RUNNING;
166 if (!is_running) { 166 if (!is_running) {
167 LOG(LS_ERROR) << "Cannot pause a stopped camera."; 167 LOG(LS_ERROR) << "Cannot pause a stopped camera.";
168 return false; 168 return false;
169 } 169 }
170 LOG(LS_INFO) << "Pausing a camera."; 170 LOG(LS_INFO) << "Pausing a camera.";
171 rtc::scoped_ptr<VideoFormat> capture_format_when_paused( 171 std::unique_ptr<VideoFormat> capture_format_when_paused(
172 capture_format_ ? new VideoFormat(*capture_format_) : NULL); 172 capture_format_ ? new VideoFormat(*capture_format_) : NULL);
173 Stop(); 173 Stop();
174 SetCaptureState(CS_PAUSED); 174 SetCaptureState(CS_PAUSED);
175 // If you override this function be sure to restore the capture format 175 // If you override this function be sure to restore the capture format
176 // after calling Stop(). 176 // after calling Stop().
177 SetCaptureFormat(capture_format_when_paused.get()); 177 SetCaptureFormat(capture_format_when_paused.get());
178 } else { // Unpause. 178 } else { // Unpause.
179 if (capture_state() != CS_PAUSED) { 179 if (capture_state() != CS_PAUSED) {
180 LOG(LS_WARNING) << "Cannot unpause a camera that hasn't been paused."; 180 LOG(LS_WARNING) << "Cannot unpause a camera that hasn't been paused.";
181 return false; 181 return false;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 } else { 344 } else {
345 --black_frame_count_down_; 345 --black_frame_count_down_;
346 } 346 }
347 } 347 }
348 348
349 if (!broadcaster_.frame_wanted()) { 349 if (!broadcaster_.frame_wanted()) {
350 return; 350 return;
351 } 351 }
352 352
353 // Use a temporary buffer to scale 353 // Use a temporary buffer to scale
354 rtc::scoped_ptr<uint8_t[]> scale_buffer; 354 std::unique_ptr<uint8_t[]> scale_buffer;
355 355
356 if (IsScreencast()) { 356 if (IsScreencast()) {
357 int scaled_width, scaled_height; 357 int scaled_width, scaled_height;
358 int desired_screencast_fps = capture_format_.get() ? 358 int desired_screencast_fps = capture_format_.get() ?
359 VideoFormat::IntervalToFps(capture_format_->interval) : 359 VideoFormat::IntervalToFps(capture_format_->interval) :
360 kDefaultScreencastFps; 360 kDefaultScreencastFps;
361 ComputeScale(captured_frame->width, captured_frame->height, 361 ComputeScale(captured_frame->width, captured_frame->height,
362 desired_screencast_fps, &scaled_width, &scaled_height); 362 desired_screencast_fps, &scaled_width, &scaled_height);
363 363
364 if (FOURCC_ARGB == captured_frame->fourcc && 364 if (FOURCC_ARGB == captured_frame->fourcc &&
(...skipping 28 matching lines...) Expand all
393 } 393 }
394 } 394 }
395 395
396 const int kYuy2Bpp = 2; 396 const int kYuy2Bpp = 2;
397 const int kArgbBpp = 4; 397 const int kArgbBpp = 4;
398 // TODO(fbarchard): Make a helper function to adjust pixels to square. 398 // TODO(fbarchard): Make a helper function to adjust pixels to square.
399 // TODO(fbarchard): Hook up experiment to scaling. 399 // TODO(fbarchard): Hook up experiment to scaling.
400 // TODO(fbarchard): Avoid scale and convert if muted. 400 // TODO(fbarchard): Avoid scale and convert if muted.
401 // Temporary buffer is scoped here so it will persist until i420_frame.Init() 401 // Temporary buffer is scoped here so it will persist until i420_frame.Init()
402 // makes a copy of the frame, converting to I420. 402 // makes a copy of the frame, converting to I420.
403 rtc::scoped_ptr<uint8_t[]> temp_buffer; 403 std::unique_ptr<uint8_t[]> temp_buffer;
404 // YUY2 can be scaled vertically using an ARGB scaler. Aspect ratio is only 404 // YUY2 can be scaled vertically using an ARGB scaler. Aspect ratio is only
405 // a problem on OSX. OSX always converts webcams to YUY2 or UYVY. 405 // a problem on OSX. OSX always converts webcams to YUY2 or UYVY.
406 bool can_scale = 406 bool can_scale =
407 FOURCC_YUY2 == CanonicalFourCC(captured_frame->fourcc) || 407 FOURCC_YUY2 == CanonicalFourCC(captured_frame->fourcc) ||
408 FOURCC_UYVY == CanonicalFourCC(captured_frame->fourcc); 408 FOURCC_UYVY == CanonicalFourCC(captured_frame->fourcc);
409 409
410 // If pixels are not square, optionally use vertical scaling to make them 410 // If pixels are not square, optionally use vertical scaling to make them
411 // square. Square pixels simplify the rest of the pipeline, including 411 // square. Square pixels simplify the rest of the pipeline, including
412 // effects and rendering. 412 // effects and rendering.
413 if (can_scale && square_pixel_aspect_ratio_ && 413 if (can_scale && square_pixel_aspect_ratio_ &&
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 } 505 }
506 adapted_width = adapted_format.width; 506 adapted_width = adapted_format.width;
507 adapted_height = adapted_format.height; 507 adapted_height = adapted_format.height;
508 } 508 }
509 509
510 if (!frame_factory_) { 510 if (!frame_factory_) {
511 LOG(LS_ERROR) << "No video frame factory."; 511 LOG(LS_ERROR) << "No video frame factory.";
512 return; 512 return;
513 } 513 }
514 514
515 rtc::scoped_ptr<VideoFrame> adapted_frame( 515 std::unique_ptr<VideoFrame> adapted_frame(
516 frame_factory_->CreateAliasedFrame(captured_frame, 516 frame_factory_->CreateAliasedFrame(captured_frame,
517 cropped_width, cropped_height, 517 cropped_width, cropped_height,
518 adapted_width, adapted_height)); 518 adapted_width, adapted_height));
519 519
520 if (!adapted_frame) { 520 if (!adapted_frame) {
521 // TODO(fbarchard): LOG more information about captured frame attributes. 521 // TODO(fbarchard): LOG more information about captured frame attributes.
522 LOG(LS_ERROR) << "Couldn't convert to I420! " 522 LOG(LS_ERROR) << "Couldn't convert to I420! "
523 << "From " << ToString(captured_frame) << " To " 523 << "From " << ToString(captured_frame) << " To "
524 << cropped_width << " x " << cropped_height; 524 << cropped_width << " x " << cropped_height;
525 return; 525 return;
(...skipping 17 matching lines...) Expand all
543 return; 543 return;
544 } 544 }
545 StateChangeParams* state_params = new StateChangeParams(state); 545 StateChangeParams* state_params = new StateChangeParams(state);
546 capture_state_ = state; 546 capture_state_ = state;
547 thread_->Post(this, MSG_STATE_CHANGE, state_params); 547 thread_->Post(this, MSG_STATE_CHANGE, state_params);
548 } 548 }
549 549
550 void VideoCapturer::OnMessage(rtc::Message* message) { 550 void VideoCapturer::OnMessage(rtc::Message* message) {
551 switch (message->message_id) { 551 switch (message->message_id) {
552 case MSG_STATE_CHANGE: { 552 case MSG_STATE_CHANGE: {
553 rtc::scoped_ptr<StateChangeParams> p( 553 std::unique_ptr<StateChangeParams> p(
554 static_cast<StateChangeParams*>(message->pdata)); 554 static_cast<StateChangeParams*>(message->pdata));
555 SignalStateChange(this, p->data()); 555 SignalStateChange(this, p->data());
556 break; 556 break;
557 } 557 }
558 case MSG_DO_PAUSE: { 558 case MSG_DO_PAUSE: {
559 Pause(true); 559 Pause(true);
560 break; 560 break;
561 } 561 }
562 case MSG_DO_UNPAUSE: { 562 case MSG_DO_UNPAUSE: {
563 Pause(false); 563 Pause(false);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 void VideoCapturer::GetVariableSnapshot( 718 void VideoCapturer::GetVariableSnapshot(
719 const rtc::RollingAccumulator<T>& data, 719 const rtc::RollingAccumulator<T>& data,
720 VariableInfo<T>* stats) { 720 VariableInfo<T>* stats) {
721 stats->max_val = data.ComputeMax(); 721 stats->max_val = data.ComputeMax();
722 stats->mean = data.ComputeMean(); 722 stats->mean = data.ComputeMean();
723 stats->min_val = data.ComputeMin(); 723 stats->min_val = data.ComputeMin();
724 stats->variance = data.ComputeVariance(); 724 stats->variance = data.ComputeVariance();
725 } 725 }
726 726
727 } // namespace cricket 727 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/base/videocapturer.h ('k') | webrtc/media/base/videoengine_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698