Add internal function - ms_find_element_in_bin_by_type()
[platform/core/api/mediastreamer.git] / include / media_streamer_gst.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __TIZEN_MEDIA_STREAMER_GST_H__
18 #define __TIZEN_MEDIA_STREAMER_GST_H__
19
20 #include <gst/gst.h>
21 #include "media_streamer_priv.h"
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #define DOT_FILE_NAME "streamer"
28
29 #define MEDIA_STREAMER_PIPELINE_NAME "media-streamer-pipeline"
30 #define MEDIA_STREAMER_SRC_BIN_NAME "streamer_src"
31 #define MEDIA_STREAMER_SINK_BIN_NAME "streamer_sink"
32 #define MEDIA_STREAMER_TRANSFORM_BIN_NAME "streamer_transform"
33
34 #define MEDIA_STREAMER_PAYLOADER_KLASS "Codec/Payloader/Network/RTP"
35 #define MEDIA_STREAMER_RTP_KLASS "Filter/Network/RTP"
36
37 #define MEDIA_STREAMER_DEPAYLOADER_KLASS "Depayloader/Network/RTP"
38 #define MEDIA_STREAMER_BIN_KLASS "Generic/Bin"
39 #define MEDIA_STREAMER_QUEUE_KLASS "Generic"
40 #define MEDIA_STREAMER_OVERLAY_KLASS "Filter/Editor"
41 #define MEDIA_STREAMER_PARSER_KLASS "Codec/Parser"
42 #define MEDIA_STREAMER_CONVERTER_KLASS "Filter/Converter"
43 #define MEDIA_STREAMER_DECODER_KLASS "Codec/Decoder"
44 #define MEDIA_STREAMER_SINK_KLASS "Sink"
45 #define MEDIA_STREAMER_STRICT "_strict_"
46
47 /**
48  * @brief Generates dot files for GStreamer pipeline.
49  */
50 void ms_generate_dots(GstElement *bin, gchar *name_tag);
51
52 /**
53  * @brief Creates GstElement by plugin name.
54  */
55 GstElement *ms_element_create(const char *plugin_name, const char *name);
56
57 /**
58  * @brief Creates GstBin name for adaptive streaming.
59  */
60 GstElement *ms_adaptive_element_create(void);
61
62 /**
63  * @brief Creates GstElement from specified node_plug_s structure.
64  */
65 GstElement *ms_node_element_create(node_plug_s *plug_info, media_streamer_node_type_e type);
66
67 /**
68  * @brief Creates rtp container GstElement.
69  */
70 GstElement *ms_rtp_element_create(void);
71
72 /**
73  * @brief Unlink all pads into GstElement.
74  */
75 gboolean ms_element_unlink(GstElement *element);
76
77 /**
78  * @brief Remove GstElement from bin.
79  */
80 gboolean ms_bin_remove_element(GstElement *element);
81
82 /**
83  * @brief Add GstElement into bin if not added before and refs it.
84  */
85 gboolean ms_bin_add_element(GstElement *bin, GstElement *element, gboolean do_ref);
86
87 /**
88  * @brief Gets pad type of element pad.
89  */
90 const gchar *ms_get_pad_type(GstPad *element_pad);
91
92 /**
93  * @brief Creates decodebin to link with sink part.
94  */
95 GstElement *ms_decodebin_create(media_streamer_s *ms_streamer, char *name);
96
97 /**
98  * @brief Creates next element by klass or by properties and links with the previous one.
99  */
100 GstElement *ms_combine_next_element(GstElement *previous_element, GstPad *prev_elem_src_pad, GstElement *bin_to_find_in, media_streamer_node_type_e node_type);
101
102 /**
103  * @brief Locks gst_element being contained in GValue data.
104  */
105 gboolean ms_element_lock_state(const GValue *item, GValue *ret, gpointer user_data);
106
107 /**
108  * @brief Unlocks gst_element being contained in GValue data.
109  */
110 gboolean ms_element_unlock_state(const GValue *item, GValue *ret, gpointer user_data);
111
112 /**
113  * @brief Creates pipeline, bus and src/sink/transform bins.
114  */
115 int ms_pipeline_create(media_streamer_s *ms_streamer);
116
117 /**
118  * @brief Prepares Media Streamer pipeline and autoplug nodes if needed.
119  *
120  */
121 int ms_pipeline_prepare(media_streamer_s *ms_streamer);
122
123 /**
124  * @brief Unprepares Media Streamer pipeline and unlink nodes
125  *        which user didn't link before.
126  */
127 int ms_pipeline_unprepare(media_streamer_s *ms_streamer);
128
129 /**
130  * @brief Gets pipeline state of media streamer.
131  */
132 void ms_pipeline_get_state(media_streamer_s *ms_streamer);
133
134 /**
135  * @brief Sets GstElement into state.
136  */
137 int ms_element_set_state(GstElement *element, GstState state);
138
139 /**
140  * @brief Iterates pas inside gst element.
141  */
142 int ms_element_pad_names(GstElement *element, GstPadDirection pad_type, char ***pad_name_array, int *pads_count);
143
144 /**
145  * @brief Gets mediaformat from the GstElement's pad by pad name.
146  */
147 int ms_element_get_pad_fmt(GstElement *element, const char *pad_name, media_format_h *fmt);
148
149 /**
150  * @brief Sets mediaformat to the GstElement's pad.
151  */
152 int ms_element_set_fmt(GstElement *element, const char *pad_name, media_format_h fmt);
153
154 /**
155  * @brief Creates GstCap's from mediaformat.
156  */
157 GstCaps *ms_create_caps_from_fmt(media_format_h fmt);
158
159 /**
160  * @brief Seeks GstElement to according time value.
161  */
162 gboolean ms_gst_seek(GstElement *element, gint64 g_time, GstSeekFlags seek_flag);
163
164 /**
165  * @brief Push the media packet buffer to the source element.
166  */
167 int ms_element_push_packet(GstElement *src_element, media_packet_h packet);
168
169 /**
170  * @brief Pull the media packet buffer from sink element.
171  */
172 int ms_element_pull_packet(GstElement *sink_element, media_packet_h *packet);
173
174 /**
175  * @brief Finds type of media
176  */
177 int ms_find_type(media_streamer_s *ms_streamer, GstElement *element);
178
179 GstElement *ms_find_element_in_bin_by_type(GstElement *bin, node_info_s *node_klass_type);
180
181 void ms_rtpbin_pad_added_cb(GstElement *element, GstPad *new_pad, gpointer user_data);
182
183 void ms_demux_pad_added_cb(GstElement *element, GstPad *new_pad, gpointer user_data);
184
185 void ms_hlsdemux_pad_added_cb(GstElement *element, GstPad *new_pad, gpointer user_data);
186
187 void ms_demux_nomore_pads_cb(GstElement *element, gpointer user_data);
188
189
190 #ifdef __cplusplus
191 }
192 #endif
193
194 #endif /* __TIZEN_MEDIA_STREAMER_GST_H__ */