Line data Source code
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_FRAME_ENCODED_h_
35 : #define GMP_VIDEO_FRAME_ENCODED_h_
36 :
37 : #include <stdint.h>
38 : #include "gmp-decryption.h"
39 : #include "gmp-video-frame.h"
40 : #include "gmp-video-codec.h"
41 :
42 : enum GMPVideoFrameType
43 : {
44 : kGMPKeyFrame = 0,
45 : kGMPDeltaFrame = 1,
46 : kGMPGoldenFrame = 2,
47 : kGMPAltRefFrame = 3,
48 : kGMPSkipFrame = 4,
49 : kGMPVideoFrameInvalid = 5 // Must always be last.
50 : };
51 :
52 : // The implementation backing this interface uses shared memory for the
53 : // buffer(s). This means it can only be used by the "owning" process.
54 : // At first the process which created the object owns it. When the object
55 : // is passed to an interface the creator loses ownership and must Destroy()
56 : // the object. Further attempts to use it may fail due to not being able to
57 : // access the underlying buffer(s).
58 : //
59 : // Methods that create or destroy shared memory must be called on the main
60 : // thread. They are marked below.
61 0 : class GMPVideoEncodedFrame : public GMPVideoFrame
62 : {
63 : public:
64 : // MAIN THREAD ONLY
65 : virtual GMPErr CreateEmptyFrame(uint32_t aSize) = 0;
66 : // MAIN THREAD ONLY
67 : virtual GMPErr CopyFrame(const GMPVideoEncodedFrame& aVideoFrame) = 0;
68 : virtual void SetEncodedWidth(uint32_t aEncodedWidth) = 0;
69 : virtual uint32_t EncodedWidth() = 0;
70 : virtual void SetEncodedHeight(uint32_t aEncodedHeight) = 0;
71 : virtual uint32_t EncodedHeight() = 0;
72 : // Microseconds
73 : virtual void SetTimeStamp(uint64_t aTimeStamp) = 0;
74 : virtual uint64_t TimeStamp() = 0;
75 : // Set frame duration (microseconds)
76 : // NOTE: next-frame's Timestamp() != this-frame's TimeStamp()+Duration()
77 : // depending on rounding to avoid having to track roundoff errors
78 : // and dropped/missing frames(!) (which may leave a large gap)
79 : virtual void SetDuration(uint64_t aDuration) = 0;
80 : virtual uint64_t Duration() const = 0;
81 : virtual void SetFrameType(GMPVideoFrameType aFrameType) = 0;
82 : virtual GMPVideoFrameType FrameType() = 0;
83 : virtual void SetAllocatedSize(uint32_t aNewSize) = 0;
84 : virtual uint32_t AllocatedSize() = 0;
85 : virtual void SetSize(uint32_t aSize) = 0;
86 : virtual uint32_t Size() = 0;
87 : virtual void SetCompleteFrame(bool aCompleteFrame) = 0;
88 : virtual bool CompleteFrame() = 0;
89 : virtual const uint8_t* Buffer() const = 0;
90 : virtual uint8_t* Buffer() = 0;
91 : virtual GMPBufferType BufferType() const = 0;
92 : virtual void SetBufferType(GMPBufferType aBufferType) = 0;
93 :
94 : // Get metadata describing how this frame is encrypted, or nullptr if the
95 : // frame is not encrypted.
96 : virtual const GMPEncryptedBufferMetadata* GetDecryptionData() const = 0;
97 : };
98 :
99 : #endif // GMP_VIDEO_FRAME_ENCODED_h_
|