2 * Copyright (C) 2020 Seungha Yang <seungha@centricular.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #ifndef __GST_MF_VIDEO_BUFFER_H__
21 #define __GST_MF_VIDEO_BUFFER_H__
24 #include <gst/video/video.h>
26 #include <mfobjects.h>
31 #error IGstMFVideoBuffer interface doesn't provide C API
34 /* Define UUID for QueryInterface() */
35 class DECLSPEC_UUID("ce922806-a8a6-4e1e-871f-e0cdd5fc9899")
36 IGstMFVideoBuffer : public IMFMediaBuffer, public IMF2DBuffer
39 static HRESULT CreateInstance (GstVideoInfo * info,
40 IMFMediaBuffer ** buffer);
42 static HRESULT CreateInstanceWrapped (GstVideoInfo * info,
45 IMFMediaBuffer ** buffer);
47 /* notify will be called right after this object is destroyed */
48 HRESULT SetUserData (gpointer user_data,
49 GDestroyNotify notify);
51 HRESULT GetUserData (gpointer * user_data);
53 /* IUnknown interface */
54 STDMETHODIMP_ (ULONG) AddRef (void);
55 STDMETHODIMP_ (ULONG) Release (void);
56 STDMETHODIMP QueryInterface (REFIID riid,
59 /* IMFMediaBuffer interface
61 * Caller of this interface expects returned raw memory layout via Lock()
62 * has no padding with default stride. If stored memory layout consists of
63 * non-default stride and/or with some padding, then Lock() / Unlock() would
64 * cause memory copy therefore.
65 * Caller should avoid to use this interface as much as possible
66 * if IMF2DBuffer interface available.
68 STDMETHODIMP Lock (BYTE ** buffer,
70 DWORD * current_length);
71 STDMETHODIMP Unlock (void);
72 STDMETHODIMP GetCurrentLength (DWORD * length);
73 STDMETHODIMP SetCurrentLength (DWORD length);
74 STDMETHODIMP GetMaxLength (DWORD * length);
76 /* IMF2DBuffer interface
78 * this interface supports any raw memory layout with non-default stride.
79 * But more complex layout (padding at bottom for instance) is not supported.
81 STDMETHODIMP Lock2D (BYTE ** buffer,
83 STDMETHODIMP Unlock2D (void);
84 STDMETHODIMP GetScanline0AndPitch (BYTE ** buffer,
86 STDMETHODIMP IsContiguousFormat (BOOL * contiguous);
87 STDMETHODIMP GetContiguousLength (DWORD * length);
88 STDMETHODIMP ContiguousCopyTo (BYTE * dest_buffer,
89 DWORD dest_buffer_length);
90 STDMETHODIMP ContiguousCopyFrom (const BYTE * src_buffer,
91 DWORD src_buffer_length);
94 IGstMFVideoBuffer (void);
95 ~IGstMFVideoBuffer (void);
97 HRESULT Initialize (GstVideoInfo * info);
98 HRESULT InitializeWrapped (GstVideoInfo * info,
105 DWORD contiguous_len_;
107 BYTE *contiguous_data_;
109 GstVideoInfo *contiguous_info_;
116 GDestroyNotify notify_;
119 #endif /* __GST_MF_VIDEO_BUFFER_H__ */