X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=plugins%2Fmedia%2Fmedia-rygel.c;h=003277955e81d57dbc34a56b67ac10f3c0d5bcf0;hb=39c2ebc125fcc694ac349ae196b62729c7f05037;hp=32969b2d1e572461874e52bcea2fb86e522fc98d;hpb=ae8e72788e8f2db33efea6045e5ee835266b10eb;p=src%2Fapp-framework-binder.git diff --git a/plugins/media/media-rygel.c b/plugins/media/media-rygel.c index 32969b2d..00327795 100644 --- a/plugins/media/media-rygel.c +++ b/plugins/media/media-rygel.c @@ -2,27 +2,43 @@ * Copyright (C) 2016 "IoT.bzh" * Author "Manuel Bachmann" * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * http://www.apache.org/licenses/LICENSE-2.0 * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * 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. */ +#define _GNU_SOURCE +#include +#include + #include "media-api.h" +#include "media-rygel.h" + +static void _rygel_device_cb (GUPnPControlPoint *, GUPnPDeviceProxy *, gpointer); +static void _rygel_av_transport_cb (GUPnPControlPoint *, GUPnPDeviceProxy *, gpointer); +static void _rygel_content_cb (GUPnPServiceProxy *, GUPnPServiceProxyAction *, gpointer); +static void _rygel_metadata_cb (GUPnPServiceProxy *, GUPnPServiceProxyAction *, gpointer); +static void _rygel_select_cb (GUPnPServiceProxy *, GUPnPServiceProxyAction *, gpointer); +static void _rygel_upload_cb (GUPnPServiceProxy *, GUPnPServiceProxyAction *, gpointer); +static void _rygel_transfer_cb (GUPnPServiceProxy *, GUPnPServiceProxyAction *, gpointer); +static void _rygel_do_cb (GUPnPServiceProxy *, GUPnPServiceProxyAction *, gpointer); + +static unsigned int client_count = 0; +static struct dev_ctx **dev_ctx = NULL; /* -------------- MEDIA RYGEL IMPLEMENTATION ---------------- */ /* --- PUBLIC FUNCTIONS --- */ -PUBLIC unsigned char _rygel_init (mediaCtxHandleT *ctx) { +unsigned char _rygel_init (mediaCtxHandleT *ctx) { GMainContext *loop; GUPnPContext *context; @@ -73,7 +89,7 @@ PUBLIC unsigned char _rygel_init (mediaCtxHandleT *ctx) { return 1; } -PUBLIC void _rygel_free (mediaCtxHandleT *ctx) { +void _rygel_free (mediaCtxHandleT *ctx) { dev_ctx_T *dev_ctx_c = (dev_ctx_T*)ctx->media_server; @@ -88,7 +104,7 @@ PUBLIC void _rygel_free (mediaCtxHandleT *ctx) { dev_ctx_c->content_res = NULL; } -PUBLIC json_object* _rygel_list (mediaCtxHandleT *ctx) { +json_object* _rygel_list (mediaCtxHandleT *ctx) { dev_ctx_T *dev_ctx_c = (dev_ctx_T*)ctx->media_server; json_object *json_o, *json_a; @@ -139,7 +155,7 @@ PUBLIC json_object* _rygel_list (mediaCtxHandleT *ctx) { return json_o; } -PUBLIC unsigned char _rygel_select (mediaCtxHandleT *ctx, unsigned int index) { +unsigned char _rygel_select (mediaCtxHandleT *ctx, unsigned int index) { dev_ctx_T *dev_ctx_c = (dev_ctx_T*)ctx->media_server; unsigned int count; @@ -157,7 +173,7 @@ PUBLIC unsigned char _rygel_select (mediaCtxHandleT *ctx, unsigned int index) { return 1; } -PUBLIC unsigned char _rygel_upload (mediaCtxHandleT *ctx, char *path) { +unsigned char _rygel_upload (mediaCtxHandleT *ctx, const char *path, void (*oncompletion)(void*,int), void *closure) { dev_ctx_T *dev_ctx_c = (dev_ctx_T*)ctx->media_server; char *raw, *upload_id; @@ -172,10 +188,10 @@ PUBLIC unsigned char _rygel_upload (mediaCtxHandleT *ctx, char *path) { /* for now, we always use the same upload container id */ upload_id = _rygel_find_upload_id (dev_ctx_c, raw); - return _rygel_start_uploading (dev_ctx_c, path, upload_id); + return _rygel_start_uploading (dev_ctx_c, strdup(path), upload_id); } -PUBLIC unsigned char _rygel_do (mediaCtxHandleT *ctx, State state, char *args) { +unsigned char _rygel_do (mediaCtxHandleT *ctx, State state, char *args) { dev_ctx_T *dev_ctx_c = (dev_ctx_T*)ctx->media_server; unsigned int index = ctx->index; @@ -198,7 +214,7 @@ PUBLIC unsigned char _rygel_do (mediaCtxHandleT *ctx, State state, char *args) { /* --- LOCAL HELPER FUNCTIONS --- */ -STATIC char* _rygel_list_raw (dev_ctx_T* dev_ctx_c, unsigned int *count) { +char* _rygel_list_raw (dev_ctx_T* dev_ctx_c, unsigned int *count) { GUPnPServiceProxy *content_dir_proxy; struct timeval tv_start, tv_now; @@ -231,7 +247,7 @@ STATIC char* _rygel_list_raw (dev_ctx_T* dev_ctx_c, unsigned int *count) { return dev_ctx_c->content_res; } -STATIC char* _rygel_find_upload_id (dev_ctx_T* dev_ctx_c, char *raw) { +char* _rygel_find_upload_id (dev_ctx_T* dev_ctx_c, char *raw) { char *found; char id[33]; @@ -246,7 +262,7 @@ STATIC char* _rygel_find_upload_id (dev_ctx_T* dev_ctx_c, char *raw) { return strdup (id); } -STATIC char* _rygel_find_id_for_index (dev_ctx_T* dev_ctx_c, char *raw, unsigned int index) { +char* _rygel_find_id_for_index (dev_ctx_T* dev_ctx_c, char *raw, unsigned int index) { char *found = raw; char id[33]; @@ -266,7 +282,7 @@ STATIC char* _rygel_find_id_for_index (dev_ctx_T* dev_ctx_c, char *raw, unsigned return strdup (id); } -STATIC char* _rygel_find_metadata_for_id (dev_ctx_T* dev_ctx_c, char *id) { +char* _rygel_find_metadata_for_id (dev_ctx_T* dev_ctx_c, char *id) { GUPnPServiceProxy *content_dir_proxy; struct timeval tv_start, tv_now; @@ -298,7 +314,7 @@ STATIC char* _rygel_find_metadata_for_id (dev_ctx_T* dev_ctx_c, char *id) { return dev_ctx_c->content_res; } -STATIC char* _rygel_find_uri_for_metadata (dev_ctx_T* dev_ctx_c, char *metadata) { +char* _rygel_find_uri_for_metadata (dev_ctx_T* dev_ctx_c, char *metadata) { char *start, *end, *uri = NULL; int length; @@ -326,7 +342,7 @@ STATIC char* _rygel_find_uri_for_metadata (dev_ctx_T* dev_ctx_c, char *metadata) return uri; } -STATIC char * _rygel_time_for_string (char *string) { +char * _rygel_time_for_string (char *string) { int total_seconds; unsigned int hours, minutes, seconds; @@ -342,7 +358,7 @@ STATIC char * _rygel_time_for_string (char *string) { return time; } -STATIC unsigned char _rygel_start_uploading (dev_ctx_T* dev_ctx_c, char *path, char *upload_id) { +unsigned char _rygel_start_uploading (dev_ctx_T* dev_ctx_c, char *path, char *upload_id) { GUPnPServiceProxy *content_dir_proxy; GUPnPDIDLLiteWriter *didl_writer; @@ -397,7 +413,7 @@ STATIC unsigned char _rygel_start_uploading (dev_ctx_T* dev_ctx_c, char *path, c return 1; } -STATIC unsigned char _rygel_start_doing (dev_ctx_T* dev_ctx_c, char *uri, char *metadata, State state, char *args) { +unsigned char _rygel_start_doing (dev_ctx_T* dev_ctx_c, char *uri, char *metadata, State state, char *args) { GUPnPServiceProxy *av_transport_proxy; struct timeval tv_start, tv_now; @@ -432,7 +448,7 @@ STATIC unsigned char _rygel_start_doing (dev_ctx_T* dev_ctx_c, char *uri, char * return 1; } -STATIC unsigned char _rygel_find_av_transport (dev_ctx_T* dev_ctx_c) { +unsigned char _rygel_find_av_transport (dev_ctx_T* dev_ctx_c) { GUPnPControlPoint *control_point; gint handler_cb; @@ -466,7 +482,7 @@ STATIC unsigned char _rygel_find_av_transport (dev_ctx_T* dev_ctx_c) { /* ---- LOCAL CALLBACK FUNCTIONS ---- */ -STATIC void _rygel_device_cb (GUPnPControlPoint *point, GUPnPDeviceProxy *proxy, +static void _rygel_device_cb (GUPnPControlPoint *point, GUPnPDeviceProxy *proxy, gpointer data) { mediaCtxHandleT *ctx = (mediaCtxHandleT*)data; @@ -498,7 +514,7 @@ STATIC void _rygel_device_cb (GUPnPControlPoint *point, GUPnPDeviceProxy *proxy, ctx->media_server = (void*)dev_ctx[client_count]; } -STATIC void _rygel_av_transport_cb (GUPnPControlPoint *point, GUPnPDeviceProxy *proxy, +static void _rygel_av_transport_cb (GUPnPControlPoint *point, GUPnPDeviceProxy *proxy, gpointer data) { dev_ctx_T *dev_ctx_c = (dev_ctx_T*)data; @@ -511,7 +527,7 @@ STATIC void _rygel_av_transport_cb (GUPnPControlPoint *point, GUPnPDeviceProxy * dev_ctx_c->av_transport = av_transport; } -STATIC void _rygel_content_cb (GUPnPServiceProxy *content_dir, GUPnPServiceProxyAction *action, +static void _rygel_content_cb (GUPnPServiceProxy *content_dir, GUPnPServiceProxyAction *action, gpointer data) { dev_ctx_T *dev_ctx_c = (dev_ctx_T*)data; @@ -554,7 +570,7 @@ STATIC void _rygel_content_cb (GUPnPServiceProxy *content_dir, GUPnPServiceProxy } } -STATIC void _rygel_metadata_cb (GUPnPServiceProxy *content_dir, GUPnPServiceProxyAction *action, +static void _rygel_metadata_cb (GUPnPServiceProxy *content_dir, GUPnPServiceProxyAction *action, gpointer data) { dev_ctx_T *dev_ctx_c = (dev_ctx_T*)data; @@ -568,7 +584,7 @@ STATIC void _rygel_metadata_cb (GUPnPServiceProxy *content_dir, GUPnPServiceProx dev_ctx_c->content_res = result; } -STATIC void _rygel_select_cb (GUPnPServiceProxy *av_transport, GUPnPServiceProxyAction *action, +static void _rygel_select_cb (GUPnPServiceProxy *av_transport, GUPnPServiceProxyAction *action, gpointer data) { @@ -622,7 +638,7 @@ STATIC void _rygel_select_cb (GUPnPServiceProxy *av_transport, GUPnPServiceProxy } } -STATIC void _rygel_upload_cb (GUPnPServiceProxy *content_dir, GUPnPServiceProxyAction *action, +static void _rygel_upload_cb (GUPnPServiceProxy *content_dir, GUPnPServiceProxyAction *action, gpointer data) { dev_ctx_T *dev_ctx_c = (dev_ctx_T*)data; @@ -676,7 +692,7 @@ STATIC void _rygel_upload_cb (GUPnPServiceProxy *content_dir, GUPnPServiceProxyA } } -STATIC void _rygel_transfer_cb (GUPnPServiceProxy *content_dir, GUPnPServiceProxyAction *action, +static void _rygel_transfer_cb (GUPnPServiceProxy *content_dir, GUPnPServiceProxyAction *action, gpointer data) { dev_ctx_T *dev_ctx_c = (dev_ctx_T*)data; @@ -691,7 +707,7 @@ STATIC void _rygel_transfer_cb (GUPnPServiceProxy *content_dir, GUPnPServiceProx dev_ctx_c->transfer_started = 1; } -STATIC void _rygel_do_cb (GUPnPServiceProxy *av_transport, GUPnPServiceProxyAction *action, +static void _rygel_do_cb (GUPnPServiceProxy *av_transport, GUPnPServiceProxyAction *action, gpointer data) { dev_ctx_T *dev_ctx_c = (dev_ctx_T*)data;