From: Maksym Veremeyenko Date: Mon, 20 Jun 2011 09:10:37 +0000 (+0300) Subject: check id before play and fix timecode range if required X-Git-Url: http://research.m1stereo.tv/gitweb?a=commitdiff_plain;h=386a21c04d1086d643ae1b23e5e7cfd92b15b3e7;p=omnplay check id before play and fix timecode range if required --- diff --git a/src/omnplay.cpp b/src/omnplay.cpp index 1f947ee..9604791 100644 --- a/src/omnplay.cpp +++ b/src/omnplay.cpp @@ -279,13 +279,36 @@ static void omnplay_ctl(omnplay_instance_t* app, control_buttons_t button) /* Attach clips to timeline */ for(i = start, c = 0, o = 0; i <= stop; i++) { - unsigned int l; + OmPlrClipInfo clip; - r = OmPlrAttach((OmPlrHandle)player->handle, - app->playlist.item[i].id, - app->playlist.item[i].in, - app->playlist.item[i].in + app->playlist.item[i].dur, - 0, omPlrShiftModeAfter, &l); + /* get clip info */ + clip.maxMsTracks = 0; + clip.size = sizeof(clip); + r = OmPlrClipGetInfo((OmPlrHandle)player->handle, app->playlist.item[i].id, &clip); + + if(!r) + { + unsigned int l; + + fprintf(stderr, "OmPlrClipGetInfo(%s): firstFrame=%d, lastFrame=%d\n", + app->playlist.item[i].id, clip.firstFrame, clip.lastFrame); + + /* should we fix playlist clip timings */ + if((! + app->playlist.item[i].in >= clip.firstFrame && + app->playlist.item[i].in + app->playlist.item[i].dur <= clip.lastFrame)) + { + app->playlist.item[i].in = clip.firstFrame; + app->playlist.item[i].dur = clip.lastFrame - clip.firstFrame; + omnplay_playlist_draw_item(app, i); + }; + + r = OmPlrAttach((OmPlrHandle)player->handle, + app->playlist.item[i].id, + app->playlist.item[i].in, + app->playlist.item[i].in + app->playlist.item[i].dur, + 0, omPlrShiftModeAfter, &l); + }; if(r) { diff --git a/src/omnplay.h b/src/omnplay.h index 33f8d75..b9edff3 100644 --- a/src/omnplay.h +++ b/src/omnplay.h @@ -148,6 +148,7 @@ void omnplay_destroy(omnplay_instance_t* app); void omnplay_playlist_load(omnplay_instance_t* app); void omnplay_playlist_save(omnplay_instance_t* app); void omnplay_playlist_draw(omnplay_instance_t* app); +void omnplay_playlist_draw_item(omnplay_instance_t* app, int idx); #ifdef __cplusplus }; diff --git a/src/playlist.c b/src/playlist.c index 0fece7b..ffe7524 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -222,3 +222,7 @@ void omnplay_playlist_draw(omnplay_instance_t* app) pthread_mutex_unlock(&app->playlist.lock); }; + +void omnplay_playlist_draw_item(omnplay_instance_t* app, int idx) +{ +};