/work/obj-fuzz/dist/include/gmp-video-decode.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* Copyright (c) 2011, The WebRTC project authors. All rights reserved. |
3 | | * Copyright (c) 2014, Mozilla |
4 | | * |
5 | | * Redistribution and use in source and binary forms, with or without |
6 | | * modification, are permitted provided that the following conditions are |
7 | | * met: |
8 | | * |
9 | | ** Redistributions of source code must retain the above copyright |
10 | | * notice, this list of conditions and the following disclaimer. |
11 | | * |
12 | | ** Redistributions in binary form must reproduce the above copyright |
13 | | * notice, this list of conditions and the following disclaimer in |
14 | | * the documentation and/or other materials provided with the |
15 | | * distribution. |
16 | | * |
17 | | ** Neither the name of Google nor the names of its contributors may |
18 | | * be used to endorse or promote products derived from this software |
19 | | * without specific prior written permission. |
20 | | * |
21 | | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
22 | | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
23 | | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
24 | | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
25 | | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
26 | | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
27 | | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
28 | | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
29 | | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
30 | | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
31 | | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
32 | | */ |
33 | | |
34 | | #ifndef GMP_VIDEO_DECODE_h_ |
35 | | #define GMP_VIDEO_DECODE_h_ |
36 | | |
37 | | #include "gmp-errors.h" |
38 | | #include "gmp-video-frame-i420.h" |
39 | | #include "gmp-video-frame-encoded.h" |
40 | | #include "gmp-video-codec.h" |
41 | | #include <stdint.h> |
42 | | |
43 | | // ALL METHODS MUST BE CALLED ON THE MAIN THREAD |
44 | | class GMPVideoDecoderCallback |
45 | | { |
46 | | public: |
47 | 0 | virtual ~GMPVideoDecoderCallback() {} |
48 | | |
49 | | virtual void Decoded(GMPVideoi420Frame* aDecodedFrame) = 0; |
50 | | |
51 | | virtual void ReceivedDecodedReferenceFrame(const uint64_t aPictureId) = 0; |
52 | | |
53 | | virtual void ReceivedDecodedFrame(const uint64_t aPictureId) = 0; |
54 | | |
55 | | virtual void InputDataExhausted() = 0; |
56 | | |
57 | | virtual void DrainComplete() = 0; |
58 | | |
59 | | virtual void ResetComplete() = 0; |
60 | | |
61 | | // Called when the decoder encounters a catestrophic error and cannot |
62 | | // continue. Gecko will not send any more input for decoding. |
63 | | virtual void Error(GMPErr aError) = 0; |
64 | | }; |
65 | | |
66 | 0 | #define GMP_API_VIDEO_DECODER "decode-video" |
67 | | |
68 | | // Video decoding for a single stream. A GMP may be asked to create multiple |
69 | | // decoders concurrently. |
70 | | // |
71 | | // API name macro: GMP_API_VIDEO_DECODER |
72 | | // Host API: GMPVideoHost |
73 | | // |
74 | | // ALL METHODS MUST BE CALLED ON THE MAIN THREAD |
75 | | class GMPVideoDecoder |
76 | | { |
77 | | public: |
78 | 0 | virtual ~GMPVideoDecoder() {} |
79 | | |
80 | | // - aCodecSettings: Details of decoder to create. |
81 | | // - aCodecSpecific: codec specific data, cast to a GMPVideoCodecXXX struct |
82 | | // to get codec specific config data. |
83 | | // - aCodecSpecificLength: number of bytes in aCodecSpecific. |
84 | | // - aCallback: Subclass should retain reference to it until DecodingComplete |
85 | | // is called. Do not attempt to delete it, host retains ownership. |
86 | | // aCoreCount: number of CPU cores. |
87 | | virtual void InitDecode(const GMPVideoCodec& aCodecSettings, |
88 | | const uint8_t* aCodecSpecific, |
89 | | uint32_t aCodecSpecificLength, |
90 | | GMPVideoDecoderCallback* aCallback, |
91 | | int32_t aCoreCount) = 0; |
92 | | |
93 | | // Decode encoded frame (as a part of a video stream). The decoded frame |
94 | | // will be returned to the user through the decode complete callback. |
95 | | // |
96 | | // - aInputFrame: Frame to decode. Call Destroy() on frame when it's decoded. |
97 | | // - aMissingFrames: True if one or more frames have been lost since the |
98 | | // previous decode call. |
99 | | // - aCodecSpecificInfo : codec specific data, pointer to a |
100 | | // GMPCodecSpecificInfo structure appropriate for |
101 | | // this codec type. |
102 | | // - aCodecSpecificInfoLength : number of bytes in aCodecSpecificInfo |
103 | | // - renderTimeMs : System time to render in milliseconds. Only used by |
104 | | // decoders with internal rendering. |
105 | | virtual void Decode(GMPVideoEncodedFrame* aInputFrame, |
106 | | bool aMissingFrames, |
107 | | const uint8_t* aCodecSpecificInfo, |
108 | | uint32_t aCodecSpecificInfoLength, |
109 | | int64_t aRenderTimeMs = -1) = 0; |
110 | | |
111 | | // Reset decoder state and prepare for a new call to Decode(...). |
112 | | // Flushes the decoder pipeline. |
113 | | // The decoder should enqueue a task to run ResetComplete() on the main |
114 | | // thread once the reset has finished. |
115 | | virtual void Reset() = 0; |
116 | | |
117 | | // Output decoded frames for any data in the pipeline, regardless of ordering. |
118 | | // All remaining decoded frames should be immediately returned via callback. |
119 | | // The decoder should enqueue a task to run DrainComplete() on the main |
120 | | // thread once the reset has finished. |
121 | | virtual void Drain() = 0; |
122 | | |
123 | | // May free decoder memory. |
124 | | virtual void DecodingComplete() = 0; |
125 | | }; |
126 | | |
127 | | #endif // GMP_VIDEO_DECODE_h_ |