Initial Commit.
[profile/tv/apps/native/musicplayer.git] / include / music-controller.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef __MUSIC_CONTROLLER_H__
18 #define __MUSIC_CONTROLLER_H__
19
20
21 #include <Eina.h>
22 //#include <usb-device.h>
23
24 struct SSongInfo;
25 struct album_info;
26
27
28 class IMusicControllerListener {
29 private:
30         static void sm_CbComplete(void *cookie);
31         static void sm_CbError(void *cookie);
32         static void sm_CbUsbConnected(void *cookie);
33         static void sm_CbUpdateContent(void *cookie);
34
35 protected:
36         virtual void t_OnComplete(void) = 0;
37         virtual void t_OnError(void) = 0;
38         virtual void t_OnUsbConnected(void) = 0;
39         virtual void t_OnUpdateContent(void) = 0;
40 };
41
42
43 class CMusicController {
44 private:
45         static CMusicController *instance;
46         static int refCnt;
47         struct SMusicController *m;
48
49 private:
50
51         enum EDirectionType {
52                 DIR_PREVIOUS,
53                 DIR_NEXT
54         };
55
56         enum ENextType {
57                 E_ON_COMPLETE,
58                 E_BUTTON_CLICK
59         };
60 private:
61         CMusicController() {}
62         virtual ~CMusicController() {}
63
64 private:
65         static void sm_CbPlaybackCompletion(void *data);
66         void m_OnPlaybackCompletion(void);
67
68         //static void sm_CbConnected(usb_device_h usb_device, char *action, void *dt);
69         //void m_OnConnected(usb_device_h usb_device, char *action);
70
71 protected:
72         bool t_PlayNext(int direction, int playnext_type);
73         SMusicController* t_Create(void);
74         void t_Destroy(void);
75
76 public:
77         static bool Initialize(void);
78         static void Finalize(void);
79
80         static CMusicController* GetInstance(void);
81
82         bool Start(void);
83         bool Stop(void);
84         bool Resume(void);
85         bool Pause(void);
86
87         bool AddListener(IMusicControllerListener *listener);
88         bool RemoveListener(IMusicControllerListener *listener);
89
90         bool GetCurrentSongIndex(int *ind);
91         bool SetCurrentSongIndex(int ind);
92         bool GetTotalSongs(int *ts);
93         bool GetSonginfoFromIndex(int index, struct SSongInfo **const csinfo);
94
95         int PlayState(void);
96         bool SetPlayState(int state);
97
98         int ShuffleState(void);
99         bool SetShuffleState(int state);
100
101         int RepeatState(void);
102         bool SetRepeatState(int state);
103
104         int SourceType(void);
105         int SortType(void);
106
107         bool SetSourceType(int type);
108         bool SetSortType(int type);
109         bool SetPosition(int milsec);
110         bool GetPosition(int *const milseconds);
111
112         bool SetCurrentSong(char *mediaid);
113
114         bool GetCurrentSong(struct SSongInfo **const sinfo);
115         bool SetCurrentAlbum(struct album_info *alinfo);
116
117         struct album_info *CurrentAlbum(void);
118
119         bool UpdatePlaylist(Eina_List *slist, int addmode);
120         bool EmptyPlaylist(void);
121         bool PlaylistUpdateShuffle(void);
122         bool PlayPreviousSong(void);
123         bool PlayNextSong(void);
124         bool PlayIndexSong(int index);
125         bool RemoveSong(struct SSongInfo *sinfo, int index);
126         bool CheckUsb(void);
127
128         bool MediaGetList(int EListType, void *info, Eina_List **list);
129         bool MediaInsertPlaylist(const char *name, Eina_List *idlist);
130         bool MediaExistPlaylist(const char *name);
131         bool MediaDeletePlaylist(int id);
132         bool MediaRenamePlaylist(int id, const char *name);
133         bool MediaAddmediaPlaylist(int id, Eina_List *idlist);
134         bool MediaRemovemediaPlaylist(int id, Eina_List *idlist);
135         bool MediaAddsongsPlaylist(int lid, Eina_List *list);
136         struct SSongInfo *MediaSongByUri(char *uri);
137 };
138
139
140
141 #endif /*__MUSIC_CONTROLLER_H__*/