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: Base Gstreamer Adaptation Source |
|
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 <gst/gst.h> |
|
26 #include <gst/app/gstappsrc.h> |
|
27 #include <gst/app/gstappsink.h> |
|
28 #include <gst/app/gstappbuffer.h> |
|
29 #include "openmaxalwrapper.h" |
|
30 #include "xaglobals.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 /* STRUCTURES */ |
|
91 |
|
92 /* Forward declaration of adaptation basecontext */ |
|
93 typedef struct XAAdaptationGstCtx_ XAAdaptationGstCtx; |
|
94 |
|
95 /* |
|
96 * Structure that holds all common variables for every |
|
97 * Gst-Adaptation context structures. |
|
98 */ |
|
99 typedef struct XAAdaptationGstCtx_ |
|
100 { |
|
101 /* Common Variables for all adaptation elements */ |
|
102 XAAdaptationBaseCtx baseObj; |
|
103 |
|
104 GstState binWantedState; /** requested gst-bin target state **/ |
|
105 GstElement *bin; /** Container for all gst elements **/ |
|
106 |
|
107 GstBus *bus; /** Gst-bus where gst sends messages **/ |
|
108 GMainLoop *busloop; /** Gst-bus listener loop **/ |
|
109 pthread_t busloopThr; |
|
110 GstBusCb busCb; /** Gst-Bus callback funtion*/ |
|
111 |
|
112 XAboolean waitingasyncop; |
|
113 sem_t semAsyncWait; |
|
114 guint asynctimer; |
|
115 |
|
116 #ifdef XA_IMPL_MEASURE_GST_DELAY |
|
117 clock_t startTime; |
|
118 clock_t endTime; |
|
119 double diff; |
|
120 #endif /*XA_IMPL_MEASURE_GST_DELAY*/ |
|
121 |
|
122 XAboolean thread_launched; |
|
123 pthread_mutex_t ds_mutex; |
|
124 pthread_cond_t ds_condition; |
|
125 XAboolean cond_mutx_inited; |
|
126 /* FUNCTIONS*/ |
|
127 |
|
128 } XAAdaptationGstCtx_; |
|
129 |
|
130 /* FUNCTIONS */ |
|
131 /* |
|
132 * gboolean XAAdaptationBase_GstBusCb( GstBus *bus, GstMessage *message, gpointer data ); |
|
133 * Default CallBack handler for gst-bus messages. This will be called if object specific callback is |
|
134 * not implemented. |
|
135 */ |
|
136 |
|
137 XAresult XAAdaptationGst_Init(XAAdaptationGstCtx* pSelf, XAuint32 ctxId); |
|
138 XAresult XAAdaptationGst_PostInit(XAAdaptationGstCtx* ctx); |
|
139 void XAAdaptationGst_Free(XAAdaptationGstCtx* ctx); |
|
140 |
|
141 gboolean XAAdaptationGst_GstBusCb(GstBus *bus, GstMessage *message, |
|
142 gpointer data); |
|
143 |
|
144 XAresult XAAdaptationGst_InitGstListener(XAAdaptationGstCtx* ctx); |
|
145 void* XAAdaptationGst_LaunchGstListener(void* args); |
|
146 void XAAdaptationGst_StopGstListener(XAAdaptationGstCtx* ctx); |
|
147 |
|
148 void XAAdaptationGst_PrepareAsyncWait(XAAdaptationGstCtx* ctx); |
|
149 void XAAdaptationGst_StartAsyncWait(XAAdaptationGstCtx* ctx); |
|
150 gboolean XAAdaptationGst_CancelAsyncWait(gpointer ctx); |
|
151 void XAAdaptationGst_CompleteAsyncWait(XAAdaptationGstCtx* ctx); |
|
152 |
|
153 GstElement* XAAdaptationGst_CreateGstSource(XADataSource* xaSrc, |
|
154 const char *name, XAboolean *isobj, XAboolean *isPCM, |
|
155 XAboolean *isRawImage); |
|
156 GstElement* XAAdaptationGst_CreateGstSink(XADataSink* xaSrc, |
|
157 const char *name, XAboolean *isobj); |
|
158 GstElement* XAAdaptationGst_CreateVideoPP(void); |
|
159 |
|
160 GstElement* XAAdaptationGst_CreateVideoPPBlackScr(void); |
|
161 GstElement* XAAdaptationGst_CreateInputSelector(void); |
|
162 GstElement* XAAdaptationGst_CreateAudioPP(void); |
|
163 void XAAdaptationGst_PadBlockCb(GstPad *pad, gboolean blocked, |
|
164 gpointer user_data); |
|
165 void XAAdaptationGst_SetAllCaps(GstCaps * caps, char *field, ...); |
|
166 |
|
167 /*XAresult XAMetadataAdapt_TryWriteTags(XAAdaptationGstCtx* mCtx, GstBin* binToWriteTo);*/ |
|
168 |
|
169 #endif /* XAADAPTATIONGST_H_ */ |
|