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