From fc80293a6ed5b97b536488b59bf63edb1f40ab8c Mon Sep 17 00:00:00 2001 From: Mrinmayee Hingolikar Date: Fri, 11 Jan 2013 22:51:09 +0530 Subject: [PATCH 1/1] Modified in accordance to coding guidelines for header and C files. --- include/gst-controller.h | 42 +- include/gui.h | 139 ++--- src/gst-controller.c | 161 +++--- src/gui.c | 1106 +++++++++++++++++--------------------- src/main.c | 26 +- 5 files changed, 687 insertions(+), 787 deletions(-) diff --git a/include/gst-controller.h b/include/gst-controller.h index 3793654..28eaa8a 100644 --- a/include/gst-controller.h +++ b/include/gst-controller.h @@ -45,8 +45,8 @@ * @brief Defines the structures and function prototypes. */ -#ifndef __GST-CONTROLLER_H__ -#define __GST-CONTROLLER_H__ +#ifndef __GST_CONTROLLER_H__ +#define __GST_CONTROLLER_H__ #include #include @@ -61,6 +61,24 @@ typedef void (*EOSFunc) (gpointer data); typedef void (*ErrorFunc) (gpointer data); +/****************************************************************************** + + Structure Definitions + +******************************************************************************/ + +typedef struct Pipeline { + /* GStreamer pipeline */ + GstElement *pipe; + + /* callback functions */ + LogFunc logFunc; + EOSFunc eosFunc; + ErrorFunc errFunc; + + /* Signal for a pipeline */ + gulong busSignal; +} Pipeline; /****************************************************************************** @@ -175,24 +193,6 @@ void DualDecode_setPipelineSink (Pipeline *pipePtr, GstElement *sink0, GstElement *sink1); -/****************************************************************************** - - Structure Definitions - -******************************************************************************/ - -typedef struct Pipeline { - /* GStreamer pipeline */ - GstElement *pipe; - - /* callback functions */ - LogFunc logFunc; - EOSFunc eosFunc; - ErrorFunc errFunc; - - /* Signal for a pipeline */ - gulong busSignal; -} Pipeline; /****************************************************************************** @@ -205,4 +205,4 @@ typedef struct Pipeline { #define HH 2 #define TIMEOUT 4000000000 -#endif /*__GST-CONTROLLER_H__*/ +#endif /*__GST_CONTROLLER_H__*/ diff --git a/include/gui.h b/include/gui.h index f9374c1..b5aaddd 100644 --- a/include/gui.h +++ b/include/gui.h @@ -52,38 +52,6 @@ #include #include -/****************************************************************************** - - Public functions declarations - -******************************************************************************/ - -/** - * @brief initialises GTK if X is present - * - * @param[in,out] argc number of command line arguments - * @param[in,out] argv command line arguments - * - * @return TRUE if X present, FALSE otherwise - * - * Called From main() - */ -gboolean DualDecode_initGUI(gint *argc, char **argv[]); - -/** - * @brief start the application - * - * Called From main() - */ -void DualDecode_startApplication(); - -/** - * @brief stop the application and return to main() - * - * Called From delete-event handlers of the windows - */ -void DualDecode_exitApplication(); - /****************************************************************************** Structure Definitions @@ -151,6 +119,47 @@ typedef struct{ +/****************************************************************************** + + Macros + + *****************************************************************************/ +/*To index the static GUIWindow and Pipeline structures */ +/*There are two of them, since it is a dual-decode application */ +#define DECODER_INDEX_SINGLE 0 +#define DECODER_INDEX_DOUBLE 1 + +/*ratio of screen size per window*/ +#define SCREEN_WIDTH_FACTOR 3 +#define SCREEN_HEIGHT_FACTOR 2 + +/*Whether the control buttons are active*/ +#define CONTROL_MODE_ACTIVE TRUE +#define CONTROL_MODE_INACTIVE FALSE + +#define CONTROL_MODE_STOPPED 0 +#define CONTROL_MODE_PLAYING 1 +#define CONTROL_MODE_PAUSED 2 +#define CONTROL_MODE_NO_FILE 4 + +#define LABEL_TEXT_NO_FILE "No File" +#define LABEL_TEXT_PLAYING "Playing" +#define LABEL_TEXT_STOPPED "Stopped" +#define LABEL_TEXT_PAUSED "Paused" + +#define TIME_LABEL_ORIGIN "--:--:--/--:--:--" + +#define FORWARD 3000000000 +#define REWIND 3000000000 +#define SWITCH_TEXT_SINGLE "Single Decode" +#define SWITCH_TEXT_DUAL "Dual Decode" + +#define TIMER_INTERVAL 1000 +#define TIMER_SIGNAL_NONE 0 + +/*The glade file to import widgets from*/ +#define GLADE_FILE "res/gui.xml" + /****************************************************************************** Statically used variables per GUI component file @@ -188,7 +197,7 @@ static inline void DualDecode_builderClose() { } static inline void DualDecode_builderCreate() { builder = gtk_builder_new(); - if(0 == gtk_builder_add_from_file(builder,GLADE_FILE,&error)){ + if(0 == gtk_builder_add_from_file (builder,GLADE_FILE,&error)){ DualDecode_checkError(); DualDecode_builderClose(); } @@ -226,46 +235,38 @@ static inline GtkWidget *DualDecode_getWidgetExclusive(const char *widget) { DualDecode_builderClose(); return retWidget; } -/****************************************************************************** - - Macros - - *****************************************************************************/ -/*To index the static GUIWindow and Pipeline structures */ -/*There are two of them, since it is a dual-decode application */ -#define DECODER_INDEX_SINGLE 0 -#define DECODER_INDEX_DOUBLE 1 - -/*ratio of screen size per window*/ -#define SCREEN_WIDTH_FACTOR 3 -#define SCREEN_HEIGHT_FACTOR 2 -/*Whether the control buttons are active*/ -#define CONTROL_MODE_ACTIVE TRUE -#define CONTROL_MODE_INACTIVE FALSE - -#define CONTROL_MODE_STOPPED 0 -#define CONTROL_MODE_PLAYING 1 -#define CONTROL_MODE_PAUSED 2 -#define CONTROL_MODE_NO_FILE 4 - -#define LABEL_TEXT_NO_FILE "No File" -#define LABEL_TEXT_PLAYING "Playing" -#define LABEL_TEXT_STOPPED "Stopped" -#define LABEL_TEXT_PAUSED "Paused" - -#define TIME_LABEL_ORIGIN "--:--:--/--:--:--" +/****************************************************************************** + + Public functions declarations + +******************************************************************************/ -#define FORWARD 3000000000 -#define REWIND 3000000000 -#define SWITCH_TEXT_SINGLE "Single Decode" -#define SWITCH_TEXT_DUAL "Dual Decode" +/** + * @brief initialises GTK if X is present + * + * @param[in,out] argc number of command line arguments + * @param[in,out] argv command line arguments + * + * @return TRUE if X present, FALSE otherwise + * + * Called From main() + */ +gboolean DualDecode_initGUI(gint *argc, char **argv[]); -#define TIMER_INTERVAL 1000 -#define TIMER_SIGNAL_NONE 0 +/** + * @brief start the application + * + * Called From main() + */ +void DualDecode_startApplication(); -/*The glade file to import widgets from*/ -#define GLADE_FILE "res/gui.xml" +/** + * @brief stop the application and return to main() + * + * Called From delete-event handlers of the windows + */ +void DualDecode_exitApplication(); #endif /*__GUI_H__*/ diff --git a/src/gst-controller.c b/src/gst-controller.c index d436a12..90e4dce 100644 --- a/src/gst-controller.c +++ b/src/gst-controller.c @@ -71,68 +71,64 @@ static gboolean attachPipeElements (Pipeline *pipePtr, GstElement *sink0, GstElement *queue1 = NULL; GstPad *pad = NULL; - - - bin = gst_bin_new ("vsinkbin"); - tee = gst_element_factory_make ("tee","splitter"); - //sink0 = createImageSinkFromWindow (drawArea1, "sink0"); - queue0 = gst_element_factory_make ("queue","q0"); - queue1 = gst_element_factory_make ("queue","q1"); - - if (NULL == sink0) - fsink0 = gst_element_factory_make ("fakesink", fsinkArr[fsinkCounter++]); - if (NULL == sink1) - fsink1 = gst_element_factory_make ("fakesink", fsinkArr[fsinkCounter++]); + bin = gst_bin_new ("vsinkbin"); + tee = gst_element_factory_make ("tee","splitter"); + queue0 = gst_element_factory_make ("queue","q0"); + queue1 = gst_element_factory_make ("queue","q1"); + + if (NULL == sink0) + fsink0 = gst_element_factory_make ("fakesink", fsinkArr[fsinkCounter++]); + if (NULL == sink1) + fsink1 = gst_element_factory_make ("fakesink", fsinkArr[fsinkCounter++]); - - if ( !bin || !tee || !queue0 || !queue1) { - ret = FALSE; - goto exit; - } - if (NULL == sink0 && NULL == sink1) { - gst_bin_add_many (GST_BIN (bin), tee, - fsink0, fsink1, queue0, queue1,NULL); - gst_element_link (queue0, fsink0); - gst_element_link(queue1,fsink1); - } - - else if (NULL != sink0 && NULL == sink1){ - gst_bin_add_many (GST_BIN (bin), tee, - sink0, fsink1, queue0, queue1,NULL); - gst_element_link (queue0, sink0); - gst_element_link(queue1,fsink1); - } - else if (NULL!= sink0 && NULL!=sink1) { - gst_bin_add_many (GST_BIN (bin), tee, - sink0, sink1, queue0, queue1,NULL); - gst_element_link (queue0, sink0); - gst_element_link(queue1,sink1); - } + if (!bin || !tee || !queue0 || !queue1) { + ret = FALSE; + goto exit; + } + if (NULL == sink0 && NULL == sink1) { + gst_bin_add_many (GST_BIN (bin), tee, fsink0, fsink1, queue0, queue1, + NULL); + gst_element_link (queue0, fsink0); + gst_element_link (queue1,fsink1); + } + + else if (NULL != sink0 && NULL == sink1) { + gst_bin_add_many (GST_BIN (bin), tee, sink0, fsink1, queue0, queue1, + NULL); + gst_element_link (queue0, sink0); + gst_element_link (queue1,fsink1); + } + else if (NULL!= sink0 && NULL!=sink1) { + gst_bin_add_many (GST_BIN (bin), tee, sink0, sink1, queue0, queue1, + NULL); + gst_element_link (queue0, sink0); + gst_element_link (queue1,sink1); + } - else { - ret = FALSE; - goto exit; - } - /*Connecting the tee through queues is necessary to sync the two displays*/ - gst_element_link(tee,queue0); - gst_element_link(tee,queue1); - - pad = gst_element_get_static_pad (tee, "sink"); - gst_element_add_pad (bin, gst_ghost_pad_new ("sink", pad)); - gst_object_unref (GST_OBJECT (pad)); - g_object_set (G_OBJECT (pipePtr->pipe), "video-sink", bin, NULL); + else { + ret = FALSE; + goto exit; + } + /*Connecting the tee through queues is necessary to sync the two displays*/ + gst_element_link (tee,queue0); + gst_element_link (tee,queue1); + + pad = gst_element_get_static_pad (tee, "sink"); + gst_element_add_pad (bin, gst_ghost_pad_new ("sink", pad)); + gst_object_unref (GST_OBJECT (pad)); + g_object_set (G_OBJECT (pipePtr->pipe), "video-sink", bin, NULL); exit: return ret; } -gboolean busCallback(GstBus *bus, GstMessage *msg, gpointer data) +static gboolean busCallback (GstBus *bus, GstMessage *msg, gpointer data) { gchar *name = (gchar *)data; gchar *debugMsg = NULL; GError *err = NULL; - static int count = 0; + static int count = 0; - switch(GST_MESSAGE_TYPE(msg)){ + switch (GST_MESSAGE_TYPE(msg)) { case GST_MESSAGE_EOS: g_printerr("%s -> Message (EOS) : End of stream.\n",name); @@ -180,6 +176,11 @@ static void getTime (gint64 arr[], gint64 time) Public Functions ******************************************************************************/ + + +/***************************************************************************** +* see gst-controller.h +******************************************************************************/ Pipeline * DualDecode_createPipeline() { Pipeline *pipelinePtr = (Pipeline *) malloc (sizeof(Pipeline)); @@ -188,8 +189,8 @@ Pipeline * DualDecode_createPipeline() GstBus *bus = NULL; - pipelinePtr->pipe = gst_element_factory_make("playbin2",NULL); - bus = gst_pipeline_get_bus (GST_PIPELINE(pipelinePtr->pipe)); + pipelinePtr->pipe = gst_element_factory_make ("playbin2",NULL); + bus = gst_pipeline_get_bus (GST_PIPELINE (pipelinePtr->pipe)); pipelinePtr->busSignal = gst_bus_add_watch (bus,busCallback, NULL); gst_object_unref (bus); pipelinePtr->logFunc = NULL; @@ -198,7 +199,8 @@ Pipeline * DualDecode_createPipeline() return pipelinePtr; } -gboolean DualDecode_setSinksForPipes (Pipeline **pipes,GstElement *sink0, GstElement *sink1) +gboolean DualDecode_setSinksForPipes (Pipeline **pipes, GstElement *sink0, + GstElement *sink1) { gboolean ret = TRUE; attachPipeElements (pipes[0], sink0, NULL); @@ -207,15 +209,14 @@ gboolean DualDecode_setSinksForPipes (Pipeline **pipes,GstElement *sink0, GstEle return ret; } -gboolean DualDecode_seekMedia(Pipeline *pipePtr, gint64 position) +gboolean DualDecode_seekMedia (Pipeline *pipePtr, gint64 position) { - if(position < 0){ + if (position < 0) { return FALSE; } - return gst_element_seek_simple(pipePtr->pipe, - GST_FORMAT_TIME, - GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT, - position); + return gst_element_seek_simple (pipePtr->pipe, GST_FORMAT_TIME, + GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT, + position); } @@ -223,13 +224,15 @@ gboolean DualDecode_pauseMedia (Pipeline *pipePtr) { gboolean ret = TRUE; GstStateChangeReturn stateReturn; - if (GST_STATE_CHANGE_ASYNC == gst_element_set_state (pipePtr->pipe, GST_STATE_PAUSED)){ + if (GST_STATE_CHANGE_ASYNC == + gst_element_set_state (pipePtr->pipe, GST_STATE_PAUSED)) { g_print ("STATE CHANGE RETURNED ASYNC \n"); stateReturn = gst_element_get_state (pipePtr->pipe, NULL, NULL, TIMEOUT); - g_print ("GET STATE RETURNED %s\n", gst_element_state_change_return_get_name (stateReturn)); + g_print ("GET STATE RETURNED %s\n", + gst_element_state_change_return_get_name (stateReturn)); } return ret; @@ -238,7 +241,7 @@ gboolean DualDecode_pauseMedia (Pipeline *pipePtr) gboolean DualDecode_resumeMedia (Pipeline *pipePtr) { gboolean ret = TRUE; - if(!gst_element_set_state (pipePtr->pipe, GST_STATE_PLAYING)) + if (!gst_element_set_state (pipePtr->pipe, GST_STATE_PLAYING)) ret = FALSE; g_print ("IN RESUME MEDIA\n"); return ret; @@ -247,7 +250,7 @@ gboolean DualDecode_resumeMedia (Pipeline *pipePtr) gboolean DualDecode_stopMedia (Pipeline *pipePtr) { gboolean ret = TRUE; - if(!gst_element_set_state (pipePtr->pipe, GST_STATE_NULL)) + if (!gst_element_set_state (pipePtr->pipe, GST_STATE_NULL)) ret = FALSE; return ret; @@ -266,15 +269,12 @@ GstState DualDecode_getMediaState(Pipeline *pipePtr) { GstState state, pending; g_print ("IN GET MEDIA STATE ENTRY\n"); - if(GST_STATE_CHANGE_SUCCESS != gst_element_get_state( - pipePtr->pipe, - &state, - &pending, - GST_CLOCK_TIME_NONE)){ + if (GST_STATE_CHANGE_SUCCESS != gst_element_get_state( + pipePtr->pipe, &state, &pending, GST_CLOCK_TIME_NONE)) { /*TODO : a bug here*/ - g_printerr("No state in GstElement\n"); - } - g_print("EXITING FROM GET MEDIA STATE\n"); + g_printerr ("No state in GstElement\n"); + } + g_print ("EXITING FROM GET MEDIA STATE\n"); return state; } @@ -319,12 +319,12 @@ gboolean DualDecode_playMedia (Pipeline *pipePtr, gchar *filename, gint64 positi gboolean ret = TRUE; g_print ("IN PLAYMEDIA2"); - g_object_set(G_OBJECT(pipePtr->pipe),"uri", filename,NULL); + g_object_set (G_OBJECT (pipePtr->pipe),"uri", filename,NULL); gst_element_set_state (pipePtr->pipe, GST_STATE_NULL); gst_element_set_state (pipePtr->pipe, GST_STATE_PLAYING); - DualDecode_getMediaState(pipePtr); - DualDecode_seekMedia(pipePtr, position); + DualDecode_getMediaState (pipePtr); + DualDecode_seekMedia (pipePtr, position); return ret; @@ -341,13 +341,10 @@ gboolean DualDecode_singleToDual (Pipeline **pipes,GstElement * otherWindowSink, GstElement *fsink = NULL; GstElement *queue0 = NULL; GstElement *queue1 = NULL; - GstState state0 = NULL; + GstState state0 = GST_STATE_NULL; - gst_element_get_state( - pipes[thisWindow]->pipe, - &state0, - NULL, - GST_CLOCK_TIME_NONE); + gst_element_get_state (pipes[thisWindow]->pipe, &state0, NULL, + GST_CLOCK_TIME_NONE); /*Remove otherWindowsink from this pipeline*/ g_object_get (G_OBJECT (pipes[thisWindow]->pipe),"video-sink", &thisbin,NULL); @@ -406,7 +403,7 @@ gboolean DualDecode_dualToSingle (Pipeline **pipes,GstElement * otherWindowSink, fsink = gst_bin_get_by_name (GST_BIN (bin), "fsink0"); if (NULL == fsink) fsink = gst_bin_get_by_name (GST_BIN (bin), "fsink1"); - name = gst_element_get_name(fsink); + name = gst_element_get_name (fsink); gst_element_unlink (queue1, fsink); gst_object_ref (fsink); gst_bin_remove (GST_BIN (bin),fsink); diff --git a/src/gui.c b/src/gui.c index a217ade..4c979eb 100644 --- a/src/gui.c +++ b/src/gui.c @@ -1,42 +1,44 @@ -/* - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Contact information for paper mail: - * Texas Instruments - * Post Office Box 655303 - * Dallas, Texas 75265 - * Contact information: - * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm - * ?DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact +/* + * Copyright (c) 2012-2013, Texas Instruments Incorporated + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Contact information for paper mail: + * Texas Instruments + * Post Office Box 655303 + * Dallas, Texas 75265 + * Contact information: + * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm? + * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact * ============================================================================ - * - */ + * + */ + /** * @file gui.c @@ -75,11 +77,11 @@ static void setControlMode (GUIWindow *thisWindow,gint modeFlag,gint activeFlag) static void setControlActive (GUIWindow *window, gboolean activeFlag); static void setup(); static void setDecodeSwitch (gint decodeSwitch); -static GtkWidget *createLogWindow(); -static GtkWidget *createHelpWindow(); +static GtkWidget *createLogWindow (); +static GtkWidget *createHelpWindow (); static GstElement *createImageSinkFromWindow (GtkWidget * window, gchar *name); -static void setWindowSizeLocation(); -static GUIWindow *createWindow(); +static void setWindowSizeLocation (); +static GUIWindow *createWindow (); static gboolean cbOpenClicked (GtkWidget *widget, gpointer data); static gboolean cbPlayClicked (GtkWidget *widget, gpointer data); @@ -93,20 +95,19 @@ static gboolean cbTimerInterval (gpointer data); static gboolean cbSeekValueChanged (GtkWidget *widget, gpointer data); static gboolean cbSwitchButtonClicked (GtkWidget *widget, gpointer data); static gboolean cbHelpClosed (GtkWidget *widget, gpointer data); -//static void logGUI (GtkWidget *logWindow, gchar *format, ...); static gint setAbsolutePathname (gchar *file, gchar **uri) { gchar *realPath = NULL; gint ret = ERR_SUCCESS; - if(NULL == uri){ + if (NULL == uri){ return ERR_INVALIDPARAM; } - if(NULL == file){ + if (NULL == file){ /*A BUG Here*/ - g_printerr("BUG: file: " __FILE__ " line: %d" "\n", __LINE__); + g_printerr ("BUG: file: " __FILE__ " line: %d" "\n", __LINE__); return ERR_BUG; } @@ -118,7 +119,7 @@ static gint setAbsolutePathname (gchar *file, gchar **uri) ret = ERR_FILENOTFOUND; goto destroy; } - g_snprintf(*uri,PATH_MAX_LEN,"file://%s",realPath); + g_snprintf (*uri,PATH_MAX_LEN,"file://%s",realPath); goto last; @@ -143,12 +144,9 @@ static gboolean cbTimerInterval(gpointer data) GUIWindow *thisWindow = (GUIWindow *)data; gboolean ret = TRUE; - //g_print ("IN timer"); - if (DECODE_MODE_SINGLE == decodeMode){ + if (DECODE_MODE_SINGLE == decodeMode) { ret = DualDecode_getMediaPosition(pipes[DECODER_INDEX_SINGLE], - &seekScaleValue, - &timeLabelText); - //g_print ("Seek Value %f", seekScaleValue); + &seekScaleValue, &timeLabelText); g_signal_handler_block (window[DECODER_INDEX_SINGLE]->seekScale, window[DECODER_INDEX_SINGLE]->seekSignal); @@ -156,54 +154,54 @@ static gboolean cbTimerInterval(gpointer data) seekScaleValue); gtk_label_set_text (GTK_LABEL (window[DECODER_INDEX_SINGLE]->timeLabel), timeLabelText); - g_signal_handler_unblock (GTK_RANGE(window[DECODER_INDEX_SINGLE]->seekScale), - window[DECODER_INDEX_SINGLE]->seekSignal); + g_signal_handler_unblock (GTK_RANGE (window[DECODER_INDEX_SINGLE]->seekScale), + window[DECODER_INDEX_SINGLE]->seekSignal); g_signal_handler_block (GTK_RANGE (window[DECODER_INDEX_DOUBLE]->seekScale), - window[DECODER_INDEX_DOUBLE]->seekSignal); - gtk_range_set_value(GTK_RANGE (window[DECODER_INDEX_DOUBLE]->seekScale), - seekScaleValue); - gtk_label_set_text(GTK_LABEL (window[DECODER_INDEX_DOUBLE]->timeLabel), - timeLabelText); - g_signal_handler_unblock(GTK_RANGE (window[DECODER_INDEX_DOUBLE]->seekScale), - window[DECODER_INDEX_DOUBLE]->seekSignal); - }else{ + window[DECODER_INDEX_DOUBLE]->seekSignal); + gtk_range_set_value (GTK_RANGE (window[DECODER_INDEX_DOUBLE]->seekScale), + seekScaleValue); + gtk_label_set_text (GTK_LABEL (window[DECODER_INDEX_DOUBLE]->timeLabel), + timeLabelText); + g_signal_handler_unblock (GTK_RANGE (window[DECODER_INDEX_DOUBLE]->seekScale), + window[DECODER_INDEX_DOUBLE]->seekSignal); + } + else { if (window[DECODER_INDEX_SINGLE] == thisWindow){ - ret = DualDecode_getMediaPosition(pipes[DECODER_INDEX_SINGLE], - &seekScaleValue, - &timeLabelText); + ret = DualDecode_getMediaPosition (pipes[DECODER_INDEX_SINGLE], + &seekScaleValue, &timeLabelText); g_signal_handler_block (GTK_RANGE(window[DECODER_INDEX_SINGLE]->seekScale), - window[DECODER_INDEX_SINGLE]->seekSignal); + window[DECODER_INDEX_SINGLE]->seekSignal); gtk_range_set_value (GTK_RANGE (window[DECODER_INDEX_SINGLE]->seekScale), - seekScaleValue); + seekScaleValue); gtk_label_set_text (GTK_LABEL (window[DECODER_INDEX_SINGLE]->timeLabel), - timeLabelText); + timeLabelText); g_signal_handler_unblock (GTK_RANGE (window[DECODER_INDEX_SINGLE]->seekScale), - window[DECODER_INDEX_SINGLE]->seekSignal); - }else{ + window[DECODER_INDEX_SINGLE]->seekSignal); + } + else { ret = DualDecode_getMediaPosition (pipes[DECODER_INDEX_DOUBLE], - &seekScaleValue, - &timeLabelText); + &seekScaleValue, &timeLabelText); g_signal_handler_block (GTK_RANGE (window[DECODER_INDEX_DOUBLE]->seekScale), - window[DECODER_INDEX_DOUBLE]->seekSignal); + window[DECODER_INDEX_DOUBLE]->seekSignal); gtk_range_set_value (GTK_RANGE (window[DECODER_INDEX_DOUBLE]->seekScale), - seekScaleValue); + seekScaleValue); gtk_label_set_text (GTK_LABEL(window[DECODER_INDEX_DOUBLE]->timeLabel), - timeLabelText); - g_signal_handler_unblock(GTK_RANGE (window[DECODER_INDEX_DOUBLE]->seekScale), - window[DECODER_INDEX_DOUBLE]->seekSignal); + timeLabelText); + g_signal_handler_unblock (GTK_RANGE (window[DECODER_INDEX_DOUBLE]->seekScale), + window[DECODER_INDEX_DOUBLE]->seekSignal); } } - if(ret){ - g_free(timeLabelText); + if (ret) { + g_free (timeLabelText); } return ret; } /*Seek Scale Changed Value Callback Function*/ -static gboolean cbSeekValueChanged(GtkWidget *widget, gpointer data) +static gboolean cbSeekValueChanged (GtkWidget *widget, gpointer data) { gboolean ret = TRUE; GstFormat format = GST_FORMAT_TIME; @@ -214,26 +212,26 @@ static gboolean cbSeekValueChanged(GtkWidget *widget, gpointer data) GUIWindow *thisWindow = (GUIWindow *)data; g_print ("IN SEEK VALUE CHANGED\n"); - if (DECODE_MODE_SINGLE == decodeMode){ + if (DECODE_MODE_SINGLE == decodeMode) { gst_element_query_duration (pipes[DECODER_INDEX_SINGLE]->pipe, &format,&duration); seekPoint = (gint64) (duration * percent/ (gdouble)100); g_print ("SEEK POINT %d\n", seekPoint); - ret = DualDecode_seekMedia(pipes[DECODER_INDEX_SINGLE], seekPoint); + ret = DualDecode_seekMedia (pipes[DECODER_INDEX_SINGLE], seekPoint); } - else{ - if(window[DECODER_INDEX_SINGLE] == thisWindow){ + else { + if (window[DECODER_INDEX_SINGLE] == thisWindow){ gst_element_query_duration (pipes[DECODER_INDEX_SINGLE]->pipe, &format,&duration); seekPoint = (gint64) (duration * percent/ (gdouble)100); - ret = DualDecode_seekMedia(pipes[DECODER_INDEX_SINGLE], seekPoint); - } + ret = DualDecode_seekMedia (pipes[DECODER_INDEX_SINGLE], seekPoint); + } else { - gst_element_query_duration(pipes[DECODER_INDEX_SINGLE]->pipe, - &format,&duration); + gst_element_query_duration (pipes[DECODER_INDEX_SINGLE]->pipe, + &format,&duration); seekPoint = (gint64) (duration * percent/ (gdouble)100); - ret = DualDecode_seekMedia(pipes[DECODER_INDEX_DOUBLE], seekPoint); + ret = DualDecode_seekMedia (pipes[DECODER_INDEX_DOUBLE], seekPoint); } } @@ -241,136 +239,125 @@ static gboolean cbSeekValueChanged(GtkWidget *widget, gpointer data) } /*Open Button Clicked Callback Function*/ -static gboolean cbOpenClicked(GtkWidget *widget, gpointer data) +static gboolean cbOpenClicked (GtkWidget *widget, gpointer data) { gboolean ret = TRUE; gchar *uri = NULL; gchar *file = NULL; GUIWindow *thisWindow = (GUIWindow *)data; - GtkWidget *fileChooser = gtk_file_chooser_dialog_new( - "Open", - GTK_WINDOW(thisWindow->window), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_OPEN, - GTK_RESPONSE_OK, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - NULL); - gtk_window_set_modal(GTK_WINDOW(fileChooser),TRUE); - gtk_window_set_destroy_with_parent(GTK_WINDOW(fileChooser),TRUE); - gtk_widget_set_sensitive(thisWindow->window,FALSE); + GtkWidget *fileChooser = gtk_file_chooser_dialog_new ("Open", + GTK_WINDOW(thisWindow->window), + GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_OPEN, + GTK_RESPONSE_OK, GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, NULL); + gtk_window_set_modal (GTK_WINDOW (fileChooser),TRUE); + gtk_window_set_destroy_with_parent (GTK_WINDOW (fileChooser),TRUE); + gtk_widget_set_sensitive (thisWindow->window,FALSE); - if(GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(fileChooser))){ - - file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fileChooser)); + if (GTK_RESPONSE_OK == gtk_dialog_run (GTK_DIALOG (fileChooser))) { - if (ERR_SUCCESS != setAbsolutePathname (file, &uri)){ + file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(fileChooser)); + if (ERR_SUCCESS != setAbsolutePathname (file, &uri)) { ret = FALSE; goto last; } - //g_print ("FILE URI :%s", uri); - if(DECODE_MODE_SINGLE == decodeMode){ + if (DECODE_MODE_SINGLE == decodeMode) { filename[DECODER_INDEX_SINGLE] = uri; - setControlMode(window[DECODER_INDEX_SINGLE], - CONTROL_MODE_PLAYING, - window[DECODER_INDEX_SINGLE]->activeFlag); - setControlMode(window[DECODER_INDEX_DOUBLE], - CONTROL_MODE_PLAYING, - window[DECODER_INDEX_DOUBLE]->activeFlag); - DualDecode_playMedia(pipes[DECODER_INDEX_SINGLE], - filename[DECODER_INDEX_SINGLE], - SEEK_START); - }else{ + setControlMode (window[DECODER_INDEX_SINGLE], CONTROL_MODE_PLAYING, + window[DECODER_INDEX_SINGLE]->activeFlag); + setControlMode (window[DECODER_INDEX_DOUBLE], CONTROL_MODE_PLAYING, + window[DECODER_INDEX_DOUBLE]->activeFlag); + DualDecode_playMedia (pipes[DECODER_INDEX_SINGLE], + filename[DECODER_INDEX_SINGLE], SEEK_START); + } + else { filename[DECODER_INDEX_SINGLE] = uri; - if(window[DECODER_INDEX_SINGLE] == thisWindow){ - setControlMode(window[DECODER_INDEX_SINGLE], - CONTROL_MODE_PLAYING, - window[DECODER_INDEX_SINGLE]->activeFlag); - DualDecode_playMedia(pipes[DECODER_INDEX_SINGLE], - filename[DECODER_INDEX_SINGLE], - SEEK_START); - }else{ + if (window[DECODER_INDEX_SINGLE] == thisWindow) { + setControlMode (window[DECODER_INDEX_SINGLE], + CONTROL_MODE_PLAYING, + window[DECODER_INDEX_SINGLE]->activeFlag); + DualDecode_playMedia (pipes[DECODER_INDEX_SINGLE], + filename[DECODER_INDEX_SINGLE], SEEK_START); + } + else { filename[DECODER_INDEX_DOUBLE] = uri; - setControlMode(window[DECODER_INDEX_DOUBLE], - CONTROL_MODE_PLAYING, - window[DECODER_INDEX_DOUBLE]->activeFlag); - DualDecode_playMedia(pipes[DECODER_INDEX_DOUBLE], - filename[DECODER_INDEX_DOUBLE], - SEEK_START); + setControlMode (window[DECODER_INDEX_DOUBLE], + CONTROL_MODE_PLAYING, + window[DECODER_INDEX_DOUBLE]->activeFlag); + DualDecode_playMedia (pipes[DECODER_INDEX_DOUBLE], + filename[DECODER_INDEX_DOUBLE], + SEEK_START); } } } if (GTK_IS_WIDGET (fileChooser)) gtk_widget_destroy (fileChooser); - if( GTK_IS_WIDGET (thisWindow->window)) + if (GTK_IS_WIDGET (thisWindow->window)) gtk_widget_set_sensitive (thisWindow->window,TRUE); last: return ret; } /*Play Button Clicked Callback Function*/ -static gboolean cbPlayClicked(GtkWidget *widget, gpointer data) +static gboolean cbPlayClicked (GtkWidget *widget, gpointer data) { gboolean ret = TRUE; GUIWindow *thisWindow = (GUIWindow *)data; - if(DECODE_MODE_SINGLE == decodeMode){ - setControlMode(window[DECODER_INDEX_SINGLE], - CONTROL_MODE_PLAYING, - window[DECODER_INDEX_SINGLE]->activeFlag); - setControlMode(window[DECODER_INDEX_DOUBLE], - CONTROL_MODE_PLAYING, - window[DECODER_INDEX_DOUBLE]->activeFlag); - if(GST_STATE_PAUSED == - DualDecode_getMediaState(pipes[DECODER_INDEX_SINGLE])){ - DualDecode_resumeMedia(pipes[DECODER_INDEX_SINGLE]); - }else{ - DualDecode_playMedia(pipes[DECODER_INDEX_SINGLE], - filename[DECODER_INDEX_SINGLE], - SEEK_START); - } - }else{ - if (window[DECODER_INDEX_SINGLE] == thisWindow){ - setControlMode (window[DECODER_INDEX_SINGLE], - CONTROL_MODE_PLAYING, - window[DECODER_INDEX_SINGLE]->activeFlag); + if (DECODE_MODE_SINGLE == decodeMode) { + setControlMode (window[DECODER_INDEX_SINGLE], CONTROL_MODE_PLAYING, + window[DECODER_INDEX_SINGLE]->activeFlag); + setControlMode (window[DECODER_INDEX_DOUBLE], CONTROL_MODE_PLAYING, + window[DECODER_INDEX_DOUBLE]->activeFlag); + if (GST_STATE_PAUSED == + DualDecode_getMediaState (pipes[DECODER_INDEX_SINGLE])) { + DualDecode_resumeMedia (pipes[DECODER_INDEX_SINGLE]); + } + else { + DualDecode_playMedia (pipes[DECODER_INDEX_SINGLE], + filename[DECODER_INDEX_SINGLE], SEEK_START); + } + } + else { + if (window[DECODER_INDEX_SINGLE] == thisWindow) { + setControlMode (window[DECODER_INDEX_SINGLE], CONTROL_MODE_PLAYING, + window[DECODER_INDEX_SINGLE]->activeFlag); if (GST_STATE_PAUSED == - DualDecode_getMediaState(pipes[DECODER_INDEX_SINGLE])){ - DualDecode_resumeMedia(pipes[DECODER_INDEX_SINGLE]); - }else if (GST_STATE_READY == - DualDecode_getMediaState(pipes[DECODER_INDEX_SINGLE])){ + DualDecode_getMediaState (pipes[DECODER_INDEX_SINGLE])) { + DualDecode_resumeMedia (pipes[DECODER_INDEX_SINGLE]); + } + else if (GST_STATE_READY == + DualDecode_getMediaState (pipes[DECODER_INDEX_SINGLE])) { g_print ("\nPipeline state is READY\n"); DualDecode_setPipelineSink (pipes[DECODER_INDEX_SINGLE], window[DECODER_INDEX_SINGLE]->sink, NULL); DualDecode_playMedia (pipes[DECODER_INDEX_SINGLE], filename[0],0); - //DualDecode_seekMedia (pipes[DECODER_INDEX_SINGLE], 0); } - else { - DualDecode_playMedia(pipes[DECODER_INDEX_SINGLE], - filename[DECODER_INDEX_SINGLE], - SEEK_START); + else { + DualDecode_playMedia (pipes[DECODER_INDEX_SINGLE], + filename[DECODER_INDEX_SINGLE], + SEEK_START); } - }else{ - setControlMode(window[DECODER_INDEX_DOUBLE], - CONTROL_MODE_PLAYING, - window[DECODER_INDEX_DOUBLE]->activeFlag); - if(GST_STATE_PAUSED == - DualDecode_getMediaState(pipes[DECODER_INDEX_DOUBLE])){ - DualDecode_resumeMedia(pipes[DECODER_INDEX_DOUBLE]); + } + else { + setControlMode (window[DECODER_INDEX_DOUBLE], CONTROL_MODE_PLAYING, + window[DECODER_INDEX_DOUBLE]->activeFlag); + if (GST_STATE_PAUSED == + DualDecode_getMediaState (pipes[DECODER_INDEX_DOUBLE])) { + DualDecode_resumeMedia (pipes[DECODER_INDEX_DOUBLE]); } else if (GST_STATE_READY == - DualDecode_getMediaState(pipes[DECODER_INDEX_DOUBLE])){ + DualDecode_getMediaState (pipes[DECODER_INDEX_DOUBLE])) { DualDecode_resumeMedia (pipes[DECODER_INDEX_DOUBLE]); - //DualDecode_seekMedia (pipes[DECODER_INDEX_SINGLE], 0); } - else{ - DualDecode_playMedia(pipes[DECODER_INDEX_DOUBLE], - filename[DECODER_INDEX_DOUBLE], - SEEK_START); + else { + DualDecode_playMedia (pipes[DECODER_INDEX_DOUBLE], + filename[DECODER_INDEX_DOUBLE], + SEEK_START); } } } @@ -378,66 +365,62 @@ static gboolean cbPlayClicked(GtkWidget *widget, gpointer data) } /*Pause Button Clicked Callback Function*/ -static gboolean cbPauseClicked(GtkWidget *widget, gpointer data) +static gboolean cbPauseClicked (GtkWidget *widget, gpointer data) { gboolean ret = TRUE; GUIWindow *thisWindow = (GUIWindow *)data; - if(DECODE_MODE_SINGLE == decodeMode){ - setControlMode(window[DECODER_INDEX_SINGLE], - CONTROL_MODE_PAUSED, - window[DECODER_INDEX_SINGLE]->activeFlag); - setControlMode(window[DECODER_INDEX_DOUBLE], - CONTROL_MODE_PAUSED, - window[DECODER_INDEX_DOUBLE]->activeFlag); - DualDecode_pauseMedia(pipes[DECODER_INDEX_SINGLE]); - }else{ - if(window[DECODER_INDEX_SINGLE] == thisWindow){ - setControlMode(window[DECODER_INDEX_SINGLE], - CONTROL_MODE_PAUSED, - window[DECODER_INDEX_SINGLE]->activeFlag); - DualDecode_pauseMedia(pipes[DECODER_INDEX_SINGLE]); - }else{ - setControlMode(window[DECODER_INDEX_DOUBLE], - CONTROL_MODE_PAUSED, - window[DECODER_INDEX_DOUBLE]->activeFlag); - DualDecode_pauseMedia(pipes[DECODER_INDEX_DOUBLE]); - } + if (DECODE_MODE_SINGLE == decodeMode) { + setControlMode (window[DECODER_INDEX_SINGLE], CONTROL_MODE_PAUSED, + window[DECODER_INDEX_SINGLE]->activeFlag); + setControlMode (window[DECODER_INDEX_DOUBLE], CONTROL_MODE_PAUSED, + window[DECODER_INDEX_DOUBLE]->activeFlag); + DualDecode_pauseMedia (pipes[DECODER_INDEX_SINGLE]); } + else { + if (window[DECODER_INDEX_SINGLE] == thisWindow) { + setControlMode (window[DECODER_INDEX_SINGLE], CONTROL_MODE_PAUSED, + window[DECODER_INDEX_SINGLE]->activeFlag); + DualDecode_pauseMedia (pipes[DECODER_INDEX_SINGLE]); + } + else { + setControlMode (window[DECODER_INDEX_DOUBLE], CONTROL_MODE_PAUSED, + window[DECODER_INDEX_DOUBLE]->activeFlag); + DualDecode_pauseMedia (pipes[DECODER_INDEX_DOUBLE]); + } + } return ret; } /*Stop Button Clicked Callback Function*/ -static gboolean cbStopClicked(GtkWidget *widget, gpointer data) +static gboolean cbStopClicked (GtkWidget *widget, gpointer data) { gboolean ret = TRUE; GUIWindow *thisWindow = (GUIWindow *)data; - if (DECODE_MODE_SINGLE == decodeMode){ - setControlMode (window[DECODER_INDEX_SINGLE], - CONTROL_MODE_STOPPED, - window[DECODER_INDEX_SINGLE]->activeFlag); - setControlMode (window[DECODER_INDEX_DOUBLE], - CONTROL_MODE_STOPPED, - window[DECODER_INDEX_DOUBLE]->activeFlag); + if (DECODE_MODE_SINGLE == decodeMode) { + setControlMode (window[DECODER_INDEX_SINGLE], CONTROL_MODE_STOPPED, + window[DECODER_INDEX_SINGLE]->activeFlag); + setControlMode (window[DECODER_INDEX_DOUBLE], CONTROL_MODE_STOPPED, + window[DECODER_INDEX_DOUBLE]->activeFlag); DualDecode_stopMedia (pipes[DECODER_INDEX_SINGLE]); - }else{ - if (window[DECODER_INDEX_SINGLE] == thisWindow){ - setControlMode(window[DECODER_INDEX_SINGLE], - CONTROL_MODE_STOPPED, - window[DECODER_INDEX_SINGLE]->activeFlag); - DualDecode_stopMedia(pipes[DECODER_INDEX_SINGLE]); - }else{ - setControlMode (window[DECODER_INDEX_DOUBLE], - CONTROL_MODE_STOPPED, - window[DECODER_INDEX_DOUBLE]->activeFlag); + } + else { + if (window[DECODER_INDEX_SINGLE] == thisWindow) { + setControlMode (window[DECODER_INDEX_SINGLE], CONTROL_MODE_STOPPED, + window[DECODER_INDEX_SINGLE]->activeFlag); + DualDecode_stopMedia (pipes[DECODER_INDEX_SINGLE]); + } + else { + setControlMode (window[DECODER_INDEX_DOUBLE], CONTROL_MODE_STOPPED, + window[DECODER_INDEX_DOUBLE]->activeFlag); DualDecode_stopMedia (pipes[DECODER_INDEX_DOUBLE]); } } return ret; } -static gboolean cbForwardClicked(GtkWidget *widget, gpointer data) +static gboolean cbForwardClicked (GtkWidget *widget, gpointer data) { gboolean ret = TRUE; GstFormat format = GST_FORMAT_TIME; @@ -447,33 +430,33 @@ static gboolean cbForwardClicked(GtkWidget *widget, gpointer data) gdouble percent = gtk_range_get_value ((GtkRange *) (thisWindow->seekScale)); g_print ("IN FORWARD CLICKED\n"); - if (DECODE_MODE_SINGLE == decodeMode){ + if (DECODE_MODE_SINGLE == decodeMode) { gst_element_query_duration (pipes[DECODER_INDEX_SINGLE]->pipe, &format,&duration); seekPoint = (duration * percent/ (gdouble)100)+ FORWARD; - g_print ("SEEK POINT %d\n", seekPoint); - ret = DualDecode_seekMedia(pipes[DECODER_INDEX_SINGLE], seekPoint); + g_print ("SEEK POINT %ld\n", seekPoint); + ret = DualDecode_seekMedia (pipes[DECODER_INDEX_SINGLE], seekPoint); } - else{ - if(window[DECODER_INDEX_SINGLE] == thisWindow){ + else { + if (window[DECODER_INDEX_SINGLE] == thisWindow) { gst_element_query_duration (pipes[DECODER_INDEX_SINGLE]->pipe, &format, &duration); seekPoint = (duration * percent/ (gdouble)100) + FORWARD; - g_print ("SEEK POINT %d\n", seekPoint); - ret = DualDecode_seekMedia(pipes[DECODER_INDEX_SINGLE], seekPoint); + g_print ("SEEK POINT %ld\n", seekPoint); + ret = DualDecode_seekMedia (pipes[DECODER_INDEX_SINGLE], seekPoint); } else { - gst_element_query_duration(pipes[DECODER_INDEX_SINGLE]->pipe, + gst_element_query_duration (pipes[DECODER_INDEX_SINGLE]->pipe, &format,&duration); seekPoint = (duration * percent/ (gdouble)100)+ FORWARD; - ret = DualDecode_seekMedia(pipes[DECODER_INDEX_DOUBLE], seekPoint); + ret = DualDecode_seekMedia (pipes[DECODER_INDEX_DOUBLE], seekPoint); } } return ret; } -static gboolean cbRewindClicked(GtkWidget *widget, gpointer data) +static gboolean cbRewindClicked (GtkWidget *widget, gpointer data) { gboolean ret = TRUE; GstFormat format = GST_FORMAT_TIME; @@ -483,30 +466,30 @@ static gboolean cbRewindClicked(GtkWidget *widget, gpointer data) gdouble percent = gtk_range_get_value ((GtkRange *) (thisWindow->seekScale)); g_print ("IN FORWARD CLICKED\n"); - if (DECODE_MODE_SINGLE == decodeMode){ + if (DECODE_MODE_SINGLE == decodeMode) { gst_element_query_duration (pipes[DECODER_INDEX_SINGLE]->pipe, &format,&duration); seekPoint = (duration * percent/ (gdouble)100) - REWIND; - g_print ("SEEK POINT %d\n", seekPoint); + g_print ("SEEK POINT %ld\n", seekPoint); seekPoint = (seekPoint < 0) ? 0 : seekPoint; - ret = DualDecode_seekMedia(pipes[DECODER_INDEX_SINGLE], seekPoint); + ret = DualDecode_seekMedia (pipes[DECODER_INDEX_SINGLE], seekPoint); } - else{ - if(window[DECODER_INDEX_SINGLE] == thisWindow){ + else { + if (window[DECODER_INDEX_SINGLE] == thisWindow) { gst_element_query_duration (pipes[DECODER_INDEX_SINGLE]->pipe, &format, &duration); seekPoint = (duration * percent/ (gdouble)100) - REWIND; - g_print ("SEEK POINT %d\n", seekPoint); + g_print ("SEEK POINT %ld\n", seekPoint); seekPoint = (seekPoint < 0) ? 0 : seekPoint; - ret = DualDecode_seekMedia(pipes[DECODER_INDEX_SINGLE], seekPoint); + ret = DualDecode_seekMedia (pipes[DECODER_INDEX_SINGLE], seekPoint); } else { - gst_element_query_duration(pipes[DECODER_INDEX_SINGLE]->pipe, + gst_element_query_duration (pipes[DECODER_INDEX_SINGLE]->pipe, &format,&duration); seekPoint = (duration * percent/ (gdouble)100) - REWIND; seekPoint = (seekPoint < 0) ? 0 : seekPoint; - ret = DualDecode_seekMedia(pipes[DECODER_INDEX_DOUBLE], seekPoint); + ret = DualDecode_seekMedia (pipes[DECODER_INDEX_DOUBLE], seekPoint); } } @@ -524,56 +507,51 @@ static gboolean cbSwitchButtonClicked (GtkWidget *widget, gpointer data) if (NULL == filename[DECODER_INDEX_SINGLE]) noFile = TRUE; - - - - if (thisWindow == window[DECODER_INDEX_SINGLE]){ + if (thisWindow == window[DECODER_INDEX_SINGLE]) { thisWindowIndex = DECODER_INDEX_SINGLE; otherWindowIndex = DECODER_INDEX_DOUBLE; } - else { + else + { otherWindowIndex = DECODER_INDEX_SINGLE; thisWindowIndex = DECODER_INDEX_DOUBLE; } - switch (decodeMode) - { - case DECODE_MODE_SINGLE : - setControlMode (window[otherWindowIndex], window[otherWindowIndex]->modeFlag, - CONTROL_MODE_ACTIVE); - setControlMode (thisWindow, thisWindow->modeFlag, - CONTROL_MODE_ACTIVE); + switch (decodeMode) { + case DECODE_MODE_SINGLE : + setControlMode (window[otherWindowIndex], + window[otherWindowIndex]->modeFlag, CONTROL_MODE_ACTIVE); + setControlMode (thisWindow, thisWindow->modeFlag, CONTROL_MODE_ACTIVE); - if (FALSE == noFile) { + if (FALSE == noFile) { ret = DualDecode_singleToDual (pipes, window[otherWindowIndex]->sink, thisWindowIndex, otherWindowIndex, filename[DECODER_INDEX_SINGLE]); - } - decodeMode = DECODE_MODE_DUAL; - setDecodeSwitch(DECODE_MODE_SINGLE); - break; + } + decodeMode = DECODE_MODE_DUAL; + setDecodeSwitch(DECODE_MODE_SINGLE); + break; - case DECODE_MODE_DUAL : - setControlMode (window[otherWindowIndex], thisWindow->modeFlag, + case DECODE_MODE_DUAL : + setControlMode (window[otherWindowIndex], thisWindow->modeFlag, CONTROL_MODE_INACTIVE); - if (FALSE == noFile) { - ret = DualDecode_dualToSingle (pipes, - window[otherWindowIndex]->sink, + if (FALSE == noFile) { + ret = DualDecode_dualToSingle (pipes, + window[otherWindowIndex]->sink, thisWindowIndex, otherWindowIndex); - } - decodeMode = DECODE_MODE_SINGLE; - setDecodeSwitch(DECODE_MODE_DUAL); - - break; + } + decodeMode = DECODE_MODE_SINGLE; + setDecodeSwitch (DECODE_MODE_DUAL); + break; } return ret; } /*Window Close Callback Function*/ -static gboolean cbWindowClosed(GtkWidget *widget, gpointer data){ +static gboolean cbWindowClosed (GtkWidget *widget, gpointer data){ DualDecode_exitApplication(); return TRUE; } @@ -594,142 +572,131 @@ static gboolean cbHelpClosed (GtkWidget *widget, gpointer data){ Static utility functions definition ******************************************************************************/ -static void setControlActive(GUIWindow *window, gboolean activeFlag) +static void setControlActive (GUIWindow *window, gboolean activeFlag) { - gtk_widget_set_sensitive(window->playButton,activeFlag); - gtk_widget_set_sensitive(window->pauseButton,activeFlag); - gtk_widget_set_sensitive(window->stopButton,activeFlag); - gtk_widget_set_sensitive(window->rewindButton,activeFlag); - gtk_widget_set_sensitive(window->forwardButton,activeFlag); - gtk_widget_set_sensitive(window->openButton,activeFlag); - gtk_widget_set_sensitive(window->seekScale,activeFlag); + gtk_widget_set_sensitive (window->playButton,activeFlag); + gtk_widget_set_sensitive (window->pauseButton,activeFlag); + gtk_widget_set_sensitive (window->stopButton,activeFlag); + gtk_widget_set_sensitive (window->rewindButton,activeFlag); + gtk_widget_set_sensitive (window->forwardButton,activeFlag); + gtk_widget_set_sensitive (window->openButton,activeFlag); + gtk_widget_set_sensitive (window->seekScale,activeFlag); gtk_widget_set_sensitive (window->switchButton, activeFlag); } -static void setControlMode(GUIWindow *thisWindow, - gint modeFlag, - gint activeFlag) +static void setControlMode (GUIWindow *thisWindow, gint modeFlag, + gint activeFlag) { - setControlActive(thisWindow, activeFlag); - if(activeFlag){ - switch(modeFlag){ - case CONTROL_MODE_NO_FILE: - gtk_widget_set_sensitive(thisWindow->playButton,FALSE); - gtk_widget_set_sensitive(thisWindow->pauseButton,FALSE); - - gtk_widget_set_sensitive(thisWindow->stopButton,FALSE); - gtk_widget_set_sensitive(thisWindow->rewindButton,FALSE); - gtk_widget_set_sensitive(thisWindow->forwardButton,FALSE); - gtk_widget_set_sensitive(thisWindow->seekScale,FALSE); - - break; - case CONTROL_MODE_PLAYING: - gtk_widget_set_sensitive(thisWindow->playButton,TRUE); - gtk_widget_set_sensitive(thisWindow->pauseButton,TRUE); - - gtk_widget_set_sensitive(thisWindow->stopButton,TRUE); - gtk_widget_set_sensitive(thisWindow->rewindButton,TRUE); - gtk_widget_set_sensitive(thisWindow->forwardButton,TRUE); - gtk_widget_set_sensitive(thisWindow->seekScale,TRUE); - - break; - case CONTROL_MODE_STOPPED: - gtk_widget_set_sensitive(thisWindow->playButton,TRUE); - gtk_widget_set_sensitive(thisWindow->pauseButton,TRUE); - - gtk_widget_set_sensitive(thisWindow->stopButton,TRUE); - gtk_widget_set_sensitive(thisWindow->rewindButton,TRUE); - gtk_widget_set_sensitive(thisWindow->forwardButton,TRUE); - gtk_widget_set_sensitive(thisWindow->seekScale,FALSE); - - break; - case CONTROL_MODE_PAUSED: - gtk_widget_set_sensitive(thisWindow->playButton,TRUE); - gtk_widget_set_sensitive(thisWindow->pauseButton,TRUE); - - gtk_widget_set_sensitive(thisWindow->stopButton,TRUE); - gtk_widget_set_sensitive(thisWindow->rewindButton,TRUE); - gtk_widget_set_sensitive(thisWindow->forwardButton,TRUE); - gtk_widget_set_sensitive(thisWindow->seekScale,TRUE); - - break; + setControlActive (thisWindow, activeFlag); + if (activeFlag) { + switch (modeFlag) { + case CONTROL_MODE_NO_FILE: + gtk_widget_set_sensitive (thisWindow->playButton,FALSE); + gtk_widget_set_sensitive (thisWindow->pauseButton,FALSE); + gtk_widget_set_sensitive (thisWindow->stopButton,FALSE); + gtk_widget_set_sensitive (thisWindow->rewindButton,FALSE); + gtk_widget_set_sensitive (thisWindow->forwardButton,FALSE); + gtk_widget_set_sensitive (thisWindow->seekScale,FALSE); + break; + case CONTROL_MODE_PLAYING: + gtk_widget_set_sensitive (thisWindow->playButton,TRUE); + gtk_widget_set_sensitive (thisWindow->pauseButton,TRUE); + gtk_widget_set_sensitive (thisWindow->stopButton,TRUE); + gtk_widget_set_sensitive (thisWindow->rewindButton,TRUE); + gtk_widget_set_sensitive (thisWindow->forwardButton,TRUE); + gtk_widget_set_sensitive (thisWindow->seekScale,TRUE); + break; + case CONTROL_MODE_STOPPED: + gtk_widget_set_sensitive (thisWindow->playButton,TRUE); + gtk_widget_set_sensitive (thisWindow->pauseButton,TRUE); + gtk_widget_set_sensitive (thisWindow->stopButton,TRUE); + gtk_widget_set_sensitive (thisWindow->rewindButton,TRUE); + gtk_widget_set_sensitive (thisWindow->forwardButton,TRUE); + gtk_widget_set_sensitive (thisWindow->seekScale,FALSE); + break; + case CONTROL_MODE_PAUSED: + gtk_widget_set_sensitive (thisWindow->playButton,TRUE); + gtk_widget_set_sensitive (thisWindow->pauseButton,TRUE); + gtk_widget_set_sensitive (thisWindow->stopButton,TRUE); + gtk_widget_set_sensitive (thisWindow->rewindButton,TRUE); + gtk_widget_set_sensitive (thisWindow->forwardButton,TRUE); + gtk_widget_set_sensitive (thisWindow->seekScale,TRUE); + break; } } - switch(modeFlag){ - case CONTROL_MODE_NO_FILE: - gtk_widget_show(thisWindow->playButton); - gtk_widget_hide(thisWindow->pauseButton); + switch (modeFlag) { + case CONTROL_MODE_NO_FILE: + gtk_widget_show (thisWindow->playButton); + gtk_widget_hide (thisWindow->pauseButton); - gtk_label_set_text(GTK_LABEL(thisWindow->statusLabel), + gtk_label_set_text (GTK_LABEL(thisWindow->statusLabel), LABEL_TEXT_NO_FILE); - gtk_label_set_text(GTK_LABEL(thisWindow->timeLabel), + gtk_label_set_text (GTK_LABEL(thisWindow->timeLabel), TIME_LABEL_ORIGIN); - if(thisWindow->timerSignal != TIMER_SIGNAL_NONE){ - g_source_remove(thisWindow->timerSignal); - thisWindow->timerSignal = TIMER_SIGNAL_NONE; - } - break; - case CONTROL_MODE_PLAYING: - gtk_widget_show(thisWindow->pauseButton); - gtk_widget_hide(thisWindow->playButton); + if (thisWindow->timerSignal != TIMER_SIGNAL_NONE) { + g_source_remove (thisWindow->timerSignal); + thisWindow->timerSignal = TIMER_SIGNAL_NONE; + } + break; + case CONTROL_MODE_PLAYING: + gtk_widget_show (thisWindow->pauseButton); + gtk_widget_hide (thisWindow->playButton); - gtk_label_set_text(GTK_LABEL(thisWindow->statusLabel), + gtk_label_set_text (GTK_LABEL(thisWindow->statusLabel), LABEL_TEXT_PLAYING); - gtk_label_set_text(GTK_LABEL(thisWindow->timeLabel), + gtk_label_set_text (GTK_LABEL(thisWindow->timeLabel), TIME_LABEL_ORIGIN); - if(thisWindow->timerSignal != TIMER_SIGNAL_NONE){ - g_source_remove(thisWindow->timerSignal); - } - thisWindow->timerSignal = g_timeout_add(TIMER_INTERVAL, - cbTimerInterval, - thisWindow); + if (thisWindow->timerSignal != TIMER_SIGNAL_NONE) { + g_source_remove (thisWindow->timerSignal); + } + thisWindow->timerSignal = g_timeout_add (TIMER_INTERVAL, cbTimerInterval, + thisWindow); - break; - case CONTROL_MODE_STOPPED: - gtk_widget_show(thisWindow->playButton); - gtk_widget_hide(thisWindow->pauseButton); - - gtk_label_set_text(GTK_LABEL(thisWindow->statusLabel), - LABEL_TEXT_STOPPED); - gtk_label_set_text(GTK_LABEL(thisWindow->timeLabel), - TIME_LABEL_ORIGIN); - - if(thisWindow->timerSignal != TIMER_SIGNAL_NONE){ - g_source_remove(thisWindow->timerSignal); - thisWindow->timerSignal = TIMER_SIGNAL_NONE; - } - break; - case CONTROL_MODE_PAUSED: - gtk_widget_show(thisWindow->playButton); - gtk_widget_hide(thisWindow->pauseButton); + break; + case CONTROL_MODE_STOPPED: + gtk_widget_show (thisWindow->playButton); + gtk_widget_hide (thisWindow->pauseButton); + + gtk_label_set_text (GTK_LABEL(thisWindow->statusLabel), + LABEL_TEXT_STOPPED); + gtk_label_set_text (GTK_LABEL(thisWindow->timeLabel), TIME_LABEL_ORIGIN); + + if (thisWindow->timerSignal != TIMER_SIGNAL_NONE) { + g_source_remove(thisWindow->timerSignal); + thisWindow->timerSignal = TIMER_SIGNAL_NONE; + } + break; + case CONTROL_MODE_PAUSED: + gtk_widget_show(thisWindow->playButton); + gtk_widget_hide(thisWindow->pauseButton); - gtk_label_set_text(GTK_LABEL(thisWindow->statusLabel), - LABEL_TEXT_PAUSED); - break; + gtk_label_set_text (GTK_LABEL (thisWindow->statusLabel), + LABEL_TEXT_PAUSED); + break; } thisWindow->modeFlag = modeFlag; thisWindow->activeFlag = activeFlag; } -static void setDecodeSwitch(gint decodeSwitch) +static void setDecodeSwitch (gint decodeSwitch) { - switch (decodeSwitch){ - case DECODE_MODE_SINGLE: - gtk_button_set_label( - GTK_BUTTON(window[DECODER_INDEX_SINGLE]->switchButton), + switch (decodeSwitch) { + case DECODE_MODE_SINGLE: + gtk_button_set_label ( + GTK_BUTTON (window[DECODER_INDEX_SINGLE]->switchButton), SWITCH_TEXT_SINGLE); - gtk_button_set_label( - GTK_BUTTON(window[DECODER_INDEX_DOUBLE]->switchButton), + gtk_button_set_label ( + GTK_BUTTON (window[DECODER_INDEX_DOUBLE]->switchButton), SWITCH_TEXT_SINGLE); - break; - case DECODE_MODE_DUAL: - gtk_button_set_label( + break; + case DECODE_MODE_DUAL: + gtk_button_set_label ( GTK_BUTTON(window[DECODER_INDEX_SINGLE]->switchButton), SWITCH_TEXT_DUAL); - gtk_button_set_label( + gtk_button_set_label ( GTK_BUTTON(window[DECODER_INDEX_DOUBLE]->switchButton), SWITCH_TEXT_DUAL); } @@ -757,76 +724,62 @@ static void setup() DualDecode_exitApplication(); } - switch(decodeMode){ - case DECODE_MODE_NONE: - setControlMode(window[DECODER_INDEX_SINGLE], - CONTROL_MODE_NO_FILE, - CONTROL_MODE_ACTIVE); - setControlMode(window[DECODER_INDEX_DOUBLE], - CONTROL_MODE_NO_FILE, - CONTROL_MODE_ACTIVE); - DualDecode_setPipelineSink (pipes[DECODER_INDEX_SINGLE], - window[DECODER_INDEX_SINGLE]->sink, - NULL); - DualDecode_setPipelineSink (pipes[DECODER_INDEX_DOUBLE], - window[DECODER_INDEX_DOUBLE]->sink, - NULL); - decodeMode = DECODE_MODE_DUAL; - setDecodeSwitch(DECODE_MODE_SINGLE); - break; - case DECODE_MODE_SINGLE: - setControlMode (window[DECODER_INDEX_SINGLE], - CONTROL_MODE_PLAYING, - CONTROL_MODE_ACTIVE); - setControlMode (window[DECODER_INDEX_DOUBLE], - CONTROL_MODE_PLAYING, - CONTROL_MODE_INACTIVE); - DualDecode_setPipelineSink (pipes[DECODER_INDEX_SINGLE], - window[DECODER_INDEX_SINGLE]->sink, - window[DECODER_INDEX_DOUBLE]->sink); - DualDecode_setPipelineSink (pipes[DECODER_INDEX_DOUBLE], NULL, - NULL); - DualDecode_playMedia (pipes[DECODER_INDEX_SINGLE], - filename[DECODER_INDEX_SINGLE], - SEEK_START); - setDecodeSwitch(DECODE_MODE_DUAL); - break; - case DECODE_MODE_DUAL: - setControlMode(window[DECODER_INDEX_SINGLE], - CONTROL_MODE_PLAYING, - CONTROL_MODE_ACTIVE); - DualDecode_setPipelineSink (pipes[DECODER_INDEX_SINGLE], - window[DECODER_INDEX_SINGLE]->sink, - NULL); - DualDecode_setPipelineSink (pipes[DECODER_INDEX_DOUBLE], - window[DECODER_INDEX_DOUBLE]->sink, - NULL); - - DualDecode_playMedia(pipes[DECODER_INDEX_SINGLE], - filename[DECODER_INDEX_SINGLE], - SEEK_START); - setControlMode(window[DECODER_INDEX_DOUBLE], - CONTROL_MODE_PLAYING, - CONTROL_MODE_ACTIVE); - DualDecode_playMedia(pipes[DECODER_INDEX_DOUBLE], - filename[DECODER_INDEX_DOUBLE], - SEEK_START); - setDecodeSwitch(DECODE_MODE_SINGLE); - break; + switch (decodeMode) { + case DECODE_MODE_NONE: + setControlMode (window[DECODER_INDEX_SINGLE], CONTROL_MODE_NO_FILE, + CONTROL_MODE_ACTIVE); + setControlMode (window[DECODER_INDEX_DOUBLE], CONTROL_MODE_NO_FILE, + CONTROL_MODE_ACTIVE); + DualDecode_setPipelineSink (pipes[DECODER_INDEX_SINGLE], + window[DECODER_INDEX_SINGLE]->sink, NULL); + DualDecode_setPipelineSink (pipes[DECODER_INDEX_DOUBLE], + window[DECODER_INDEX_DOUBLE]->sink, NULL); + decodeMode = DECODE_MODE_DUAL; + setDecodeSwitch (DECODE_MODE_SINGLE); + break; + case DECODE_MODE_SINGLE: + setControlMode (window[DECODER_INDEX_SINGLE], + CONTROL_MODE_PLAYING, CONTROL_MODE_ACTIVE); + setControlMode (window[DECODER_INDEX_DOUBLE],CONTROL_MODE_PLAYING, + CONTROL_MODE_INACTIVE); + DualDecode_setPipelineSink (pipes[DECODER_INDEX_SINGLE], + window[DECODER_INDEX_SINGLE]->sink, + window[DECODER_INDEX_DOUBLE]->sink); + DualDecode_setPipelineSink (pipes[DECODER_INDEX_DOUBLE], NULL, NULL); + DualDecode_playMedia (pipes[DECODER_INDEX_SINGLE], + filename[DECODER_INDEX_SINGLE], SEEK_START); + setDecodeSwitch (DECODE_MODE_DUAL); + break; + case DECODE_MODE_DUAL: + setControlMode (window[DECODER_INDEX_SINGLE], CONTROL_MODE_PLAYING, + CONTROL_MODE_ACTIVE); + DualDecode_setPipelineSink (pipes[DECODER_INDEX_SINGLE], + window[DECODER_INDEX_SINGLE]->sink, NULL); + DualDecode_setPipelineSink (pipes[DECODER_INDEX_DOUBLE], + window[DECODER_INDEX_DOUBLE]->sink, NULL); + + DualDecode_playMedia (pipes[DECODER_INDEX_SINGLE], + filename[DECODER_INDEX_SINGLE], SEEK_START); + setControlMode (window[DECODER_INDEX_DOUBLE], CONTROL_MODE_PLAYING, + CONTROL_MODE_ACTIVE); + DualDecode_playMedia (pipes[DECODER_INDEX_DOUBLE], + filename[DECODER_INDEX_DOUBLE], SEEK_START); + setDecodeSwitch (DECODE_MODE_SINGLE); + break; } } static GUIWindow *createWindow() { GUIWindow *ret = NULL; - ret = g_malloc0(sizeof(GUIWindow)); + ret = g_malloc0 (sizeof(GUIWindow)); if(NULL == ret){ return ret; } - DualDecode_builderCreate(); + DualDecode_builderCreate (); - ret->window = DualDecode_getWidget("decodeWindowSingle"); - if(NULL == ret->window){ + ret->window = DualDecode_getWidget ("decodeWindowSingle"); + if (NULL == ret->window) { goto memCleanup; } ret->windowCloseSignal = g_signal_connect(G_OBJECT(ret->window), @@ -834,159 +787,134 @@ static GUIWindow *createWindow() G_CALLBACK(cbWindowClosed), NULL); - GtkWidget *toolbar = DualDecode_getWidget("toolbarSingle"); - if(NULL == toolbar){ + GtkWidget *toolbar = DualDecode_getWidget ("toolbarSingle"); + if (NULL == toolbar) { goto memCleanup; } - ret->drawArea = DualDecode_getWidget("videoViewerSingle"); - if(NULL == ret->drawArea){ + ret->drawArea = DualDecode_getWidget ("videoViewerSingle"); + if (NULL == ret->drawArea) { goto memCleanup; } - ret->openButton = GTK_WIDGET( - gtk_tool_button_new_from_stock(GTK_STOCK_OPEN)); - if(NULL == ret->openButton){ + ret->openButton = GTK_WIDGET ( + gtk_tool_button_new_from_stock(GTK_STOCK_OPEN)); + if (NULL == ret->openButton) { goto memCleanup; } - ret->rewindButton = GTK_WIDGET( - gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_REWIND)); - if(NULL == ret->rewindButton){ + ret->rewindButton = GTK_WIDGET ( + gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_REWIND)); + if (NULL == ret->rewindButton) { goto memCleanup; } - ret->playButton = GTK_WIDGET( - gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_PLAY)); - if(NULL == ret->playButton){ + ret->playButton = GTK_WIDGET ( + gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_PLAY)); + if (NULL == ret->playButton) { goto memCleanup; } - ret->pauseButton = GTK_WIDGET( - gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_PAUSE)); - if(NULL == ret->pauseButton){ + ret->pauseButton = GTK_WIDGET ( + gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_PAUSE)); + if (NULL == ret->pauseButton) { goto memCleanup; } - ret->stopButton = GTK_WIDGET( - gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_STOP)); - if(NULL == ret->stopButton){ + ret->stopButton = GTK_WIDGET ( + gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_STOP)); + if (NULL == ret->stopButton) { goto memCleanup; } - ret->forwardButton = GTK_WIDGET( - gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_FORWARD)); - if(NULL == ret->forwardButton){ + ret->forwardButton = GTK_WIDGET ( + gtk_tool_button_new_from_stock(GTK_STOCK_MEDIA_FORWARD)); + if (NULL == ret->forwardButton) { goto memCleanup; } - ret->helpButton = GTK_WIDGET( - gtk_tool_button_new_from_stock(GTK_STOCK_HELP)); - if(NULL == ret->helpButton){ + ret->helpButton = GTK_WIDGET ( + gtk_tool_button_new_from_stock(GTK_STOCK_HELP)); + if (NULL == ret->helpButton) { goto memCleanup; } - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), - GTK_TOOL_ITEM(ret->openButton), - -1); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), - gtk_separator_tool_item_new(), - -1); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), - GTK_TOOL_ITEM(ret->rewindButton), - -1); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), - GTK_TOOL_ITEM(ret->playButton), - -1); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), - GTK_TOOL_ITEM(ret->pauseButton), - -1); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), - GTK_TOOL_ITEM(ret->stopButton), - -1); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), - GTK_TOOL_ITEM(ret->forwardButton), - -1); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), - gtk_separator_tool_item_new(), - -1); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), - GTK_TOOL_ITEM(ret->helpButton), - -1); - - ret->openSignal = g_signal_connect(G_OBJECT(ret->openButton), - "clicked", - G_CALLBACK(cbOpenClicked), - ret); - ret->stopSignal = g_signal_connect(G_OBJECT(ret->stopButton), - "clicked", - G_CALLBACK(cbStopClicked), + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (ret->openButton), + -1); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), gtk_separator_tool_item_new(), + -1); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM(ret->rewindButton), + -1); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM(ret->playButton), + -1); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM(ret->pauseButton), + -1); + gtk_toolbar_insert (GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(ret->stopButton), + -1); + gtk_toolbar_insert (GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(ret->forwardButton), + -1); + gtk_toolbar_insert (GTK_TOOLBAR(toolbar), gtk_separator_tool_item_new(), + -1); + gtk_toolbar_insert (GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(ret->helpButton), + -1); + + ret->openSignal = g_signal_connect (G_OBJECT (ret->openButton), "clicked", + G_CALLBACK (cbOpenClicked), ret); + ret->stopSignal = g_signal_connect (G_OBJECT (ret->stopButton), "clicked", + G_CALLBACK (cbStopClicked), ret); + ret->pauseSignal = g_signal_connect (G_OBJECT (ret->pauseButton), "clicked", + G_CALLBACK (cbPauseClicked), ret); + ret->playSignal = g_signal_connect (G_OBJECT (ret->playButton), "clicked", + G_CALLBACK (cbPlayClicked), ret); - ret->pauseSignal = g_signal_connect(G_OBJECT(ret->pauseButton), - "clicked", - G_CALLBACK(cbPauseClicked), - ret); - ret->playSignal = g_signal_connect(G_OBJECT(ret->playButton), - "clicked", - G_CALLBACK(cbPlayClicked), - ret); - ret->forwardSignal = g_signal_connect(G_OBJECT(ret->forwardButton), - "clicked", - G_CALLBACK(cbForwardClicked), - ret); - ret->rewindSignal = g_signal_connect(G_OBJECT(ret->rewindButton), - "clicked", - G_CALLBACK(cbRewindClicked), - ret); - - ret->helpSignal = g_signal_connect(G_OBJECT(ret->helpButton), - "clicked", - G_CALLBACK(cbHelpClicked), - ret); - - - ret->switchButton = DualDecode_getWidget("switchButtonSingle"); - if(NULL == ret->switchButton){ + ret->forwardSignal = g_signal_connect (G_OBJECT (ret->forwardButton),"clicked", + G_CALLBACK (cbForwardClicked), ret); + ret->rewindSignal = g_signal_connect (G_OBJECT (ret->rewindButton),"clicked", + G_CALLBACK (cbRewindClicked), ret); + + ret->helpSignal = g_signal_connect (G_OBJECT (ret->helpButton), "clicked", + G_CALLBACK(cbHelpClicked), ret); + + + ret->switchButton = DualDecode_getWidget ("switchButtonSingle"); + if (NULL == ret->switchButton) { goto memCleanup; } - ret->switchSignal = g_signal_connect (G_OBJECT (ret->switchButton), - "clicked", - G_CALLBACK (cbSwitchButtonClicked), - ret); + ret->switchSignal = g_signal_connect (G_OBJECT (ret->switchButton), "clicked", + G_CALLBACK (cbSwitchButtonClicked), + ret); - ret->seekScale = DualDecode_getWidget("seekScaleSingle"); - if(NULL == ret->seekScale){ + ret->seekScale = DualDecode_getWidget ("seekScaleSingle"); + if (NULL == ret->seekScale) { goto memCleanup; } - ret->seekSignal = g_signal_connect (G_OBJECT (ret->seekScale), - "value_changed", - G_CALLBACK (cbSeekValueChanged), - ret); + ret->seekSignal = g_signal_connect (G_OBJECT (ret->seekScale), + "value_changed", + G_CALLBACK (cbSeekValueChanged), ret); - ret->statusLabel = DualDecode_getWidget("statusLabelSingle"); - if(NULL == ret->statusLabel){ + ret->statusLabel = DualDecode_getWidget ("statusLabelSingle"); + if (NULL == ret->statusLabel) { goto memCleanup; } - ret->timeLabel = DualDecode_getWidget("timeLabelSingle"); - if(NULL == ret->timeLabel){ + ret->timeLabel = DualDecode_getWidget ("timeLabelSingle"); + if (NULL == ret->timeLabel) { goto memCleanup; } ret->activeFlag = FALSE; goto last; - gtk_widget_destroy(ret->window); + gtk_widget_destroy (ret->window); memCleanup: - g_free(ret); + g_free (ret); last: - DualDecode_builderClose(); + DualDecode_builderClose (); return ret; } -static GtkWidget *createLogWindow() +static GtkWidget *createLogWindow () { - /*TODO: create help window*/ - return gtk_window_new(GTK_WINDOW_TOPLEVEL); + return gtk_window_new (GTK_WINDOW_TOPLEVEL); } -static GtkWidget *createHelpWindow() +static GtkWidget *createHelpWindow () { GtkWidget * helpWindow; gint width; @@ -1010,11 +938,7 @@ static GtkWidget *createHelpWindow() -/*static void logGUI(GtkWidget *logWindow, gchar *format, ...) -{ - //TODO: dummy now -}*/ -static void setWindowSizeLocation() +static void setWindowSizeLocation () { GdkScreen *screen = NULL; gint screenWidth = -1; @@ -1022,47 +946,46 @@ static void setWindowSizeLocation() gint windowWidth = -1; gint windowHeight = -1; - screen = gdk_screen_get_default(); - screenWidth = gdk_screen_get_width(screen); - screenHeight = gdk_screen_get_height(screen); + screen = gdk_screen_get_default (); + screenWidth = gdk_screen_get_width (screen); + screenHeight = gdk_screen_get_height (screen); windowWidth = screenWidth/SCREEN_WIDTH_FACTOR; windowHeight = screenHeight/SCREEN_HEIGHT_FACTOR; - gtk_widget_set_size_request(window[DECODER_INDEX_SINGLE]->window, - windowWidth,windowHeight); - gtk_widget_set_size_request(window[DECODER_INDEX_DOUBLE]->window, - windowWidth,windowHeight); - gtk_window_move(GTK_WINDOW(window[DECODER_INDEX_SINGLE]->window), - (screenWidth-2*windowWidth)/2, - 0); - gtk_window_move(GTK_WINDOW(window[DECODER_INDEX_DOUBLE]->window), - (screenWidth-2*windowWidth)/2+windowWidth, + gtk_widget_set_size_request (window[DECODER_INDEX_SINGLE]->window, + windowWidth,windowHeight); + gtk_widget_set_size_request (window[DECODER_INDEX_DOUBLE]->window, + windowWidth,windowHeight); + gtk_window_move (GTK_WINDOW (window[DECODER_INDEX_SINGLE]->window), + (screenWidth - 2 * windowWidth) / 2, 0); + gtk_window_move (GTK_WINDOW (window[DECODER_INDEX_DOUBLE]->window), + (screenWidth - 2 * windowWidth) / 2 + windowWidth, 0); } static GstElement *createImageSinkFromWindow (GtkWidget * window, gchar *name) { - GstElement *sinkElement = NULL; + GstElement *sinkElement = NULL; XID xid = 0; GdkDrawable *drawable = NULL; /*make an xvimagesink element from factory*/ sinkElement = gst_element_factory_make (sink,name); - if (NULL == sinkElement){ + if (NULL == sinkElement) { g_print ("%s sink cannot be created\n", sink); goto return_pos; } /*get the XID of the display window's drawable*/ drawable = gtk_widget_get_window (GTK_WIDGET (window)); - if(FALSE == GDK_IS_DRAWABLE(drawable)){ + if (FALSE == GDK_IS_DRAWABLE (drawable)) { /*TODO: A BUG HERE?*/ g_object_unref (G_OBJECT (sinkElement)); sinkElement=NULL; goto return_pos; } - xid = gdk_x11_drawable_get_xid(drawable); + xid = gdk_x11_drawable_get_xid (drawable); /*link the gst sink element to the XID*/ gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sinkElement),xid); @@ -1072,81 +995,60 @@ return_pos: } /****************************************************************************** - * Exported Function Definition + + Public Functions + ******************************************************************************/ /****************************************************************************** - * See gui.h + See gui.h ******************************************************************************/ -void DualDecode_startApplication() +void DualDecode_startApplication () { window[DECODER_INDEX_SINGLE] = createWindow(); - g_assert(window[DECODER_INDEX_SINGLE] != NULL); + g_assert (window[DECODER_INDEX_SINGLE] != NULL); - /*window[DECODER_INDEX_SINGLE]->sink = createImageSinkFromWindow ( - window[DECODER_INDEX_SINGLE]->drawArea, - "sink0"); - - */ window[DECODER_INDEX_DOUBLE] = createWindow(); - g_assert(window[DECODER_INDEX_DOUBLE] != NULL); + g_assert (window[DECODER_INDEX_DOUBLE] != NULL); - /* window[DECODER_INDEX_DOUBLE]->sink = createImageSinkFromWindow ( - window[DECODER_INDEX_DOUBLE]->drawArea, - "sink1"); - */ setWindowSizeLocation(); helpWindow = createHelpWindow(); g_assert (helpWindow != NULL); - logWindow[DECODER_INDEX_SINGLE] = createLogWindow(); + logWindow[DECODER_INDEX_SINGLE] = createLogWindow (); g_assert (logWindow[DECODER_INDEX_SINGLE] != NULL); - logWindow[DECODER_INDEX_DOUBLE] = createLogWindow(); + logWindow[DECODER_INDEX_DOUBLE] = createLogWindow (); g_assert (logWindow[DECODER_INDEX_DOUBLE] != NULL); - pipes[DECODER_INDEX_SINGLE] = DualDecode_createPipeline(); -/* DualDecode_setLogFunction(pipes[DECODER_INDEX_SINGLE], - logGUI, - logWindow[DECODER_INDEX_SINGLE]); -*/ - pipes[DECODER_INDEX_DOUBLE] = DualDecode_createPipeline(); -/* DualDecode_setLogFunction(pipes[DECODER_INDEX_DOUBLE], - logGUI, - logWindow[DECODER_INDEX_DOUBLE]); -*/ - setup(); - - gtk_main(); + pipes[DECODER_INDEX_SINGLE] = DualDecode_createPipeline (); + pipes[DECODER_INDEX_DOUBLE] = DualDecode_createPipeline (); + setup (); + + gtk_main (); } -/****************************************************************************** - * See gui.h - ******************************************************************************/ void DualDecode_exitApplication() { - gtk_widget_destroy(window[DECODER_INDEX_SINGLE]->window); - gtk_widget_destroy(window[DECODER_INDEX_DOUBLE]->window); - g_free(window[DECODER_INDEX_SINGLE]); - g_free(window[DECODER_INDEX_DOUBLE]); - gtk_widget_destroy(logWindow[DECODER_INDEX_SINGLE]); - gtk_widget_destroy(logWindow[DECODER_INDEX_DOUBLE]); + gtk_widget_destroy (window[DECODER_INDEX_SINGLE]->window); + gtk_widget_destroy (window[DECODER_INDEX_DOUBLE]->window); + g_free (window[DECODER_INDEX_SINGLE]); + g_free (window[DECODER_INDEX_DOUBLE]); + gtk_widget_destroy (logWindow[DECODER_INDEX_SINGLE]); + gtk_widget_destroy (logWindow[DECODER_INDEX_DOUBLE]); gtk_widget_destroy (helpWindow); /*TODO: destroy pipes here*/ if (gtk_main_level()) - gtk_main_quit(); - exit(0); + gtk_main_quit (); + exit (0); } -/****************************************************************************** - * See gui.h - ******************************************************************************/ gboolean DualDecode_initGUI(gint *argc, char **argv[]) { - return gtk_init_check(argc,argv); + return gtk_init_check (argc,argv); } diff --git a/src/main.c b/src/main.c index 3712174..beef8f0 100644 --- a/src/main.c +++ b/src/main.c @@ -50,8 +50,8 @@ #include #include -#include -#include +#include "common.h" +#include "gui.h" gint decodeMode = DECODE_MODE_NONE; gchar *filename[] = {NULL, NULL}; @@ -63,7 +63,7 @@ const gchar *version_text = "0.2"; gint setAbsolutePathname (gchar *file, gchar **uri) { - gchar *realPath = NULL; + gchar *realPathname = NULL; gint ret = ERR_SUCCESS; if (NULL == uri){ @@ -71,26 +71,26 @@ gint setAbsolutePathname (gchar *file, gchar **uri) } if (NULL == file){ - g_printerr("BUG: file: " __FILE__ " line: %d" "\n", __LINE__); + g_printerr ("BUG: file: " __FILE__ " line: %d" "\n", __LINE__); return ERR_BUG; } *uri = (gchar *) g_malloc (sizeof(gchar) * PATH_MAX_LEN); - realPath = realpath (file, realPath); - if (NULL == realPath) { + realPathname = realpath (file, realPathname); + if (NULL == realPathname) { g_printerr ("File %s not found\n", file); ret = ERR_FILENOTFOUND; goto destroy; } - g_snprintf (*uri,PATH_MAX_LEN,"file://%s",realPath); + g_snprintf (*uri,PATH_MAX_LEN,"file://%s",realPathname); goto last; destroy: - g_free(*uri); + g_free (*uri); *uri = NULL; last: - free (realPath); + free (realPathname); return ret; } @@ -117,7 +117,7 @@ gint processOpts() decodeMode++; filename[fileCount] = uri; }else{ - g_printerr("Ignoring file : %s\n",files[fileCount]); + g_printerr ("Ignoring file : %s\n",files[fileCount]); } fileCount++; } @@ -147,7 +147,7 @@ gint processArgs (int *argc, char **argv[]) /* Parse the command line arguments and options*/ if (!g_option_context_parse (context, argc, argv, &error)) { g_printerr ("option parsing failed: %s\n", error->message); - g_error_free(error); + g_error_free (error); return ERR_OPTIONPARSE; } return processOpts (); @@ -155,7 +155,7 @@ gint processArgs (int *argc, char **argv[]) -int main(int argc, char *argv[]) +int main (int argc, char *argv[]) { gint ret = ERR_SUCCESS; @@ -164,7 +164,7 @@ int main(int argc, char *argv[]) return ret; } - if(FALSE == DualDecode_initGUI(&argc,&argv)){ + if (FALSE == DualDecode_initGUI(&argc,&argv)) { /*replace with a debug*/ g_printerr("X is not found. Exiting\n"); return ERR_XNOTFOUND; -- 2.39.2