Modified in acordance 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  */
48 #ifndef __GST-CONTROLLER_H__                                                               
49 #define __GST-CONTROLLER_H__
50  
51 #include <gtk/gtk.h>
52 #include <gst/gst.h>
55 /**
56  *    @brief    Defines the callback function pointer types
57  *      
58  */
59 typedef void (*LogFunc) (gpointer data, gchar * string, ...) G_GNUC_PRINTF(2,3);
60 typedef void (*EOSFunc) (gpointer data);
61 typedef void (*ErrorFunc) (gpointer data);
65 /****************************************************************************** 
66                                                                                 
67                             Function Prototypes                              
68                                                                                 
69 ******************************************************************************/ 
71 /**
72  *    @brief    Sets the pipeline to PLAYING state.
73  *    @param pipePtr     Pointer to Pipeline structure  
74  *    @param filename    Uri of the file to be played
75  *    @param Position    Position from where the playing should start
76  *    @param drawArea1   Display in window1
77  *    @param drawArea2   Display in window2 
78  *    @return   TRUE if success, FALSE otherwise.
79 */
80 gboolean DualDecode_playMedia (Pipeline *pipePtr, gchar *filename, gint64 position);
82 /**
83  *    @brief    Sets the pipeline to PAUSED state
84  *    @param pipePtr    Pointer to Pipeline structure
85  *    @return    TRUE if success, FALSE otherwise
86 */
87 gboolean DualDecode_pauseMedia (Pipeline *pipePtr);
89 /**                                                                             
90  *    @brief    Resumes media playback for the pipeline                              
91  *    @param pipePtr    Pointer to Pipeline structure                                             
92  *    @return    TRUE if success, FALSE otherwise                               
93 */
94 gboolean DualDecode_resumeMedia (Pipeline *pipePtr);
96 /**                                                                             
97  *    @brief    Sets the pipeline to READY state                              
98  *    @param pipePtr    Pointer to Pipeline structure                                         
99  *    @return    TRUE if success, FALSE otherwise                               
100 */
101 gboolean DualDecode_stopMedia (Pipeline *pipePtr);
103 /**                                                                             
104  *    @brief    Create a Pipeline structure                              
105  *    @param void                                     
106  *    @return Pipeline *pipe if success
107               NULL if failure                                  
108 */
109 Pipeline * DualDecode_createPipeline ();
111 /**                                                                             
112  *    @brief    Seek media position in the pipeline                             
113  *    @param pipePtr    Pointer to Pipeline structure    
114  *    @param position   Position to be seeked                                     
115  *    @return    TRUE if success, FALSE otherwise                               
116 */
117 gboolean DualDecode_seekMedia(Pipeline *pipePtr, gint64 position);
120 /**                                                                             
121  *    @brief                    destroy a Pipeline structure                              
122  *    @param pipePtr    Pipeline structure                                     
123 */
124 void DualDecode_destroyPipeline (Pipeline *pipePtr);
126 /**                                                                             
127  *    @brief                    Get state of the pipeline
128  *    @param pipePtr    Pipeline structure                                     
129  *        @return                       pipeline GstState
130 */
131 GstState DualDecode_getMediaState (Pipeline *pipePtr);
133 /**                                                                             
134  *    @brief    Get media position in the pipeline                             
135  *    @param pipePtr    Pointer to Pipeline structure    
136  *    @param seekScaleValue   Value of the seek scale bar                                     
137  *    @param timeLabelText    Text to be displayed on the label. 
138  *    @return    TRUE if success, FALSE otherwise                               
139 */
140 gboolean DualDecode_getMediaPosition (Pipeline *pipePtr, 
141                                       gdouble *seekScaleValue,
142                                       gchar **timeLabelText);
143 /**                                                                             
144  *    @brief    Switch decode mode from single to dual                             
145  *    @param pipes    Pointer to an array consisting of both the pipelines   
146  *    @param otherWindowSink  Video sink of the other window                                     
147  *    @param thisWindow       Index of the window where switch button is clicked
148  *    @param otherWindow      Index of the other window  
149  *    @param filename         File to be played
150  *    @return    TRUE if success, FALSE otherwise                               
151 */
152 gboolean DualDecode_singleToDual (Pipeline **pipes, 
153                                   GstElement * otherWindowSink,
154                                   gint thisWindow, gint otherWindow,            
155                                   gchar *filename);
156 /**                                                                             
157  *    @brief    Switch decode mode from dual to single                             
158  *    @param pipes    Pointer to an array consisting of both the pipelines   
159  *    @param otherWindowSink  Video sink of the other window                                     
160  *    @param thisWindow       Index of the window where switch button is clicked
161  *    @param otherWindow      Index of the other window  
162  *    @return    TRUE if success, FALSE otherwise                               
163 */
164 gboolean DualDecode_dualToSingle (Pipeline **pipes,
165                                   GstElement * otherWindowSink,
166                                   gint thisWindow, gint otherWindow);
167 /**                                                                             
168  *    @brief    Set video sinks of the pipeline                             
169  *    @return    TRUE if success, FALSE otherwise                               
170  *    @param pipePtr   Pointer to Pipeline structure    
171  *    @param sink0     First sink of the pipeline                                
172  *    @param sink1     Second sink of the pipeline
173 */
174 void DualDecode_setPipelineSink (Pipeline *pipePtr, GstElement *sink0, 
175                                  GstElement *sink1);
178 /******************************************************************************
180                             Structure Definitions
181         
182 ******************************************************************************/
184 typedef struct Pipeline {
185     /* GStreamer pipeline */
186     GstElement *pipe;
188     /* callback functions */
189     LogFunc  logFunc;
190         EOSFunc eosFunc;
191         ErrorFunc errFunc;
193     /* Signal for a pipeline */
194     gulong busSignal;
195 } Pipeline;
197 /******************************************************************************
198  
199                                Macros
201  *****************************************************************************/
202 #define NANOSEC 1e9     
203 #define SS 0
204 #define MM 1
205 #define HH 2
206 #define TIMEOUT 4000000000
208 #endif /*__GST-CONTROLLER_H__*/