2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_FRAMEWORK_NORMAL_ASYNC_TEST_H_
12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_FRAMEWORK_NORMAL_ASYNC_TEST_H_
14 #include "webrtc/common_types.h"
19 #include "webrtc/modules/video_coding/codecs/test_framework/normal_test.h"
20 #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
25 FrameQueueTuple(webrtc::VideoFrame *frame,
26 const webrtc::CodecSpecificInfo* codecSpecificInfo = NULL)
29 _codecSpecificInfo(codecSpecificInfo)
32 webrtc::VideoFrame* _frame;
33 const webrtc::CodecSpecificInfo* _codecSpecificInfo;
41 _queueRWLock(*webrtc::RWLockWrapper::CreateRWLock())
50 void PushFrame(webrtc::VideoFrame *frame,
51 webrtc::CodecSpecificInfo* codecSpecificInfo = NULL);
52 FrameQueueTuple* PopFrame();
56 webrtc::RWLockWrapper& _queueRWLock;
57 std::queue<FrameQueueTuple *> _frameBufferQueue;
60 // feedback signal to encoder
63 fbSignal(int d, uint8_t pid) : delay(d), id(pid) {};
68 class NormalAsyncTest : public NormalTest
72 NormalAsyncTest(uint32_t bitRate);
73 NormalAsyncTest(std::string name, std::string description,
75 NormalAsyncTest(std::string name, std::string description,
76 uint32_t bitRate, unsigned int testNo);
77 NormalAsyncTest(std::string name, std::string description,
78 uint32_t bitRate, unsigned int testNo,
79 unsigned int rttFrames);
80 virtual ~NormalAsyncTest() {};
81 virtual void Perform();
82 virtual void Encoded(const webrtc::EncodedImage& encodedImage);
83 virtual void Decoded(const webrtc::I420VideoFrame& decodedImage);
84 virtual webrtc::CodecSpecificInfo*
85 CopyCodecSpecificInfo(
86 const webrtc::CodecSpecificInfo* codecSpecificInfo) const;
87 virtual void CopyEncodedImage(webrtc::VideoFrame& dest,
88 webrtc::EncodedImage& src,
89 void* /*codecSpecificInfo*/) const;
90 virtual webrtc::CodecSpecificInfo* CreateEncoderSpecificInfo() const
94 virtual int32_t ReceivedDecodedReferenceFrame(
95 const uint64_t pictureId);
96 virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId);
100 virtual void Teardown();
101 virtual bool Encode();
102 virtual int Decode(int lossValue = 0);
103 virtual void CodecSpecific_InitBitrate();
104 virtual int SetCodecSpecificParameters() {return 0;};
105 double tGetTime();// return time in sec
109 uint32_t _decodedWidth;
110 uint32_t _decodedHeight;
111 double _totalEncodeTime;
112 double _totalDecodeTime;
113 double _decodeCompleteTime;
114 double _encodeCompleteTime;
115 double _totalEncodePipeTime;
116 double _totalDecodePipeTime;
120 bool _requestKeyFrame;
121 unsigned int _lengthEncFrame;
122 FrameQueueTuple* _frameToDecode;
124 std::map<uint32_t, double> _encodeTimes;
125 std::map<uint32_t, double> _decodeTimes;
127 std::list<fbSignal> _signalSLI;
129 mutable bool _hasReceivedSLI;
130 mutable bool _hasReceivedRPSI;
131 uint8_t _pictureIdSLI;
132 uint16_t _pictureIdRPSI;
133 uint64_t _lastDecRefPictureId;
134 uint64_t _lastDecPictureId;
135 std::list<fbSignal> _signalPLI;
136 bool _hasReceivedPLI;
140 class VideoEncodeCompleteCallback : public webrtc::EncodedImageCallback
143 VideoEncodeCompleteCallback(FILE* encodedFile, FrameQueue *frameQueue,
144 NormalAsyncTest& test)
146 _encodedFile(encodedFile),
147 _frameQueue(frameQueue),
153 Encoded(webrtc::EncodedImage& encodedImage,
154 const webrtc::CodecSpecificInfo* codecSpecificInfo = NULL,
155 const webrtc::RTPFragmentationHeader* fragmentation = NULL);
156 uint32_t EncodedBytes();
159 FrameQueue* _frameQueue;
160 NormalAsyncTest& _test;
161 uint32_t _encodedBytes;
164 class VideoDecodeCompleteCallback : public webrtc::DecodedImageCallback
167 VideoDecodeCompleteCallback(FILE* decodedFile, NormalAsyncTest& test)
169 _decodedFile(decodedFile),
174 virtual int32_t Decoded(webrtc::I420VideoFrame& decodedImage);
176 ReceivedDecodedReferenceFrame(const uint64_t pictureId);
177 virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId);
179 uint32_t DecodedBytes();
182 NormalAsyncTest& _test;
183 uint32_t _decodedBytes;
186 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_FRAMEWORK_NORMAL_ASYNC_TEST_H_