From: Maksym Veremeyenko Date: Tue, 26 Jun 2012 15:25:48 +0000 (+0300) Subject: mvcp protocol support embedded from melted project X-Git-Url: http://research.m1stereo.tv/gitweb?a=commitdiff_plain;h=3022037d61a5e41f1e89f53b53708fec33c9bac7;p=melted_gui mvcp protocol support embedded from melted project --- diff --git a/configure.in b/configure.in index 088795b..da70122 100644 --- a/configure.in +++ b/configure.in @@ -24,21 +24,14 @@ PKG_CHECK_MODULES(CURL, [libcurl]) AC_SUBST(CURL_CFLAGS) AC_SUBST(CURL_LIBS) -AC_ARG_WITH([ommedia], - [AS_HELP_STRING([--with-ommedia=path], [path to ommedia /Media API/])], - [OMMEDIA_PATH=$withval], - [OMMEDIA_PATH=/usr/local/omneon/ommedia]) - -AC_ARG_WITH([omplrlib], - [AS_HELP_STRING([--with-omplrlib=path], [path to omplrlib /Player API/])], - [OMPLRLIB_PATH=$withval], - [OMPLRLIB_PATH=/usr/local/omneon/omplrlib]) - -OM_CFLAGS="-I$OMPLRLIB_PATH/include -I$OMMEDIA_PATH/include" -AC_SUBST(OM_CFLAGS) - -OM_LIBS="-L$OMPLRLIB_PATH/lib -L$OMMEDIA_PATH/lib -lomplrlib -lommedia" -AC_SUBST(OM_LIBS) +AC_ARG_WITH([melted], + [AS_HELP_STRING([--with-melted=path], [path to melted source])], + [MELTED_PATH=$withval], + [MELTED_PATH=/home/verem/devel/melted.git]) +AC_SUBST(MELTED_PATH) + +MELTED_CFLAGS="-I$MELTED_PATH/src -I$MELTED_PATH/src/mvcp -DMVCP_EMBEDDED" +AC_SUBST(MELTED_CFLAGS) dnl #GETTEXT_PACKAGE=omnplay dnl #AC_SUBST(GETTEXT_PACKAGE) diff --git a/src/Makefile.am b/src/Makefile.am index 9e6d5ec..4bd2cde 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,17 +3,25 @@ INCLUDES = \ -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ - @GTHREAD_CFLAGS@ @GTK_CFLAGS@ @OM_CFLAGS@ @CURL_CFLAGS@ + @GTHREAD_CFLAGS@ @GTK_CFLAGS@ @MELTED_CFLAGS@ @CURL_CFLAGS@ bin_PROGRAMS = melted_gui +MVCP_FILES = \ + mvcp.c mvcp_tokeniser.c mvcp_parser.c mvcp_response.c mvcp_util.c mvcp_notifier.c \ + mvcp_socket.c mvcp_remote.c mvcp_status.c + +CLEANFILES = $(MVCP_FILES) + melted_gui_SOURCES = \ + $(MVCP_FILES) \ timecode.c timecode.h \ support.c support.h \ main.c \ instance.c instance.h \ ui.c ui.h ui_utils.h \ ui_buttons.c ui_buttons.h \ + player.c player.h \ opts.c opts.h # \ # playlist.c \ @@ -21,4 +29,7 @@ melted_gui_SOURCES = \ # whois.c \ # omnplay.cpp omnplay.h -melted_gui_LDADD = @GTHREAD_LIBS@ @GTK_LIBS@ @OM_LIBS@ @CURL_LIBS@ -lpthread +$(MVCP_FILES): + ln -s $(MELTED_PATH)/src/mvcp/$@ $@ + +melted_gui_LDADD = @GTHREAD_LIBS@ @GTK_LIBS@ @CURL_LIBS@ -lpthread diff --git a/src/instance.c b/src/instance.c index 62d955b..757d8a6 100644 --- a/src/instance.c +++ b/src/instance.c @@ -36,6 +36,7 @@ #include "ui.h" #include "opts.h" #include "timecode.h" +#include "player.h" static gboolean on_main_window_delete_event( GtkWidget *widget, GdkEvent *event, gpointer user_data ) { @@ -115,11 +116,11 @@ void instance_init(instance_t* app) pthread_mutex_init(&app->library.lock, &attr); pthread_mutexattr_destroy(&attr); -#if 0 - /* create a status thread */ + /* run unit monitoring threads */ for(i = 0; i < app->players.count; i++) - app->players.item[i].thread = g_thread_create( - omnplay_thread_proc, &app->players.item[i], TRUE, NULL); + player_run(app, i); + +#if 0 /* attach buttons click */ for(i = 1; i < BUTTON_LAST; i++) @@ -159,9 +160,9 @@ void instance_release(instance_t* app) app->f_exit = 1; + /* stop unit monitoring threads */ for(i = 0; i < app->players.count; i++) - /* create a omneon status thread */ - g_thread_join(app->players.item[i].thread); + player_stop(app, i); /* destroy lock */ pthread_mutex_destroy(&app->players.lock); diff --git a/src/player.c b/src/player.c new file mode 100644 index 0000000..bd456b6 --- /dev/null +++ b/src/player.c @@ -0,0 +1,134 @@ +/* + * player.h -- GTK+ 2 melted gui + * Copyright (C) 2012 Maksym Veremeyenko + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "player.h" + +static void* player_thread_proc(void* data) +{ + int r; + int playlist_start_prev = 0; +// OmPlrStatus st_curr, st_prev; + player_t* player = (player_t*)data; + + g_warning("omnplay_thread_proc\n"); + +// memset(&st_curr, 0, sizeof(OmPlrStatus)); +// memset(&st_prev, 0, sizeof(OmPlrStatus)); + + /* connect */ + pthread_mutex_lock(&player->app->players.lock); +// r = OmPlrOpen(player->host, player->name, (OmPlrHandle*)&player->handle); + pthread_mutex_unlock(&player->app->players.lock); + if(r) + { +// g_warning("ERROR: OmPlrOpen(%s, %s) failed with 0x%.8X\n", +// player->host, player->name, r); + + return (void*)r; + }; + + /* setup to do not reconnect */ + pthread_mutex_lock(&player->app->players.lock); +// OmPlrSetRetryOpen((OmPlrHandle)player->handle, 0); + pthread_mutex_unlock(&player->app->players.lock); + + /* setup directory */ +// if(player->app->players.path[0]) + { + pthread_mutex_lock(&player->app->players.lock); +// r = OmPlrClipSetDirectory((OmPlrHandle)player->handle, player->app->players.path); + pthread_mutex_unlock(&player->app->players.lock); + + if(r) + { +// g_warning("ERROR: OmPlrClipSetDirectory(%s) failed with 0x%.8X\n", +// player->app->players.path, r); + + pthread_mutex_lock(&player->app->players.lock); +// OmPlrClose((OmPlrHandle)player->handle); + pthread_mutex_unlock(&player->app->players.lock); + + return (void*)r; + }; + }; + + /* endless loop */ + for(r = 0 ; !player->app->f_exit && !r;) + { + /* sleep */ +#ifdef _WIN32 + Sleep(100); +#else + usleep(100000); +#endif + + /* get status */ + pthread_mutex_lock(&player->app->players.lock); +// st_curr.size = sizeof(OmPlrStatus); +// r = OmPlrGetPlayerStatus((OmPlrHandle)player->handle, &st_curr); + pthread_mutex_unlock(&player->app->players.lock); + + if(r) + g_warning("ERROR: OmPlrGetPlayerStatus failed with 0x%.8X\n", r); + else + { +// omnplay_update_status(player, &st_prev , &st_curr, &playlist_start_prev); +// playlist_start_prev = player->playlist_start; +// memcmp(&st_curr, &st_prev, sizeof(OmPlrStatus)); + }; + }; + + pthread_mutex_lock(&player->app->players.lock); +// OmPlrClose((OmPlrHandle)player->handle); + pthread_mutex_unlock(&player->app->players.lock); + + return NULL; +}; + + +void player_run(instance_t* app, int idx) +{ + mvcp_parser parser = mvcp_parser_init_remote(app->players.host, 5250); + mvcp command = mvcp_init(parser); + + app->players.item[idx].thread = g_thread_create( + player_thread_proc, &app->players.item[idx], TRUE, NULL); +}; + +void player_stop(instance_t* app, int idx) +{ + g_thread_join(app->players.item[idx].thread); +}; diff --git a/src/player.h b/src/player.h new file mode 100644 index 0000000..d27f42c --- /dev/null +++ b/src/player.h @@ -0,0 +1,37 @@ +/* + * player.h -- GTK+ 2 melted gui + * Copyright (C) 2012 Maksym Veremeyenko + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef PLAYER_H +#define PLAYER_H + +#include "instance.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +void player_run(instance_t* app, int idx); +void player_stop(instance_t* app, int idx); + +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + +#endif /* PLAYER_H */