53bbe867ea260282e58f9ed0d9d2971c4239415d
[profile/ivi/renderer-service-upnp.git] / src / device.h
1 /*
2  * renderer-service-upnp
3  *
4  * Copyright (C) 2012 Intel Corporation. All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU Lesser General Public License,
8  * version 2.1, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
13  * for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Mark Ryan <mark.d.ryan@intel.com>
20  *
21  */
22
23 #ifndef RSU_DEVICE_H__
24 #define RSU_DEVICE_H__
25
26 #include <gio/gio.h>
27 #include <glib.h>
28
29 #include "host-service.h"
30 #include "upnp.h"
31
32 typedef struct rsu_device_t_ rsu_device_t;
33
34 typedef struct rsu_service_proxies_t_ rsu_service_proxies_t;
35 struct rsu_service_proxies_t_ {
36         GUPnPServiceProxy *cm_proxy;
37         GUPnPServiceProxy *av_proxy;
38         GUPnPServiceProxy *rc_proxy;
39 };
40
41 typedef struct rsu_device_context_t_ rsu_device_context_t;
42 struct rsu_device_context_t_ {
43         gchar *ip_address;
44         GUPnPDeviceProxy *device_proxy;
45         rsu_service_proxies_t service_proxies;
46         rsu_device_t *device;
47         gboolean subscribed_av;
48         gboolean subscribed_cm;
49         gboolean subscribed_rc;
50         guint timeout_id_av;
51         guint timeout_id_cm;
52         guint timeout_id_rc;
53 };
54
55 typedef struct rsu_props_t_ rsu_props_t;
56 struct rsu_props_t_ {
57         GHashTable *root_props;
58         GHashTable *player_props;
59         gboolean synced;
60 };
61
62 struct rsu_device_t_ {
63         GDBusConnection *connection;
64         guint ids[RSU_INTERFACE_INFO_MAX];
65         gchar *path;
66         GPtrArray *contexts;
67         gpointer current_task;
68         rsu_props_t props;
69         guint timeout_id;
70 };
71
72 gboolean rsu_device_new(GDBusConnection *connection,
73                         GUPnPDeviceProxy *proxy,
74                         const gchar *ip_address,
75                         guint counter,
76                         rsu_interface_info_t *interface_info,
77                         void *user_data,
78                         rsu_device_t **device);
79
80 void rsu_device_delete(void *device);
81
82 void rsu_device_append_new_context(rsu_device_t *device,
83                                    const gchar *ip_address,
84                                    GUPnPDeviceProxy *proxy);
85 rsu_device_t *rsu_device_from_path(const gchar *path, GHashTable *device_list);
86 rsu_device_context_t *rsu_device_get_context(rsu_device_t *device);
87 void rsu_device_subscribe_to_service_changes(rsu_device_t *device);
88
89 void rsu_device_get_prop(rsu_device_t *device, rsu_task_t *task,
90                         GCancellable *cancellable,
91                         rsu_upnp_task_complete_t cb,
92                         void *user_data);
93 void rsu_device_get_all_props(rsu_device_t *device, rsu_task_t *task,
94                               GCancellable *cancellable,
95                               rsu_upnp_task_complete_t cb,
96                               void *user_data);
97 void rsu_device_play(rsu_device_t *device, rsu_task_t *task,
98                      GCancellable *cancellable,
99                      rsu_upnp_task_complete_t cb,
100                      void *user_data);
101 void rsu_device_pause(rsu_device_t *device, rsu_task_t *task,
102                      GCancellable *cancellable,
103                      rsu_upnp_task_complete_t cb,
104                      void *user_data);
105 void rsu_device_play_pause(rsu_device_t *device, rsu_task_t *task,
106                            GCancellable *cancellable,
107                            rsu_upnp_task_complete_t cb,
108                            void *user_data);
109 void rsu_device_stop(rsu_device_t *device, rsu_task_t *task,
110                      GCancellable *cancellable,
111                      rsu_upnp_task_complete_t cb,
112                      void *user_data);
113 void rsu_device_next(rsu_device_t *device, rsu_task_t *task,
114                      GCancellable *cancellable,
115                      rsu_upnp_task_complete_t cb,
116                      void *user_data);
117 void rsu_device_previous(rsu_device_t *device, rsu_task_t *task,
118                          GCancellable *cancellable,
119                          rsu_upnp_task_complete_t cb,
120                          void *user_data);
121 void rsu_device_open_uri(rsu_device_t *device, rsu_task_t *task,
122                          GCancellable *cancellable,
123                          rsu_upnp_task_complete_t cb,
124                          void *user_data);
125 void rsu_device_seek(rsu_device_t *device, rsu_task_t *task,
126                      GCancellable *cancellable,
127                      rsu_upnp_task_complete_t cb,
128                      void *user_data);
129 void rsu_device_set_position(rsu_device_t *device, rsu_task_t *task,
130                              GCancellable *cancellable,
131                              rsu_upnp_task_complete_t cb,
132                              void *user_data);
133 void rsu_device_host_uri(rsu_device_t *device, rsu_task_t *task,
134                          rsu_host_service_t *host_service,
135                          GCancellable *cancellable,
136                          rsu_upnp_task_complete_t cb,
137                          void *user_data);
138 void rsu_device_remove_uri(rsu_device_t *device, rsu_task_t *task,
139                            rsu_host_service_t *host_service,
140                            GCancellable *cancellable,
141                            rsu_upnp_task_complete_t cb,
142                            void *user_data);
143
144 #endif