summaryrefslogtreecommitdiff
path: root/video_engine/test/libvietest/include/tb_I420_codec.h
blob: 2125def4b0465a37d21c1f417f87d9dccb056861 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
 *  Copyright (c) 2012 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.
 */

/*
 * This file contains the interface to I420 "codec"
 * This is a dummy wrapper to allow VCM deal with raw I420 sequences
 */

#ifndef WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_I420_CODEC_H_
#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_I420_CODEC_H_

#include "modules/video_coding/codecs/interface/video_codec_interface.h"

class TbI420Encoder: public webrtc::VideoEncoder
{
public:
    TbI420Encoder();
    virtual ~TbI420Encoder();

    static WebRtc_Word32 VersionStatic(char* version,
                                       WebRtc_Word32 length);
    virtual WebRtc_Word32  Version(char* version,
                                   WebRtc_Word32 length) const;

    virtual WebRtc_Word32 InitEncode(const webrtc::VideoCodec* codecSettings,
                                     WebRtc_Word32 numberOfCores,
                                     WebRtc_UWord32 maxPayloadSize);

    virtual WebRtc_Word32 Encode(
        const webrtc::I420VideoFrame& inputImage,
        const webrtc::CodecSpecificInfo* codecSpecificInfo,
        const std::vector<webrtc::VideoFrameType>* frameTypes);

    virtual WebRtc_Word32 RegisterEncodeCompleteCallback(
        webrtc::EncodedImageCallback* callback);

    virtual WebRtc_Word32 Release();

    virtual WebRtc_Word32 Reset();

    virtual WebRtc_Word32 SetChannelParameters(WebRtc_UWord32 packetLoss,
                                               int rtt);

    virtual WebRtc_Word32 SetRates(WebRtc_UWord32 newBitRate,
                                   WebRtc_UWord32 frameRate);

    virtual WebRtc_Word32 SetPeriodicKeyFrames(bool enable);

    virtual WebRtc_Word32 CodecConfigParameters(WebRtc_UWord8* /*buffer*/,
                                                WebRtc_Word32 /*size*/);

    struct FunctionCalls
    {
        WebRtc_Word32 InitEncode;
        WebRtc_Word32 Encode;
        WebRtc_Word32 RegisterEncodeCompleteCallback;
        WebRtc_Word32 Release;
        WebRtc_Word32 Reset;
        WebRtc_Word32 SetChannelParameters;
        WebRtc_Word32 SetRates;
        WebRtc_Word32 SetPeriodicKeyFrames;
        WebRtc_Word32 CodecConfigParameters;

    };

    FunctionCalls GetFunctionCalls();
private:
    bool _inited;
    webrtc::EncodedImage _encodedImage;
    FunctionCalls _functionCalls;
    webrtc::EncodedImageCallback* _encodedCompleteCallback;

}; // end of tbI420Encoder class


/***************************/
/* tbI420Decoder class */
/***************************/

class TbI420Decoder: public webrtc::VideoDecoder
{
public:
    TbI420Decoder();
    virtual ~TbI420Decoder();

    virtual WebRtc_Word32 InitDecode(const webrtc::VideoCodec* inst,
                                     WebRtc_Word32 numberOfCores);
    virtual WebRtc_Word32 Decode(
        const webrtc::EncodedImage& inputImage,
        bool missingFrames,
        const webrtc::RTPFragmentationHeader* fragmentation,
        const webrtc::CodecSpecificInfo* codecSpecificInfo = NULL,
        WebRtc_Word64 renderTimeMs = -1);

    virtual WebRtc_Word32
        RegisterDecodeCompleteCallback(webrtc::DecodedImageCallback* callback);
    virtual WebRtc_Word32 Release();
    virtual WebRtc_Word32 Reset();

    struct FunctionCalls
    {
        WebRtc_Word32 InitDecode;
        WebRtc_Word32 Decode;
        WebRtc_Word32 RegisterDecodeCompleteCallback;
        WebRtc_Word32 Release;
        WebRtc_Word32 Reset;
    };

    FunctionCalls GetFunctionCalls();

private:

    webrtc::I420VideoFrame _decodedImage;
    WebRtc_Word32 _width;
    WebRtc_Word32 _height;
    bool _inited;
    FunctionCalls _functionCalls;
    webrtc::DecodedImageCallback* _decodeCompleteCallback;

}; // end of tbI420Decoder class

#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_I420_CODEC_H_