1/*
2 *  Copyright (c) 2012 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_TEST_GENERIC_CODEC_TEST_H_
12#define WEBRTC_MODULES_VIDEO_CODING_TEST_GENERIC_CODEC_TEST_H_
13
14#include "webrtc/modules/video_coding/main/interface/video_coding.h"
15
16#include <fstream>
17#include <string.h>
18
19#include "webrtc/modules/video_coding/main/test/test_callbacks.h"
20#include "webrtc/modules/video_coding/main/test/test_util.h"
21/*
22Test consists of:
231. Sanity checks
242. Bit rate validation
253. Encoder control test / General API functionality
264. Decoder control test / General API functionality
27
28*/
29
30namespace webrtc {
31
32int VCMGenericCodecTest(CmdArgs& args);
33
34class SimulatedClock;
35
36class GenericCodecTest
37{
38public:
39    GenericCodecTest(webrtc::VideoCodingModule* vcm,
40                     webrtc::SimulatedClock* clock);
41    ~GenericCodecTest();
42    static int RunTest(CmdArgs& args);
43    int32_t Perform(CmdArgs& args);
44    float WaitForEncodedFrame() const;
45
46private:
47    void Setup(CmdArgs& args);
48    void Print();
49    int32_t TearDown();
50    void IncrementDebugClock(float frameRate);
51
52    webrtc::SimulatedClock*              _clock;
53    webrtc::VideoCodingModule*           _vcm;
54    webrtc::VideoCodec                   _sendCodec;
55    webrtc::VideoCodec                   _receiveCodec;
56    std::string                          _inname;
57    std::string                          _outname;
58    std::string                          _encodedName;
59    int32_t                        _sumEncBytes;
60    FILE*                                _sourceFile;
61    FILE*                                _decodedFile;
62    FILE*                                _encodedFile;
63    uint16_t                       _width;
64    uint16_t                       _height;
65    float                                _frameRate;
66    uint32_t                       _lengthSourceFrame;
67    uint32_t                       _timeStamp;
68    VCMDecodeCompleteCallback*           _decodeCallback;
69    VCMEncodeCompleteCallback*           _encodeCompleteCallback;
70
71}; // end of GenericCodecTest class definition
72
73class RTPSendCallback_SizeTest : public webrtc::Transport
74{
75public:
76    // constructor input: (receive side) rtp module to send encoded data to
77    RTPSendCallback_SizeTest() : _maxPayloadSize(0), _payloadSizeSum(0), _nPackets(0) {}
78    virtual int SendPacket(int channel, const void *data, int len);
79    virtual int SendRTCPPacket(int channel, const void *data, int len) {return 0;}
80    void SetMaxPayloadSize(uint32_t maxPayloadSize);
81    void Reset();
82    float AveragePayloadSize() const;
83private:
84    uint32_t         _maxPayloadSize;
85    uint32_t         _payloadSizeSum;
86    uint32_t         _nPackets;
87};
88
89class VCMEncComplete_KeyReqTest : public webrtc::VCMPacketizationCallback
90{
91public:
92    VCMEncComplete_KeyReqTest(webrtc::VideoCodingModule &vcm) : _vcm(vcm), _seqNo(0), _timeStamp(0) {}
93    int32_t SendData(
94            const webrtc::FrameType frameType,
95            const uint8_t payloadType,
96            uint32_t timeStamp,
97            int64_t capture_time_ms,
98            const uint8_t* payloadData,
99            const uint32_t payloadSize,
100            const webrtc::RTPFragmentationHeader& fragmentationHeader,
101            const webrtc::RTPVideoHeader* videoHdr);
102private:
103    webrtc::VideoCodingModule& _vcm;
104    uint16_t _seqNo;
105    uint32_t _timeStamp;
106}; // end of VCMEncodeCompleteCallback
107
108}  // namespace webrtc
109
110#endif // WEBRTC_MODULES_VIDEO_CODING_TEST_GENERIC_CODEC_TEST_H_
111