In accordance to coding guidelines.
[glsdk/dual-decode.git] / include / gst-controller.h
1 /*                                                                              
2  *  Copyright (c) 2012-2013, Texas Instruments Incorporated                     
3  *                                                                              
4  *  Redistribution and use in source and binary forms, with or without          
5  *  modification, are permitted provided that the following conditions          
6  *  are met:                                                                    
7  *                                                                              
8  *  *  Redistributions of source code must retain the above copyright           
9  *   notice, this list of conditions and the following disclaimer.              
10  *                                                                              
11  *  *  Redistributions in binary form must reproduce the above copyright        
12  *   notice, this list of conditions and the following disclaimer in the        
13  *   documentation and/or other materials provided with the distribution.       
14  *                                                                              
15  *  *  Neither the name of Texas Instruments Incorporated nor the names of      
16  *   its contributors may be used to endorse or promote products derived        
17  *   from this software without specific prior written permission.              
18  *                                                                              
19  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
20  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,       
21  *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR      
22  *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            
23  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,       
24  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,         
25  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
26  *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,    
27  *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR     
28  *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,              
29  *  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                          
30  *                                                                              
31  *  Contact information for paper mail:                                         
32  *  Texas Instruments                                                           
33  *  Post Office Box 655303                                                      
34  *  Dallas, Texas 75265                                                         
35  *  Contact information:                                                        
36  *  http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
37  *  DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact                             
38  *  ============================================================================
39  *                                                                              
40  */                                                                             
41                                                                                 
42 /**                                                                             
43  * @file  gst-controller.h                                                                
44  *                                                                              
45  * @brief Defines the structures and function prototypes.                                                                       
46  */
47  
48 #include <gtk/gtk.h>
49 #include <gst/gst.h>
51 #define NANOSEC 1e9     
52 #define SS 0
53 #define MM 1
54 #define HH 2
55 #define TIMEOUT 4000000000
56 /**
57  *    @brief    Defines the callback function pointer types
58  *      
59  */
60 typedef void (*LogFunc) (gpointer data, gchar * string, ...) G_GNUC_PRINTF(2,3);
61 typedef void (*EOSFunc) (gpointer data);
62 typedef void (*ErrorFunc) (gpointer data);
64 /******************************************************************************
66                             Structure Definitions
67         
68 ******************************************************************************/
70 typedef struct Pipeline {
71     /* GStreamer pipeline */
72     GstElement *pipe;
74     /* callback functions */
75     LogFunc  logFunc;
76         EOSFunc eosFunc;
77         ErrorFunc errFunc;
79     /* Signal for a pipeline */
80     gulong busSignal;
81 } Pipeline;
83 /****************************************************************************** 
84                                                                                 
85                             Function Prototypes                              
86                                                                                 
87 ******************************************************************************/ 
89 /**
90  *    @brief    Sets the pipeline to PLAYING state.
91  *    @param pipePtr     Pointer to Pipeline structure  
92  *    @param filename    Uri of the file to be played
93  *    @param Position    Position from where the playing should start
94  *    @param drawArea1   Display in window1
95  *    @param drawArea2   Display in window2 
96  *    @return   TRUE if success, FALSE otherwise.
97 */
98 gboolean DualDecode_playMedia (Pipeline *pipePtr, gchar *filename, gint64 position);
99 /**
100  *    @brief    Sets the pipeline to PAUSED state
101  *    @param pipePtr    Pointer to Pipeline structure
102  *    @return    TRUE if success, FALSE otherwise
103 */
104 gboolean DualDecode_pauseMedia (Pipeline *pipePtr);
106 /**                                                                             
107  *    @brief    Resumes media playback for the pipeline                              
108  *    @param pipePtr    Pointer to Pipeline structure                                             
109  *    @return    TRUE if success, FALSE otherwise                               
110 */
111 gboolean DualDecode_resumeMedia (Pipeline *pipePtr);
113 /**                                                                             
114  *    @brief    Sets the pipeline to READY state                              
115  *    @param pipePtr    Pointer to Pipeline structure                                         
116  *    @return    TRUE if success, FALSE otherwise                               
117 */
118 gboolean DualDecode_stopMedia (Pipeline *pipePtr);
120 /**                                                                             
121  *    @brief    Create a Pipeline structure                              
122  *    @param void                                     
123  *    @return Pipeline *pipe if success
124               NULL if failure                                  
125 */
127 gboolean DualDecode_seekMedia(Pipeline *pipePtr, gint64 position);
129 Pipeline * DualDecode_createPipeline ();
131 /**                                                                             
132  *    @brief                    destroy a Pipeline structure                              
133  *    @param pipePtr    Pipeline structure                                     
134 */
135 void DualDecode_destroyPipeline (Pipeline *pipePtr);
137 /**                                                                             
138  *    @brief                    Get state of the pipeline
139  *    @param pipePtr    Pipeline structure                                     
140  *        @return                       pipeline GstState
141 */
142 GstState DualDecode_getMediaState (Pipeline *pipePtr);
144 gboolean DualDecode_getMediaPosition (Pipeline *pipePtr, gdouble *seekScaleValue,
145                                       gchar **timeLabelText);
147 gboolean DualDecode_singleToDual (Pipeline **pipes,GstElement * otherWindowSink,
148                                   gint thisWindow, gint otherWindow,            
149                                   gchar *filename);
151 gboolean DualDecode_dualToSingle (Pipeline **pipes,GstElement * otherWindowSink,
152                                   gint thisWindow, gint otherWindow);
154 void DualDecode_setPipelineSink (Pipeline *pipePtr, GstElement *sink0, GstElement *sink1);