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_H_
24 #define _MM_WFD_SINK_H_
28 #include <mm_message.h>
33 * * Enumerations of wifi-display sink state.
36 MM_WFD_SINK_STATE_NONE, /**< wifi-display is not created */
37 MM_WFD_SINK_STATE_NULL, /**< wifi-display is created */
38 MM_WFD_SINK_STATE_PREPARED, /**< wifi-display is prepared */
39 MM_WFD_SINK_STATE_CONNECTED, /**< wifi-display is connected */
40 MM_WFD_SINK_STATE_PLAYING, /**< wifi-display is now playing */
41 MM_WFD_SINK_STATE_PAUSED, /**< wifi-display is now paused */
42 MM_WFD_SINK_STATE_DISCONNECTED, /**< wifi-display is disconnected */
43 MM_WFD_SINK_STATE_NUM, /**< Number of wifi-display states */
46 typedef void (*MMWFDMessageCallback)(int error_type, MMWFDSinkStateType state_type, void *user_data);
49 * This function creates a wi-fi display sink object. \n
50 * The attributes of wi-fi display sink are created to get/set some values with application. \n
51 * And, mutex, gstreamer and other resources are initialized at this time. \n
52 * If wi-fi display sink is created, he state will become MM_WFD_SINK_STATE_NULL.. \n
54 * @param wfd_sink [out] Handle of wi-fi display sink
56 * @return This function returns zero on success, or negative value with error code. \n
57 * Please refer 'mm_error.h' to know it in detail.
59 * @post MM_WFD_SINK_STATE_NULL
60 * @see mm_wfd_sink_destroy
61 * @remark You can create multiple handles on a context at the same time. \n
62 * However, wi-fi display sink cannot guarantee proper operation because of limitation of resources, \n
63 * such as audio device or display device.
67 if (mm_wfd_sink_create(&g_wfd_sink) != MM_ERROR_NONE)
69 wfd_sink_error("failed to create wi-fi display sink\n");
72 mm_wfd_sink_set_message_callback(g_wfd_sink, msg_callback, (void*)g_wfd_sink);
75 int mm_wfd_sink_create(MMHandleType *wfd_sink);
78 * This function trys to make gstreamer pipeline. \n
79 * If wi-fi display sink is realized, the state will become MM_WFD_SINK_STATE_READY.. \n
81 * @param wfd_sink [out] Handle of wi-fi display sink
83 * @return This function returns zero on success, or negative value with error code. \n
84 * Please refer 'mm_error.h' to know it in detail.
85 * @pre MM_WFD_SINK_STATE_NULL
86 * @post MM_WFD_SINK_STATE_READY
87 * @see mm_wfd_sink_unprepare
91 if (mm_wfd_sink_prepare(&g_wfd_sink) != MM_ERROR_NONE)
93 wfd_sink_error("failed to realize wi-fi display sink\n");
97 int mm_wfd_sink_prepare(MMHandleType wfd_sink);
100 * This function connect wi-fi display source using uri. \n
101 * audio type(AC3 AAC, LPCM) is decided at this time. \n
103 * @param wfd_sink [in] Handle of wi-fi display sink
104 * @param uri [in] URI of wi-fi displaysource to be connected
106 * @return This function returns zero on success, or negative value with error code.
108 * @pre wi-fi display sink state should be MM_WFD_SINK_STATE_READY
109 * @post wi-fi display sink state will be MM_WFD_SINK_STATE_PAUSED with no preroll.
113 if (mm_wfd_sink_connect(g_wfd_sink, g_uri) != MM_ERROR_NONE)
115 wfd_sink_error("failed to connect to wi-fi display source\n");
119 int mm_wfd_sink_connect(MMHandleType wfd_sink, const char *uri);
122 * This function is to start playing. \n
123 * Data from wi-fi display source will be received. \n
125 * @param wfd_sink [in] Handle of wi-fi display sink
127 * @return This function returns zero on success, or negative value with error code.
130 * @pre wi-fi display sink state may be MM_WFD_SINK_STATE_PAUSED.
131 * @post wi-fi display sink state will be MM_WFD_SINK_STATE_PLAYING.
132 * @see mm_wfd_sink_disconnect
136 if (mm_wfd_sink_start(g_wfd_sink) != MM_ERROR_NONE)
138 wfd_sink_error("failed to start wi-fi display sink\n");
142 int mm_wfd_sink_start(MMHandleType wfd_sink);
145 * This function is to stop playing wi-fi display. \n
147 * @param wfd_sink [in] Handle of wi-fi display sink
149 * @return This function returns zero on success, or negative value with error code.
151 * @pre wi-fi display sink state may be MM_WFD_SINK_STATE_PLAYING.
152 * @post wi-fi display sink state will be MM_WFD_SINK_STATE_READY.
153 * @see mm_wfd_sink_start
157 if (mm_wfd_sink_disconnect(g_wfd_sink) != MM_ERROR_NONE)
159 wfd_sink_error("failed to stop wi-fi display sink\n");
163 int mm_wfd_sink_disconnect(MMHandleType wfd_sink);
166 * This function trys to destroy gstreamer pipeline. \n
168 * @param wfd_sink [out] Handle of wi-fi display sink
170 * @return This function returns zero on success, or negative value with error code. \n
171 * Please refer 'mm_error.h' to know it in detail.
172 * @pre wi-fi display sink state may be MM_WFD_SINK_STATE_READY.
173 * But, it can be called in any state.
174 * @post MM_WFD_SINK_STATE_NULL
175 * @see mm_wfd_sink_prepare
179 if (mm_wfd_sink_unprepare(&g_wfd_sink) != MM_ERROR_NONE)
181 wfd_sink_error("failed to unrealize wi-fi display sink\n");
185 int mm_wfd_sink_unprepare(MMHandleType wfd_sink);
188 * This function releases wi-fi display sink object and all resources which were created by mm_wfd_sink_create(). \n
189 * And, wi-fi display sink handle will also be destroyed. \n
191 * @param wfd_sink [in] Handle of wi-fi display sink
193 * @return This function returns zero on success, or negative value with error code.
194 * @pre wi-fi display state may be MM_WFD_SINK_STATE_NULL. \n
195 * But, it can be called in any state.
196 * @post Because handle is released, there is no any state.
197 * @see mm_wfd_sink_create
198 * @remark This method can be called with a valid wi-fi display sink handle from any state to \n
199 * completely shutdown the wi-fi display sink operation.
203 if (mm_wfd_sink_destroy(g_wfd_sink) != MM_ERROR_NONE)
205 wfd_sink_error("failed to destroy wi-fi display sink\n");
209 int mm_wfd_sink_destroy(MMHandleType wfd_sink);
212 * This function sets callback function for receiving messages from wi-fi display sink. \n
213 * So, player can notify warning, error and normal cases to application. \n
215 * @param wfd_sink [in] Handle of wi-fi display sink
216 * @param callback [in] Message callback function.
217 * @param user_param [in] User parameter which is passed to callback function.
219 * @return This function returns zero on success, or negative value with error code.
220 * @see MMWFDMessageCallback
225 int msg_callback(int error_type, MMWFDSinkStateType state_type, void *user_data)
229 case MM_WFD_SINK_STATE_NULL:
233 case MM_WFD_SINK_STATE_READY:
237 case MM_WFD_SINK_STATE_PAUSED:
241 case MM_WFD_SINK_STATE_PLAYING:
245 case MM_WFD_SINK_STATE_TEARDOWN:
255 mm_wfd_sink_set_message_callback(g_wfd_sink, msg_callback, (void*)g_wfd_sink);
258 int mm_wfd_sink_set_message_callback(MMHandleType wfd_sink, MMWFDMessageCallback callback, void *user_param);
260 int mm_wfd_sink_set_attribute(MMHandleType wfd_sink, char **err_attr_name, const char *first_attribute_name, ...);
263 * This function get resources \n
265 * @param wfd_sink [in] Handle of wi-fi display sink
267 * @return This function returns zero on success, or negative value with error code.
268 * @pre wi-fi display state should be MM_WFD_SINK_STATE_READY or MM_WFD_SINK_STATE_PAUSED. \n
270 * @remark resources are released when mm_wfd_sink_destory is called
274 if (mm_wfd_sink_get_resource(g_wfd_sink) != MM_ERROR_NONE)
276 wfd_sink_error("failed to get resources for wi-fi display sink\n");
280 int mm_wfd_sink_get_resource(MMHandleType wfd_sink);
283 * This function sets the display surface type for wi-fi display sink\n
285 * @param wfd_sink [in] Handle of wi-fi display sink
286 * @param display_surface_type [in] Display surface type
288 * @return This function returns zero on success, or negative value with error code.
289 * @pre wi-fi display state should be MM_WFD_SINK_STATE_NULL. \n
293 if (mm_wfd_sink_set_display_surface_type(g_wfd_sink, g_display_surface_type) != MM_ERROR_NONE)
295 wfd_sink_error("failed to set display surface type for wi-fi display sink\n");
299 int mm_wfd_sink_set_display_surface_type(MMHandleType wfd_sink, gint display_surface_type);
302 * This function sets the display overlay for wi-fi display sink\n
304 * @param wfd_sink [in] Handle of wi-fi display sink
305 * @param display_overlay [in] Display overlay
307 * @return This function returns zero on success, or negative value with error code.
308 * @pre wi-fi display state should be MM_WFD_SINK_STATE_NULL. \n
312 if (mm_wfd_sink_set_display_overlay(g_wfd_sink, g_display_overlay) != MM_ERROR_NONE)
314 wfd_sink_error("failed to set display overlay for wi-fi display sink\n");
318 int mm_wfd_sink_set_display_overlay(MMHandleType wfd_sink, void *display_overlay);
321 * This function sets the display method for wi-fi display sink\n
323 * @param wfd_sink [in] Handle of wi-fi display sink
324 * @param display_method [in] Display method
326 * @return This function returns zero on success, or negative value with error code.
327 * @pre wi-fi display state should be MM_WFD_SINK_STATE_NULL. \n
331 if (mm_wfd_sink_set_display_method(g_wfd_sink, g_display_method) != MM_ERROR_NONE)
333 wfd_sink_error("failed to set display method for wi-fi display sink\n");
337 int mm_wfd_sink_set_display_method(MMHandleType wfd_sink, gint display_method);
340 * This function sets the display visible for wi-fi display sink\n
342 * @param wfd_sink [in] Handle of wi-fi display sink
343 * @param display_visible [in] Display visible
345 * @return This function returns zero on success, or negative value with error code.
346 * @pre wi-fi display state should be MM_WFD_SINK_STATE_NULL. \n
350 if (mm_wfd_sink_set_display_visible(g_wfd_sink, g_display_visible) != MM_ERROR_NONE)
352 wfd_sink_error("failed to set display visible for wi-fi display sink\n");
356 int mm_wfd_sink_set_display_visible(MMHandleType wfd_sink, gint display_visible);
359 * This function gets the width and height of video which is played by wi-fi display sink\n
361 * @param wfd_sink [in] Handle of wi-fi display sink
362 * @param width [in] Width of video
363 * @param height [in] Height of video
365 * @return This function returns zero on success, or negative value with error code.
366 * @pre wi-fi display state should be MM_WFD_SINK_STATE_PAUSED. \n
370 gint g_width=0, g_height=0;
372 if (mm_wfd_sink_get_video_resolution(g_wfd_sink, &g_width, &g_height) != MM_ERROR_NONE)
374 wfd_sink_error("failed to get video resolution.\n");
378 int mm_wfd_sink_get_video_resolution(MMHandleType wfd_sink, gint *width, gint *height );
381 * This function gets the width and height of video which is played by wi-fi display sink\n
383 * @param wfd_sink [in] Handle of wi-fi display sink
384 * @param framerate [in] Framerate of video
386 * @return This function returns zero on success, or negative value with error code.
387 * @pre wi-fi display state should be MM_WFD_SINK_STATE_PAUSED. \n
393 if (mm_wfd_sink_get_video_framerate(g_wfd_sink, &g_framerate) != MM_ERROR_NONE)
395 wfd_sink_error("failed to get video framerate.\n");
399 int mm_wfd_sink_get_video_framerate(MMHandleType wfd_sink, gint *framerate);