#include "omnplay.h"
#include "ui.h"
#include "opts.h"
+#include "timecode.h"
#include "omplrclnt.h"
-static char* frames2tc( int f, float fps, char* buf )
-{
- int tc[4] = { 0, 0, 0, 0 };
- float d;
- int t;
-
- if ( fps && f >= 0)
- {
- d = f / fps;
- t = d;
-
- tc[0] = (d - t) * fps;
- tc[1] = t % 60; t /= 60;
- tc[2] = t % 60; t /= 60;
- tc[3] = t % 24;
- }
-
- sprintf(buf, "%.2d:%.2d:%.2d:%.2d", tc[3], tc[2], tc[1], tc[0]);
-
- return buf;
-}
-
-
static gboolean on_main_window_delete_event( GtkWidget *widget, GdkEvent *event, gpointer user_data )
{
gtk_exit(0);
omnplay_player_t* player = (omnplay_player_t*)data;
/* connect */
- pthread_mutex_lock(&player->lock);
+ pthread_mutex_lock(&player->app->players.lock);
r = OmPlrOpen(player->host, player->name, (OmPlrHandle*)&player->handle);
- pthread_mutex_unlock(&player->lock);
+ pthread_mutex_unlock(&player->app->players.lock);
if(r)
{
fprintf(stderr, "ERROR: OmPlrOpen(%s, %s) failed with 0x%.8X\n",
};
/* setup to do not reconnect */
- pthread_mutex_lock(&player->lock);
+ pthread_mutex_lock(&player->app->players.lock);
OmPlrSetRetryOpen((OmPlrHandle)player->handle, 0);
- pthread_mutex_unlock(&player->lock);
+ pthread_mutex_unlock(&player->app->players.lock);
/* setup directory */
if(player->app->players.path[0])
{
- pthread_mutex_lock(&player->lock);
+ pthread_mutex_lock(&player->app->players.lock);
// r = OmPlrClipSetDirectory((OmPlrHandle)player->handle, player->app->players.path);
- pthread_mutex_unlock(&player->lock);
+ pthread_mutex_unlock(&player->app->players.lock);
if(r)
{
fprintf(stderr, "ERROR: OmPlrClipSetDirectory(%s) failed with 0x%.8X\n",
player->app->players.path, r);
- pthread_mutex_lock(&player->lock);
+ pthread_mutex_lock(&player->app->players.lock);
OmPlrClose((OmPlrHandle)player->handle);
- pthread_mutex_unlock(&player->lock);
+ pthread_mutex_unlock(&player->app->players.lock);
return (void*)r;
};
usleep(100000);
/* get status */
- pthread_mutex_lock(&player->lock);
+ pthread_mutex_lock(&player->app->players.lock);
st_curr.size = sizeof(OmPlrStatus);
r = OmPlrGetPlayerStatus((OmPlrHandle)player->handle, &st_curr);
- pthread_mutex_unlock(&player->lock);
+ pthread_mutex_unlock(&player->app->players.lock);
if(r)
fprintf(stderr, "ERROR: OmPlrGetPlayerStatus failed with 0x%.8X\n", r);
omnplay_update_status(player, &st_prev , &st_curr);
};
- pthread_mutex_lock(&player->lock);
+ pthread_mutex_lock(&player->app->players.lock);
OmPlrClose((OmPlrHandle)player->handle);
- pthread_mutex_unlock(&player->lock);
+ pthread_mutex_unlock(&player->app->players.lock);
return NULL;
};
+static void omnplay_cue(omnplay_instance_t* app)
+{
+ int idx, start, stop;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ omnplay_player_t *player;
+
+ pthread_mutex_lock(&app->playlist.lock);
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(app->playlist_grid));
+ if(selection && gtk_tree_selection_get_selected(selection, &model, &iter))
+ {
+ gtk_tree_model_get(model, &iter, 7, &idx, -1);
+
+ fprintf(stderr, "cue: selected item is %d\n", idx);
+
+ for(start = idx; start >= 0; start--)
+ if(app->playlist.item[start].type & OMNPLAY_PLAYLIST_BLOCK_BEGIN)
+ break;
+
+ for(stop = idx; stop < app->playlist.count; stop++)
+ if(app->playlist.item[stop].type & OMNPLAY_PLAYLIST_BLOCK_END)
+ break;
+
+ /* check block range */
+ if(start >= 0 && stop < app->playlist.count)
+ {
+ fprintf(stderr, "cue: range %d -> %d\n", start, stop);
+
+ /* check player range */
+ if(app->playlist.item[start].player > -1 && app->playlist.item[start].player < player->app->players.count)
+ {
+ player = &app->players.item[app->playlist.item[start].player];
+
+ /* 1. stop */
+ pthread_mutex_lock(&app->players.lock);
+ OmPlrStop((OmPlrHandle)player->handle);
+ pthread_mutex_unlock(&app->players.lock);
+
+ /* 2. detach previous clips */
+ pthread_mutex_lock(&app->players.lock);
+ OmPlrDetachAllClips((OmPlrHandle)player->handle);
+ pthread_mutex_unlock(&app->players.lock);
+
+ // http://research.m1stereo.tv/viewvc-int/viewvc.cgi/Ingest2Srv/trunk/SrvPlayCtl.cpp?view=markup
+ };
+ };
+ };
+
+ pthread_mutex_unlock(&app->playlist.lock);
+
+};
+
static gboolean omnplay_button_click(omnplay_instance_t* app, control_buttons_t button)
{
switch(button)
case BUTTON_PLAYLIST_ITEM_UP:
case BUTTON_PLAYLIST_ITEM_DOWN:
case BUTTON_PLAYER_CUE:
+ omnplay_cue(app);
case BUTTON_PLAYER_PLAY:
case BUTTON_PLAYER_PAUSE:
case BUTTON_PLAYER_STOP:
gtk_signal_connect( GTK_OBJECT( app->window ), "destroy",
GTK_SIGNAL_FUNC(on_main_window_delete_event), app);
- for(i = 0; i < app->players.count; i++)
- {
- /* create lock */
- pthread_mutex_init(&app->players.item[i].lock, NULL);
+ /* create lock */
+ pthread_mutex_init(&app->players.lock, NULL);
- /* create a omneon status thread */
+ /* create a omneon status thread */
+ for(i = 0; i < app->players.count; i++)
pthread_create(&app->players.item[i].thread, NULL,
omnplay_thread_proc, &app->players.item[i]);
- };
/* create lock */
pthread_mutex_init(&app->playlist.lock, NULL);
app->f_exit = 1;
for(i = 0; i < app->players.count; i++)
- {
/* create a omneon status thread */
pthread_join(app->players.item[i].thread, &r);
- /* create lock */
- pthread_mutex_destroy(&app->players.item[i].lock);
-
- };
+ /* destroy lock */
+ pthread_mutex_destroy(&app->players.lock);
- /* create lock */
+ /* destroy lock */
pthread_mutex_destroy(&app->playlist.lock);
};