2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __TIZEN_MEDIA_PLAYER_PRIVATE_H__
18 #define __TIZEN_MEDIA_PLAYER_PRIVATE_H__
19 #include <tbm_bufmgr.h>
20 #include <media_format.h>
21 #include <muse_player.h>
32 #define LOG_TAG "TIZEN_N_PLAYER"
34 #define PLAYER_CHECK_CONDITION(condition, error, msg) \
36 if (condition) {} else \
37 { LOGE("[%s] %s(0x%08x)", __FUNCTION__, msg, error); return error; } \
40 #define PLAYER_INSTANCE_CHECK(player) \
41 PLAYER_CHECK_CONDITION(player != NULL, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER")
43 #define PLAYER_STATE_CHECK(player, expected_state) \
45 player_state_e __state; \
46 if (_get_current_state(player, &__state) != PLAYER_ERROR_NONE) { \
47 LOGE("Failed to get state"); \
48 return PLAYER_ERROR_INVALID_OPERATION; \
50 PLAYER_CHECK_CONDITION(__state == expected_state, PLAYER_ERROR_INVALID_STATE, "PLAYER_ERROR_INVALID_STATE"); \
53 #define PLAYER_NULL_ARG_CHECK(arg) \
54 PLAYER_CHECK_CONDITION((arg), PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER")
56 #define PLAYER_VIDEO_SUPPORTABLE_CHECK(p) \
58 if (p && !p->support_video) { \
59 LOGW("video display interface is not supported"); \
60 return PLAYER_ERROR_INVALID_OPERATION; \
64 #define PLAYER_FEATURE_CHECK(fkey) \
66 bool __supported__ = false; \
67 if (system_info_get_platform_bool(fkey, &__supported__) != SYSTEM_INFO_ERROR_NONE) { \
68 LOGE("failed to get system feature info"); \
69 return PLAYER_ERROR_INVALID_OPERATION; \
71 if (!__supported__) { \
72 LOGW("feature is not supported."); \
73 return PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE; \
77 #define CONNECTION_RETRY 51
78 #define CONNECTION_TIME_OUT 50 /* ms */
79 #define CREATE_CB_TIME_OUT 400 /* ms */
80 #define CALLBACK_TIME_OUT 5000 /* ms */
81 #define MAX_SERVER_TIME_OUT 35000 /* ms */
82 #define MAX_URL_LEN 2048 /**< Maximum length of the maximum URL */
85 * @brief Enumeration for private display type
88 PLAYER_PRIVATE_DISPLAY_TYPE_OVERLAY = 0, /**< Overlay surface display */
89 PLAYER_PRIVATE_DISPLAY_TYPE_EVAS, /**< Evas image object surface display */
90 PLAYER_PRIVATE_DISPLAY_TYPE_NONE, /**< This disposes off buffers */
91 } player_private_display_type_e;
94 PLAYER_SEEK_CB_STATE_NONE,
95 PLAYER_SEEK_CB_STATE_DROP,
96 PLAYER_SEEK_CB_STATE_WAIT,
97 } player_seek_cb_state_e;
99 typedef struct _ret_msg_s {
102 struct _ret_msg_s *next;
109 ret_msg_s *retMsgHead;
110 gchar *part_of_msg; /* keep msg till we receive the hole msg */
113 typedef struct _player_data {
115 struct _player_data *next;
126 GMutex idle_ev_mutex;
128 } player_event_queue;
133 } player_tsurf_info_t;
134 #ifdef TIZEN_FEATURE_EVAS_RENDERER
137 EVAS_VISIBLE_NONE, /* if user dont set visibility, it will be changed to true */
144 visible_info_e visible;
145 player_display_rotation_e rotation;
146 player_display_mode_e mode;
147 gboolean update_needed;
152 gboolean support_video;
153 } player_evas_info_s;
155 typedef struct _callback_cb_info {
160 gpointer user_cb[MUSE_PLAYER_EVENT_TYPE_NUM];
161 gpointer user_data[MUSE_PLAYER_EVENT_TYPE_NUM];
163 GCond player_cond[MUSE_PLAYER_API_MAX];
164 GCond server_ack_cond;
166 player_seek_cb_state_e seek_cb_state;
167 GMutex seek_cb_mutex;
169 player_event_queue event_queue;
170 media_format_h pkt_fmt;
171 #ifdef TIZEN_FEATURE_EVAS_RENDERER
172 player_evas_info_s *evas_info;
175 tbm_fd tfd; /* for player_get_album_art*/
176 GList *tsurf_list; /* player_tsurf_info_t */
177 int video_frame_pool_size;
179 } callback_cb_info_s;
183 gint timeout; /* ms */
186 typedef struct _player_cli_s {
187 callback_cb_info_s *cb_info;
189 server_info_s server;
190 void *dl_handle; /* dlopen handle for display interface */
191 gboolean have_evas_callback;
192 gboolean push_media_stream;
193 gboolean support_video;
194 gboolean is_audio_only;
197 /* player callback information */
198 #define CALLBACK_INFO(h) ((h)->cb_info)
199 /* MSG Channel socket fd */
200 #define MSG_FD(h) (CALLBACK_INFO(h)->fd)
201 /* Data Channel socket fd */
202 #define DATA_FD(h) (CALLBACK_INFO(h)->data_fd)
203 /* TBM buffer manager */
204 #define TBM_BUFMGR(h) (CALLBACK_INFO(h)->bufmgr)
205 #ifdef TIZEN_FEATURE_EVAS_RENDERER
206 /* evas display handle */
207 #define EVAS_INFO(h) ((h)->cb_info->evas_info)
208 #define EVAS_HANDLE(h) (EVAS_INFO(h)->handle)
211 #define SERVER_TBM_BO(h) ((h)->server.bo)
212 /* server state change timeout (sec) */
213 #define SERVER_TIMEOUT(h) ((h)->server.timeout)
216 #define PATH_DISP_LIB PATH_LIBDIR"/libcapi-media-player-display.so"
218 #define PLAYER_DISP_DLOPEN(pc) \
220 pc->dl_handle = dlopen(PATH_DISP_LIB, RTLD_LAZY); \
221 if (pc->dl_handle == NULL) { \
222 LOGW("not support video rendering"); \
224 pc->support_video = TRUE; \
225 EVAS_INFO(pc)->support_video = TRUE; \
229 #define PLAYER_DISP_DLSYM(handle, sym, function_name) \
232 sym = dlsym(handle, function_name); \
233 if ((error = dlerror()) != NULL) { \
235 LOGE("dlsym error %s", error); \
239 #define PLAYER_DISP_DLCLOSE(handle) \
247 int client_get_api_timeout(player_cli_s *pc, muse_player_api_e api);
248 int client_wait_for_cb_return(muse_player_api_e api, callback_cb_info_s *cb_info, char **ret_buf, int time_out);
249 int _player_convert_display_type(player_display_type_e type, player_private_display_type_e *out_type);
250 int _player_get_valid_path(const char *uri, char *origin);
255 #endif /*__TIZEN_MEDIA_PLAYER_PRIVATE_H__*/