summaryrefslogtreecommitdiff
path: root/src/include/music.h
blob: 997c351d98845985e21670deb4a3446f278311a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
/*
 * Copyright 2012  Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.tizenopensource.org/license
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#ifndef __DEF_music_H_
#define __DEF_music_H_

#include <Elementary.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <glib.h>
#include <vconf.h>
#include <audio-svc.h>
#include <audio-svc-error.h>
#include <audio-svc-types.h>
#include <Ecore_IMF.h>
#include <Ecore_X.h>
#include <appcore-efl.h>
#include <Edje.h>
#include <errno.h>
#include <libintl.h>

#include <mm_error.h>
#include <mm_player.h>
#include <sys/times.h>

#include "mp-player-debug.h"
#include "mp-player-drm.h"
#include "mp-define.h"
#include "mp-play-list.h"
#include "mp-http-mgr.h"

typedef struct
{

	/* controlbar tab item */
	Elm_Object_Item *ctltab_songs;
	Elm_Object_Item *ctltab_plist;
	Elm_Object_Item *ctltab_album;
	Elm_Object_Item *ctltab_artist;
	Elm_Object_Item *ctltab_genres;
	Elm_Object_Item *ctltab_year;
	Elm_Object_Item *ctltab_composer;

	/* navi bar */
	Evas_Object *cur_view;	//navibar of current view

	//relative to music setting
	int albums;
	int artists;
	int genres;
	int composers;
	int years;
} mp_library;


typedef enum
{
	MP_VIEW_MODE_DEFAULT,
	MP_VIEW_MODE_EDIT,
	MP_VIEW_MODE_SEARCH,
} mp_view_mode_t;

typedef enum
{
	MP_VIEW_TYPE_SONGS,
	MP_VIEW_TYPE_PLAYLIST,
	MP_VIEW_TYPE_ALBUM,
	MP_VIEW_TYPE_GENRE,
	MP_VIEW_TYPE_ARTIST,
	MP_VIEW_TYPE_YEAR,
	MP_VIEW_TYPE_COMPOSER,
	MP_VIEW_TYPE_PLAYVIEW,
	MP_VIEW_TYPE_MAX,
} mp_view_type_t;



#define MP_VIEW_DATA_MAGIC	0x801211aa
#define MP_SET_VIEW_DATA_MAGIC(view_data)	((view_data_t *)view_data)->magic = MP_VIEW_DATA_MAGIC
#define MP_CHECK_VIEW_DATA(view_data)	\
do {                                                  \
	if (((view_data_t *)view_data)->magic != MP_VIEW_DATA_MAGIC) {        \
		ERROR_TRACE("\n###########      ERROR   CHECK  #############\nPARAM is not view_data\n###########      ERROR   CHECK  #############\n"); \
		mp_assert(FALSE);}            \
} while (0)

typedef struct
{
	int magic;
	Evas_Object *navibar;
	mp_view_type_t view_type;
	struct appdata *ad;	//appdata
} view_data_t;

typedef struct
{
	//EDJ Layout
	Evas_Object *layout;
	Evas_Object *content;
	Evas_Object *play_view;
	Evas_Object *play_control;
	Evas_Object *play_menu;	//information, srs, shuffle, repeat
	Evas_Object *play_info;
	Evas_Object *play_progressbar;
	Evas_Object *play_ctrl;	//progress bar and index, track name
	Evas_Object *play_title;
	Evas_Object *albumart_bg;

	int flick_direction;	//1 for right, 2 for left, other for invalid
	int albumart_width;
	int albumart_height;

	Evas_Object *play_view_next;
	char music_play_time_text[16];
	Ecore_Timer *progressbar_timer;
	Ecore_Timer *show_ctrl_timer;

	bool transition_state;

	struct music_list_item *playing_list_item;
	Evas_Object *play_icon;

	bool paused_by_progressbar;

	struct appdata *ad;
} mp_playing_view;

enum
{
	MP_CREATE_PLAYLIST_MODE_NONE,
	MP_CREATE_PLAYLIST_MODE_NEW,
	MP_CREATE_PLAYLIST_MODE_WITHMUSICS,
	MP_CREATE_PLAYLIST_MODE_SAVEAS,
	MP_CREATE_PLAYLIST_MODE_SWEEP
};

typedef struct
{
	AudioHandleType *plst;
	Elm_Object_Item *item;
	void *data;
} mp_playlist_item_t;

typedef enum
{
	MP_LAUNCH_DEFAULT = 0,
	MP_LAUNCH_PATH,
	MP_LAUNCH_PLAY_RECENT,
	MP_LAUNCH_PLAY_GROUP,
	MP_LAUNCH_PLAY_PLAYLIST,
	MP_LAUNCH_PLAY_SOMETHING,

} mp_launch_type;

