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_RANGE_ARG_CHECK(arg, min, max) \
58 PLAYER_CHECK_CONDITION(arg >= min, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER"); \
59 PLAYER_CHECK_CONDITION(arg <= max, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER"); \
62 #define PLAYER_VIDEO_SUPPORTABLE_CHECK(p) \
64 if (p && !p->support_video) { \
65 LOGW("video display interface is not supported"); \
66 return PLAYER_ERROR_INVALID_OPERATION; \
70 #define PLAYER_FEATURE_CHECK(fkey) \
72 bool __supported__ = false; \
73 if (system_info_get_platform_bool(fkey, &__supported__) != SYSTEM_INFO_ERROR_NONE) { \
74 LOGE("failed to get system feature info"); \
75 return PLAYER_ERROR_INVALID_OPERATION; \
77 if (!__supported__) { \
78 LOGW("feature is not supported."); \
79 return PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE; \
83 #define CONNECTION_RETRY 51
84 #define CONNECTION_TIME_OUT 50 /* ms */
85 #define CREATE_CB_TIME_OUT 400 /* ms */
86 #define CALLBACK_TIME_OUT 5000 /* ms */
87 #define MAX_SERVER_TIME_OUT 35000 /* ms */
88 #define MAX_URL_LEN 2048 /**< Maximum length of the maximum URL */
89 #define MAX_SUPPORTED_MEDIA_FORMAT 10
92 * @brief Enumeration for private display type
95 PLAYER_PRIVATE_DISPLAY_TYPE_OVERLAY = 0, /**< Overlay surface display */
96 PLAYER_PRIVATE_DISPLAY_TYPE_EVAS, /**< Evas image object surface display */
97 PLAYER_PRIVATE_DISPLAY_TYPE_NONE, /**< This disposes off buffers */
98 } player_private_display_type_e;
101 PLAYER_SEEK_CB_STATE_NONE,
102 PLAYER_SEEK_CB_STATE_DROP,
103 PLAYER_SEEK_CB_STATE_WAIT,
104 } player_seek_cb_state_e;
106 typedef struct _ret_msg_s {
109 struct _ret_msg_s *next;
116 ret_msg_s *retMsgHead;
117 gchar *part_of_msg; /* keep msg till we receive the hole msg */
120 typedef struct _player_data {
122 struct _player_data *next;
133 GMutex idle_ev_mutex;
135 } player_event_queue;
140 } player_tsurf_info_t;
141 #ifdef TIZEN_FEATURE_EVAS_RENDERER
144 EVAS_VISIBLE_NONE, /* if user dont set visibility, it will be changed to true */
151 visible_info_e visible;
152 player_display_rotation_e rotation;
153 player_display_mode_e mode;
154 gboolean update_needed;
159 gboolean support_video;
160 } player_evas_info_s;
162 typedef struct _callback_cb_info {
167 gpointer user_cb[MUSE_PLAYER_EVENT_TYPE_NUM];
168 gpointer user_data[MUSE_PLAYER_EVENT_TYPE_NUM];
170 GCond player_cond[MUSE_PLAYER_API_MAX];
171 GCond server_ack_cond;
173 player_seek_cb_state_e seek_cb_state;
174 GMutex seek_cb_mutex;
176 player_event_queue event_queue;
177 media_format_h pkt_fmt;
178 #ifdef TIZEN_FEATURE_EVAS_RENDERER
179 player_evas_info_s *evas_info;
182 tbm_fd tfd; /* for player_get_album_art*/
183 GList *tsurf_list; /* player_tsurf_info_t */
184 int video_frame_pool_size;
186 } callback_cb_info_s;
190 gint timeout; /* ms */
193 typedef struct _player_cli_s {
194 callback_cb_info_s *cb_info;
196 server_info_s server;
197 void *dl_handle; /* dlopen handle for display interface */
198 gboolean have_evas_callback;
199 gboolean push_media_stream;
200 gboolean support_video;
201 gboolean is_audio_only;
205 void *data; /**< PCM data */
206 int size; /**< Data Size */
207 int channel; /**< Channel */
208 int rate; /**< Samplerate */
209 unsigned long long channel_mask; /**< channel_mask */
210 media_format_mimetype_e pcm_format;
211 } player_audio_decoded_data_info_t;
213 /* player callback information */
214 #define CALLBACK_INFO(h) ((h)->cb_info)
215 /* MSG Channel socket fd */
216 #define MSG_FD(h) (CALLBACK_INFO(h)->fd)
217 /* Data Channel socket fd */
218 #define DATA_FD(h) (CALLBACK_INFO(h)->data_fd)
219 /* TBM buffer manager */
220 #define TBM_BUFMGR(h) (CALLBACK_INFO(h)->bufmgr)
221 #ifdef TIZEN_FEATURE_EVAS_RENDERER
222 /* evas display handle */
223 #define EVAS_INFO(h) ((h)->cb_info->evas_info)
224 #define EVAS_HANDLE(h) (EVAS_INFO(h)->handle)
227 #define SERVER_TBM_BO(h) ((h)->server.bo)
228 /* server state change timeout (sec) */
229 #define SERVER_TIMEOUT(h) ((h)->server.timeout)
232 #define PATH_DISP_LIB PATH_LIBDIR"/libcapi-media-player-display.so"
234 #define PLAYER_DISP_DLOPEN(pc) \
236 pc->dl_handle = dlopen(PATH_DISP_LIB, RTLD_LAZY); \
237 if (pc->dl_handle == NULL) { \
238 LOGW("not support video rendering"); \
240 pc->support_video = TRUE; \
241 EVAS_INFO(pc)->support_video = TRUE; \
245 #define PLAYER_DISP_DLSYM(handle, sym, function_name) \
248 sym = dlsym(handle, function_name); \
249 if ((error = dlerror()) != NULL) { \
251 LOGE("dlsym error %s", error); \
255 #define PLAYER_DISP_DLCLOSE(handle) \
263 int client_get_api_timeout(player_cli_s *pc, muse_player_api_e api);
264 int client_wait_for_cb_return(muse_player_api_e api, callback_cb_info_s *cb_info, char **ret_buf, int time_out);
265 int _player_convert_display_type(player_display_type_e type, player_private_display_type_e *out_type);
266 int _player_get_valid_path(const char *uri, char *origin);
271 #endif /*__TIZEN_MEDIA_PLAYER_PRIVATE_H__*/