OLD | NEW |
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 int frame_feedback_id)); | 70 int frame_feedback_id)); |
71 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); | 71 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); |
72 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); | 72 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); |
73 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); | 73 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); |
74 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void)); | 74 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void)); |
75 MOCK_METHOD2(OnError, | 75 MOCK_METHOD2(OnError, |
76 void(const tracked_objects::Location& from_here, | 76 void(const tracked_objects::Location& from_here, |
77 const std::string& reason)); | 77 const std::string& reason)); |
78 | 78 |
79 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>. | 79 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>. |
80 std::unique_ptr<Buffer> ReserveOutputBuffer(const gfx::Size& dimensions, | 80 Buffer ReserveOutputBuffer(const gfx::Size& dimensions, |
81 media::VideoPixelFormat format, | 81 media::VideoPixelFormat format, |
82 media::VideoPixelStorage storage, | 82 media::VideoPixelStorage storage, |
83 int frame_feedback_id) override { | 83 int frame_feedback_id) override { |
84 EXPECT_TRUE(format == media::PIXEL_FORMAT_I420 && | 84 EXPECT_TRUE(format == media::PIXEL_FORMAT_I420 && |
85 storage == media::PIXEL_STORAGE_CPU); | 85 storage == media::PIXEL_STORAGE_CPU); |
86 DoReserveOutputBuffer(); | 86 DoReserveOutputBuffer(); |
87 return std::unique_ptr<Buffer>(); | 87 return Buffer(); |
88 } | 88 } |
89 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, | 89 void OnIncomingCapturedBuffer(Buffer buffer, |
90 const media::VideoCaptureFormat& format, | 90 const media::VideoCaptureFormat& format, |
91 base::TimeTicks reference_time, | 91 base::TimeTicks reference_time, |
92 base::TimeDelta timestamp) override { | 92 base::TimeDelta timestamp) override { |
93 DoOnIncomingCapturedBuffer(); | 93 DoOnIncomingCapturedBuffer(); |
94 } | 94 } |
95 void OnIncomingCapturedBufferExt( | 95 void OnIncomingCapturedBufferExt( |
96 std::unique_ptr<Buffer> buffer, | 96 Buffer buffer, |
97 const media::VideoCaptureFormat& format, | 97 const media::VideoCaptureFormat& format, |
98 base::TimeTicks reference_time, | 98 base::TimeTicks reference_time, |
99 base::TimeDelta timestamp, | 99 base::TimeDelta timestamp, |
100 gfx::Rect visible_rect, | 100 gfx::Rect visible_rect, |
101 const media::VideoFrameMetadata& additional_metadata) override { | 101 const media::VideoFrameMetadata& additional_metadata) override { |
102 DoOnIncomingCapturedVideoFrame(); | 102 DoOnIncomingCapturedVideoFrame(); |
103 } | 103 } |
104 std::unique_ptr<Buffer> ResurrectLastOutputBuffer( | 104 Buffer ResurrectLastOutputBuffer(const gfx::Size& dimensions, |
105 const gfx::Size& dimensions, | 105 media::VideoPixelFormat format, |
106 media::VideoPixelFormat format, | 106 media::VideoPixelStorage storage, |
107 media::VideoPixelStorage storage, | 107 int frame_feedback_id) override { |
108 int frame_feedback_id) override { | |
109 EXPECT_TRUE(format == media::PIXEL_FORMAT_I420 && | 108 EXPECT_TRUE(format == media::PIXEL_FORMAT_I420 && |
110 storage == media::PIXEL_STORAGE_CPU); | 109 storage == media::PIXEL_STORAGE_CPU); |
111 DoResurrectLastOutputBuffer(); | 110 DoResurrectLastOutputBuffer(); |
112 return std::unique_ptr<Buffer>(); | 111 return Buffer(); |
113 } | 112 } |
114 double GetBufferPoolUtilization() const override { return 0.0; } | 113 double GetBufferPoolUtilization() const override { return 0.0; } |
115 }; | 114 }; |
116 | 115 |
117 // Creates a DesktopFrame that has the first pixel bytes set to | 116 // Creates a DesktopFrame that has the first pixel bytes set to |
118 // kFakePixelValueFirst, and the rest of the bytes set to kFakePixelValue, for | 117 // kFakePixelValueFirst, and the rest of the bytes set to kFakePixelValue, for |
119 // UnpackedFrame and InvertedFrame verification. | 118 // UnpackedFrame and InvertedFrame verification. |
120 std::unique_ptr<webrtc::BasicDesktopFrame> CreateBasicFrame( | 119 std::unique_ptr<webrtc::BasicDesktopFrame> CreateBasicFrame( |
121 const webrtc::DesktopSize& size) { | 120 const webrtc::DesktopSize& size) { |
122 std::unique_ptr<webrtc::BasicDesktopFrame> frame( | 121 std::unique_ptr<webrtc::BasicDesktopFrame> frame( |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 frame_size); | 556 frame_size); |
558 for (int i = 0; i < output_frame_->size().height(); ++i) { | 557 for (int i = 0; i < output_frame_->size().height(); ++i) { |
559 EXPECT_EQ(0, | 558 EXPECT_EQ(0, |
560 memcmp(inverted_frame->data() + i * inverted_frame->stride(), | 559 memcmp(inverted_frame->data() + i * inverted_frame->stride(), |
561 output_frame_->data() + i * output_frame_->stride(), | 560 output_frame_->data() + i * output_frame_->stride(), |
562 output_frame_->stride())); | 561 output_frame_->stride())); |
563 } | 562 } |
564 } | 563 } |
565 | 564 |
566 } // namespace content | 565 } // namespace content |
OLD | NEW |