Modified in acordance to coding guidelines.
authorMrinmayee Hingolikar <mrinmayee@ti.com>
Fri, 11 Jan 2013 03:31:22 +0000 (09:01 +0530)
committerMrinmayee <mrinmayee@ubuntu.(none)>
Fri, 11 Jan 2013 03:31:22 +0000 (09:01 +0530)
include/gst-controller.h
include/gui.h
src/gst-controller.c
src/gui.c
src/main.c

index 035dccc749ecd327404c65fe4d7603bcdbfaed44..37936543744e5660f82f1563a1de7c315caccb08 100644 (file)
  *                                                                              
  * @brief Defines the structures and function prototypes.                                                                       
  */
+
+#ifndef __GST-CONTROLLER_H__                                                               
+#define __GST-CONTROLLER_H__
  
 #include <gtk/gtk.h>
 #include <gst/gst.h>
 
-#define NANOSEC 1e9    
-#define SS 0
-#define MM 1
-#define HH 2
-#define TIMEOUT 4000000000
+
 /**
  *    @brief    Defines the callback function pointer types
  *     
@@ -61,24 +60,7 @@ typedef void (*LogFunc) (gpointer data, gchar * string, ...) G_GNUC_PRINTF(2,3);
 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;
 
 /****************************************************************************** 
                                                                                 
@@ -96,6 +78,7 @@ typedef struct Pipeline {
  *    @return   TRUE if success, FALSE otherwise.
 */
 gboolean DualDecode_playMedia (Pipeline *pipePtr, gchar *filename, gint64 position);
+
 /**
  *    @brief    Sets the pipeline to PAUSED state
  *    @param pipePtr    Pointer to Pipeline structure
@@ -123,10 +106,16 @@ gboolean DualDecode_stopMedia (Pipeline *pipePtr);
  *    @return Pipeline *pipe if success
               NULL if failure                                  
 */
+Pipeline * DualDecode_createPipeline ();
 
+/**                                                                             
+ *    @brief    Seek media position in the pipeline                             
+ *    @param pipePtr    Pointer to Pipeline structure    
+ *    @param position   Position to be seeked                                     
+ *    @return    TRUE if success, FALSE otherwise                               
+*/
 gboolean DualDecode_seekMedia(Pipeline *pipePtr, gint64 position);
 
-Pipeline * DualDecode_createPipeline ();
 
 /**                                                                             
  *    @brief                   destroy a Pipeline structure                              
@@ -141,14 +130,79 @@ void DualDecode_destroyPipeline (Pipeline *pipePtr);
 */
 GstState DualDecode_getMediaState (Pipeline *pipePtr);
 
