2 * Copyright (C) 2016 "IoT.bzh"
3 * Author "Manuel Bachmann"
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 /* --------------- MEDIA RYGEL DEFINITIONS ------------------ */
24 #include <json-c/json.h>
25 #include <libgupnp/gupnp-control-point.h>
26 #include <libgupnp-av/gupnp-av.h>
28 #include "media-api.h"
30 #define URN_MEDIA_SERVER "urn:schemas-upnp-org:device:MediaServer:1"
31 #define URN_MEDIA_RENDERER "urn:schemas-upnp-org:device:MediaRenderer:1"
32 #define URN_CONTENT_DIR "urn:schemas-upnp-org:service:ContentDirectory"
33 #define URN_AV_TRANSPORT "urn:schemas-upnp-org:service:AVTransport"
35 typedef enum { PLAY, PAUSE, STOP, SEEK } State;
36 typedef struct dev_ctx dev_ctx_T;
40 GUPnPContext *context;
41 GUPnPDeviceInfo *device_info;
42 GUPnPServiceInfo *content_dir;
43 GUPnPServiceInfo *av_transport;
50 unsigned char transfer_started;
53 unsigned char _rygel_init (mediaCtxHandleT *);
54 void _rygel_free (mediaCtxHandleT *);
55 json_object* _rygel_list (mediaCtxHandleT *);
56 unsigned char _rygel_select (mediaCtxHandleT *, unsigned int);
57 unsigned char _rygel_upload (mediaCtxHandleT *, char *);
58 unsigned char _rygel_do (mediaCtxHandleT *, State, char *);
60 char* _rygel_list_raw (dev_ctx_T *, unsigned int *);
61 char* _rygel_find_upload_id (dev_ctx_T *, char *);
62 char* _rygel_find_id_for_index (dev_ctx_T *, char *, unsigned int);
63 char* _rygel_find_metadata_for_id (dev_ctx_T *, char *);
64 char* _rygel_find_uri_for_metadata (dev_ctx_T *, char *);
65 unsigned char _rygel_start_uploading (dev_ctx_T *, char *, char *);
66 unsigned char _rygel_start_doing (dev_ctx_T *, char *, char *, State, char *);
67 unsigned char _rygel_find_av_transport (dev_ctx_T *);
68 static void _rygel_device_cb (GUPnPControlPoint *, GUPnPDeviceProxy *, gpointer);
69 static void _rygel_av_transport_cb (GUPnPControlPoint *, GUPnPDeviceProxy *, gpointer);
70 static void _rygel_content_cb (GUPnPServiceProxy *, GUPnPServiceProxyAction *, gpointer);
71 static void _rygel_metadata_cb (GUPnPServiceProxy *, GUPnPServiceProxyAction *, gpointer);
72 static void _rygel_select_cb (GUPnPServiceProxy *, GUPnPServiceProxyAction *, gpointer);
73 static void _rygel_upload_cb (GUPnPServiceProxy *, GUPnPServiceProxyAction *, gpointer);
74 static void _rygel_transfer_cb (GUPnPServiceProxy *, GUPnPServiceProxyAction *, gpointer);
75 static void _rygel_do_cb (GUPnPServiceProxy *, GUPnPServiceProxyAction *, gpointer);
77 static unsigned int client_count = 0;
78 static struct dev_ctx **dev_ctx = NULL;
80 #endif /* MEDIA_RYGEL_H */