Add sound manager initial source code
[staging/soundmanager.git] / sample / mediaplayer / binding / mediaplayer-manager.h
1 /*
2  *  Copyright 2017 Konsulko Group
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 MEDIAPLAYER_MANAGER_H
18 #define MEDIAPLAYER_MANAGER_H
19
20 #include <glib.h>
21 #include <gio/gio.h>
22 #include <glib-object.h>
23
24 #include "lightmediascanner_interface.h"
25
26     /* Debug Trace Level */
27 #define DT_LEVEL_ERROR          (1 << 1)
28 #define DT_LEVEL_WARNING        (1 << 2)
29 #define DT_LEVEL_NOTICE         (1 << 3)
30 #define DT_LEVEL_INFO           (1 << 4)
31 #define DT_LEVEL_DEBUG          (1 << 5)
32 //#define _DEBUG
33
34 #define LOGE(fmt, args...)   \
35     DebugTraceSendMsg(DT_LEVEL_ERROR, g_strdup_printf("[%d:%s]" fmt, __LINE__, __FUNCTION__, ## args))
36 #define LOGW(fmt, args...)   \
37     DebugTraceSendMsg(DT_LEVEL_WARNING, g_strdup_printf("[%d:%s]" fmt, __LINE__, __FUNCTION__, ## args))
38 #define LOGN(fmt, args...)   \
39     DebugTraceSendMsg(DT_LEVEL_NOTICE,  g_strdup_printf("[%d:%s]" fmt, __LINE__, __FUNCTION__, ## args))
40 #define LOGI(fmt, args...)   \
41     DebugTraceSendMsg(DT_LEVEL_INFO, g_strdup_printf("[%d:%s]" fmt, __LINE__, __FUNCTION__, ## args))
42 #define LOGD(fmt, args...)   \
43     DebugTraceSendMsg(DT_LEVEL_DEBUG,  g_strdup_printf("[%d:%s]" fmt, __LINE__, __FUNCTION__, ## args))
44
45 #ifdef _DEBUG
46  #define _DEBUG_PRINT_DBUS
47  #define LOCAL_PRINT_DEBUG
48 #endif
49
50 #ifdef LOCAL_PRINT_DEBUG
51 #define D_PRINTF(fmt, args...) \
52         g_print("[DEBUG][%d:%s]"fmt,  __LINE__, __FUNCTION__, ## args)
53 #define D_PRINTF_RAW(fmt, args...) \
54         g_print(""fmt, ## args)
55 #else
56 #define D_PRINTF(fmt, args...)
57 #define D_PRINTF_RAW(fmt, args...)
58 #endif  /* ifdef _DEBUG */
59
60 void DebugTraceSendMsg(int level, gchar* message);
61
62 //service
63 #define AGENT_SERVICE               "org.agent"
64
65 //remote service
66 #define LIGHTMEDIASCANNER_SERVICE   "org.lightmediascanner"
67
68 //object path
69 #define LIGHTMEDIASCANNER_PATH      "/org/lightmediascanner/Scanner1"
70
71 //interface
72 #define LIGHTMEDIASCANNER_INTERFACE "org.lightmediascanner.Scanner1"
73 #define UDISKS_INTERFACE            "org.freedesktop.UDisks"
74 #define FREEDESKTOP_PROPERTIES      "org.freedesktop.DBus.Properties"
75
76 //sqlite
77 #define SQL_QUERY "SELECT files.path FROM files LEFT JOIN audios " \
78                   "WHERE audios.id = files.id ORDER BY " \
79                   "audios.artist_id, audios.album_id, audios.trackno"
80
81 typedef struct {
82     GList *list;
83     GMutex m;
84     Scanner1 *lms_proxy;
85 } stMediaPlayerManage;
86
87 typedef struct tagBinding_RegisterCallback
88 {
89     void (*binding_device_added)(GList *list);
90     void (*binding_device_removed)(const char *obj_path);
91 } Binding_RegisterCallback_t;
92
93 /* ------ PUBLIC PLUGIN FUNCTIONS --------- */
94 void BindingAPIRegister(const Binding_RegisterCallback_t* pstRegisterCallback);
95 int MediaPlayerManagerInit(void);
96
97 void ListLock();
98 void ListUnlock();
99
100 GList* media_lightmediascanner_scan(void);
101 GList* media_local_scan(GList *list);
102
103 #endif