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_PLANE_h_
35 : #define GMP_VIDEO_PLANE_h_
36 :
37 : #include "gmp-errors.h"
38 : #include <stdint.h>
39 :
40 : // The implementation backing this interface uses shared memory for the
41 : // buffer(s). This means it can only be used by the "owning" process.
42 : // At first the process which created the object owns it. When the object
43 : // is passed to an interface the creator loses ownership and must Destroy()
44 : // the object. Further attempts to use it may fail due to not being able to
45 : // access the underlying buffer(s).
46 : //
47 : // Methods that create or destroy shared memory must be called on the main
48 : // thread. They are marked below.
49 0 : class GMPPlane {
50 : public:
51 : // MAIN THREAD ONLY
52 : // CreateEmptyPlane - set allocated size, actual plane size and stride:
53 : // If current size is smaller than current size, then a buffer of sufficient
54 : // size will be allocated.
55 : virtual GMPErr CreateEmptyPlane(int32_t aAllocatedSize,
56 : int32_t aStride,
57 : int32_t aPlaneSize) = 0;
58 :
59 : // MAIN THREAD ONLY
60 : // Copy the entire plane data.
61 : virtual GMPErr Copy(const GMPPlane& aPlane) = 0;
62 :
63 : // MAIN THREAD ONLY
64 : // Copy buffer: If current size is smaller
65 : // than current size, then a buffer of sufficient size will be allocated.
66 : virtual GMPErr Copy(int32_t aSize, int32_t aStride, const uint8_t* aBuffer) = 0;
67 :
68 : // Swap plane data.
69 : virtual void Swap(GMPPlane& aPlane) = 0;
70 :
71 : // Get allocated size.
72 : virtual int32_t AllocatedSize() const = 0;
73 :
74 : // Set actual size.
75 : virtual void ResetSize() = 0;
76 :
77 : // Return true is plane size is zero, false if not.
78 : virtual bool IsZeroSize() const = 0;
79 :
80 : // Get stride value.
81 : virtual int32_t Stride() const = 0;
82 :
83 : // Return data pointer.
84 : virtual const uint8_t* Buffer() const = 0;
85 :
86 : // Overloading with non-const.
87 : virtual uint8_t* Buffer() = 0;
88 :
89 : // MAIN THREAD ONLY IF OWNING PROCESS
90 : // Call this when done with the object. This may delete it.
91 : virtual void Destroy() = 0;
92 : };
93 :
94 : #endif // GMP_VIDEO_PLANE_h_
|