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_PREPARED
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_PREPARED
109 * @post wi-fi display sink state will be MM_WFD_SINK_STATE_CONNECTED 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_CONNECTED.
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 pause playing. \n
146 * The wi-fi display sink pause the current stream being received form wi-fi display source. \n
148 * @param wfd_sink [in] Handle of wi-fi display sink
150 * @return This function returns zero on success, or negative value with error code.
153 * @pre wi-fi display sink state should be MM_WFD_SINK_STATE_PLAYING.
154 * @post wi-fi display sink state will be MM_WFD_SINK_STATE_PAUSED.
155 * @see mm_wfd_sink_pause
159 if (mm_wfd_sink_pause(g_wfd_sink) != MM_ERROR_NONE)
161 wfd_sink_error("failed to pause wi-fi display sink\n");
165 int mm_wfd_sink_pause(MMHandleType wfd_sink);
168 * This function is to resume playing. \n
169 * Data from wi-fi display source will be received. \n
171 * @param wfd_sink [in] Handle of wi-fi display sink
173 * @return This function returns zero on success, or negative value with error code.
176 * @pre wi-fi display sink state may be MM_WFD_SINK_STATE_PAUSED.
177 * @post wi-fi display sink state will be MM_WFD_SINK_STATE_PLAYING.
178 * @see mm_wfd_sink_disconnect
182 if (mm_wfd_sink_start(g_wfd_sink) != MM_ERROR_NONE)
184 wfd_sink_error("failed to resume wi-fi display sink\n");
188 int mm_wfd_sink_resume(MMHandleType wfd_sink);
191 * This function is to stop playing wi-fi display. \n
193 * @param wfd_sink [in] Handle of wi-fi display sink
195 * @return This function returns zero on success, or negative value with error code.
197 * @pre wi-fi display sink state may be MM_WFD_SINK_STATE_PLAYING.
198 * @post wi-fi display sink state will be MM_WFD_SINK_STATE_DISCONNECTED.
199 * @see mm_wfd_sink_start
203 if (mm_wfd_sink_disconnect(g_wfd_sink) != MM_ERROR_NONE)
205 wfd_sink_error("failed to stop wi-fi display sink\n");
209 int mm_wfd_sink_disconnect(MMHandleType wfd_sink);
212 * This function trys to destroy gstreamer pipeline. \n
214 * @param wfd_sink [out] Handle of wi-fi display sink
216 * @return This function returns zero on success, or negative value with error code. \n
217 * Please refer 'mm_error.h' to know it in detail.
218 * @pre wi-fi display sink state may be MM_WFD_SINK_STATE_PREPARED or MM_WFD_SINK_STATE_DISCONNECTED.
219 * But, it can be called in any state.
220 * @post MM_WFD_SINK_STATE_NULL
221 * @see mm_wfd_sink_prepare
225 if (mm_wfd_sink_unprepare(&g_wfd_sink) != MM_ERROR_NONE)
227 wfd_sink_error("failed to unprepare wi-fi display sink\n");
231 int mm_wfd_sink_unprepare(MMHandleType wfd_sink);
234 * This function releases wi-fi display sink object and all resources which were created by mm_wfd_sink_create(). \n
235 * And, wi-fi display sink handle will also be destroyed. \n
237 * @param wfd_sink [in] Handle of wi-fi display sink
239 * @return This function returns zero on success, or negative value with error code.
240 * @pre wi-fi display state may be MM_WFD_SINK_STATE_NULL. \n
241 * But, it can be called in any state.
242 * @post Because handle is released, there is no any state.
243 * @see mm_wfd_sink_create
244 * @remark This method can be called with a valid wi-fi display sink handle from any state to \n
245 * completely shutdown the wi-fi display sink operation.
249 if (mm_wfd_sink_destroy(g_wfd_sink) != MM_ERROR_NONE)
251 wfd_sink_error("failed to destroy wi-fi display sink\n");
255 int mm_wfd_sink_destroy(MMHandleType wfd_sink);
258 * This function sets callback function for receiving messages from wi-fi display sink. \n
259 * So, player can notify warning, error and normal cases to application. \n
261 * @param wfd_sink [in] Handle of wi-fi display sink
262 * @param callback [in] Message callback function.
263 * @param user_param [in] User parameter which is passed to callback function.
265 * @return This function returns zero on success, or negative value with error code.
266 * @see MMWFDMessageCallback
271 int msg_callback(int error_type, MMWFDSinkStateType state_type, void *user_data)
275 case MM_WFD_SINK_STATE_NULL:
279 case MM_WFD_SINK_STATE_PREPARED:
283 case MM_WFD_SINK_STATE_CONNECTED:
287 case MM_WFD_SINK_STATE_PLAYING:
291 case MM_WFD_SINK_STATE_PAUSED:
295 case MM_WFD_SINK_DISCONNECTED:
305 mm_wfd_sink_set_message_callback(g_wfd_sink, msg_callback, (void*)g_wfd_sink);
308 int mm_wfd_sink_set_message_callback(MMHandleType wfd_sink, MMWFDMessageCallback callback, void *user_param);
310 int mm_wfd_sink_set_attribute(MMHandleType wfd_sink, char **err_attr_name, const char *first_attribute_name, ...);
313 * This function get resources \n
315 * @param wfd_sink [in] Handle of wi-fi display sink
317 * @return This function returns zero on success, or negative value with error code.
318 * @pre wi-fi display state should be MM_WFD_SINK_STATE_READY or MM_WFD_SINK_STATE_PREPARED. \n
320 * @remark resources are released when mm_wfd_sink_destory is called
324 if (mm_wfd_sink_get_resource(g_wfd_sink) != MM_ERROR_NONE)
326 wfd_sink_error("failed to get resources for wi-fi display sink\n");
330 int mm_wfd_sink_get_resource(MMHandleType wfd_sink);
333 * This function sets the display surface type for wi-fi display sink\n
335 * @param wfd_sink [in] Handle of wi-fi display sink
336 * @param display_surface_type [in] Display surface type
338 * @return This function returns zero on success, or negative value with error code.
339 * @pre wi-fi display state should be MM_WFD_SINK_STATE_NULL. \n
343 if (mm_wfd_sink_set_display_surface_type(g_wfd_sink, g_display_surface_type) != MM_ERROR_NONE)
345 wfd_sink_error("failed to set display surface type for wi-fi display sink\n");
349 int mm_wfd_sink_set_display_surface_type(MMHandleType wfd_sink, gint display_surface_type);
352 * This function sets the display overlay for wi-fi display sink\n
354 * @param wfd_sink [in] Handle of wi-fi display sink
355 * @param display_overlay [in] Display overlay
357 * @return This function returns zero on success, or negative value with error code.
358 * @pre wi-fi display state should be MM_WFD_SINK_STATE_NULL. \n
362 if (mm_wfd_sink_set_display_overlay(g_wfd_sink, g_display_overlay) != MM_ERROR_NONE)
364 wfd_sink_error("failed to set display overlay for wi-fi display sink\n");
368 int mm_wfd_sink_set_display_overlay(MMHandleType wfd_sink, void *display_overlay);
371 * This function sets the display method for wi-fi display sink\n
373 * @param wfd_sink [in] Handle of wi-fi display sink
374 * @param display_method [in] Display method
376 * @return This function returns zero on success, or negative value with error code.
377 * @pre wi-fi display state should be MM_WFD_SINK_STATE_NULL. \n
381 if (mm_wfd_sink_set_display_method(g_wfd_sink, g_display_method) != MM_ERROR_NONE)
383 wfd_sink_error("failed to set display method for wi-fi display sink\n");
387 int mm_wfd_sink_set_display_method(MMHandleType wfd_sink, gint display_method);
390 * This function sets the display visible for wi-fi display sink\n
392 * @param wfd_sink [in] Handle of wi-fi display sink
393 * @param display_visible [in] Display visible
395 * @return This function returns zero on success, or negative value with error code.
396 * @pre wi-fi display state should be MM_WFD_SINK_STATE_NULL. \n
400 if (mm_wfd_sink_set_display_visible(g_wfd_sink, g_display_visible) != MM_ERROR_NONE)
402 wfd_sink_error("failed to set display visible for wi-fi display sink\n");
406 int mm_wfd_sink_set_display_visible(MMHandleType wfd_sink, gint display_visible);
409 * This function gets the width and height of video which is played by wi-fi display sink\n
411 * @param wfd_sink [in] Handle of wi-fi display sink
412 * @param width [in] Width of video
413 * @param height [in] Height of video
415 * @return This function returns zero on success, or negative value with error code.
416 * @pre wi-fi display state should be MM_WFD_SINK_STATE_CONNECTED or MM_WFD_SINK_STATE_PLAYING. \n
420 gint g_width=0, g_height=0;
422 if (mm_wfd_sink_get_video_resolution(g_wfd_sink, &g_width, &g_height) != MM_ERROR_NONE)
424 wfd_sink_error("failed to get video resolution.\n");
428 int mm_wfd_sink_get_video_resolution(MMHandleType wfd_sink, gint *width, gint *height);
431 * This function gets the width and height of video which is played by wi-fi display sink\n
433 * @param wfd_sink [in] Handle of wi-fi display sink
434 * @param framerate [in] Framerate of video
436 * @return This function returns zero on success, or negative value with error code.
437 * @pre wi-fi display state should be MM_WFD_SINK_STATE_CONNECTED or MM_WFD_SINK_STATE_PLAYING. \n
443 if (mm_wfd_sink_get_video_framerate(g_wfd_sink, &g_framerate) != MM_ERROR_NONE)
445 wfd_sink_error("failed to get video framerate.\n");
449 int mm_wfd_sink_get_video_framerate(MMHandleType wfd_sink, gint *framerate);
452 * This function sets the resolutions for wi-fi display sink\n
454 * @param wfd_sink [in] Handle of wi-fi display sink
455 * @param resolution [in] Resolutions for wi-fi display sink
457 * @return This function returns zero on success, or negative value with error code.
458 * @pre wi-fi display state should be MM_WFD_SINK_STATE_NULL. \n
461 int mm_wfd_sink_set_resolution(MMHandleType wfd_sink, gint resolution);