1e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent#ifndef MODULE_COMMON_TYPES_H
2e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent#define MODULE_COMMON_TYPES_H
3e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
4e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent#include <cstring> // memcpy
5e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent#include <assert.h>
6e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
7e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent#include "typedefs.h"
8e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent#include "common_types.h"
9e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
10e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent#ifdef _WIN32
11e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    #pragma warning(disable:4351)       // remove warning "new behavior: elements of array
12e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                                        // 'array' will be default initialized"
13e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent#endif
14e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
15e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentnamespace webrtc
16e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent{
17e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentstruct RTPHeader
18e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent{
19e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    bool           markerBit;
20e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8  payloadType;
21e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord16 sequenceNumber;
22e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord32 timestamp;
23e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord32 ssrc;
24e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8  numCSRCs;
25e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord32 arrOfCSRCs[kRtpCsrcSize];
26e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8  paddingLength;
27e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord16 headerLength;
28e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent};
29e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
30c55a96383497a772a307b346368133960b02ad03Eric Laurentstruct RTPHeaderExtension
31c55a96383497a772a307b346368133960b02ad03Eric Laurent{
32c55a96383497a772a307b346368133960b02ad03Eric Laurent    WebRtc_Word32  transmissionTimeOffset;
33c55a96383497a772a307b346368133960b02ad03Eric Laurent};
34c55a96383497a772a307b346368133960b02ad03Eric Laurent
35e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentstruct RTPAudioHeader
36e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent{
37e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8  numEnergy;                         // number of valid entries in arrOfEnergy
38e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8  arrOfEnergy[kRtpCsrcSize];   // one energy byte (0-9) per channel
39e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    bool           isCNG;                             // is this CNG
40e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8  channel;                           // number of channels 2 = stereo
41e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent};
42e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
43e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentstruct RTPVideoHeaderH263
44e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent{
45c55a96383497a772a307b346368133960b02ad03Eric Laurent    void InitRTPVideoHeaderH263() {};
46e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    bool independentlyDecodable;  // H.263-1998 if no P bit it's not independently decodable
47e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    bool bits;                    // H.263 mode B, Xor the lasy byte of previus packet with the
48e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                                  // first byte of this packet
49e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent};
50c55a96383497a772a307b346368133960b02ad03Eric Laurent
51e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentenum {kNoPictureId = -1};
52c55a96383497a772a307b346368133960b02ad03Eric Laurentenum {kNoTl0PicIdx = -1};
53c55a96383497a772a307b346368133960b02ad03Eric Laurentenum {kNoTemporalIdx = -1};
54c55a96383497a772a307b346368133960b02ad03Eric Laurentenum {kNoKeyIdx = -1};
55c55a96383497a772a307b346368133960b02ad03Eric Laurentenum {kNoSimulcastIdx = 0};
56c55a96383497a772a307b346368133960b02ad03Eric Laurent
57e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentstruct RTPVideoHeaderVP8
58e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent{
59c55a96383497a772a307b346368133960b02ad03Eric Laurent    void InitRTPVideoHeaderVP8()
60c55a96383497a772a307b346368133960b02ad03Eric Laurent    {
61c55a96383497a772a307b346368133960b02ad03Eric Laurent        nonReference = false;
62c55a96383497a772a307b346368133960b02ad03Eric Laurent        pictureId = kNoPictureId;
63c55a96383497a772a307b346368133960b02ad03Eric Laurent        tl0PicIdx = kNoTl0PicIdx;
64c55a96383497a772a307b346368133960b02ad03Eric Laurent        temporalIdx = kNoTemporalIdx;
65c55a96383497a772a307b346368133960b02ad03Eric Laurent        layerSync = false;
66c55a96383497a772a307b346368133960b02ad03Eric Laurent        keyIdx = kNoKeyIdx;
67c55a96383497a772a307b346368133960b02ad03Eric Laurent        partitionId = 0;
68c55a96383497a772a307b346368133960b02ad03Eric Laurent        beginningOfPartition = false;
69c55a96383497a772a307b346368133960b02ad03Eric Laurent        frameWidth = 0;
70c55a96383497a772a307b346368133960b02ad03Eric Laurent        frameHeight = 0;
71c55a96383497a772a307b346368133960b02ad03Eric Laurent    }
72c55a96383497a772a307b346368133960b02ad03Eric Laurent
73c55a96383497a772a307b346368133960b02ad03Eric Laurent    bool           nonReference;   // Frame is discardable.
74c55a96383497a772a307b346368133960b02ad03Eric Laurent    WebRtc_Word16  pictureId;      // Picture ID index, 15 bits;
75c55a96383497a772a307b346368133960b02ad03Eric Laurent                                   // kNoPictureId if PictureID does not exist.
76c55a96383497a772a307b346368133960b02ad03Eric Laurent    WebRtc_Word16  tl0PicIdx;      // TL0PIC_IDX, 8 bits;
77c55a96383497a772a307b346368133960b02ad03Eric Laurent                                   // kNoTl0PicIdx means no value provided.
78c55a96383497a772a307b346368133960b02ad03Eric Laurent    WebRtc_Word8   temporalIdx;    // Temporal layer index, or kNoTemporalIdx.
79c55a96383497a772a307b346368133960b02ad03Eric Laurent    bool           layerSync;      // This frame is a layer sync frame.
80c55a96383497a772a307b346368133960b02ad03Eric Laurent                                   // Disabled if temporalIdx == kNoTemporalIdx.
81c55a96383497a772a307b346368133960b02ad03Eric Laurent    int            keyIdx;         // 5 bits; kNoKeyIdx means not used.
82c55a96383497a772a307b346368133960b02ad03Eric Laurent    int            partitionId;    // VP8 partition ID
83c55a96383497a772a307b346368133960b02ad03Eric Laurent    bool           beginningOfPartition;  // True if this packet is the first
84c55a96383497a772a307b346368133960b02ad03Eric Laurent                                          // in a VP8 partition. Otherwise false
85c55a96383497a772a307b346368133960b02ad03Eric Laurent    int            frameWidth;     // Exists for key frames.
86c55a96383497a772a307b346368133960b02ad03Eric Laurent    int            frameHeight;    // Exists for key frames.
87e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent};
88e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentunion RTPVideoTypeHeader
89e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent{
90e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    RTPVideoHeaderH263      H263;
91e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    RTPVideoHeaderVP8       VP8;
92e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent};
93e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
94e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentenum RTPVideoCodecTypes
95e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent{
96e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    kRTPVideoGeneric  = 0,
97e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    kRTPVideoH263     = 1,
98e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    kRTPVideoMPEG4    = 5,
99e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    kRTPVideoVP8      = 8,
100e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    kRTPVideoNoVideo  = 10,
101e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    kRTPVideoFEC      = 11,
102e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    kRTPVideoI420     = 12
103e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent};
104e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentstruct RTPVideoHeader
105e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent{
106e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord16          width;                  // size
107e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord16          height;
108e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
109e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    bool                    isFirstPacket;   // first packet in frame
110c55a96383497a772a307b346368133960b02ad03Eric Laurent    WebRtc_UWord8           simulcastIdx;    // Index if the simulcast encoder creating
111c55a96383497a772a307b346368133960b02ad03Eric Laurent                                             // this frame, 0 if not using simulcast.
112e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    RTPVideoCodecTypes      codec;
113e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    RTPVideoTypeHeader      codecHeader;
114e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent};
115e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentunion RTPTypeHeader
116e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent{
117e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    RTPAudioHeader  Audio;
118e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    RTPVideoHeader  Video;
119e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent};
120e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
121e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentstruct WebRtcRTPHeader
122e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent{
123e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    RTPHeader       header;
124e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    FrameType       frameType;
125e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    RTPTypeHeader   type;
126c55a96383497a772a307b346368133960b02ad03Eric Laurent    RTPHeaderExtension extension;
127e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent};
128e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
129e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentclass RTPFragmentationHeader
130e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent{
131e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentpublic:
132e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    RTPFragmentationHeader() :
133e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        fragmentationVectorSize(0),
134e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        fragmentationOffset(NULL),
135e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        fragmentationLength(NULL),
136e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        fragmentationTimeDiff(NULL),
137e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        fragmentationPlType(NULL)
138e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    {};
139e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
140e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    ~RTPFragmentationHeader()
141e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    {
142e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        delete [] fragmentationOffset;
143e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        delete [] fragmentationLength;
144e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        delete [] fragmentationTimeDiff;
145e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        delete [] fragmentationPlType;
146e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    }
147e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
148e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    RTPFragmentationHeader& operator=(const RTPFragmentationHeader& header)
149e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    {
150e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        if(this == &header)
151e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        {
152e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            return *this;
153e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        }
154e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
155e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        if(header.fragmentationVectorSize != fragmentationVectorSize)
156e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        {
157e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            // new size of vectors
158e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
159e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            // delete old
160e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            delete [] fragmentationOffset;
161e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            fragmentationOffset = NULL;
162e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            delete [] fragmentationLength;
163e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            fragmentationLength = NULL;
164e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            delete [] fragmentationTimeDiff;
165e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            fragmentationTimeDiff = NULL;
166e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            delete [] fragmentationPlType;
167e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            fragmentationPlType = NULL;
168e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
169e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            if(header.fragmentationVectorSize > 0)
170e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            {
171e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                // allocate new
172e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                if(header.fragmentationOffset)
173e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                {
174e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                    fragmentationOffset = new WebRtc_UWord32[header.fragmentationVectorSize];
175e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                }
176e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                if(header.fragmentationLength)
177e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                {
178e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                    fragmentationLength = new WebRtc_UWord32[header.fragmentationVectorSize];
179e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                }
180e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                if(header.fragmentationTimeDiff)
181e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                {
182e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                    fragmentationTimeDiff = new WebRtc_UWord16[header.fragmentationVectorSize];
183e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                }
184e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                if(header.fragmentationPlType)
185e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                {
186e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                    fragmentationPlType = new WebRtc_UWord8[header.fragmentationVectorSize];
187e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                }
188e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            }
189e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            // set new size
190e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            fragmentationVectorSize =   header.fragmentationVectorSize;
191e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        }
192e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
193e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        if(header.fragmentationVectorSize > 0)
194e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        {
195e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            // copy values
196e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            if(header.fragmentationOffset)
197e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            {
198e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                memcpy(fragmentationOffset, header.fragmentationOffset,
199e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                        header.fragmentationVectorSize * sizeof(WebRtc_UWord32));
200e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            }
201e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            if(header.fragmentationLength)
202e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            {
203e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                memcpy(fragmentationLength, header.fragmentationLength,
204e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                        header.fragmentationVectorSize * sizeof(WebRtc_UWord32));
205e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            }
206e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            if(header.fragmentationTimeDiff)
207e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            {
208e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                memcpy(fragmentationTimeDiff, header.fragmentationTimeDiff,
209e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                        header.fragmentationVectorSize * sizeof(WebRtc_UWord16));
210e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            }
211e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            if(header.fragmentationPlType)
212e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            {
213e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                memcpy(fragmentationPlType, header.fragmentationPlType,
214e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                        header.fragmentationVectorSize * sizeof(WebRtc_UWord8));
215e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            }
216e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        }
217e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        return *this;
218e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    }
219e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    void VerifyAndAllocateFragmentationHeader( const WebRtc_UWord16 size)
220e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    {
221e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        if( fragmentationVectorSize < size)
222e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        {
223e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            WebRtc_UWord16 oldVectorSize = fragmentationVectorSize;
224e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            {
225e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                // offset
226e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                WebRtc_UWord32* oldOffsets = fragmentationOffset;
227e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                fragmentationOffset = new WebRtc_UWord32[size];
228e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                memset(fragmentationOffset+oldVectorSize, 0,
229e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                       sizeof(WebRtc_UWord32)*(size-oldVectorSize));
230e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                // copy old values
231e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                memcpy(fragmentationOffset,oldOffsets, sizeof(WebRtc_UWord32) * oldVectorSize);
232e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                delete[] oldOffsets;
233e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            }
234e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            // length
235e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            {
236e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                WebRtc_UWord32* oldLengths = fragmentationLength;
237e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                fragmentationLength = new WebRtc_UWord32[size];
238e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                memset(fragmentationLength+oldVectorSize, 0,
239e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                       sizeof(WebRtc_UWord32) * (size- oldVectorSize));
240e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                memcpy(fragmentationLength, oldLengths,
241e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                       sizeof(WebRtc_UWord32) * oldVectorSize);
242e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                delete[] oldLengths;
243e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            }
244e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            // time diff
245e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            {
246e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                WebRtc_UWord16* oldTimeDiffs = fragmentationTimeDiff;
247e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                fragmentationTimeDiff = new WebRtc_UWord16[size];
248e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                memset(fragmentationTimeDiff+oldVectorSize, 0,
249e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                       sizeof(WebRtc_UWord16) * (size- oldVectorSize));
250e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                memcpy(fragmentationTimeDiff, oldTimeDiffs,
251e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                       sizeof(WebRtc_UWord16) * oldVectorSize);
252e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                delete[] oldTimeDiffs;
253e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            }
254e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            // payload type
255e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            {
256e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                WebRtc_UWord8* oldTimePlTypes = fragmentationPlType;
257e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                fragmentationPlType = new WebRtc_UWord8[size];
258e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                memset(fragmentationPlType+oldVectorSize, 0,
259e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                       sizeof(WebRtc_UWord8) * (size- oldVectorSize));
260e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                memcpy(fragmentationPlType, oldTimePlTypes,
261e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                       sizeof(WebRtc_UWord8) * oldVectorSize);
262e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                delete[] oldTimePlTypes;
263e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            }
264e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            fragmentationVectorSize = size;
265e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        }
266e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    }
267e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
268e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord16    fragmentationVectorSize;    // Number of fragmentations
269e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord32*   fragmentationOffset;        // Offset of pointer to data for each fragm.
270e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord32*   fragmentationLength;        // Data size for each fragmentation
271e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord16*   fragmentationTimeDiff;      // Timestamp difference relative "now" for
272e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                                                  // each fragmentation
273e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8*    fragmentationPlType;        // Payload type of each fragmentation
274e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent};
275e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
276e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentstruct RTCPVoIPMetric
277e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent{
278e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    // RFC 3611 4.7
279e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8     lossRate;
280e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8     discardRate;
281e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8     burstDensity;
282e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8     gapDensity;
283e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord16    burstDuration;
284e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord16    gapDuration;
285e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord16    roundTripDelay;
286e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord16    endSystemDelay;
287e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8     signalLevel;
288e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8     noiseLevel;
289e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8     RERL;
290e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8     Gmin;
291e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8     Rfactor;
292e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8     extRfactor;
293e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8     MOSLQ;
294e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8     MOSCQ;
295e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8     RXconfig;
296e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord16    JBnominal;
297e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord16    JBmax;
298e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord16    JBabsMax;
299e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent};
300e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
301e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent// class describing a complete, or parts of an encoded frame.
302e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentclass EncodedVideoData
303e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent{
304e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentpublic:
305e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    EncodedVideoData() :
306e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        completeFrame(false),
307e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        missingFrame(false),
308e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        payloadData(NULL),
309e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        payloadSize(0),
310e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        bufferSize(0)
311e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    {};
312e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
313e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    EncodedVideoData(const EncodedVideoData& data)
314e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    {
315e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        payloadType         = data.payloadType;
316e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        timeStamp           = data.timeStamp;
317e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        renderTimeMs        = data.renderTimeMs;
318e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        encodedWidth        = data.encodedWidth;
319e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        encodedHeight       = data.encodedHeight;
320e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        completeFrame       = data.completeFrame;
321e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        missingFrame        = data.missingFrame;
322e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        payloadSize         = data.payloadSize;
323e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        fragmentationHeader = data.fragmentationHeader;
324e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        frameType           = data.frameType;
325e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        codec               = data.codec;
326e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        if (data.payloadSize > 0)
327e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        {
328e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            payloadData = new WebRtc_UWord8[data.payloadSize];
329e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            memcpy(payloadData, data.payloadData, data.payloadSize);
330e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        }
331e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        else
332e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        {
333e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            payloadData = NULL;
334e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        }
335e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    }
336e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
337e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
338e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    ~EncodedVideoData()
339e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    {
340e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        delete [] payloadData;
341e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    };
342e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
343e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    EncodedVideoData& operator=(const EncodedVideoData& data)
344e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    {
345e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        if (this == &data)
346e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        {
347e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            return *this;
348e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        }
349e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        payloadType         = data.payloadType;
350e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        timeStamp           = data.timeStamp;
351e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        renderTimeMs        = data.renderTimeMs;
352e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        encodedWidth        = data.encodedWidth;
353e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        encodedHeight       = data.encodedHeight;
354e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        completeFrame       = data.completeFrame;
355e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        missingFrame        = data.missingFrame;
356e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        payloadSize         = data.payloadSize;
357e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        fragmentationHeader = data.fragmentationHeader;
358e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        frameType           = data.frameType;
359e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        codec               = data.codec;
360e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        if (data.payloadSize > 0)
361e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        {
362e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            delete [] payloadData;
363e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            payloadData = new WebRtc_UWord8[data.payloadSize];
364e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            memcpy(payloadData, data.payloadData, data.payloadSize);
365e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            bufferSize = data.payloadSize;
366e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        }
367e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        return *this;
368e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    };
369e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    void VerifyAndAllocate( const WebRtc_UWord32 size)
370e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    {
371e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        if (bufferSize < size)
372e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        {
373e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            WebRtc_UWord8* oldPayload = payloadData;
374e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            payloadData = new WebRtc_UWord8[size];
375e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            memcpy(payloadData, oldPayload, sizeof(WebRtc_UWord8) * payloadSize);
376e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
377e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            bufferSize = size;
378e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            delete[] oldPayload;
379e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent        }
380e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    }
381e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
382e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8               payloadType;
383e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord32              timeStamp;
384e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_Word64               renderTimeMs;
385e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord32              encodedWidth;
386e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord32              encodedHeight;
387e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    bool                        completeFrame;
388e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    bool                        missingFrame;
389e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord8*              payloadData;
390e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord32              payloadSize;
391e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord32              bufferSize;
392e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    RTPFragmentationHeader      fragmentationHeader;
393e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    FrameType                   frameType;
394e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    VideoCodecType              codec;
395e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent};
396e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
397e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent// Video Content Metrics
398e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentstruct VideoContentMetrics
399e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent{
400e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    VideoContentMetrics(): motionMagnitudeNZ(0), sizeZeroMotion(0), spatialPredErr(0),
401c55a96383497a772a307b346368133960b02ad03Eric Laurent            spatialPredErrH(0), spatialPredErrV(0), motionPredErr(0),
402e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            motionHorizontalness(0), motionClusterDistortion(0),
403e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            nativeWidth(0), nativeHeight(0), contentChange(false) {   }
404e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    void Reset(){ motionMagnitudeNZ = 0; sizeZeroMotion = 0; spatialPredErr = 0;
405c55a96383497a772a307b346368133960b02ad03Eric Laurent            spatialPredErrH = 0; spatialPredErrV = 0; motionPredErr = 0;
406e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            motionHorizontalness = 0; motionClusterDistortion = 0;
407e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent            nativeWidth = 0; nativeHeight = 0; contentChange = false; }
408e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
409e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    float            motionMagnitudeNZ;
410e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    float            sizeZeroMotion;
411e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    float            spatialPredErr;
412e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    float            spatialPredErrH;
413e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    float            spatialPredErrV;
414e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    float            motionPredErr;
415e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    float            motionHorizontalness;
416e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    float            motionClusterDistortion;
417e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord32   nativeWidth;
418e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord32   nativeHeight;
419e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_UWord32   nativeFrameRate;
420e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    bool             contentChange;
421e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent};
422e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent
423e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent/*************************************************
424e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent *
425e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent * VideoFrame class
426e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent *
427e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent * The VideoFrame class allows storing and
428e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent * handling of video frames.
429e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent *
430e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent *
431e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent *************************************************/
432e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentclass VideoFrame
433e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent{
434e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurentpublic:
435e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    VideoFrame();
436e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    ~VideoFrame();
437e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    /**
438e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    * Verifies that current allocated buffer size is larger than or equal to the input size.
439e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    * If the current buffer size is smaller, a new allocation is made and the old buffer data
440e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    * is copied to the new buffer.
441e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    * Buffer size is updated to minimumSize.
442e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    */
443e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_Word32 VerifyAndAllocate(const WebRtc_UWord32 minimumSize);
444e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    /**
445e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    *    Update length of data buffer in frame. Function verifies that new length is less or
446e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    *    equal to allocated size.
447e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    */
448e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_Word32 SetLength(const WebRtc_UWord32 newLength);
449e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    /*
450e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    *    Swap buffer and size data
451e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    */
452e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent    WebRtc_Word32 Swap(WebRtc_UWord8*& newMemory,
453e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                       WebRtc_UWord32& newLength,
454e48d5845c8b35de2ab73ea055c18a61fa3a9f0beEric Laurent                       WebRtc_UWord32& newSize);
455