mfvideosrc: Add support for DirectShow capture filter
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / sys / mediafoundation / gstmfsourceobject.h
1 /* GStreamer
2  * Copyright (C) 2019 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_SOURCE_OBJECT_H__
22 #define __GST_MF_SOURCE_OBJECT_H__
23
24 #include <gst/gst.h>
25 #include "gstmfutils.h"
26
27 G_BEGIN_DECLS
28
29 #define GST_TYPE_MF_SOURCE_OBJECT             (gst_mf_source_object_get_type())
30 #define GST_MF_SOURCE_OBJECT(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_MF_SOURCE_OBJECT, GstMFSourceObject))
31 #define GST_MF_SOURCE_OBJECT_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_MF_SOURCE_OBJECT, GstMFSourceObjectClass))
32 #define GST_IS_MF_SOURCE_OBJECT(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_MF_SOURCE_OBJECT))
33 #define GST_IS_MF_SOURCE_OBJECT_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_MF_SOURCE_OBJECT))
34 #define GST_MF_SOURCE_OBJECT_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_MF_SOURCE_OBJECT, GstMFSourceObjectClass))
35
36 typedef struct _GstMFSourceObject        GstMFSourceObject;
37 typedef struct _GstMFSourceObjectClass   GstMFSourceObjectClass;
38
39 typedef enum
40 {
41   GST_MF_SOURCE_TYPE_VIDEO,
42 } GstMFSourceType;
43
44 #define GST_TYPE_MF_SOURCE_TYPE (gst_mf_source_type_get_type())
45 GType gst_mf_source_type_get_type (void);
46
47 struct _GstMFSourceObject
48 {
49   GstObject parent;
50
51   gboolean opened;
52
53   GstMFSourceType source_type;
54   gchar *device_path;
55   gchar *device_name;
56   gint device_index;
57
58   GWeakRef client;
59 };
60
61 struct _GstMFSourceObjectClass
62 {
63   GstObjectClass parent_class;
64
65   gboolean      (*start)       (GstMFSourceObject * object);
66
67   gboolean      (*stop)        (GstMFSourceObject * object);
68
69   GstFlowReturn (*fill)        (GstMFSourceObject * object,
70                                 GstBuffer * buffer);
71
72   GstFlowReturn (*create)      (GstMFSourceObject * object,
73                                 GstBuffer ** buffer);
74
75   GstFlowReturn (*get_sample)  (GstMFSourceObject * object,
76                                 GstSample ** sample);
77
78   gboolean      (*unlock)      (GstMFSourceObject * object);
79
80   gboolean      (*unlock_stop) (GstMFSourceObject * object);
81
82   GstCaps *     (*get_caps)    (GstMFSourceObject * object);
83
84   gboolean      (*set_caps)    (GstMFSourceObject * object,
85                                 GstCaps * caps);
86 };
87
88 GType           gst_mf_source_object_get_type     (void);
89
90 gboolean        gst_mf_source_object_start        (GstMFSourceObject * object);
91
92 gboolean        gst_mf_source_object_stop         (GstMFSourceObject * object);
93
94 /* Used for raw format */
95 GstFlowReturn   gst_mf_source_object_fill         (GstMFSourceObject * object,
96                                                    GstBuffer * buffer);
97
98 /* Used for compressed/raw format */
99 GstFlowReturn   gst_mf_source_object_create       (GstMFSourceObject * object,
100                                                    GstBuffer ** buffer);
101
102 /* DirectShow filter */
103 GstFlowReturn   gst_mf_source_object_get_sample   (GstMFSourceObject * object,
104                                                    GstSample ** sample);
105
106 void            gst_mf_source_object_set_flushing (GstMFSourceObject * object,
107                                                    gboolean flushing);
108
109 GstCaps *       gst_mf_source_object_get_caps     (GstMFSourceObject * object);
110
111 gboolean        gst_mf_source_object_set_caps     (GstMFSourceObject * object,
112                                                    GstCaps * caps);
113
114 gboolean        gst_mf_source_object_set_client   (GstMFSourceObject * object,
115                                                    GstElement * element);
116
117 GstClockTime    gst_mf_source_object_get_running_time (GstMFSourceObject * object);
118
119 /* A factory method for subclass impl. selection */
120 GstMFSourceObject * gst_mf_source_object_new      (GstMFSourceType type,
121                                                    gint device_index,
122                                                    const gchar * device_name,
123                                                    const gchar * device_path,
124                                                    gpointer dispatcher);
125
126 /* Utility methods */
127 gint            gst_mf_source_object_caps_compare (GstCaps * caps1,
128                                                    GstCaps * caps2);
129
130 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstMFSourceObject, gst_object_unref)
131
132 G_END_DECLS
133
134 #endif /* __GST_MF_SOURCE_OBJECT_H__ */