4e03bebdc96dc4e8cfecb61693f3b94583823716
[platform/core/api/mediastreamer.git] / include / media_streamer_priv.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_PRIVATE_H__
18 #define __TIZEN_MEDIA_STREAMER_PRIVATE_H__
19
20 #include <gst/gst.h>
21 #include <stdio.h>
22 #include <restriction.h>
23 #include <mm_resource_manager.h>
24 #include "media_streamer.h"
25 #include "media_streamer_util.h"
26 #include "media_streamer_http_server.h"
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 struct media_streamer_node_s;
33
34 /**
35  * @brief Media Streamer callbacks structure.
36  */
37 typedef struct {
38         void *callback;
39         void *user_data;
40 } media_streamer_callback_s;
41
42 /**
43  * @brief Media Streamer sink callbacks structure.
44  */
45 typedef struct {
46         media_streamer_callback_s data_ready_cb;
47         media_streamer_callback_s eos_cb;
48 } media_streamer_sink_callbacks_s;
49
50 /**
51  * @brief Media Streamer webrtc node callbacks structure.
52  */
53 typedef struct {
54         media_streamer_callback_s message_cb;
55         media_streamer_callback_s decoded_ready_cb;
56 } media_streamer_webrtc_callbacks_s;
57
58 /**
59  * @brief Media Streamer param type handle.
60  */
61 typedef struct {
62         char *param_name;
63         char *origin_name;
64 } param_s;
65
66 /**
67  * @brief Media Streamer node_info type handle.
68  */
69 typedef struct {
70         char *klass_name;
71         char *default_name;
72 } node_info_s;
73
74 /**
75  * @brief Media Streamer node_plug type handle.
76  */
77 typedef struct {
78         node_info_s *info;
79         GstCaps *src_caps;
80         GstCaps *sink_caps;
81         gchar **exclude_names;
82 } node_plug_s;
83
84 /**
85  * @brief Media Streamer type handle.
86  */
87 typedef struct {
88         media_streamer_ini_t ini;
89         GstElement *pipeline;
90
91         GstElement *src_bin;
92         GstElement *sink_bin;
93         GstElement *transform_bin;
94
95         GHashTable *nodes_table;
96         GMutex mutex_lock;
97         GList *autoplug_sig_list;
98         GList *pads_types_list;
99
100         GstBus *bus;
101         guint bus_watcher;
102         gboolean is_seeking;
103
104         media_streamer_state_e state;
105         media_streamer_state_e pend_state;
106         gboolean need_paused_by_live_source;
107
108         media_streamer_callback_s error_cb;
109         media_streamer_callback_s state_changed_cb;
110         media_streamer_callback_s seek_done_cb;
111         media_streamer_callback_s interrupted_cb;
112
113         gboolean is_interrupted;
114         mm_resource_manager_h resource_manager;
115         mm_resource_manager_res_h video_decoder_resource;
116
117         media_streamer_http_server_h http_server;
118 } media_streamer_s;
119
120 /**
121  * @brief Media Streamer node type handle.
122  */
123 typedef struct {
124         GstElement *gst_element;
125         media_streamer_s *parent_streamer;
126
127         char *name;
128         media_streamer_node_type_e type;
129         int subtype;
130
131         gboolean linked_by_user;
132
133         GList *sig_list;
134
135         void *callbacks_structure;
136
137         mm_resource_manager_res_h resource;
138         device_policy_manager_h dpm_handle;
139         int policy_changed_cb_id;
140 } media_streamer_node_s;
141
142 /**
143  * @brief Gets the play position of Media streamer element.
144  */
145 int ms_get_position(media_streamer_s *ms_streamer, int *time);
146
147 /**
148  * @brief Gets the duration of Media streamer element.
149  */
150 int ms_get_duration(media_streamer_s *ms_streamer, int *time);
151
152 /**
153  * @brief Seeks Media streamer element to the pointed position.
154  */
155 int ms_seek(media_streamer_s *ms_streamer, int time, bool flag);
156
157 /**
158  * @brief Destroys media streamer structure.
159  */
160 int ms_destroy(media_streamer_s *ms_streamer);
161
162 /**
163  * @brief Creates media streamer structure.
164  */
165 int ms_create(media_streamer_s *ms_streamer);
166
167 /**
168  * @brief Set state of media streamer.
169  */
170 int ms_set_state(media_streamer_s *ms_streamer, media_streamer_state_e state);
171
172 void ms_update_state_from_pend_state(media_streamer_s *ms_streamer);
173
174 #ifdef __cplusplus
175 }
176 #endif /* __cplusplus */
177
178 #endif /* __TIZEN_MEDIA_STREAMER_PRIVATE_H__ */