Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

112 lines
3.7 KiB
C
Raw Normal View History

/*
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_TEST_H_
#define WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_TEST_H_
#include <memory>
Reland of Move video_encoder.h and video_decoder.h to /api and create GN targets for them (patchset #1 id:1 of https://codereview.webrtc.org/2794033002/ ) Reason for revert: Reland with temporary deprecated API to not break chromium and google3. Original issue's description: > Revert of Move video_encoder.h and video_decoder.h to /api and create GN targets for them (patchset #8 id:140001 of https://codereview.webrtc.org/2780943003/ ) > > Reason for revert: > Suspect of breaking Chrome FYI bots. > > See > https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/23065 > https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Builder > > Example logs: > ../../content/renderer/media/gpu/rtc_video_encoder_unittest.cc:18:46: fatal error: third_party/webrtc/video_encoder.h: No such file or directory > #include "third_party/webrtc/video_encoder.h" > ^ > > Original issue's description: > > Move video_encoder.h and video_decoder.h to /api and create GN targets for them > > > > BUG=webrtc:5881 > > # Because PRESUBMIT ignores LINT blacklist for moved files and these > > # headers have some not easy to resolve issues. > > NOPRESUBMIT=True > > > > Review-Url: https://codereview.webrtc.org/2780943003 > > Cr-Commit-Position: refs/heads/master@{#17511} > > Committed: https://chromium.googlesource.com/external/webrtc/+/c42f54057050c933008a49d57582577bfb9aed25 > > TBR=solenberg@webrtc.org,sprang@webrtc.org,ilnik@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:5881 > > Review-Url: https://codereview.webrtc.org/2794033002 > Cr-Commit-Position: refs/heads/master@{#17514} > Committed: https://chromium.googlesource.com/external/webrtc/+/716d7ac5c1ed6e392e264b34065800bbf03772b3 TBR=solenberg@webrtc.org,sprang@webrtc.org,guidou@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5881 Review-Url: https://codereview.webrtc.org/2795163002 Cr-Commit-Position: refs/heads/master@{#17537}
2017-04-05 03:02:20 -07:00
#include "webrtc/api/video_codecs/video_decoder.h"
#include "webrtc/api/video_codecs/video_encoder.h"
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
#include "webrtc/modules/video_coding/utility/vp8_header_parser.h"
#include "webrtc/modules/video_coding/utility/vp9_uncompressed_header_parser.h"
#include "webrtc/rtc_base/criticalsection.h"
#include "webrtc/rtc_base/event.h"
#include "webrtc/rtc_base/thread_annotations.h"
#include "webrtc/test/gtest.h"
namespace webrtc {
class VideoCodecTest : public ::testing::Test {
public:
VideoCodecTest()
: encode_complete_callback_(this),
decode_complete_callback_(this),
encoded_frame_event_(false /* manual reset */,
false /* initially signaled */),
decoded_frame_event_(false /* manual reset */,
false /* initially signaled */) {}
protected:
class FakeEncodeCompleteCallback : public webrtc::EncodedImageCallback {
public:
explicit FakeEncodeCompleteCallback(VideoCodecTest* test) : test_(test) {}
Result OnEncodedImage(const EncodedImage& frame,
const CodecSpecificInfo* codec_specific_info,
const RTPFragmentationHeader* fragmentation);
private:
VideoCodecTest* const test_;
};
class FakeDecodeCompleteCallback : public webrtc::DecodedImageCallback {
public:
explicit FakeDecodeCompleteCallback(VideoCodecTest* test) : test_(test) {}
int32_t Decoded(VideoFrame& frame) override {
RTC_NOTREACHED();
return -1;
}
int32_t Decoded(VideoFrame& frame, int64_t decode_time_ms) override {
RTC_NOTREACHED();
return -1;
}
void Decoded(VideoFrame& frame,
rtc::Optional<int32_t> decode_time_ms,
rtc::Optional<uint8_t> qp) override;
private:
VideoCodecTest* const test_;
};
virtual VideoEncoder* CreateEncoder() = 0;
virtual VideoDecoder* CreateDecoder() = 0;
virtual VideoCodec codec_settings() = 0;
void SetUp() override;
bool WaitForEncodedFrame(EncodedImage* frame,
CodecSpecificInfo* codec_specific_info);
bool WaitForDecodedFrame(std::unique_ptr<VideoFrame>* frame,
rtc::Optional<uint8_t>* qp);
// Populated by InitCodecs().
VideoCodec codec_settings_;
std::unique_ptr<VideoFrame> input_frame_;
std::unique_ptr<VideoEncoder> encoder_;
std::unique_ptr<VideoDecoder> decoder_;
private:
void InitCodecs();
FakeEncodeCompleteCallback encode_complete_callback_;
FakeDecodeCompleteCallback decode_complete_callback_;
rtc::Event encoded_frame_event_;
rtc::CriticalSection encoded_frame_section_;
rtc::Optional<EncodedImage> encoded_frame_
RTC_GUARDED_BY(encoded_frame_section_);
CodecSpecificInfo codec_specific_info_ RTC_GUARDED_BY(encoded_frame_section_);
rtc::Event decoded_frame_event_;
rtc::CriticalSection decoded_frame_section_;
rtc::Optional<VideoFrame> decoded_frame_
RTC_GUARDED_BY(decoded_frame_section_);
rtc::Optional<uint8_t> decoded_qp_ RTC_GUARDED_BY(decoded_frame_section_);
};
} // namespace webrtc
#endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_TEST_H_