From 499664bbfa646b6280553d1dc2dfb71db8c2e4d9 Mon Sep 17 00:00:00 2001 From: Maksym Veremeyenko Date: Wed, 22 Jun 2011 14:22:53 +0300 Subject: [PATCH] omneon content requesting added --- src/library.c | 14 ++++++++++++++ src/omnplay.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ src/omnplay.h | 4 ++++ 3 files changed, 61 insertions(+), 0 deletions(-) diff --git a/src/library.c b/src/library.c index 4e8695d..3152eca 100644 --- a/src/library.c +++ b/src/library.c @@ -132,8 +132,22 @@ void omnplay_library_save(omnplay_instance_t* app) pthread_mutex_unlock(&app->library.lock); }; +static void omnplay_get_content_cb(omnplay_instance_t* app, playlist_item_t* item, void* data) +{ + fprintf(stderr, "requested: id=[%s]\n", item->id); +}; + void omnplay_library_refresh(omnplay_instance_t* app) { + int count; + playlist_item_t* items; + + + items = (playlist_item_t*)malloc(sizeof(playlist_item_t) * MAX_LIBRARY_ITEMS); + + count = omnplay_get_content(app, items, MAX_LIBRARY_ITEMS, omnplay_get_content_cb, NULL); + + free(items); }; void omnplay_library_draw(omnplay_instance_t* app) diff --git a/src/omnplay.cpp b/src/omnplay.cpp index 5535828..2912ecd 100644 --- a/src/omnplay.cpp +++ b/src/omnplay.cpp @@ -39,6 +39,49 @@ #include "omplrclnt.h" +int omnplay_get_content(omnplay_instance_t* app, playlist_item_t *items, int limit, + omnplay_get_content_cb_proc proc, void* data) +{ + int r, c = 0; + OmPlrClipInfo clip_info; + char clip_name[omPlrMaxClipDirLen]; + + pthread_mutex_lock(&app->players.lock); + + r = OmPlrClipGetFirst((OmPlrHandle)app->players.item[0].handle, clip_name, sizeof(clip_name)); + for(; c < limit && !r;) + { + /* get clip info */ + clip_info.maxMsTracks = 0; + clip_info.size = sizeof(clip_info); + + r = OmPlrClipGetInfo((OmPlrHandle)app->players.item[0].handle, clip_name, &clip_info); + + if(!r) + { + /* copy item props */ + strncpy(items[c].id, clip_name, PATH_MAX); + items[c].in = clip_info.firstFrame; + items[c].dur = clip_info.lastFrame - clip_info.firstFrame; + + /* callback */ + pthread_mutex_unlock(&app->players.lock); + if(proc) + proc(app, &items[c], data); + pthread_mutex_lock(&app->players.lock); + + c++; + }; + + r = OmPlrClipGetNext((OmPlrHandle)app->players.item[0].handle, clip_name, sizeof(clip_name)); + }; + + pthread_mutex_unlock(&app->players.lock); + + return c; +}; + + static gboolean on_main_window_delete_event( GtkWidget *widget, GdkEvent *event, gpointer user_data ) { gtk_exit(0); diff --git a/src/omnplay.h b/src/omnplay.h index 9cceb61..e36e862 100644 --- a/src/omnplay.h +++ b/src/omnplay.h @@ -163,6 +163,10 @@ void omnplay_library_load(omnplay_instance_t* app); void omnplay_library_save(omnplay_instance_t* app); void omnplay_library_refresh(omnplay_instance_t* app); void omnplay_library_draw(omnplay_instance_t* app); +typedef void (*omnplay_get_content_cb_proc)(omnplay_instance_t* app, playlist_item_t *items, void* data); +int omnplay_get_content(omnplay_instance_t* app, playlist_item_t *items, int limit, + omnplay_get_content_cb_proc proc, void* data); + #ifdef __cplusplus }; -- 1.7.4.4