summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2018-01-04 08:25:18 -0800
committerTadao Tanikawa <tanikawa.tadao@jp.panasonic.com>2018-01-04 16:55:14 +0000
commit5aea105d4bbd371ed08e0f6c88f30659240969b4 (patch)
tree1fd09694d1785b97c22f2a494ed969df5e629d9f
parent4eefbe0ab828b71abab511ba2d276d870fcc1f25 (diff)
binding: mediaplayer: allow selection of audio or video playlistsandbox/ruke47/ces2018
Some clients may not want or need both audio and video media in the the returned playlist. Allow them to select audio, video, or both playlists. Bug-AGL: SPEC-1236 Change-Id: I4cdd45c21b7ea7343d48f8ffd0d323ae637b3199 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--binding/media-api.c20
-rw-r--r--binding/media-manager.h8
2 files changed, 22 insertions, 6 deletions
diff --git a/binding/media-api.c b/binding/media-api.c
index 892f67d..2e5c103 100644
--- a/binding/media-api.c
+++ b/binding/media-api.c
@@ -126,12 +126,28 @@ static json_object *new_json_object_from_device(GList *list)
static void media_results_get (struct afb_req request)
{
+ const char *value = afb_req_value(request, "value");
GList *list = NULL;
json_object *jresp = NULL;
+ int scan_type = 0;
ListLock();
- list = media_lightmediascanner_scan(list, NULL, LMS_AUDIO_SCAN);
- list = media_lightmediascanner_scan(list, NULL, LMS_VIDEO_SCAN);
+
+ if (!value || !strcasecmp(value, "both")) {
+ scan_type = LMS_AUDIO_SCAN | LMS_VIDEO_SCAN;
+ } else {
+ if (!strcasecmp(value, "audio"))
+ scan_type = LMS_AUDIO_SCAN;
+ else if (!strcasecmp(value, "video"))
+ scan_type = LMS_VIDEO_SCAN;
+ }
+
+ if (scan_type & LMS_AUDIO_SCAN)
+ list = media_lightmediascanner_scan(list, NULL, LMS_AUDIO_SCAN);
+
+ if (scan_type & LMS_VIDEO_SCAN)
+ list = media_lightmediascanner_scan(list, NULL, LMS_VIDEO_SCAN);
+
if (list == NULL) {
afb_req_fail(request, "failed", "media scan error");
ListUnlock();
diff --git a/binding/media-manager.h b/binding/media-manager.h
index 2190a16..f5b28fb 100644
--- a/binding/media-manager.h
+++ b/binding/media-manager.h
@@ -130,9 +130,9 @@ struct Media_Item {
} metadata;
};
-enum {
- LMS_AUDIO_SCAN,
- LMS_VIDEO_SCAN,
-};
+#define BIT(x) (1<<x)
+
+#define LMS_AUDIO_SCAN BIT(0)
+#define LMS_VIDEO_SCAN BIT(1)
#endif