| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/capture/video/fake_video_capture_device.h" | 5 #include "media/capture/video/fake_video_capture_device.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 return; | 584 return; |
| 585 | 585 |
| 586 auto required_sk_n32_buffer_size = VideoFrame::AllocationSize( | 586 auto required_sk_n32_buffer_size = VideoFrame::AllocationSize( |
| 587 PIXEL_FORMAT_ARGB, device_state()->format.frame_size); | 587 PIXEL_FORMAT_ARGB, device_state()->format.frame_size); |
| 588 sk_n32_buffer_.resize(required_sk_n32_buffer_size); | 588 sk_n32_buffer_.resize(required_sk_n32_buffer_size); |
| 589 memset(&sk_n32_buffer_[0], 0, required_sk_n32_buffer_size); | 589 memset(&sk_n32_buffer_[0], 0, required_sk_n32_buffer_size); |
| 590 | 590 |
| 591 frame_painter()->PaintFrame(timestamp_to_paint, &sk_n32_buffer_[0]); | 591 frame_painter()->PaintFrame(timestamp_to_paint, &sk_n32_buffer_[0]); |
| 592 | 592 |
| 593 static const int kQuality = 75; | 593 static const int kQuality = 75; |
| 594 const gfx::JPEGCodec::ColorFormat encoding_source_format = | 594 SkImageInfo info = SkImageInfo::MakeN32( |
| 595 (kN32_SkColorType == kRGBA_8888_SkColorType) | |
| 596 ? gfx::JPEGCodec::FORMAT_RGBA | |
| 597 : gfx::JPEGCodec::FORMAT_BGRA; | |
| 598 bool success = gfx::JPEGCodec::Encode( | |
| 599 &sk_n32_buffer_[0], encoding_source_format, | |
| 600 device_state()->format.frame_size.width(), | 595 device_state()->format.frame_size.width(), |
| 601 device_state()->format.frame_size.height(), | 596 device_state()->format.frame_size.height(), kOpaque_SkAlphaType); |
| 602 VideoFrame::RowBytes(0 /* plane */, PIXEL_FORMAT_ARGB, | 597 SkPixmap src(info, &sk_n32_buffer_[0], |
| 603 device_state()->format.frame_size.width()), | 598 VideoFrame::RowBytes(0 /* plane */, PIXEL_FORMAT_ARGB, |
| 604 kQuality, &jpeg_buffer_); | 599 device_state()->format.frame_size.width())); |
| 600 bool success = gfx::JPEGCodec::Encode(src, kQuality, &jpeg_buffer_); |
| 605 if (!success) { | 601 if (!success) { |
| 606 DLOG(ERROR) << "Jpeg encoding failed"; | 602 DLOG(ERROR) << "Jpeg encoding failed"; |
| 607 return; | 603 return; |
| 608 } | 604 } |
| 609 | 605 |
| 610 const size_t frame_size = jpeg_buffer_.size(); | 606 const size_t frame_size = jpeg_buffer_.size(); |
| 611 base::TimeTicks now = base::TimeTicks::Now(); | 607 base::TimeTicks now = base::TimeTicks::Now(); |
| 612 client()->OnIncomingCapturedData(&jpeg_buffer_[0], frame_size, | 608 client()->OnIncomingCapturedData(&jpeg_buffer_[0], frame_size, |
| 613 device_state()->format, 0 /* rotation */, | 609 device_state()->format, 0 /* rotation */, |
| 614 now, CalculateTimeSinceFirstInvocation(now)); | 610 now, CalculateTimeSinceFirstInvocation(now)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 int session_id) { | 646 int session_id) { |
| 651 DCHECK(thread_checker_.CalledOnValidThread()); | 647 DCHECK(thread_checker_.CalledOnValidThread()); |
| 652 if (session_id != current_session_id_) | 648 if (session_id != current_session_id_) |
| 653 return; | 649 return; |
| 654 | 650 |
| 655 frame_deliverer_->PaintAndDeliverNextFrame(elapsed_time_); | 651 frame_deliverer_->PaintAndDeliverNextFrame(elapsed_time_); |
| 656 BeepAndScheduleNextCapture(expected_execution_time); | 652 BeepAndScheduleNextCapture(expected_execution_time); |
| 657 } | 653 } |
| 658 | 654 |
| 659 } // namespace media | 655 } // namespace media |
| OLD | NEW |