8cc09a4c3b149267ae01082a52d5ce768fece509
[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   gboolean      (*unlock)      (GstMFSourceObject * object);
76
77   gboolean      (*unlock_stop) (GstMFSourceObject * object);
78
79   GstCaps *     (*get_caps)    (GstMFSourceObject * object);
80
81   gboolean      (*set_caps)    (GstMFSourceObject * object,
82                                 GstCaps * caps);
83 };
84
85 GType           gst_mf_source_object_get_type     (void);
86
87 gboolean        gst_mf_source_object_start        (GstMFSourceObject * object);
88
89 gboolean        gst_mf_source_object_stop         (GstMFSourceObject * object);
90
91 /* Used for raw format */
92 GstFlowReturn   gst_mf_source_object_fill         (GstMFSourceObject * object,
93                                                    GstBuffer * buffer);
94
95 /* Used for compressed/raw format */
96 GstFlowReturn   gst_mf_source_object_create       (GstMFSourceObject * object,
97                                                    GstBuffer ** buffer);
98
99 void            gst_mf_source_object_set_flushing (GstMFSourceObject * object,
100                                                    gboolean flushing);
101
102 GstCaps *       gst_mf_source_object_get_caps     (GstMFSourceObject * object);
103
104 gboolean        gst_mf_source_object_set_caps     (GstMFSourceObject * object,
105                                                    GstCaps * caps);
106
107 gboolean        gst_mf_source_object_set_client   (GstMFSourceObject * object,
108                                                    GstElement * element);
109
110 GstClockTime    gst_mf_source_object_get_running_time (GstMFSourceObject * object);
111
112 /* A factory method for subclass impl. selection */
113 GstMFSourceObject * gst_mf_source_object_new      (GstMFSourceType type,
114                                                    gint device_index,
115                                                    const gchar * device_name,
116                                                    const gchar * device_path,
117                                                    gpointer dispatcher);
118
119 /* Utility methods */
120 gint            gst_mf_source_object_caps_compare (GstCaps * caps1,
121                                                    GstCaps * caps2);
122
123 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstMFSourceObject, gst_object_unref)
124
125 G_END_DECLS
126
127 #endif /* __GST_MF_SOURCE_OBJECT_H__ */