Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 #ifndef WEBRTC_TEST_FAKE_TEXTURE_FRAME_H_ | 10 #ifndef WEBRTC_TEST_FAKE_TEXTURE_FRAME_H_ |
| 11 #define WEBRTC_TEST_FAKE_TEXTURE_FRAME_H_ | 11 #define WEBRTC_TEST_FAKE_TEXTURE_FRAME_H_ |
| 12 | 12 |
| 13 #include "webrtc/api/video/video_frame.h" | |
| 13 #include "webrtc/base/checks.h" | 14 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/common_video/include/video_frame_buffer.h" | 15 #include "webrtc/common_video/include/video_frame_buffer.h" |
| 15 #include "webrtc/video_frame.h" | |
| 16 | 16 |
| 17 namespace webrtc { | 17 namespace webrtc { |
| 18 namespace test { | 18 namespace test { |
| 19 | 19 |
| 20 class FakeNativeHandle { | 20 class FakeNativeHandle { |
| 21 public: | 21 public: |
| 22 static VideoFrame CreateFrame(FakeNativeHandle* native_handle, | 22 static VideoFrame CreateFrame(FakeNativeHandle* native_handle, |
| 23 int width, | 23 int width, |
| 24 int height, | 24 int height, |
| 25 uint32_t timestamp, | 25 uint32_t timestamp, |
| 26 int64_t render_time_ms, | 26 int64_t render_time_ms, |
| 27 VideoRotation rotation); | 27 VideoRotation rotation); |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 class FakeNativeHandleBuffer : public NativeHandleBuffer { | 30 class FakeNativeHandleBuffer : public NativeHandleBuffer { |
| 31 public: | 31 public: |
| 32 FakeNativeHandleBuffer(void* native_handle, int width, int height) | 32 FakeNativeHandleBuffer(void* native_handle, int width, int height) |
| 33 : NativeHandleBuffer(native_handle, width, height) {} | 33 : NativeHandleBuffer(native_handle, width, height) {} |
| 34 | 34 |
| 35 ~FakeNativeHandleBuffer() { | 35 ~FakeNativeHandleBuffer() { |
| 36 delete reinterpret_cast<FakeNativeHandle*>(native_handle_); | 36 delete reinterpret_cast<FakeNativeHandle*>(native_handle_); |
| 37 } | 37 } |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override { | 40 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override { |
| 41 rtc::scoped_refptr<I420Buffer> buffer = I420Buffer::Create(width_, height_); | 41 rtc::scoped_refptr<I420Buffer> buffer = I420Buffer::Create(width_, height_); |
| 42 int half_height = (height_ + 1) / 2; | 42 buffer->InitializeData(); |
|
the sun
2016/12/05 22:36:29
SetToBlack()? Do we really need both SetToBlack an
nisse-webrtc
2016/12/06 12:02:15
Probably not. Do you want InitializeData deleted i
the sun
2016/12/07 15:43:51
Not necessarily, but if you intend to delete it, d
nisse-webrtc
2016/12/13 15:08:02
Done. Have to keep the old method for compatibilit
the sun
2016/12/13 15:29:28
Sure.
| |
| 43 int half_width = (width_ + 1) / 2; | |
| 44 memset(buffer->MutableDataY(), 0, height_ * width_); | |
| 45 memset(buffer->MutableDataU(), 0, half_height * half_width); | |
| 46 memset(buffer->MutableDataV(), 0, half_height * half_width); | |
| 47 return buffer; | 43 return buffer; |
| 48 } | 44 } |
| 49 }; | 45 }; |
| 50 | 46 |
| 51 } // namespace test | 47 } // namespace test |
| 52 } // namespace webrtc | 48 } // namespace webrtc |
| 53 #endif // WEBRTC_TEST_FAKE_TEXTURE_FRAME_H_ | 49 #endif // WEBRTC_TEST_FAKE_TEXTURE_FRAME_H_ |
| OLD | NEW |