2 * Copyright (C) 2016 "IoT.bzh"
3 * Author "Manuel Bachmann"
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "media-api.h"
21 /* ------ LOCAL HELPER FUNCTIONS --------- */
23 /* private client context creation ; default values */
24 STATIC mediaCtxHandleT* initMediaCtx () {
28 ctx = malloc (sizeof(mediaCtxHandleT));
29 ctx->media_server = NULL;
34 /* called when client session dies [e.g. client quits for more than 15mns] */
35 STATIC void freeMedia (void *context, void *handle) {
40 /* ------ PUBLIC PLUGIN FUNCTIONS --------- */
42 STATIC json_object* init (AFB_request *request) { /* AFB_SESSION_CHECK */
46 /* create a private client context */
47 if (!request->context)
48 request->context = initMediaCtx();
50 /* initialize server connection */
51 _rygel_init (request->context);
53 jresp = json_object_new_object();
54 json_object_object_add(jresp, "info", json_object_new_string ("Media initialized"));
58 STATIC json_object* list (AFB_request *request) { /* AFB_SESSION_CHECK */
62 result = _rygel_list (request->context);
64 return jsonNewMessage(AFB_SUCCESS, result);
67 STATIC json_object* ping (AFB_request *request) { /* AFB_SESSION_NONE */
68 return jsonNewMessage(AFB_SUCCESS, "Ping Binder Daemon - Media API");
72 STATIC AFB_restapi pluginApis[]= {
73 {"init" , AFB_SESSION_CHECK, (AFB_apiCB)init , "Media API - init"},
74 {"list" , AFB_SESSION_CHECK, (AFB_apiCB)list , "Media API - list"},
75 {"ping" , AFB_SESSION_NONE, (AFB_apiCB)ping , "Media API - ping"},
79 PUBLIC AFB_plugin* pluginRegister () {
80 AFB_plugin *plugin = malloc (sizeof(AFB_plugin));
81 plugin->type = AFB_PLUGIN_JSON;
82 plugin->info = "Application Framework Binder - Media plugin";
83 plugin->prefix = "media";
84 plugin->apis = pluginApis;
86 /*plugin->handle = initRadioPlugin();*/
87 plugin->freeCtxCB = (AFB_freeCtxCB)freeMedia;