Note: We no longer publish the latest version of our code here. We primarily use a kumc-bmi github organization. The heron ETL repository, in particular, is not public. Peers in the informatics community should see MultiSiteDev for details on requesting access.

source: webrtc/webrtc/modules/video_coding/main/source/generic_decoder.h @ 0:4bda6873e34c

pub_scrub_3792 tip
Last change on this file since 0:4bda6873e34c was 0:4bda6873e34c, checked in by Michael Prittie <mprittie@…>, 6 years ago

Scrubbed password for publication.

File size: 3.7 KB
Line 
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_GENERIC_DECODER_H_
12#define WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_
13
14#include "webrtc/modules/interface/module_common_types.h"
15#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h"
16#include "webrtc/modules/video_coding/main/source/encoded_frame.h"
17#include "webrtc/modules/video_coding/main/source/timestamp_map.h"
18#include "webrtc/modules/video_coding/main/source/timing.h"
19
20namespace webrtc
21{
22
23class VCMReceiveCallback;
24
25enum { kDecoderFrameMemoryLength = 10 };
26
27struct VCMFrameInformation
28{
29    int64_t     renderTimeMs;
30    int64_t     decodeStartTimeMs;
31    void*             userData;
32};
33
34class VCMDecodedFrameCallback : public DecodedImageCallback
35{
36public:
37    VCMDecodedFrameCallback(VCMTiming& timing, Clock* clock);
38    virtual ~VCMDecodedFrameCallback();
39    void SetUserReceiveCallback(VCMReceiveCallback* receiveCallback);
40    VCMReceiveCallback* UserReceiveCallback();
41
42    virtual int32_t Decoded(I420VideoFrame& decodedImage);
43    virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId);
44    virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId);
45
46    uint64_t LastReceivedPictureID() const;
47
48    int32_t Map(uint32_t timestamp, VCMFrameInformation* frameInfo);
49    int32_t Pop(uint32_t timestamp);
50
51private:
52    // Protect |_receiveCallback| and |_timestampMap|.
53    CriticalSectionWrapper* _critSect;
54    Clock* _clock;
55    VCMReceiveCallback* _receiveCallback;  // Guarded by |_critSect|.
56    VCMTiming& _timing;
57    VCMTimestampMap _timestampMap;  // Guarded by |_critSect|.
58    uint64_t _lastReceivedPictureID;
59};
60
61
62class VCMGenericDecoder
63{
64    friend class VCMCodecDataBase;
65public:
66    VCMGenericDecoder(VideoDecoder& decoder, int32_t id = 0, bool isExternal = false);
67    ~VCMGenericDecoder();
68
69    /**
70    *   Initialize the decoder with the information from the VideoCodec
71    */
72    int32_t InitDecode(const VideoCodec* settings,
73                             int32_t numberOfCores);
74
75    /**
76    *   Decode to a raw I420 frame,
77    *
78    *   inputVideoBuffer        reference to encoded video frame
79    */
80    int32_t Decode(const VCMEncodedFrame& inputFrame, int64_t nowMs);
81
82    /**
83    *   Free the decoder memory
84    */
85    int32_t Release();
86
87    /**
88    *   Reset the decoder state, prepare for a new call
89    */
90    int32_t Reset();
91
92    /**
93    *   Codec configuration data sent out-of-band, i.e. in SIP call setup
94    *
95    *   buffer pointer to the configuration data
96    *   size the size of the configuration data in bytes
97    */
98    int32_t SetCodecConfigParameters(const uint8_t* /*buffer*/,
99                                           int32_t /*size*/);
100
101    /**
102    * Set decode callback. Deregistering while decoding is illegal.
103    */
104    int32_t RegisterDecodeCompleteCallback(VCMDecodedFrameCallback* callback);
105
106    bool External() const;
107
108protected:
109
110    int32_t               _id;
111    VCMDecodedFrameCallback*    _callback;
112    VCMFrameInformation         _frameInfos[kDecoderFrameMemoryLength];
113    uint32_t              _nextFrameInfoIdx;
114    VideoDecoder&               _decoder;
115    VideoCodecType              _codecType;
116    bool                        _isExternal;
117    bool                        _keyFrameDecoded;
118
119};
120
121}  // namespace webrtc
122
123#endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_
Note: See TracBrowser for help on using the repository browser.