diff --git a/include/gui.h b/include/gui.h
index bb3f714383baaee990025e4eb59618200e657862..f9374c11fb0a4fdd88b24096b821c3f6cc81e32a 100644 (file)
--- a/include/gui.h
+++ b/include/gui.h
-/*
- * Copyright (c) 2010-2011, 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.h
- *
- * @brief function declarations for the GUI functions
- */
-
-#ifndef __GUI_H__
-#define __GUI_H__
-
-#include<gst/gst.h>
-
-#ifdef GST_APP_DEBUG
-#define debug(args...) g_printerr(args)
-#else
-#define debug(args...)
-#endif
-
-#define NANOSEC 1e9
-#define WINDOW_WIDTH 1200
-#define WINDOW_HEIGHT 50
-#define STRLEN 100
-#define PLAY 0
-#define OPEN 1
-#define STOP 2
-#define TITLE "Player"
-/**
- * @brief set the scale widget appropriately when a duration and position
- * is obtained.
- *
- * @param [IN] totalDuration total duration of media file
- * @param [IN] currPosition position of media file being played
- *
- * called from: timer callback function
- */
-void set_duration (gint64 totalDuration , gint64 currPosition);
-
-/**
- * @brief exits gtk_main loop and destroys the window widget
- *
- * called from: EOS and ERROR handlers
- */
-void exit_application(void);
-
-/**
- * @brief initialises GUI. TODO: one problem. NO ERROR HANDLING.
- *
- * @param [IN] argc pointer to number of arguments to the program
- * @param [IN] argv pointer to argument string to the program
- *
- * called from: main()
- */
-void init_gui (int *argc, char **argv[], GstElement *inpipeline);
-
-#endif /*__GUI_H__*/
+/*\r
+ * Copyright (c) 2012-2013, Texas Instruments Incorporated\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ *\r
+ * * Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ *\r
+ * * Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ *\r
+ * * Neither the name of Texas Instruments Incorporated nor the names of\r
+ * its contributors may be used to endorse or promote products derived\r
+ * from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ * Contact information for paper mail:\r
+ * Texas Instruments\r
+ * Post Office Box 655303\r
+ * Dallas, Texas 75265\r
+ * Contact information:\r
+ * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm\r
+ * ?DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact\r
+ * ============================================================================\r
+ *\r
+ */\r
+\r
+/**\r
+ * @file gui.h\r
+ *\r
+ * @brief Declares the data structures and the functions exported by the \r
+ * GUI. \r
+ */\r
+\r
+#ifndef __GUI_H__\r
+#define __GUI_H__\r
+\r
+#include <gtk/gtk.h>\r
+#include <gst/gst.h>\r
+\r
+/******************************************************************************\r
+ \r
+ Public functions declarations\r
+ \r
+******************************************************************************/\r
+\r
+/**\r
+ * @brief initialises GTK if X is present\r
+ *\r
+ * @param[in,out] argc number of command line arguments\r
+ * @param[in,out] argv command line arguments\r
+ *\r
+ * @return TRUE if X present, FALSE otherwise \r
+ *\r
+ * Called From main()\r
+ */\r
+gboolean DualDecode_initGUI(gint *argc, char **argv[]);\r
+\r
+/**\r
+ * @brief start the application\r
+ *\r
+ * Called From main()\r
+ */\r
+void DualDecode_startApplication();\r
+\r
+/**\r
+ * @brief stop the application and return to main()\r
+ *\r
+ * Called From delete-event handlers of the windows\r
+ */\r
+void DualDecode_exitApplication();\r
+\r
+/******************************************************************************\r
+ \r
+ Structure Definitions\r
+ \r
+*****************************************************************************/\r
+\r
+/**\r
+ * @brief This structure defines all the components and the signals\r
+ * for a Dual-Decode GUI window. There will be two such\r
+ * windows when the application is running \r
+ */\r
+typedef struct{\r
+\r
+ /*The Window and its delete-event signal handler*/\r
+ GtkWidget *window;\r
+ gulong windowCloseSignal;\r
+ \r
+ /*Image sink for the window*/\r
+ GstElement *sink;\r
+\r
+ /*The Seekbar widget and the value-changed signal handler */\r
+ /*value-changed handler is called when media is seeked using seekbar*/\r
+ GtkWidget *seekScale;\r
+ gulong seekSignal;\r
+\r
+ /*File Open button and clicked signal handler*/\r
+ GtkWidget *openButton;\r
+ gulong openSignal;\r
+\r
+ /*Media control buttons and clicked signal handlers*/\r
+ GtkWidget *playButton;\r
+ gulong playSignal;\r
+ GtkWidget *pauseButton;\r
+ gulong pauseSignal;\r
+ GtkWidget *stopButton;\r
+ gulong stopSignal;\r
+ GtkWidget *forwardButton;\r
+ gulong forwardSignal;\r
+ GtkWidget *rewindButton;\r
+ gulong rewindSignal;\r
+\r
+ /*Help Button and clicked signal handler*/\r
+ GtkWidget *helpButton;\r
+ gulong helpSignal;\r
+\r
+ /*The decode mode switch button and the clicked signal handler*/\r
+ GtkWidget *switchButton;\r
+ gulong switchSignal;\r
+\r
+ /*Labels to display media playback status and position in media*/\r
+ GtkWidget *statusLabel;\r
+ GtkWidget *timeLabel;\r
+\r
+ /*The timer signal to report position in media every*/\r
+ /*REPORT_INTERVAL seconds */\r
+ gulong timerSignal;\r
+\r
+ /*The draw area where the video is displayed*/\r
+ GtkWidget *drawArea;\r
+\r
+ /*The state of the controls*/\r
+ gint activeFlag;\r
+ gint modeFlag;\r
+} GUIWindow;\r
+\r
+\r
+\r
+/******************************************************************************\r
+ \r
+ Statically used variables per GUI component file\r
+\r
+ *****************************************************************************/\r
+\r
+static GError *error = NULL;\r
+static GtkBuilder *builder = NULL;\r
+\r
+/******************************************************************************\r
+ \r
+ Static Inline functions\r
+ \r
+*****************************************************************************/\r
+\r
+/**\r
+ * Report and then free the error, if error is not NULL\r
+ *This function is called when a NULL is returned from\r
+ *an allocation function\r
+ */ \r
+static inline void DualDecode_checkError(){\r
+ if(NULL == error){\r
+ g_printerr("GError Report : Unknown error\n");\r
+ }else{\r
+ g_printerr("GError Report : %s\n",error->message);\r
+ g_error_free(error);\r
+ error = NULL;\r
+ }\r
+}\r
+\r
+/*create and close a static GtkBuilder*/\r
+static inline void DualDecode_builderClose() {\r
+ g_object_unref(G_OBJECT(builder));\r
+ builder = NULL;\r
+}\r
+static inline void DualDecode_builderCreate() {\r
+ builder = gtk_builder_new();\r
+ if(0 == gtk_builder_add_from_file(builder,GLADE_FILE,&error)){\r
+ DualDecode_checkError();\r
+ DualDecode_builderClose();\r
+ }\r
+}\r
+\r
+/*get a widget from the builder*/\r
+static inline GtkWidget *DualDecode_getWidget(const char *widget) {\r
+ GtkWidget *retWidget = NULL;\r
+ if(NULL == builder){\r
+ retWidget = NULL;\r
+ }else{\r
+ retWidget = (GtkWidget *)gtk_builder_get_object(builder,widget);\r
+ }\r
+ return retWidget;\r
+}\r
+\r
+/**\r
+ * Get a widget exclusively from the builder \r
+ * this will let the application create two instances \r
+ * of a widget defined in the glade file. \r
+ * \r
+ * For example : this macro can be used like - \r
+ * \r
+ * widget0 = DualDecode_getWidgetExclusive("applicationWindow") \r
+ * widget1 = DualDecode_getWidgetExclusive("applicationWindow") \r
+ * \r
+ * this will create two different widgets with the same \r
+ * look and feel \r
+ */\r
+\r
+static inline GtkWidget *DualDecode_getWidgetExclusive(const char *widget) {\r
+ GtkWidget *retWidget = NULL;\r
+ DualDecode_builderCreate();\r
+ retWidget=DualDecode_getWidget(widget);\r
+ DualDecode_builderClose();\r
+ return retWidget;\r
+}\r
+/******************************************************************************\r
+\r
+ Macros\r
+\r
+ *****************************************************************************/\r
+/*To index the static GUIWindow and Pipeline structures */\r
+/*There are two of them, since it is a dual-decode application */\r
+#define DECODER_INDEX_SINGLE 0\r
+#define DECODER_INDEX_DOUBLE 1\r
+\r
+/*ratio of screen size per window*/\r
+#define SCREEN_WIDTH_FACTOR 3\r
+#define SCREEN_HEIGHT_FACTOR 2\r
+\r
+/*Whether the control buttons are active*/\r
+#define CONTROL_MODE_ACTIVE TRUE\r
+#define CONTROL_MODE_INACTIVE FALSE\r
+\r
+#define CONTROL_MODE_STOPPED 0\r
+#define CONTROL_MODE_PLAYING 1\r
+#define CONTROL_MODE_PAUSED 2\r
+#define CONTROL_MODE_NO_FILE 4\r
+\r
+#define LABEL_TEXT_NO_FILE "No File"\r
+#define LABEL_TEXT_PLAYING "Playing"\r
+#define LABEL_TEXT_STOPPED "Stopped"\r
+#define LABEL_TEXT_PAUSED "Paused"\r
+\r
+#define TIME_LABEL_ORIGIN "--:--:--/--:--:--"\r
+\r
+#define FORWARD 3000000000\r
+#define REWIND 3000000000\r
+#define SWITCH_TEXT_SINGLE "Single Decode"\r
+#define SWITCH_TEXT_DUAL "Dual Decode"\r
+\r
+#define TIMER_INTERVAL 1000\r
+#define TIMER_SIGNAL_NONE 0\r
+\r
+/*The glade file to import widgets from*/\r
+#define GLADE_FILE "res/gui.xml"\r
+\r
+\r
+#endif /*__GUI_H__*/\r