Implemented forward and rewind.
authorMrinmayee Hingolikar <mrinmayee@ti.com>
Tue, 8 Jan 2013 20:21:30 +0000 (01:51 +0530)
committerMrinmayee <mrinmayee@ubuntu.(none)>
Tue, 8 Jan 2013 20:21:30 +0000 (01:51 +0530)
include/gui.h
src/gui.c

index 7efd2b430e51fa6580976f40b2990411c175f3e1..4662a71bfb63c6aa9a3c0c61024cbfd538e7a7ea 100644 (file)
@@ -115,7 +115,7 @@ typedef struct{
 #define DECODER_INDEX_SINGLE 0\r
 #define DECODER_INDEX_DOUBLE 1\r
 \r
 #define DECODER_INDEX_SINGLE 0\r
 #define DECODER_INDEX_DOUBLE 1\r
 \r
-/*ratio of scrren size per window*/\r
+/*ratio of screen size per window*/\r
 #define SCREEN_WIDTH_FACTOR 3\r
 #define SCREEN_HEIGHT_FACTOR 2\r
 \r
 #define SCREEN_WIDTH_FACTOR 3\r
 #define SCREEN_HEIGHT_FACTOR 2\r
 \r
@@ -135,6 +135,8 @@ typedef struct{
 \r
 #define TIME_LABEL_ORIGIN "--:--:--/--:--:--"\r
 \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 SWITCH_TEXT_SINGLE "Single Decode"\r
 #define SWITCH_TEXT_DUAL "Dual Decode"\r
 \r
index db6bdd65f97901d17df735e59fdac7842337b19e..b3aed4e6a9534c0d3fa7addc47fdee7043fd3505 100644 (file)
--- a/src/gui.c
+++ b/src/gui.c
@@ -1,5 +1,4 @@
 /*
 /*
- *  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
  *
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions
@@ -82,6 +81,8 @@ static gboolean cbOpenClicked (GtkWidget *widget, gpointer data);
 static gboolean cbPlayClicked (GtkWidget *widget, gpointer data);
 static gboolean cbPauseClicked (GtkWidget *widget, gpointer data);
 static gboolean cbStopClicked (GtkWidget *widget, gpointer data);
 static gboolean cbPlayClicked (GtkWidget *widget, gpointer data);
 static gboolean cbPauseClicked (GtkWidget *widget, gpointer data);
 static gboolean cbStopClicked (GtkWidget *widget, gpointer data);
+static gboolean cbForwardClicked (GtkWidget *widget, gpointer data);
+static gboolean cbRewindClicked (GtkWidget *widget, gpointer data);
 static gboolean cbWindowClosed (GtkWidget *widget, gpointer data);
 static gboolean cbHelpClicked (GtkWidget *widget, gpointer data);
 static gboolean cbTimerInterval (gpointer data);
 static gboolean cbWindowClosed (GtkWidget *widget, gpointer data);
 static gboolean cbHelpClicked (GtkWidget *widget, gpointer data);
 static gboolean cbTimerInterval (gpointer data);
@@ -324,15 +325,23 @@ static gboolean cbPlayClicked(GtkWidget *widget, gpointer data)
                                        SEEK_START);
              }
        }else{
                                        SEEK_START);
              }
        }else{
-               if(window[DECODER_INDEX_SINGLE] == thisWindow){
-                       setControlMode(window[DECODER_INDEX_SINGLE],
+               if (window[DECODER_INDEX_SINGLE] == thisWindow){
+                       setControlMode (window[DECODER_INDEX_SINGLE],
                                        CONTROL_MODE_PLAYING,
                                        window[DECODER_INDEX_SINGLE]->activeFlag);
                                        CONTROL_MODE_PLAYING,
                                        window[DECODER_INDEX_SINGLE]->activeFlag);
-                       if(GST_STATE_PAUSED == 
+                       if (GST_STATE_PAUSED == 
                                        DualDecode_getMediaState(pipes[DECODER_INDEX_SINGLE])){
                                DualDecode_resumeMedia(pipes[DECODER_INDEX_SINGLE]);
                                        DualDecode_getMediaState(pipes[DECODER_INDEX_SINGLE])){
                                DualDecode_resumeMedia(pipes[DECODER_INDEX_SINGLE]);
-                       }else{
-                               DualDecode_playMedia(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);
                        }
                                                filename[DECODER_INDEX_SINGLE],
                                                SEEK_START);
                        }
@@ -343,7 +352,14 @@ static gboolean cbPlayClicked(GtkWidget *widget, gpointer data)
                        if(GST_STATE_PAUSED == 
                                        DualDecode_getMediaState(pipes[DECODER_INDEX_DOUBLE])){
                                DualDecode_resumeMedia(pipes[DECODER_INDEX_DOUBLE]);
                        if(GST_STATE_PAUSED == 
                                        DualDecode_getMediaState(pipes[DECODER_INDEX_DOUBLE])){
                                DualDecode_resumeMedia(pipes[DECODER_INDEX_DOUBLE]);
-                       }else{
+                       }
+            else if (GST_STATE_READY ==                                        
+                         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);
                                DualDecode_playMedia(pipes[DECODER_INDEX_DOUBLE],
                                                filename[DECODER_INDEX_DOUBLE],
                                                SEEK_START);
@@ -390,29 +406,104 @@ static gboolean cbStopClicked(GtkWidget *widget, gpointer data)
     GUIWindow *thisWindow = (GUIWindow *)data;
    
 
     GUIWindow *thisWindow = (GUIWindow *)data;
    
 
-       if(DECODE_MODE_SINGLE == decodeMode){
-               setControlMode(window[DECODER_INDEX_SINGLE],
+       if (DECODE_MODE_SINGLE == decodeMode){
+               setControlMode (window[DECODER_INDEX_SINGLE],
                                CONTROL_MODE_STOPPED,
                                window[DECODER_INDEX_SINGLE]->activeFlag);
                                CONTROL_MODE_STOPPED,
                                window[DECODER_INDEX_SINGLE]->activeFlag);
-               setControlMode(window[DECODER_INDEX_DOUBLE],
+               setControlMode (window[DECODER_INDEX_DOUBLE],
                                CONTROL_MODE_STOPPED,
                                window[DECODER_INDEX_DOUBLE]->activeFlag);
                                CONTROL_MODE_STOPPED,
                                window[DECODER_INDEX_DOUBLE]->activeFlag);
-               DualDecode_stopMedia(pipes[DECODER_INDEX_SINGLE]);
+               DualDecode_stopMedia (pipes[DECODER_INDEX_SINGLE]);
        }else{
        }else{
-               if(window[DECODER_INDEX_SINGLE] == thisWindow){
+               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_SINGLE],
                                        CONTROL_MODE_STOPPED,
                                        window[DECODER_INDEX_SINGLE]->activeFlag);
                        DualDecode_stopMedia(pipes[DECODER_INDEX_SINGLE]);
                }else{
-                       setControlMode(window[DECODER_INDEX_DOUBLE],
+                       setControlMode (window[DECODER_INDEX_DOUBLE],
                                        CONTROL_MODE_STOPPED,
                                        window[DECODER_INDEX_DOUBLE]->activeFlag);
                                        CONTROL_MODE_STOPPED,
                                        window[DECODER_INDEX_DOUBLE]->activeFlag);
-                       DualDecode_stopMedia(pipes[DECODER_INDEX_DOUBLE]);
+                       DualDecode_stopMedia (pipes[DECODER_INDEX_DOUBLE]);
                }
        }
     return ret;
 }
                }
        }
     return ret;
 }
+static gboolean cbForwardClicked(GtkWidget *widget, gpointer data)                 
+{                                                                               
+    gboolean ret = TRUE;                                                        
+    GstFormat format = GST_FORMAT_TIME;                                         
+    gint64 duration = 0;                                                        
+    gint64 seekPoint = 0;                                                         
+    GUIWindow *thisWindow = (GUIWindow *)data;               
+    gdouble percent = gtk_range_get_value ((GtkRange *) (thisWindow->seekScale));                   
+                                                                                
+    g_print ("IN FORWARD CLICKED\n");                                        
+    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);     
+    }                                                                           
+    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); 
+        }                                                                       
+        else {                                                                  
+            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); 
+        }                                                                       
+    }                                                                           
+                                                                                
+        return ret; 
+}                                                                                
+static gboolean cbRewindClicked(GtkWidget *widget, gpointer data)                 
+{
+    gboolean ret = TRUE;                                                        
+    GstFormat format = GST_FORMAT_TIME;                                         
+    gint64 duration = 0;                                                        
+    gint64 seekPoint = 0;                                                       
+    GUIWindow *thisWindow = (GUIWindow *)data;                                  
+    gdouble percent = gtk_range_get_value ((GtkRange *) (thisWindow->seekScale));
+                                                                                
+    g_print ("IN FORWARD CLICKED\n");                                           
+    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);
+        seekPoint = (seekPoint < 0) ? 0 : seekPoint;                                 
+        ret = DualDecode_seekMedia(pipes[DECODER_INDEX_SINGLE], seekPoint);     
+    }                                                                           
+    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);
+            seekPoint = (seekPoint < 0) ? 0 : seekPoint;                             
+            ret = DualDecode_seekMedia(pipes[DECODER_INDEX_SINGLE], seekPoint); 
+        }                                                                       
+        else {                                                                  
+            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); 
+        }                                                                       
+    }                                                                           
+                                                                                
+        return ret;                                                                                  
+}    
 static gboolean cbSwitchButtonClicked (GtkWidget *widget, gpointer data)
 {
     gboolean ret = TRUE;
 static gboolean cbSwitchButtonClicked (GtkWidget *widget, gpointer data)
 {
     gboolean ret = TRUE;
@@ -638,8 +729,8 @@ static void setup()
 {
 
     g_print ("SINK TO BE USED %s\n", sink);
 {
 
     g_print ("SINK TO BE USED %s\n", sink);
-       gtk_widget_show_all(window[DECODER_INDEX_SINGLE]->window);
-       gtk_widget_show_all(window[DECODER_INDEX_DOUBLE]->window);
+       gtk_widget_show_all (window[DECODER_INDEX_SINGLE]->window);
+       gtk_widget_show_all (window[DECODER_INDEX_DOUBLE]->window);
 
     window[DECODER_INDEX_SINGLE]->sink = createImageSinkFromWindow (            
                                         window[DECODER_INDEX_SINGLE]->drawArea, 
 
     window[DECODER_INDEX_SINGLE]->sink = createImageSinkFromWindow (            
                                         window[DECODER_INDEX_SINGLE]->drawArea, 
@@ -656,8 +747,6 @@ static void setup()
             DualDecode_exitApplication();
     
     }
             DualDecode_exitApplication();
     
     }
-    //DualDecode_setSinksForPipes (pipes,window[DECODER_INDEX_SINGLE]->sink,
-     //                            window[DECODER_INDEX_DOUBLE]->sink);
        switch(decodeMode){
                case DECODE_MODE_NONE:
                        setControlMode(window[DECODER_INDEX_SINGLE],
        switch(decodeMode){
                case DECODE_MODE_NONE:
                        setControlMode(window[DECODER_INDEX_SINGLE],
@@ -819,8 +908,16 @@ static GUIWindow *createWindow()
                        "clicked",
                        G_CALLBACK(cbPlayClicked),
                        ret);
                        "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->playSignal = g_signal_connect(G_OBJECT(ret->helpButton),               
+    ret->helpSignal = g_signal_connect(G_OBJECT(ret->helpButton),               
             "clicked",                                                          
             G_CALLBACK(cbHelpClicked),                                          
             ret);   
             "clicked",                                                          
             G_CALLBACK(cbHelpClicked),                                          
             ret);