-gboolean DualDecode_getMediaPosition (Pipeline *pipePtr, gdouble *seekScaleValue,
+/**                                                                             
+ *    @brief    Get media position in the pipeline                             
+ *    @param pipePtr    Pointer to Pipeline structure    
+ *    @param seekScaleValue   Value of the seek scale bar                                     
+ *    @param timeLabelText    Text to be displayed on the label. 
+ *    @return    TRUE if success, FALSE otherwise                               
+*/
+gboolean DualDecode_getMediaPosition (Pipeline *pipePtr, 
+                                      gdouble *seekScaleValue,
                                       gchar **timeLabelText);
-
-gboolean DualDecode_singleToDual (Pipeline **pipes,GstElement * otherWindowSink,
+/**                                                                             
+ *    @brief    Switch decode mode from single to dual                             
+ *    @param pipes    Pointer to an array consisting of both the pipelines   
+ *    @param otherWindowSink  Video sink of the other window                                     
+ *    @param thisWindow       Index of the window where switch button is clicked
+ *    @param otherWindow      Index of the other window  
+ *    @param filename         File to be played
+ *    @return    TRUE if success, FALSE otherwise                               
+*/
+gboolean DualDecode_singleToDual (Pipeline **pipes, 
+                                  GstElement * otherWindowSink,
                                   gint thisWindow, gint otherWindow,            
                                   gchar *filename);
-
-gboolean DualDecode_dualToSingle (Pipeline **pipes,GstElement * otherWindowSink,
+/**                                                                             
+ *    @brief    Switch decode mode from dual to single                             
+ *    @param pipes    Pointer to an array consisting of both the pipelines   
+ *    @param otherWindowSink  Video sink of the other window                                     
+ *    @param thisWindow       Index of the window where switch button is clicked
+ *    @param otherWindow      Index of the other window  
+ *    @return    TRUE if success, FALSE otherwise                               
+*/
+gboolean DualDecode_dualToSingle (Pipeline **pipes,
+                                  GstElement * otherWindowSink,
                                   gint thisWindow, gint otherWindow);
+/**                                                                             
+ *    @brief    Set video sinks of the pipeline                             
+ *    @return    TRUE if success, FALSE otherwise                               
+ *    @param pipePtr   Pointer to Pipeline structure    
+ *    @param sink0     First sink of the pipeline                                
+ *    @param sink1     Second sink of the pipeline
+*/
+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;
+
+/******************************************************************************
+                               Macros
+
+ *****************************************************************************/
+#define NANOSEC 1e9    
+#define SS 0
+#define MM 1
+#define HH 2
+#define TIMEOUT 4000000000
 
-void DualDecode_setPipelineSink (Pipeline *pipePtr, GstElement *sink0, GstElement *sink1);
+#endif /*__GST-CONTROLLER_H__*/  
index 4662a71bfb63c6aa9a3c0c61024cbfd538e7a7ea..f9374c11fb0a4fdd88b24096b821c3f6cc81e32a 100644 (file)
 \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
+ */\r
 typedef struct{\r
 \r
        /*The Window and its delete-event signal handler*/\r
@@ -74,7 +113,7 @@ typedef struct{
        GtkWidget *openButton;\r
        gulong openSignal;\r
 \r
-       /*media control buttons and clicked signal handlers*/\r
+       /*Media control buttons and clicked signal handlers*/\r
        GtkWidget *playButton;\r
        gulong playSignal;\r
        GtkWidget *pauseButton;\r
@@ -110,75 +149,28 @@ typedef struct{
        gint modeFlag;\r
 } GUIWindow;\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
-/******************************************************************************\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
+              Statically used variables per GUI component file\r
 \r
-/*The glade file to import widgets from*/\r
-#define GLADE_FILE "res/gui.xml"\r
+ *****************************************************************************/\r
 \r
-/*statically used variables per GUI component file*/\r
 static GError *error                   = NULL;\r
 static GtkBuilder *builder             = NULL;\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
\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
@@ -213,17 +205,19 @@ static inline GtkWidget *DualDecode_getWidget(const char *widget) {
        return retWidget;\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
+ * 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
@@ -232,4 +226,46 @@ static inline GtkWidget *DualDecode_getWidgetExclusive(const char *widget) {
        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
index 7a26542a1b8b8da88c3932d1becf9b1837daada8..d436a12b7480c7ce44db3f777c24faa386d3901b 100644 (file)
@@ -42,7 +42,7 @@
 /**                                                                             
  * @file  gst-controller.c                                                                 
  *                                                                              
- * @brief                                                                       
+ * @brief Imeplements GStreamer related functions                                                                      
  */ 
 #include <stdint.h>
 #include <string.h>
@@ -54,6 +54,11 @@ gchar * fsinkArr [] = {"fsink0", "fsink1"};
 static gint fsinkCounter = 0;
 static void getTime (gint64 arr[], gint64 time);
 
+/******************************************************************************
+                     
+                           Static Functions
+
+******************************************************************************/
 static gboolean attachPipeElements (Pipeline *pipePtr, GstElement *sink0, 
                              GstElement *sink1)
 {
@@ -111,18 +116,15 @@ static gboolean attachPipeElements (Pipeline *pipePtr, GstElement *sink0,
        /*Connecting the tee through queues is necessary to sync the two displays*/ 
        gst_element_link(tee,queue0);                                               
        gst_element_link(tee,queue1);                                               
-       //gst_element_link(queue0,sink0);                                             
-       //gst_element_link(queue1,sink1);                                             
                                                                                 
        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)
 {    
        gchar *name             = (gchar *)data;
@@ -132,26 +134,27 @@ gboolean busCallback(GstBus *bus, GstMessage *msg, gpointer data)
 
     switch(GST_MESSAGE_TYPE(msg)){                                              
                                                                                 
-        case GST_MESSAGE_EOS:                                                   
-            g_printerr("%s -> Message (EOS) : End of stream.\n",name);                          
-                       count++;
-            break;                                                              
+    case GST_MESSAGE_EOS:                                                   
+        g_printerr("%s -> Message (EOS) : End of stream.\n",name);                          
+           count++;
+        break;                                                              
                                                                                
-         case GST_MESSAGE_ERROR: {                                             
-            gst_message_parse_error(msg,&err,&debugMsg);                      
-            g_printerr("%s -> Message (ERROR) : %s : debug ( %s )\n", name,err->message,debugMsg);                                                      
-            g_free(debugMsg);                                                   
-            g_error_free(err);                                                  
-                       count++;
-            break;                                                              
-        }                                                                       
-        case GST_MESSAGE_WARNING: {                                             
-            gst_message_parse_warning(msg,&err,&debugMsg);                      
-            g_printerr("%s -> Message (WARNING) : %s : debug ( %s )\n",
+    case GST_MESSAGE_ERROR: {                                             
+        gst_message_parse_error(msg,&err,&debugMsg);                      
+        g_printerr("%s -> Message (ERROR) : %s : debug ( %s )\n", 
+                            name,err->message,debugMsg);                                                      
+        g_free(debugMsg);                                                   
+        g_error_free(err);                                                  
+           count++;
+        break;                                                              
+    }                                                                       
+    case GST_MESSAGE_WARNING: {                                             
+        gst_message_parse_warning(msg,&err,&debugMsg);                      
+        g_printerr("%s -> Message (WARNING) : %s : debug ( %s )\n",
                                            name,err->message,debugMsg);                                                      
-            g_free(debugMsg);                                                   
-            g_error_free(err);                                                  
-            break;                                                              
+        g_free(debugMsg);                                                   
+        g_error_free(err);                                                  
+        break;                                                              
         }                                                                       
                                                                                 
         default:                                                                
@@ -159,8 +162,24 @@ gboolean busCallback(GstBus *bus, GstMessage *msg, gpointer data)
     }                                                                           
                                                                                 
     return TRUE;                                                                
+}
+
+static void getTime (gint64 arr[], gint64 time)
+{
+    gint8 i = 0;
+    time = time / (gint64) NANOSEC;
+
+    for (i = 0; i < 3; i++){
+        arr[i] = time % 60;
+        time = time / 60;
+    } 
+    
 } 
-       
+/*****************************************************************************
+
+                          Public Functions
+
+******************************************************************************/       
 Pipeline * DualDecode_createPipeline()
 {
     Pipeline *pipelinePtr = (Pipeline *) malloc (sizeof(Pipeline));
@@ -286,23 +305,13 @@ gboolean DualDecode_getMediaPosition (Pipeline *pipePtr, gdouble *seekScaleValue
     return ret;
 }
 
-static void getTime (gint64 arr[], gint64 time)
-{
-    gint8 i = 0;
-    time = time / (gint64) NANOSEC;
 
-    for (i = 0; i < 3; i++){
-        arr[i] = time % 60;
-        time = time / 60;
-    } 
-    
-}
 
-void DualDecode_setPipelineSink (Pipeline *pipePtr, GstElement *sink0, GstElement *sink1)
+void DualDecode_setPipelineSink (Pipeline *pipePtr, GstElement *sink0, 
+                                 GstElement *sink1)
 {
     g_print ("IN SET PIPE IN SINGLE MODE");
     attachPipeElements (pipePtr, sink0, sink1);
-    //gst_element_set_state (pipePtr->pipe, GST_STATE_READY);
 }
 
 gboolean DualDecode_playMedia (Pipeline *pipePtr, gchar *filename, gint64 position)            
@@ -327,44 +336,45 @@ gboolean DualDecode_singleToDual (Pipeline **pipes,GstElement * otherWindowSink,
 {
     gboolean ret = TRUE;
 
-    GstElement *thisbin = NULL;
-    GstElement *otherbin = NULL;
-    GstElement *fsink = NULL;
-    GstElement *queue0 = NULL;                                                  
-    GstElement *queue1 = NULL;                                                  
-    GstState state0 ; 
+    GstElement *thisbin   = NULL;
+    GstElement *otherbin  = NULL;
+    GstElement *fsink     = NULL;
+    GstElement *queue0    = NULL;                                                  
+    GstElement *queue1    = NULL;                                                  
+    GstState state0       = NULL
    
-    //gst_element_set_state (pipes[thisWindow]->pipe, GST_STATE_PAUSED);
     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);
     queue1 = gst_bin_get_by_name (GST_BIN (thisbin), "q1");                   
     gst_element_unlink (queue1, otherWindowSink);          
     gst_object_ref (otherWindowSink);                      
     gst_bin_remove (GST_BIN (thisbin), otherWindowSink);       
-                                                                                
+    
+    /*Remove a fake sink from the other pipeline*/                                                                            
     g_object_get (G_OBJECT (pipes[otherWindow]->pipe), "video-sink", &otherbin, NULL);
     queue0 = gst_bin_get_by_name (GST_BIN (otherbin), "q0");                  
     fsink = gst_bin_get_by_name (GST_BIN (otherbin), "fsink0");               
     gst_element_unlink (queue0, fsink);                                   
     gst_object_ref (fsink);                                               
     gst_bin_remove (GST_BIN (otherbin), fsink);                               
-                                                                                
+      
+    /*Add fakesink to this pipeline*/                                                                          
     gst_bin_add (GST_BIN (thisbin), fsink);                                  
     gst_element_sync_state_with_parent (fsink);                          
     gst_element_link (queue1, fsink);                                    
-                                                                                
+    
+    /* Add otherWindowSink to other pipeline */                                                                            
     gst_element_set_state (otherWindowSink, GST_STATE_READY);
     gst_bin_add (GST_BIN (otherbin), otherWindowSink);        
-    //gst_element_sync_state_with_parent (window[otherWindow]->sink);                          
     gst_element_link (queue0, otherWindowSink);           
                                                                                 
     DualDecode_playMedia (pipes[otherWindow], filename, 0);
-    //DualDecode_playMedia (pipes[thiswindow], filename[DECODER_INDEX_SINGLE], SEEK_START);
     gst_element_set_state (pipes[thisWindow]->pipe, state0); 
 
     return ret;
@@ -374,35 +384,36 @@ gboolean DualDecode_dualToSingle (Pipeline **pipes,GstElement * otherWindowSink,
                                   gint thisWindow, gint otherWindow)  
 {
     gboolean ret = TRUE;
-
-    GstElement *bin = NULL;
-    GstElement *bin2 = NULL;
-    GstElement *fsink = NULL;
+    GstElement *bin    = NULL;
+    GstElement *bin2   = NULL;
+    GstElement *fsink  = NULL;
     GstElement *fsink0 = NULL;
     GstElement *queue0 = NULL;
     GstElement *queue1 = NULL; 
-    gchar *name = NULL;
+    gchar *name        = NULL;
+    
+    /*Remove otherWindow sink from other pipeline*/
     gst_element_set_state (pipes[otherWindow]->pipe, GST_STATE_PAUSED);
-                                                                                
     g_object_get (G_OBJECT (pipes[otherWindow]->pipe), "video-sink", &bin2, NULL);
     queue0 = gst_bin_get_by_name (GST_BIN (bin2), "q0");                  
     gst_element_unlink (queue0, otherWindowSink);          
     gst_object_ref (otherWindowSink);                      
     gst_bin_remove (GST_BIN (bin2), otherWindowSink);       
-                                                                                
+    
+    /*Remove fake sink from this pipeline*/                                                                            
     g_object_get (G_OBJECT (pipes[thisWindow]->pipe), "video-sink", &bin, NULL);
     queue1 = gst_bin_get_by_name (GST_BIN (bin), "q1");                   
     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);                                   
-                                                                                
     gst_element_unlink (queue1, fsink);                                   
     gst_object_ref (fsink);                                               
     gst_bin_remove (GST_BIN (bin),fsink);                                 
                                                                                 
     gst_element_set_state (otherWindowSink, GST_STATE_READY);
-                                                                                
+    
+    /*Add fake sink to other pipeline */                                                                            
     gst_bin_add (GST_BIN (bin2), fsink);                                  
     gst_element_sync_state_with_parent (fsink);                           
                                                                                 
@@ -419,7 +430,9 @@ gboolean DualDecode_dualToSingle (Pipeline **pipes,GstElement * otherWindowSink,
         gst_element_link (queue1, fsink);                                 
         gst_element_link (queue0, fsink0);                                
     }                                                                     
-    g_free (name);                                                       
+    g_free (name);
+
+    /*Add otherWindowSink to this pipeline*/                                                      
     gst_bin_add (GST_BIN (bin), otherWindowSink);         
     gst_element_sync_state_with_parent (otherWindowSink); 
     gst_element_link (queue1, otherWindowSink); 
index b3aed4e6a9534c0d3fa7addc47fdee7043fd3505..a217ade9d85eadceca1aad78544a42972847e3bf 100644 (file)
--- a/src/gui.c
+++ b/src/gui.c
 #include <gst-controller.h>
 
 /******************************************************************************
- *     Static variables declaration
- ******************************************************************************/
+       
+                      Static variables declaration
+*****************************************************************************/
 static GUIWindow *window[]             = {NULL, NULL};
 static Pipeline *pipes[]               = {NULL, NULL};
 static GtkWidget *logWindow[]  = {NULL, NULL};
@@ -64,7 +66,9 @@ static GtkWidget *helpWindow  = NULL;
 
 
 /******************************************************************************
- *     Static functions declaration
+                          Static functions declaration
+
  ******************************************************************************/
 static gint setAbsolutePathname (gchar *file, gchar **uri)  ;
 static void setControlMode (GUIWindow *thisWindow,gint modeFlag,gint activeFlag);
@@ -126,7 +130,9 @@ last:
     return ret;                                                                 
 }        
 /******************************************************************************
- *     Callback functions definition
+                       Callback functions definition
+
  ******************************************************************************/
 
 /*Timer Interval Callback Function*/
@@ -150,10 +156,10 @@ 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),
+               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),
+               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);
@@ -167,22 +173,22 @@ static gboolean cbTimerInterval(gpointer data)
                                        &seekScaleValue,
                                        &timeLabelText);
                        
-            g_signal_handler_block(GTK_RANGE(window[DECODER_INDEX_SINGLE]->seekScale),
+            g_signal_handler_block (GTK_RANGE(window[DECODER_INDEX_SINGLE]->seekScale),
                                        window[DECODER_INDEX_SINGLE]->seekSignal);
-                       gtk_range_set_value(GTK_RANGE (window[DECODER_INDEX_SINGLE]->seekScale),
+                       gtk_range_set_value (GTK_RANGE (window[DECODER_INDEX_SINGLE]->seekScale),
                                        seekScaleValue);
-                       gtk_label_set_text(GTK_LABEL (window[DECODER_INDEX_SINGLE]->timeLabel),
+                       gtk_label_set_text (GTK_LABEL (window[DECODER_INDEX_SINGLE]->timeLabel),
                                        timeLabelText);
-                       g_signal_handler_unblock(GTK_RANGE (window[DECODER_INDEX_SINGLE]->seekScale),
+                       g_signal_handler_unblock (GTK_RANGE (window[DECODER_INDEX_SINGLE]->seekScale),
                                        window[DECODER_INDEX_SINGLE]->seekSignal);
                }else{
-                       ret = DualDecode_getMediaPosition(pipes[DECODER_INDEX_DOUBLE],
+                       ret = DualDecode_getMediaPosition (pipes[DECODER_INDEX_DOUBLE],
                                        &seekScaleValue,
                                        &timeLabelText);
 
-                       g_signal_handler_block(GTK_RANGE (window[DECODER_INDEX_DOUBLE]->seekScale),
+                       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),
+                       gtk_range_set_value (GTK_RANGE (window[DECODER_INDEX_DOUBLE]->seekScale),
                                        seekScaleValue);
                        gtk_label_set_text (GTK_LABEL(window[DECODER_INDEX_DOUBLE]->timeLabel),
                                        timeLabelText);
@@ -335,7 +341,9 @@ static gboolean cbPlayClicked(GtkWidget *widget, gpointer data)
                        }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_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);
             }
@@ -582,7 +590,9 @@ static gboolean cbHelpClosed (GtkWidget *widget, gpointer data){
     return TRUE;
 }
 /******************************************************************************
- *     static utility functions definition
+                       Static utility functions definition
+
  ******************************************************************************/
 static void setControlActive(GUIWindow *window, gboolean activeFlag)
 {
@@ -755,9 +765,11 @@ static void setup()
                        setControlMode(window[DECODER_INDEX_DOUBLE],
                                        CONTROL_MODE_NO_FILE,
                                        CONTROL_MODE_ACTIVE);
-             DualDecode_setPipelineSink (pipes[DECODER_INDEX_SINGLE], window[DECODER_INDEX_SINGLE]->sink,
+             DualDecode_setPipelineSink (pipes[DECODER_INDEX_SINGLE], 
+                                         window[DECODER_INDEX_SINGLE]->sink,
                                               NULL);                            
-             DualDecode_setPipelineSink (pipes[DECODER_INDEX_DOUBLE], window[DECODER_INDEX_DOUBLE]->sink,
+             DualDecode_setPipelineSink (pipes[DECODER_INDEX_DOUBLE], 
+                                         window[DECODER_INDEX_DOUBLE]->sink,
                                               NULL);
                        decodeMode = DECODE_MODE_DUAL;
                        setDecodeSwitch(DECODE_MODE_SINGLE);
@@ -769,8 +781,9 @@ static void setup()
                        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_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],
@@ -782,9 +795,11 @@ static void setup()
                        setControlMode(window[DECODER_INDEX_SINGLE],
                                        CONTROL_MODE_PLAYING,
                                        CONTROL_MODE_ACTIVE);
-             DualDecode_setPipelineSink (pipes[DECODER_INDEX_SINGLE], window[DECODER_INDEX_SINGLE]->sink,
+             DualDecode_setPipelineSink (pipes[DECODER_INDEX_SINGLE], 
+                                         window[DECODER_INDEX_SINGLE]->sink,
                                               NULL);
-             DualDecode_setPipelineSink (pipes[DECODER_INDEX_DOUBLE], window[DECODER_INDEX_DOUBLE]->sink,
+             DualDecode_setPipelineSink (pipes[DECODER_INDEX_DOUBLE], 
+                                         window[DECODER_INDEX_DOUBLE]->sink,
                                               NULL);
 
                        DualDecode_playMedia(pipes[DECODER_INDEX_SINGLE],
@@ -1043,7 +1058,7 @@ static GstElement *createImageSinkFromWindow (GtkWidget * window, gchar *name)
     drawable = gtk_widget_get_window (GTK_WIDGET (window));                     
     if(FALSE == GDK_IS_DRAWABLE(drawable)){                                     
         /*TODO: A BUG HERE?*/                                                   
-        g_object_unref(G_OBJECT(sinkElement));                                         
+        g_object_unref (G_OBJECT (sinkElement));                                         
         sinkElement=NULL;                                                              
         goto return_pos;                                                        
     }                                                                           
index 9fa6608869242e87996f328f0fb4240d72dd51d4..37121748e95fae2b01af97fe43c5a751600f8ad8 100644 (file)
@@ -71,7 +71,6 @@ gint setAbsolutePathname (gchar *file, gchar **uri)
        }       
 
        if (NULL == file){
-               /*A BUG Here*/
                g_printerr("BUG: file: " __FILE__ " line: %d" "\n", __LINE__);          
                return ERR_BUG;
        }
@@ -79,7 +78,6 @@ gint setAbsolutePathname (gchar *file, gchar **uri)
        *uri = (gchar *) g_malloc (sizeof(gchar) * PATH_MAX_LEN);          
        realPath = realpath (file, realPath);
        if (NULL == realPath) {
-               /*TODO: a debug trace here*/
                g_printerr ("File %s not found\n", file);
                ret = ERR_FILENOTFOUND;
                goto destroy;   
@@ -119,7 +117,6 @@ gint processOpts()
                        decodeMode++;
                        filename[fileCount] = uri;
                }else{
-                       /*TODO: A debug trace here*/
                        g_printerr("Ignoring file : %s\n",files[fileCount]);
                }
                fileCount++;
@@ -149,7 +146,6 @@ gint processArgs (int *argc, char **argv[])
                                                                                                                                                                
        /* Parse the command line arguments and options*/                                                  
        if (!g_option_context_parse (context, argc, argv, &error)) {                       
-               /*TODO: a debug trace here*/
                g_printerr ("option parsing failed: %s\n", error->message);                               
                g_error_free(error);
                return ERR_OPTIONPARSE;