4 * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, ByungWook Jang <bw.jang@samsung.com>,
7 * Maksym Ukhanov <m.ukhanov@samsung.com>, Hyunjun Ko <zzoon.ko@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 #ifndef _MM_WFD_SINK_PRIV_H_
24 #define _MM_WFD_SINK_PRIV_H_
32 #include <mm_message.h>
35 #include <mm_wfd_sink_ini.h>
36 #include <mm_wfd_attrs.h>
38 #include "mm_wfd_sink.h"
40 /* main pipeline's element id */
41 enum WFDSinkMainElementID {
42 WFD_SINK_M_PIPE = 0, /* NOTE : WFD_SINK_M_PIPE should be zero */
49 /* audio pipeline's element id */
50 enum WFDSinkAudioElementID {
51 WFD_SINK_A_BIN = 0, /* NOTE : WFD_SINK_A_BIN should be zero */
58 WFD_SINK_A_LPCM_CONVERTER,
59 WFD_SINK_A_LPCM_FILTER,
60 WFD_SINK_A_CAPSFILTER,
67 /* video pipeline's element id */
68 enum WFDSinkVideoElementID {
69 WFD_SINK_V_BIN = 0, /* NOTE : WFD_SINK_V_BIN should be zero */
73 WFD_SINK_V_CAPSSETTER,
76 WFD_SINK_V_CAPSFILTER,
82 * * Enumerations of wifi-display command.
85 MM_WFD_SINK_COMMAND_NONE, /**< command for nothing */
86 MM_WFD_SINK_COMMAND_CREATE, /**< command for creating wifi-display sink */
87 MM_WFD_SINK_COMMAND_PREPARE, /**< command for preparing wifi-display sink */
88 MM_WFD_SINK_COMMAND_CONNECT, /**< command for connecting wifi-display sink */
89 MM_WFD_SINK_COMMAND_START, /**< command for starting wifi-display sink */
90 MM_WFD_SINK_COMMAND_PAUSE, /**< command for pausing wifi-display sink */
91 MM_WFD_SINK_COMMAND_RESUME, /**< command for resuming wifi-display sink */
92 MM_WFD_SINK_COMMAND_DISCONNECT, /**< command for disconnecting wifi-display sink */
93 MM_WFD_SINK_COMMAND_UNPREPARE, /**< command for unpreparing wifi-display sink */
94 MM_WFD_SINK_COMMAND_DESTROY, /**< command for destroting wifi-display sink */
95 MM_WFD_SINK_COMMAND_NUM, /**< Number of wifi-display commands */
96 } MMWFDSinkCommandType;
99 * * Enumerations of thread command.
102 WFD_SINK_MANAGER_CMD_NONE = 0,
103 WFD_SINK_MANAGER_CMD_LINK_A_BIN = (1 << 0),
104 WFD_SINK_MANAGER_CMD_LINK_V_BIN = (1 << 1),
105 WFD_SINK_MANAGER_CMD_PREPARE_A_BIN = (1 << 2),
106 WFD_SINK_MANAGER_CMD_PREPARE_V_BIN = (1 << 3),
107 WFD_SINK_MANAGER_CMD_EXIT = (1 << 8)
108 } WFDSinkManagerCMDType;
111 * * Enumerations of resolution.
114 MM_WFD_SINK_RESOLUTION_UNKNOWN = 0,
115 MM_WFD_SINK_RESOLUTION_1920x1080_P30 = (1 << 0), /**< W-1920, H-1080, 30 fps*/
116 MM_WFD_SINK_RESOLUTION_1280x720_P30 = (1 << 1), /**< W-1280, H-720, 30 fps*/
117 MM_WFD_SINK_RESOLUTION_960x540_P30 = (1 << 2), /**< W-960, H-540, 30 fps*/
118 MM_WFD_SINK_RESOLUTION_864x480_P30 = (1 << 3), /**< W-864, H-480, 30 fps*/
119 MM_WFD_SINK_RESOLUTION_720x480_P60 = (1 << 4), /**< W-720, H-480, 30 fps*/
120 MM_WFD_SINK_RESOLUTION_640x480_P60 = (1 << 5), /**< W-640, H-480, 60 fps*/
121 MM_WFD_SINK_RESOLUTION_640x360_P30 = (1 << 6), /**< W-640, H-360, 30 fps*/
122 MM_WFD_SINK_RESOLUTION_MAX = 128,
123 } MMWFDSinkResolution;
130 } MMWFDSinkVideoStreamInfo;
137 } MMWFDSinkAudioStreamInfo;
140 MMWFDSinkAudioStreamInfo audio_stream_info;
141 MMWFDSinkVideoStreamInfo video_stream_info;
142 } MMWFDSinkStreamInfo;
148 } MMWFDSinkGstElement;
151 MMWFDSinkGstElement *mainbin;
152 MMWFDSinkGstElement *audiobin;
153 MMWFDSinkGstElement *videobin;
154 } MMWFDSinkGstPipelineInfo;
157 MMWFDSinkStateType state; /* wfd current state */
158 MMWFDSinkStateType prev_state; /* wfd previous state */
159 MMWFDSinkStateType pending_state; /* wfd state which is going to now */
162 #define MMWFDSINK_GET_ATTRS(x_wfd) ((x_wfd)? ((mm_wfd_sink_t*)x_wfd)->attrs : (MMHandleType)NULL)
165 /* gstreamer pipeline */
166 MMWFDSinkGstPipelineInfo *pipeline;
167 gint added_av_pad_num;
168 gboolean audio_bin_is_linked;
169 gboolean video_bin_is_linked;
170 GstPad *prev_audio_dec_src_pad;
171 GstPad *next_audio_dec_sink_pad;
173 /* timestamp compensation */
174 gboolean need_to_reset_basetime;
177 gint64 video_average_gap;
178 gint64 video_accumulated_gap;
179 gint64 video_buffer_count;
180 gint64 audio_average_gap;
181 gint64 audio_accumulated_gap;
182 gint64 audio_buffer_count;
183 GstClockTime last_buffer_timestamp;
189 MMWFDSinkState state;
191 /* initialize values */
192 mm_wfd_sink_ini_t ini;
195 MMWFDSinkCommandType cmd;
197 gboolean waiting_cmd;
199 /* stream information */
200 MMWFDSinkStreamInfo stream_info;
202 /* Message handling */
203 MMWFDMessageCallback msg_cb;
206 /* audio session manager related variables */
207 GList *resource_list;
209 /* video resolution for negotiation */
210 MMWFDSinkResolution supportive_resolution;
212 GThread *manager_thread;
213 GMutex manager_thread_mutex;
214 GCond manager_thread_cond;
215 WFDSinkManagerCMDType manager_thread_cmd;
219 int _mm_wfd_sink_create(mm_wfd_sink_t **wfd_sink);
220 int _mm_wfd_sink_destroy(mm_wfd_sink_t *wfd_sink);
221 int _mm_wfd_sink_prepare(mm_wfd_sink_t *wfd_sink);
222 int _mm_wfd_sink_unprepare(mm_wfd_sink_t *wfd_sink);
223 int _mm_wfd_sink_connect(mm_wfd_sink_t *wfd_sink, const char *uri);
224 int _mm_wfd_sink_disconnect(mm_wfd_sink_t *wfd_sink);
225 int _mm_wfd_sink_start(mm_wfd_sink_t *wfd_sink);
226 int _mm_wfd_sink_pause(mm_wfd_sink_t *wfd_sink);
227 int _mm_wfd_sink_resume(mm_wfd_sink_t *wfd_sink);
228 int _mm_wfd_set_message_callback(mm_wfd_sink_t *wfd_sink, MMWFDMessageCallback callback, void *user_data);
229 int _mm_wfd_sink_get_resource(mm_wfd_sink_t *wfd_sink);
230 int _mm_wfd_sink_set_resolution(mm_wfd_sink_t *wfd_sink, MMWFDSinkResolution resolution);
232 int __mm_wfd_sink_link_audiobin(mm_wfd_sink_t *wfd_sink);
233 int __mm_wfd_sink_link_videobin(mm_wfd_sink_t *wfd_sink);
234 int __mm_wfd_sink_prepare_videobin(mm_wfd_sink_t *wfd_sink);
235 int __mm_wfd_sink_prepare_audiobin(mm_wfd_sink_t *wfd_sink);
237 const gchar *_mm_wfds_sink_get_state_name(MMWFDSinkStateType state);