| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 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 | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_TEST_H_ | |
| 12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_TEST_H_ | |
| 13 | |
| 14 #include <memory> | |
| 15 | |
| 16 #include "webrtc/base/criticalsection.h" | |
| 17 #include "webrtc/base/event.h" | |
| 18 #include "webrtc/base/thread_annotations.h" | |
| 19 #include "webrtc/test/gtest.h" | |
| 20 #include "webrtc/video_decoder.h" | |
| 21 #include "webrtc/video_encoder.h" | |
| 22 | |
| 23 namespace webrtc { | |
| 24 | |
| 25 class VideoCodecTest : public ::testing::Test { | |
| 26 public: | |
| 27 VideoCodecTest() | |
| 28 : encode_complete_callback_(this), | |
| 29 decode_complete_callback_(this), | |
| 30 encoded_frame_event_(false /* manual reset */, | |
| 31 false /* initially signaled */), | |
| 32 decoded_frame_event_(false /* manual reset */, | |
| 33 false /* initially signaled */) {} | |
| 34 | |
| 35 protected: | |
| 36 class FakeEncodeCompleteCallback : public webrtc::EncodedImageCallback { | |
| 37 public: | |
| 38 explicit FakeEncodeCompleteCallback(VideoCodecTest* test) : test_(test) {} | |
| 39 | |
| 40 Result OnEncodedImage(const EncodedImage& frame, | |
| 41 const CodecSpecificInfo* codec_specific_info, | |
| 42 const RTPFragmentationHeader* fragmentation); | |
| 43 | |
| 44 private: | |
| 45 VideoCodecTest* const test_; | |
| 46 }; | |
| 47 | |
| 48 class FakeDecodeCompleteCallback : public webrtc::DecodedImageCallback { | |
| 49 public: | |
| 50 explicit FakeDecodeCompleteCallback(VideoCodecTest* test) : test_(test) {} | |
| 51 | |
| 52 int32_t Decoded(VideoFrame& frame) override { | |
| 53 RTC_NOTREACHED(); | |
| 54 return -1; | |
| 55 } | |
| 56 int32_t Decoded(VideoFrame& frame, int64_t decode_time_ms) override { | |
| 57 RTC_NOTREACHED(); | |
| 58 return -1; | |
| 59 } | |
| 60 void Decoded(VideoFrame& frame, | |
| 61 rtc::Optional<int32_t> decode_time_ms, | |
| 62 rtc::Optional<uint8_t> qp) override; | |
| 63 | |
| 64 private: | |
| 65 VideoCodecTest* const test_; | |
| 66 }; | |
| 67 | |
| 68 virtual VideoEncoder* CreateEncoder() = 0; | |
| 69 virtual VideoDecoder* CreateDecoder() = 0; | |
| 70 virtual VideoCodec codec_settings() = 0; | |
| 71 | |
| 72 void SetUp() override; | |
| 73 | |
| 74 bool WaitForEncodedFrame(EncodedImage* frame); | |
| 75 bool WaitForDecodedFrame(std::unique_ptr<VideoFrame>* frame, | |
| 76 rtc::Optional<uint8_t>* qp); | |
| 77 | |
| 78 std::unique_ptr<VideoFrame> input_frame_; | |
| 79 | |
| 80 std::unique_ptr<VideoEncoder> encoder_; | |
| 81 std::unique_ptr<VideoDecoder> decoder_; | |
| 82 | |
| 83 private: | |
| 84 void InitCodecs(); | |
| 85 | |
| 86 FakeEncodeCompleteCallback encode_complete_callback_; | |
| 87 FakeDecodeCompleteCallback decode_complete_callback_; | |
| 88 | |
| 89 rtc::Event encoded_frame_event_; | |
| 90 rtc::CriticalSection encoded_frame_section_; | |
| 91 rtc::Optional<EncodedImage> encoded_frame_ GUARDED_BY(encoded_frame_section_); | |
| 92 | |
| 93 rtc::Event decoded_frame_event_; | |
| 94 rtc::CriticalSection decoded_frame_section_; | |
| 95 rtc::Optional<VideoFrame> decoded_frame_ GUARDED_BY(decoded_frame_section_); | |
| 96 rtc::Optional<uint8_t> decoded_qp_ GUARDED_BY(decoded_frame_section_); | |
| 97 }; | |
| 98 | |
| 99 } // namespace webrtc | |
| 100 | |
| 101 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_TEST_H_ | |
| OLD | NEW |