blob: 01b348d2471f2ada575ca1ae55fdc4a721f9da87 [file] [log] [blame]
* Copyright (c) 2011 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.
#include "test.h"
#include "event_wrapper.h"
// Disable "conditional expression is constant" warnings on the perfectly
// acceptable
// do { ... } while (0) constructions below.
// Refer to
// is-there-better-way-to-write-do-while0-construct-to-avoid-compiler-warnings
// for some discussion of the issue.
#ifdef _WIN32
#pragma warning(disable : 4127)
class VideoSource;
class UnitTestEncodeCompleteCallback;
class UnitTestDecodeCompleteCallback;
class UnitTest : public Test
virtual ~UnitTest();
virtual void Perform();
virtual void Print();
UnitTest(std::string name, std::string description);
virtual WebRtc_UWord32 CodecSpecific_SetBitrate(
WebRtc_UWord32 bitRate,
WebRtc_UWord32 /* frameRate */);
virtual void Setup();
virtual void Teardown();
virtual void RateControlTests();
virtual int Decode();
virtual int DecodeWithoutAssert();
virtual int SetCodecSpecificParameters() {return 0;};
virtual bool CheckIfBitExact(const void *ptrA, unsigned int aLengthBytes,
const void *ptrB, unsigned int bLengthBytes);
WebRtc_UWord32 WaitForEncodedFrame() const;
WebRtc_UWord32 WaitForDecodedFrame() const;
int _tests;
int _errors;
VideoSource* _source;
unsigned char* _refFrame;
unsigned char* _refEncFrame;
unsigned char* _refDecFrame;
int _refEncFrameLength;
FILE* _sourceFile;
UnitTestEncodeCompleteCallback* _encodeCompleteCallback;
UnitTestDecodeCompleteCallback* _decodeCompleteCallback;
enum { kMaxWaitEncTimeMs = 100 };
enum { kMaxWaitDecTimeMs = 25 };
class UnitTestEncodeCompleteCallback : public webrtc::EncodedImageCallback
UnitTestEncodeCompleteCallback(TestVideoEncodedBuffer* buffer,
WebRtc_UWord32 decoderSpecificSize = 0,
void* decoderSpecificInfo = NULL) :
_encodeComplete(false) {}
WebRtc_Word32 Encoded(webrtc::EncodedImage& encodedImage,
const webrtc::CodecSpecificInfo* codecSpecificInfo,
const webrtc::RTPFragmentationHeader*
fragmentation = NULL);
bool EncodeComplete();
// Note that this only makes sense if an encode has been completed
webrtc::VideoFrameType EncodedFrameType() const;
TestVideoEncodedBuffer* _encodedVideoBuffer;
void* _decoderSpecificInfo;
WebRtc_UWord32 _decoderSpecificSize;
bool _encodeComplete;
webrtc::VideoFrameType _encodedFrameType;
class UnitTestDecodeCompleteCallback : public webrtc::DecodedImageCallback
UnitTestDecodeCompleteCallback(TestVideoBuffer* buffer) :
_decodedVideoBuffer(buffer), _decodeComplete(false) {}
WebRtc_Word32 Decoded(webrtc::RawImage& image);
bool DecodeComplete();
TestVideoBuffer* _decodedVideoBuffer;
bool _decodeComplete;