typedef enum
{
	LOAD_DEFAULT,
	LOAD_TRACK,		//load by path
	LOAD_GROUP,
	LOAD_PLAYLIST,
	LOAD_PLAY,
	LOAD_MM_KEY,

} mp_load_type;

typedef enum
{
	MP_POPUP_NORAML = 0,
	MP_POPUP_GENLIST,
	MP_POPUP_CTX,
	MP_POPUP_PROGRESS,
	MP_POPUP_MAX,
} mp_popup_type;

typedef enum
{
	PLAY_STATE_INIT,
	PLAY_STATE_READY,
	PLAY_STATE_PLAYING,
	PLAY_STATE_PAUSED,
	PLAY_STATE_STOP
} mp_player_state;

typedef enum
{
	PLAY_REP_ALL,
	PLAY_REP_NON,
	PLAY_REP_1
} mp_player_rep_state;


struct appdata
{

	Evas *evas;
	Evas_Object *win_main;
	Evas_Object *bg;
	Evas_Object *popup[MP_POPUP_MAX];

	Ecore_X_Window xwin;

	/* Layout for each view */
	Evas_Object *base_layout_main;		//layout for transparent indicator area
	Evas_Object *controlbar_layout;		//layout for show hide controlbar.

	bool show_optional_menu;
	double music_pos;
	double music_length;
	Ecore_Timer *progressbar_timer;

	mp_playing_view *playing_view;


	// for Plalying Control
	mp_player_rep_state play_rep_state;	//repeat_all, repeat_non, repeat_1
	bool play_shuffle_state;	//shuffle on/off
	bool can_play_drm_contents;
	bool show_now_playing;

	mp_player_state player_state;

	mp_drm drm_info;
	char * latest_playing_key_id;
	mp_play_list *playing_list;

	mp_launch_type launch_type;
	mp_load_type loadtype;
	audio_svc_track_type_e track_type;
	audio_svc_group_type_e group_type;

	char *request_group_name;
	char *request_playing_path;
	audio_svc_group_type_e request_group_type;
	int request_play_id;
	//update default view layout if this flag set. set true when album/artist/genre short cut pressed.

	Ecore_IMF_Context *imf_context;
	mp_library *library;

	Evas_Object *ctrl_bar;

	Evas_Object *editfiled_new_playlist;
	Evas_Object *editfiled_entry;
	char *new_playlist_name;

	bool b_add_tracks;

	int new_playlist_id;

	Evas_Object *radio_group;
	Evas_Object *notify;
	Evas_Object *notify_layout;

	Evas_Object *popup_delete;
	Evas_Object *notify_delete;

	bool b_search_mode;
	Evas_Object *isf_entry;
	Evas_Object *editfield;

	bool freeze_indicator_icon;	//set it true to prevent flickering play icon of indicator.

	int ear_key_press_cnt;
	Ecore_Timer *ear_key_timer;

	//scale factor for scalable UI..
	double scale;		//scale factor;

	GList *view_history;
	Ecore_Pipe *inotify_pipe;

	void *layout_data;
	AudioHandleType *group_item_handler;
	char *fid;

	bool paused_by_user;

	mp_http_mgr_t *http_mgr;	//http mgr

	bool navi_effect_in_progress;	//Use this not to excute button callbacks while transition effect
	bool prohibit_aul_relaunch;	//aul relaunch only available when music is in pause state
	bool is_focus_out;

	mp_snd_path snd_path;	//indicate sound path;

	Ecore_Event_Handler *key_down;
	Ecore_Event_Handler *focus_in;
	Ecore_Event_Handler *focus_out;
	Ecore_Event_Handler *visibility_change;
	Ecore_Event_Handler *client_msg;

	Evas_Object *buffering_popup;

	bool edit_in_progress;	//don't update view in inotify callback while delete operation.

	Ecore_Timer *volume_down_timer;
	Ecore_Timer *mute_popup_show_timer;	//timer for showing mute popup
	bool volume_long_pressed;
	bool mute_flag;		//flag for mute

	double ff_rew;		//for ff and rew when there is no play view

	bool music_setting_change_flag;	//true for change music setting data, false for not

	bool load_play_view; /*set it true if play view must be displayed directly when app is launching*/

	bool is_Longpress;
	bool is_ff;

	Ecore_Idler *playing_err_idler;
	Ecore_Idler *bt_pause_idler;
	Ecore_Idler *setting_idler;
	Ecore_Idler *app_init_idler;

	Ecore_Timer *longpress_timer;
	Ecore_Timer *live_pos_timer;
	bool seek_off;

	int haptic_handle;
	Ecore_Timer *vib_timer;
	Ecore_Pipe *player_msg_pipe;

	Ecore_Animator *minfo_ani;
	GList *minfo_list;
	Evas_Object *minfo_genlist;

	MediaSvcHandle *media_svc_handle;
};

#endif /* __DEF_music_H__ */