• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) 2020 Seungha Yang <seungha.yang@navercorp.com>
3  * Copyright (C) 2020 Seungha Yang <seungha@centricular.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef __GST_MF_TRANSFORM_OBJECT_H__
22 #define __GST_MF_TRANSFORM_OBJECT_H__
23 
24 #include <gst/gst.h>
25 #include "gstmfutils.h"
26 #include <codecapi.h>
27 #include "gststrmif.h"
28 
29 G_BEGIN_DECLS
30 
31 #define GST_TYPE_MF_TRANSFORM_OBJECT  (gst_mf_transform_get_type())
32 G_DECLARE_FINAL_TYPE (GstMFTransform, gst_mf_transform,
33     GST, MF_TRANSFORM, GstObject);
34 
35 #define GST_MF_TRANSFORM_FLOW_NEED_DATA GST_FLOW_CUSTOM_SUCCESS
36 
37 /* NOTE: This GUID is defined in mfapi.h header but it's available only for
38  * at least Windows 10 RS1. So defining the GUID here again so that
39  * make use even if build target (e.g., WINVER) wasn't for Windows 10 */
40 DEFINE_GUID(GST_GUID_MFT_ENUM_ADAPTER_LUID,
41     0x1d39518c, 0xe220, 0x4da8, 0xa0, 0x7f, 0xba, 0x17, 0x25, 0x52, 0xd6, 0xb1);
42 
43 /* below GUIDs are defined in mftransform.h for Windows 8 or greater
44  * FIXME: remove below defines when we bump minimum supported OS version to
45  * Windows 10 */
46 DEFINE_GUID(GST_GUID_MF_SA_D3D11_AWARE,
47     0x206b4fc8, 0xfcf9, 0x4c51, 0xaf, 0xe3, 0x97, 0x64, 0x36, 0x9e, 0x33, 0xa0);
48 DEFINE_GUID(GST_GUID_MF_SA_BUFFERS_PER_SAMPLE,
49     0x873c5171, 0x1e3d, 0x4e25, 0x98, 0x8d, 0xb4, 0x33, 0xce, 0x04, 0x19, 0x83);
50 DEFINE_GUID(GST_GUID_MF_SA_D3D11_USAGE,
51     0xe85fe442, 0x2ca3, 0x486e, 0xa9, 0xc7, 0x10, 0x9d, 0xda, 0x60, 0x98, 0x80);
52 DEFINE_GUID(GST_GUID_MF_SA_D3D11_SHARED_WITHOUT_MUTEX,
53     0x39dbd44d, 0x2e44, 0x4931, 0xa4, 0xc8, 0x35, 0x2d, 0x3d, 0xc4, 0x21, 0x15);
54 DEFINE_GUID(GST_GUID_MF_SA_D3D11_BINDFLAGS,
55     0xeacf97ad, 0x065c, 0x4408, 0xbe, 0xe3, 0xfd, 0xcb, 0xfd, 0x12, 0x8b, 0xe2);
56 
57 typedef struct _GstMFTransformEnumParams
58 {
59   GUID category;
60   guint32 enum_flags;
61   MFT_REGISTER_TYPE_INFO *input_typeinfo;
62   MFT_REGISTER_TYPE_INFO *output_typeinfo;
63 
64   guint device_index;
65   gint64 adapter_luid;
66 } GstMFTransformEnumParams;
67 
68 typedef HRESULT (*GstMFTransformNewSampleCallback) (GstMFTransform * object,
69                                                     IMFSample * sample,
70                                                     gpointer user_data);
71 
72 GstMFTransform * gst_mf_transform_new             (GstMFTransformEnumParams * params);
73 
74 gboolean        gst_mf_transform_open             (GstMFTransform * object);
75 
76 gboolean        gst_mf_transform_set_device_manager (GstMFTransform * object,
77                                                      IMFDXGIDeviceManager * manager);
78 
79 void            gst_mf_transform_set_new_sample_callback (GstMFTransform * object,
80                                                           GstMFTransformNewSampleCallback callback,
81                                                           gpointer user_data);
82 
83 IMFActivate *   gst_mf_transform_get_activate_handle (GstMFTransform * object);
84 
85 IMFTransform *  gst_mf_transform_get_transform_handle (GstMFTransform * object);
86 
87 ICodecAPI *     gst_mf_transform_get_codec_api_handle (GstMFTransform * object);
88 
89 gboolean        gst_mf_transform_process_input    (GstMFTransform * object,
90                                                    IMFSample * sample);
91 
92 GstFlowReturn   gst_mf_transform_get_output       (GstMFTransform * object,
93                                                    IMFSample ** sample);
94 
95 gboolean        gst_mf_transform_flush            (GstMFTransform * object);
96 
97 gboolean        gst_mf_transform_drain            (GstMFTransform * object);
98 
99 gboolean        gst_mf_transform_get_input_available_types  (GstMFTransform * object,
100                                                              GList ** input_types);
101 
102 gboolean        gst_mf_transform_get_output_available_types (GstMFTransform * object,
103                                                              GList ** output_types);
104 
105 gboolean        gst_mf_transform_set_input_type  (GstMFTransform * object,
106                                                   IMFMediaType * input_type);
107 
108 gboolean        gst_mf_transform_set_output_type (GstMFTransform * object,
109                                                   IMFMediaType * output_type);
110 
111 gboolean        gst_mf_transform_get_input_current_type  (GstMFTransform * object,
112                                                           IMFMediaType ** input_type);
113 
114 gboolean        gst_mf_transform_get_output_current_type (GstMFTransform * object,
115                                                           IMFMediaType ** output_type);
116 
117 gboolean        gst_mf_transform_set_codec_api_uint32  (GstMFTransform * object,
118                                                         const GUID * api,
119                                                         guint32 value);
120 
121 gboolean        gst_mf_transform_set_codec_api_uint64  (GstMFTransform * object,
122                                                         const GUID * api,
123                                                         guint64 value);
124 
125 gboolean        gst_mf_transform_set_codec_api_boolean (GstMFTransform * object,
126                                                         const GUID * api,
127                                                         gboolean value);
128 
129 G_END_DECLS
130 
131 #endif /* __GST_MF_TRANSFORM_OBJECT_H__ */