|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef XAADAPTATIONGST_H_ |
|
19 #define XAADAPTATIONGST_H_ |
|
20 |
|
21 #include <pthread.h> |
|
22 #include <semaphore.h> |
|
23 #include <string.h> |
|
24 #include <unistd.h> |
|
25 #include "openmaxalwrapper.h" |
|
26 #include "xaglobals.h" |
|
27 #include <gst.h> |
|
28 #include <gstappsrc.h> |
|
29 #include <gstappsink.h> |
|
30 #include <gstappbuffer.h> |
|
31 #include "xaplatform.h" |
|
32 #include "xaadptbasectx.h" |
|
33 #include <stdlib.h> |
|
34 |
|
35 #ifdef XA_IMPL_MEASURE_GST_DELAY |
|
36 #include <time.h> |
|
37 #endif /* XA_IMPL_MEASURE_GST_DELAY */ |
|
38 |
|
39 /* MACROS */ |
|
40 #define FLIP_NONE 0 |
|
41 #define FLIP_CLOCKWISE 1 /* Rotate clockwise 90 degrees */ |
|
42 #define FLIP_ROTATE_180 2 /* Rotate 180 degrees */ |
|
43 #define FLIP_COUNTERCLOCKWISE 3 /* Rotate counter-clockwise 90 degrees */ |
|
44 #define FLIP_HORIZONTAL 4 /* Flip image horizontally */ |
|
45 #define FLIP_VERTICAL 5 /* Flip image vertically */ |
|
46 |
|
47 /* TYPEDEFS */ |
|
48 typedef gboolean (*GstBusCb)( GstBus *bus, GstMessage *message, gpointer data ); |
|
49 |
|
50 #define CONTENT_PIPE_BUFFER_SIZE 1000 |
|
51 #define TEST_VIDEO_WIDTH 640 |
|
52 #define TEST_VIDEO_HEIGHT 480 |
|
53 |
|
54 /*typedef enum |
|
55 { |
|
56 XA_AUDIO_WAVENC = 0, |
|
57 XA_AUDIO_VORBISENC, |
|
58 XA_AUDIO_PCM, |
|
59 XA_NUM_OF_AUDIOENCODERS Do not move this line |
|
60 } XAAudioEnc;*/ |
|
61 |
|
62 /*typedef enum |
|
63 { |
|
64 XA_VIDEO_JPEGENC = 0, |
|
65 XA_VIDEO_THEORAENC, |
|
66 XA_NUM_OF_VIDEOENCODERS Do not move this line |
|
67 } XAVideoEnc;*/ |
|
68 |
|
69 /*typedef enum CP_STATE |
|
70 { |
|
71 CPStateNull =0, |
|
72 CPStateInitialized, |
|
73 CPStatePrerolling, |
|
74 CPStateStarted, |
|
75 CPStateRunning, |
|
76 CPStatePaused, |
|
77 CPStateStopped, |
|
78 CPStateWaitForData, |
|
79 CPStateEOS, |
|
80 CPStateError |
|
81 }CP_STATE;*/ |
|
82 |
|
83 /*typedef enum |
|
84 { |
|
85 XA_IMAGE_JPEGENC = 0, |
|
86 XA_IMAGE_RAW, |
|
87 XA_NUM_OF_IMAGEENCODERS Do not move this line |
|
88 } XAImageEnc;*/ |
|
89 |
|
90 |
|
91 /* STRUCTURES */ |
|
92 |
|
93 /* Forward declaration of adaptation basecontext */ |
|
94 typedef struct XAAdaptationGstCtx_ XAAdaptationGstCtx; |
|
95 |
|
96 /* |
|
97 * Structure that holds all common variables for every |
|
98 * Gst-Adaptation context structures. |
|
99 */ |
|
100 typedef struct XAAdaptationGstCtx_ |
|
101 { |
|
102 /* Common Variables for all adaptation elements */ |
|
103 XAAdaptationBaseCtx baseObj; |
|
104 |
|
105 GstState binWantedState; /** requested gst-bin target state **/ |
|
106 GstElement *bin; /** Container for all gst elements **/ |
|
107 |
|
108 GstBus *bus; /** Gst-bus where gst sends messages **/ |
|
109 GMainLoop *busloop; /** Gst-bus listener loop **/ |
|
110 pthread_t busloopThr; |
|
111 GstBusCb busCb; /** Gst-Bus callback funtion*/ |
|
112 |
|
113 XAboolean waitingasyncop; |
|
114 sem_t semAsyncWait; |
|
115 guint asynctimer; |
|
116 |
|
117 #ifdef XA_IMPL_MEASURE_GST_DELAY |
|
118 clock_t startTime; |
|
119 clock_t endTime; |
|
120 double diff; |
|
121 #endif /*XA_IMPL_MEASURE_GST_DELAY*/ |
|
122 |
|
123 XAboolean thread_launched; |
|
124 pthread_mutex_t ds_mutex; |
|
125 pthread_cond_t ds_condition; |
|
126 XAboolean cond_mutx_inited; |
|
127 /* FUNCTIONS*/ |
|
128 |
|
129 } XAAdaptationGstCtx_; |
|
130 |
|
131 /* FUNCTIONS */ |
|
132 /* |
|
133 * gboolean XAAdaptationBase_GstBusCb( GstBus *bus, GstMessage *message, gpointer data ); |
|
134 * Default CallBack handler for gst-bus messages. This will be called if object specific callback is |
|
135 * not implemented. |
|
136 */ |
|
137 |
|
138 XAresult XAAdaptationGst_Init( XAAdaptationGstCtx* pSelf, XAuint32 ctxId ); |
|
139 XAresult XAAdaptationGst_PostInit( XAAdaptationGstCtx* ctx ); |
|
140 void XAAdaptationGst_Free( XAAdaptationGstCtx* ctx ); |
|
141 |
|
142 |
|
143 gboolean XAAdaptationGst_GstBusCb( GstBus *bus, GstMessage *message, gpointer data ); |
|
144 |
|
145 XAresult XAAdaptationGst_InitGstListener(XAAdaptationGstCtx* ctx); |
|
146 void* XAAdaptationGst_LaunchGstListener(void* args); |
|
147 void XAAdaptationGst_StopGstListener(XAAdaptationGstCtx* ctx); |
|
148 |
|
149 void XAAdaptationGst_PrepareAsyncWait(XAAdaptationGstCtx* ctx); |
|
150 void XAAdaptationGst_StartAsyncWait(XAAdaptationGstCtx* ctx); |
|
151 gboolean XAAdaptationGst_CancelAsyncWait(gpointer ctx); |
|
152 void XAAdaptationGst_CompleteAsyncWait(XAAdaptationGstCtx* ctx); |
|
153 |
|
154 GstElement* XAAdaptationGst_CreateGstSource( XADataSource* xaSrc, const char *name, XAboolean *isobj, XAboolean *isPCM, XAboolean *isRawImage ); |
|
155 GstElement* XAAdaptationGst_CreateGstSink( XADataSink* xaSrc, const char *name, XAboolean *isobj ); |
|
156 GstElement* XAAdaptationGst_CreateVideoPP(void); |
|
157 |
|
158 GstElement* XAAdaptationGst_CreateVideoPPBlackScr(void); |
|
159 GstElement* XAAdaptationGst_CreateInputSelector(void); |
|
160 GstElement* XAAdaptationGst_CreateAudioPP(void); |
|
161 void XAAdaptationGst_PadBlockCb(GstPad *pad, gboolean blocked, gpointer user_data); |
|
162 void XAAdaptationGst_SetAllCaps (GstCaps * caps, char *field, ...); |
|
163 |
|
164 |
|
165 |
|
166 /*XAresult XAMetadataAdapt_TryWriteTags(XAAdaptationGstCtx* mCtx, GstBin* binToWriteTo);*/ |
|
167 |
|
168 #endif /* XAADAPTATIONGST_H_ */ |