diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2017-08-07 20:05:22 -0700 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2017-08-07 20:19:28 -0700 |
commit | 50c1f859444b27010d56401c4310b266131dcc97 (patch) | |
tree | 1c5de1ab96e7f1dd8a09ebde844fe95de85735f0 | |
parent | 059eb5b736d154e01d2a35fd27ca157d7de51a7a (diff) |
binding: media: switch to v2 binding format
Update functions and structure to use the new version 2
of the afm binder framework
Change-Id: I052da8c34bd45641325bc889f0234221f382d062
Bug-AGL: SPEC-812
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r-- | binding/export.map | 2 | ||||
-rw-r--r-- | binding/mediaplayer-api.c | 44 |
2 files changed, 20 insertions, 26 deletions
diff --git a/binding/export.map b/binding/export.map index 52c1b4a..eea0d7b 100644 --- a/binding/export.map +++ b/binding/export.map @@ -1 +1 @@ -{ global: afbBindingV1*; local: *; }; +{ global: afbBindingV2*; local: *; }; diff --git a/binding/mediaplayer-api.c b/binding/mediaplayer-api.c index 08372ad..e81c98a 100644 --- a/binding/mediaplayer-api.c +++ b/binding/mediaplayer-api.c @@ -20,12 +20,12 @@ #include <stdlib.h> #include <unistd.h> #include <json-c/json.h> + +#define AFB_BINDING_VERSION 2 #include <afb/afb-binding.h> #include "mediaplayer-manager.h" -const struct afb_binding_interface *afbitf; - static struct afb_event media_added_event; static struct afb_event media_removed_event; @@ -139,41 +139,35 @@ static void media_broadcast_device_removed (const char *obj_path) afb_event_push(media_removed_event, jresp); } -static const struct afb_verb_desc_v1 binding_verbs[] = { - { "media_result", AFB_SESSION_CHECK, media_results_get, "Media scan result" }, - { "subscribe", AFB_SESSION_CHECK, subscribe, "Subscribe for an event" }, - { "unsubscribe", AFB_SESSION_CHECK, unsubscribe, "Unsubscribe for an event" }, +static const struct afb_verb_v2 binding_verbs[] = { + { "media_result", media_results_get, NULL, "Media scan result", AFB_SESSION_CHECK }, + { "subscribe", subscribe, NULL, "Subscribe for an event", AFB_SESSION_CHECK }, + { "unsubscribe", unsubscribe, NULL, "Unsubscribe for an event", AFB_SESSION_CHECK }, { NULL } }; -static const struct afb_binding binding_description = { - .type = AFB_BINDING_VERSION_1, - .v1 = { - .prefix = "media-manager", - .info = "mediaplayer API", - .verbs = binding_verbs, - } -}; - -const struct afb_binding -*afbBindingV1Register(const struct afb_binding_interface *itf) +static int preinit() { - afbitf = itf; - 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); - MediaPlayerManagerInit(); - - return &binding_description; + return MediaPlayerManagerInit(); } -int afbBindingV1ServiceInit(struct afb_service service) +static int init() { - media_added_event = afb_daemon_make_event(afbitf->daemon, "media_added"); - media_removed_event = afb_daemon_make_event(afbitf->daemon, "media_removed"); + media_added_event = afb_daemon_make_event("media_added"); + media_removed_event = afb_daemon_make_event("media_removed"); return 0; } + +const struct afb_binding_v2 afbBindingV2 = { + .api = "media-manager", + .specification = "mediaplayer API", + .preinit = preinit, + .init = init, + .verbs = binding_verbs, +}; |