summaryrefslogtreecommitdiffstats
path: root/binding/media-api.c
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2018-10-19 14:32:26 +0200
committerMatt Ranostay <matt.ranostay@konsulko.com>2018-10-20 23:25:06 +0100
commit0f1b9ab89114da646c3626e752efbb86600c731d (patch)
treeb72abb70ccbe4e97fac8a06957f34466f7290f3d /binding/media-api.c
parentb208ad43cc1797c558adc49d3fe39fb199964aad (diff)
binding: mediascanner: upgrade binding to afb version 3
Change-Id: Ieec8a71a815eeed02ecd5e17429bb81e84b0a9b5 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding/media-api.c')
-rw-r--r--binding/media-api.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/binding/media-api.c b/binding/media-api.c
index 065b258..d02ad93 100644
--- a/binding/media-api.c
+++ b/binding/media-api.c
@@ -21,13 +21,13 @@
#include <unistd.h>
#include <json-c/json.h>
-#define AFB_BINDING_VERSION 2
+#define AFB_BINDING_VERSION 3
#include <afb/afb-binding.h>
#include "media-manager.h"
-static struct afb_event media_added_event;
-static struct afb_event media_removed_event;
+static afb_event_t media_added_event;
+static afb_event_t media_removed_event;
/*
* @brief Subscribe for an event
@@ -35,7 +35,7 @@ static struct afb_event media_removed_event;
* @param struct afb_req : an afb request structure
*
*/
-static void subscribe(struct afb_req request)
+static void subscribe(afb_req_t request)
{
const char *value = afb_req_value(request, "value");
if(value) {
@@ -57,7 +57,7 @@ static void subscribe(struct afb_req request)
* @param struct afb_req : an afb request structure
*
*/
-static void unsubscribe(struct afb_req request)
+static void unsubscribe(afb_req_t request)
{
const char *value = afb_req_value(request, "value");
if(value) {
@@ -127,7 +127,7 @@ static json_object *new_json_object_from_device(GList *list)
return jresp;
}
-static void media_results_get (struct afb_req request)
+static void media_results_get (afb_req_t request)
{
GList *list = NULL;
json_object *jresp = NULL;
@@ -172,35 +172,29 @@ static void media_broadcast_device_removed (const char *obj_path)
afb_event_push(media_removed_event, jresp);
}
-static const struct afb_verb_v2 binding_verbs[] = {
+static const afb_verb_t binding_verbs[] = {
{ .verb = "media_result", .callback = media_results_get, .info = "Media scan result" },
{ .verb = "subscribe", .callback = subscribe, .info = "Subscribe for an event" },
{ .verb = "unsubscribe", .callback = unsubscribe, .info = "Unsubscribe for an event" },
{ }
};
-static int preinit()
+static int init(afb_api_t api)
{
Binding_RegisterCallback_t API_Callback;
API_Callback.binding_device_added = media_broadcast_device_added;
API_Callback.binding_device_removed = media_broadcast_device_removed;
BindingAPIRegister(&API_Callback);
- return MediaPlayerManagerInit();
-}
-
-static int init()
-{
media_added_event = afb_daemon_make_event("media_added");
media_removed_event = afb_daemon_make_event("media_removed");
- return 0;
+ return MediaPlayerManagerInit();
}
-const struct afb_binding_v2 afbBindingV2 = {
+const afb_binding_t afbBindingV3 = {
.api = "mediascanner",
.specification = "mediaplayer API",
- .preinit = preinit,
.init = init,
.verbs = binding_verbs,
};