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

Side by Side Diff: content/browser/media/capture/desktop_capture_device_unittest.cc

Issue 1826643003: Add frame refresh to VideoCaptureDevice, and buffer pool resurrection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE before commit 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/browser/media/capture/desktop_capture_device.h" 5 #include "content/browser/media/capture/desktop_capture_device.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 #include <algorithm> 10 #include <algorithm>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 const uint8_t* v_data, 72 const uint8_t* v_data,
73 size_t y_stride, 73 size_t y_stride,
74 size_t u_stride, 74 size_t u_stride,
75 size_t v_stride, 75 size_t v_stride,
76 const media::VideoCaptureFormat& frame_format, 76 const media::VideoCaptureFormat& frame_format,
77 int clockwise_rotation, 77 int clockwise_rotation,
78 const base::TimeTicks& timestamp)); 78 const base::TimeTicks& timestamp));
79 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); 79 MOCK_METHOD0(DoReserveOutputBuffer, void(void));
80 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); 80 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void));
81 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); 81 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void));
82 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void));
82 MOCK_METHOD2(OnError, 83 MOCK_METHOD2(OnError,
83 void(const tracked_objects::Location& from_here, 84 void(const tracked_objects::Location& from_here,
84 const std::string& reason)); 85 const std::string& reason));
85 86
86 // Trampoline methods to workaround GMOCK problems with scoped_ptr<>. 87 // Trampoline methods to workaround GMOCK problems with scoped_ptr<>.
87 scoped_ptr<Buffer> ReserveOutputBuffer( 88 scoped_ptr<Buffer> ReserveOutputBuffer(
88 const gfx::Size& dimensions, 89 const gfx::Size& dimensions,
89 media::VideoPixelFormat format, 90 media::VideoPixelFormat format,
90 media::VideoPixelStorage storage) override { 91 media::VideoPixelStorage storage) override {
91 EXPECT_TRUE(format == media::PIXEL_FORMAT_I420 && 92 EXPECT_TRUE(format == media::PIXEL_FORMAT_I420 &&
92 storage == media::PIXEL_STORAGE_CPU); 93 storage == media::PIXEL_STORAGE_CPU);
93 DoReserveOutputBuffer(); 94 DoReserveOutputBuffer();
94 return scoped_ptr<Buffer>(); 95 return scoped_ptr<Buffer>();
95 } 96 }
96 void OnIncomingCapturedBuffer(scoped_ptr<Buffer> buffer, 97 void OnIncomingCapturedBuffer(scoped_ptr<Buffer> buffer,
97 const media::VideoCaptureFormat& frame_format, 98 const media::VideoCaptureFormat& frame_format,
98 const base::TimeTicks& timestamp) override { 99 const base::TimeTicks& timestamp) override {
99 DoOnIncomingCapturedBuffer(); 100 DoOnIncomingCapturedBuffer();
100 } 101 }
101 void OnIncomingCapturedVideoFrame( 102 void OnIncomingCapturedVideoFrame(
102 scoped_ptr<Buffer> buffer, 103 scoped_ptr<Buffer> buffer,
103 const scoped_refptr<media::VideoFrame>& frame, 104 const scoped_refptr<media::VideoFrame>& frame,
104 const base::TimeTicks& timestamp) override { 105 const base::TimeTicks& timestamp) override {
105 DoOnIncomingCapturedVideoFrame(); 106 DoOnIncomingCapturedVideoFrame();
106 } 107 }
107 108 scoped_ptr<Buffer> ResurrectLastOutputBuffer(
109 const gfx::Size& dimensions,
110 media::VideoPixelFormat format,
111 media::VideoPixelStorage storage) override {
112 EXPECT_TRUE(format == media::PIXEL_FORMAT_I420 &&
113 storage == media::PIXEL_STORAGE_CPU);
114 DoResurrectLastOutputBuffer();
115 return scoped_ptr<Buffer>();
116 }
108 double GetBufferPoolUtilization() const override { return 0.0; } 117 double GetBufferPoolUtilization() const override { return 0.0; }
109 }; 118 };
110 119
111 // Creates a DesktopFrame that has the first pixel bytes set to 120 // Creates a DesktopFrame that has the first pixel bytes set to
112 // kFakePixelValueFirst, and the rest of the bytes set to kFakePixelValue, for 121 // kFakePixelValueFirst, and the rest of the bytes set to kFakePixelValue, for
113 // UnpackedFrame and InvertedFrame verification. 122 // UnpackedFrame and InvertedFrame verification.
114 webrtc::BasicDesktopFrame* CreateBasicFrame(const webrtc::DesktopSize& size) { 123 webrtc::BasicDesktopFrame* CreateBasicFrame(const webrtc::DesktopSize& size) {
115 webrtc::BasicDesktopFrame* frame = new webrtc::BasicDesktopFrame(size); 124 webrtc::BasicDesktopFrame* frame = new webrtc::BasicDesktopFrame(size);
116 DCHECK_EQ(frame->size().width() * webrtc::DesktopFrame::kBytesPerPixel, 125 DCHECK_EQ(frame->size().width() * webrtc::DesktopFrame::kBytesPerPixel,
117 frame->stride()); 126 frame->stride());
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 frame_size); 533 frame_size);
525 for (int i = 0; i < output_frame_->size().height(); ++i) { 534 for (int i = 0; i < output_frame_->size().height(); ++i) {
526 EXPECT_EQ(0, 535 EXPECT_EQ(0,
527 memcmp(inverted_frame->data() + i * inverted_frame->stride(), 536 memcmp(inverted_frame->data() + i * inverted_frame->stride(),
528 output_frame_->data() + i * output_frame_->stride(), 537 output_frame_->data() + i * output_frame_->stride(),
529 output_frame_->stride())); 538 output_frame_->stride()));
530 } 539 }
531 } 540 }
532 541
533 } // namespace content 542 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698