khronosfws/openmax_al/src/mmf_adaptation/cmmfbackendengine.h
changeset 31 8dfd592727cb
parent 22 128eb6a32b84
child 32 94fc26b6e006
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: MMF Backend Engine Header
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18 #ifndef XA_CMMFBackendEngine_H
    18 #ifndef CMMFBackendEngine_H
    19 #define XA_CMMFBackendEngine_H
    19 #define CMMFBackendEngine_H
    20 
    20 
    21 #define ENABLE_GRAPHICS_SURFACE_INTEGRATION
    21 #define ENABLE_GRAPHICS_SURFACE_INTEGRATION
    22 
    22 
    23 #include "openmaxalwrapper.h"
    23 #include "openmaxalwrapper.h"
    24 
    24 
    43 #include <AudioInput.h>
    43 #include <AudioInput.h>
    44 #include "sfmrlocaltimer.h"
    44 #include "sfmrlocaltimer.h"
    45 #endif
    45 #endif
    46 
    46 
    47 // MetaDataWrite Custom Command UID
    47 // MetaDataWrite Custom Command UID
    48 const TUid KUidMetaDataWriteCustomCommand = {0x10207af9};
    48 const TUid KUidMetaDataWriteCustomCommand =
       
    49     {
       
    50     0x10207af9
       
    51     };
    49 
    52 
    50 #define MAX_EXTENSION_SIZE 10
    53 #define MAX_EXTENSION_SIZE 10
    51 
    54 
    52 class CMarkerPositionTimer;
    55 class CMarkerPositionTimer;
    53 class CPositionUpdateTimer;
    56 class CPositionUpdateTimer;
    54 NONSHARABLE_CLASS(CMMFBackendEngine) : public CBase,
    57 NONSHARABLE_CLASS(CMMFBackendEngine) : public CBase,
    55                           public MVideoPlayerUtilityObserver,
    58         public MVideoPlayerUtilityObserver,
    56                           public MVideoLoadingObserver,
    59         public MVideoLoadingObserver,
    57                           public MMdaAudioPlayerCallback,
    60         public MMdaAudioPlayerCallback,
    58                           public MMdaObjectStateChangeObserver
    61         public MMdaObjectStateChangeObserver
    59     {
    62     {
    60 public:      
    63 public:
    61       enum TFuncInUse
    64     enum TFuncInUse
    62           {
    65         {
    63           EPlay = 0,
    66                 EPlay = 0, 
    64           ERecord
    67                 ERecord
    65           };
    68         };
    66       
    69 
    67 	enum TMMFUtiltyInUse
    70     enum TUriType
    68 	    {
    71         {
       
    72                 ELocal = 0, 
       
    73                 EStreaming
       
    74         };
       
    75 
       
    76     enum TMMFUtiltyInUse
       
    77         {
    69         ENoUtility,
    78         ENoUtility,
    70         EVideoPlayerUtility,
    79         EVideoPlayerUtility,
    71         EAudioPlayerUtility,
    80         EAudioPlayerUtility,
    72         EAudioRecorderUtility
    81         EAudioRecorderUtility
    73 	    };
    82         };
    74 	
    83 
    75 	enum TRecorderState
    84     enum TRecorderState
    76 	{
    85         {
    77 	  ERecorderNotReady = 0,
    86                 ERecorderNotReady = 0, 
    78 	  ERecorderOpen,
    87                 ERecorderOpen, 
    79 	  ERecorderRecording
    88                 ERecorderRecording
    80 	};
    89         };
    81 	      
    90 
    82 public:
    91 public:
    83 
    92 
    84     static CMMFBackendEngine* NewL();
    93     static CMMFBackendEngine* NewL();
    85     ~CMMFBackendEngine();
    94     ~CMMFBackendEngine();
    86     
    95 
    87     TInt SetFileName(char* uri,XAuint32 format,TFuncInUse func);
    96     TInt SetFileName(char* uri, XAuint32 format, TFuncInUse func);
    88     void Close();
    97     void Close();
    89     void Destroy();
    98     void Destroy();
    90     TInt SetRecorderState(TRecorderState state, XAboolean stopCalled);
    99     TInt SetRecorderState(TRecorderState state, XAboolean stopCalled);
    91     TInt GetRecordPosition(XAuint64* position);
   100     TInt GetRecordPosition(XAuint64* position);
    92     TInt SetPositionUpdatePerioed(XAmillisecond period);
   101     TInt SetPositionUpdatePerioed(XAmillisecond period);
    97     TInt GetChannels(XAuint32* channels);
   106     TInt GetChannels(XAuint32* channels);
    98     TInt SetDestinationBitRate(XAuint32* bitrate);
   107     TInt SetDestinationBitRate(XAuint32* bitrate);
    99     TInt SetDestinationSampleRate(XAmilliHertz* samplerate);
   108     TInt SetDestinationSampleRate(XAmilliHertz* samplerate);
   100     TInt SetDestinationChannels(XAuint32* channels);
   109     TInt SetDestinationChannels(XAuint32* channels);
   101 
   110 
   102 /*    XAresult SetWindowHandle(void* display_info);*/
       
   103     XAresult CreateAndConfigureWindowL();
   111     XAresult CreateAndConfigureWindowL();
   104     XAresult SetNativeDisplayInformation(void* display_info);
   112     XAresult SetNativeDisplayInformation(void* display_info);
   105     XAresult ResumePlayback();
   113     XAresult ResumePlayback();
   106     XAresult PausePlayback();    
   114     XAresult PausePlayback();
   107     XAresult StopPlayback();
   115     XAresult StopPlayback();
   108     XAresult GetPlayState(XAuint32 *pState);
   116     XAresult GetPlayState(XAuint32 *pState);
   109     XAresult GetDuration(XAmillisecond *pMsec);
   117     XAresult GetDuration(XAmillisecond *pMsec);
   110     XAresult GetPosition(XAmillisecond *pMsec);
   118     XAresult GetPosition(XAmillisecond *pMsec);
   111     XAresult SetPlayAdaptContext(void * adaptcontext);
   119     XAresult SetPlayAdaptContext(void * adaptcontext);
   116     XAresult SetPositionUpdatePeriod(XAmillisecond mSec);
   124     XAresult SetPositionUpdatePeriod(XAmillisecond mSec);
   117 
   125 
   118     XAresult SetPosition(XAmillisecond pMsec);
   126     XAresult SetPosition(XAmillisecond pMsec);
   119     XAresult SetRepeats(XAboolean repeat);
   127     XAresult SetRepeats(XAboolean repeat);
   120     XAresult SetPlayWindow(XAmillisecond start, XAmillisecond end);
   128     XAresult SetPlayWindow(XAmillisecond start, XAmillisecond end);
   121 	
   129 
   122     XAresult GetNumStreams(XAuint32* numstreams);
   130     XAresult GetNumStreams(XAuint32* numstreams);
   123     XAresult GetStreamInfo(XAuint32 streamindex, XAuint32* streamtype);
   131     XAresult GetStreamInfo(XAuint32 streamindex, XAuint32* streamtype);
   124     XAresult GetVideoFrameSize(XAuint32* height, XAuint32* width, XAuint32* frameRate);
   132     XAresult GetVideoFrameSize(XAuint32* height, XAuint32* width,
       
   133             XAuint32* frameRate);
   125     XAresult SetActiveState(XAuint32 streamindex, XAboolean active);
   134     XAresult SetActiveState(XAuint32 streamindex, XAboolean active);
   126 	
   135 
   127     XAresult SetVolume(XAuint32 volume);
   136     XAresult SetVolume(XAuint32 volume);
   128     XAresult GetVolume(XAuint32* volume);
   137     XAresult GetVolume(XAuint32* volume);
   129     XAresult GetMaxVolume(XAuint32* maxvolume);
   138     XAresult GetMaxVolume(XAuint32* maxvolume);
   130 public:
   139 public:
   131 
   140 
   132     // MMdaObjectStateChangeObserver
   141     // MMdaObjectStateChangeObserver
   133     void MoscoStateChangeEvent(
   142     void MoscoStateChangeEvent(CBase* aObject, TInt aPreviousState,
   134             CBase* aObject,
   143             TInt aCurrentState, TInt aErrorcCode);
   135             TInt aPreviousState,
       
   136             TInt aCurrentState,
       
   137             TInt aErrorcCode);
       
   138 
   144 
   139     //MMdaAudioPlayerCallback
   145     //MMdaAudioPlayerCallback
   140     void MapcInitComplete(
   146     void MapcInitComplete(TInt aError,
   141             TInt aError,
       
   142             const TTimeIntervalMicroSeconds& aDuration);
   147             const TTimeIntervalMicroSeconds& aDuration);
   143     void MapcPlayComplete(TInt aError);
   148     void MapcPlayComplete(TInt aError);
   144     
   149 
   145     //From MVidePlayerUtilityObserver
   150     //From MVidePlayerUtilityObserver
   146     void MvpuoOpenComplete(TInt aError);
   151     void MvpuoOpenComplete(TInt aError);
   147     void MvpuoPrepareComplete(TInt aError);
   152     void MvpuoPrepareComplete(TInt aError);
   148     void MvpuoFrameReady(CFbsBitmap& aFrame, TInt aError);
   153     void MvpuoFrameReady(CFbsBitmap& aFrame, TInt aError);
   149     void MvpuoPlayComplete(TInt aError);
   154     void MvpuoPlayComplete(TInt aError);
   150     void MvpuoEvent(const TMMFEvent& aEvent);
   155     void MvpuoEvent(const TMMFEvent& aEvent);
   151 
   156 
   152     // From MRebufferCallback
   157     // From MRebufferCallback
   153     void MvloLoadingStarted();
   158     void MvloLoadingStarted();
   154     void MvloLoadingComplete();     
   159     void MvloLoadingComplete();
   155 
   160 
   156 private:  
   161 private:
   157     enum TPlayerState
   162     enum TPlayerState
   158     {
   163         {
   159       EPlayerClosed,
   164         EPlayerClosed,
   160       EPlayerOpened,
   165         EPlayerOpened,
   161       EPlayerPrepared,
   166         EPlayerPrepared,
   162       EPlayerPaused,
   167         EPlayerPaused,
   163       EPlayerPlaying,
   168         EPlayerPlaying,
   164     };
   169         };
   165     
   170 
   166 private:
   171 private:
   167     CMMFBackendEngine();
   172     CMMFBackendEngine();
   168     void ConstructL();
   173     void ConstructL();
   169     void InitAudioRecorderUtilityL();
   174     void InitAudioRecorderUtilityL();
   170     void InitAudioPlayerUtilityL();
   175     void InitAudioPlayerUtilityL();
   174     XAresult DoHandlePlayItfAttributesChanged();
   179     XAresult DoHandlePlayItfAttributesChanged();
   175     void DoPostEvent(XAuint32 event);
   180     void DoPostEvent(XAuint32 event);
   176     TInt InitializeURIForMMFUtil(char *uri);
   181     TInt InitializeURIForMMFUtil(char *uri);
   177 
   182 
   178 private:
   183 private:
   179     CVideoPlayerUtility2*       iVideoPlayer;
   184     CVideoPlayerUtility2* iVideoPlayer;
   180     CBase*		                iBaseVideoPlayer;
   185     CBase* iBaseVideoPlayer;
   181     CMdaAudioPlayerUtility*     iAudioPlayer;  
   186     CMdaAudioPlayerUtility* iAudioPlayer;
   182     CBase*                      iBaseAudioPlayer; 
   187     CBase* iBaseAudioPlayer;
   183     CMdaAudioRecorderUtility*   iAudioRecorder;
   188     CMdaAudioRecorderUtility* iAudioRecorder;
   184     CBase*                      iBaseAudioRecorder;
   189     CBase* iBaseAudioRecorder;
   185     TFileName                   iFileName;
   190     TFileName iFileName;
   186     TInt                        iAPIBeingUsed;		
   191     TInt iAPIBeingUsed;
   187     TInt                        iPreviousRecordState;
   192     TInt iPreviousRecordState;
   188     TInt                        iCurrentRecordState;
   193     TInt iCurrentRecordState;
   189     TInt                        iErrorCode;
   194     TInt iErrorCode;
   190     TRecorderState              iRecordState;
   195     TRecorderState iRecordState;
   191     LocalTimer*                 iPositionUpdateTimer;
   196     LocalTimer* iPositionUpdateTimer;
   192     TUint64                     iTimerDelay;
   197     TUint64 iTimerDelay;
   193     void*                       iAdaptContext;
   198     void* iAdaptContext;
   194     XAuint32                    iFileFormat;
   199     XAuint32 iFileFormat;
   195     TInt                        iPauseSupportMP4;
   200     TInt iPauseSupportMP4;
   196     CActiveSchedulerWait*       iActiveSchedulerWait;
   201     CActiveSchedulerWait* iActiveSchedulerWait;
   197 		CAudioInput*              iaudioInputRecord;
   202     CAudioInput* iAudioInputRecord;
   198 #ifdef USE_LOCAL_WINDOW_RESOURCES
   203 #ifdef USE_LOCAL_WINDOW_RESOURCES
   199     CMediaClientVideoDisplay* iMediaClientVideoDisplay;
   204     CMediaClientVideoDisplay* iMediaClientVideoDisplay;
   200     TRect m_clipRect;
   205     TRect m_clipRect;
   201     TRect m_videoExtent;    
   206     TRect m_videoExtent;
   202     TRect m_cropRegion;
   207     TRect m_cropRegion;
   203     TVideoAspectRatio m_pixelAspectRatio;
   208     TVideoAspectRatio m_pixelAspectRatio;
   204     RWindow m_Window;
   209     RWindow m_Window;
   205     TRect m_cropRect;
   210     TRect m_cropRect;
   206     TSurfaceId m_surfaceId;
   211     TSurfaceId m_surfaceId;
   207     TVideoRotation m_rotation;
   212     TVideoRotation m_rotation;
   208     TReal32 m_scaleWidth;
   213     TReal32 m_scaleWidth;
   209     TReal32 m_scaleHeight;
   214     TReal32 m_scaleHeight;
   210     TInt m_horizPos;
   215     TInt m_horizPos;
   211     TInt m_vertPos; 
   216     TInt m_vertPos;
   212     TInt m_displayId;   
   217     TInt m_displayId;
   213     /*TBool m_bWindowReferencePassed;*/
   218     /*TBool m_bWindowReferencePassed;*/
   214     RWsSession m_ws;
   219     RWsSession m_ws;
   215 #endif /* USE_LOCAL_WINDOW_RESOURCES */
   220 #endif /* USE_LOCAL_WINDOW_RESOURCES */
   216 
   221 
   217     /* Holds duration of the media clip opend for playback */
   222     /* Holds duration of the media clip opend for playback */
   237     /* Property set by client */
   242     /* Property set by client */
   238     XAmillisecond iPositionUpdatePeriod;
   243     XAmillisecond iPositionUpdatePeriod;
   239     /* Property set by client (for file without file:///) */
   244     /* Property set by client (for file without file:///) */
   240     HBufC* iUri; /* owns */
   245     HBufC* iUri; /* owns */
   241     TPtr iUriPtr;
   246     TPtr iUriPtr;
       
   247     TUriType iUriType;
   242     /* Property set by client */
   248     /* Property set by client */
   243     RWsSession* m_pWs;
   249     RWsSession* m_pWs;
   244     /* Property set by client */
   250     /* Property set by client */
   245     RWindow* m_pWindow;   
   251     RWindow* m_pWindow;
   246     };
   252     };
   247 
   253 
   248 #else  /* __cplusplus */
   254 #else  /* __cplusplus */
   249 
       
   250 
   255 
   251 extern int mmf_backend_engine_init(void** engine);
   256 extern int mmf_backend_engine_init(void** engine);
   252 extern int mmf_backend_engine_deinit(void* engine);
   257 extern int mmf_backend_engine_deinit(void* engine);
   253 
   258 
   254 extern int mmf_set_recorder_uri(void* context, char* uri, XAuint32 format);
   259 extern int mmf_set_recorder_uri(void* context, char* uri, XAuint32 format);
   255 
       
   256 
   260 
   257 extern void mmf_close(void* context);
   261 extern void mmf_close(void* context);
   258 
   262 
   259 extern int mmf_set_adapt_context(void* context, void* adaptcontext);
   263 extern int mmf_set_adapt_context(void* context, void* adaptcontext);
   260 
   264 
   296 extern XAresult mmf_seekitf_set_playwindow(void * context, XAmillisecond start, XAmillisecond end);
   300 extern XAresult mmf_seekitf_set_playwindow(void * context, XAmillisecond start, XAmillisecond end);
   297 extern XAresult mmf_seekitf_set_repeats(void * context, XAboolean repeat);
   301 extern XAresult mmf_seekitf_set_repeats(void * context, XAboolean repeat);
   298 
   302 
   299 extern XAresult mmf_streaminformationitf_get_numstreams(void * context, XAuint32* numstreams);
   303 extern XAresult mmf_streaminformationitf_get_numstreams(void * context, XAuint32* numstreams);
   300 extern XAresult mmf_streaminformationitf_get_streaminfo(void * context, XAuint32 streamindex,
   304 extern XAresult mmf_streaminformationitf_get_streaminfo(void * context, XAuint32 streamindex,
   301                                                                 XAuint32* streamtype);
   305         XAuint32* streamtype);
   302 extern XAresult mmf_streaminformationitf_get_videoframesize(void * context, XAuint32* height,
   306 extern XAresult mmf_streaminformationitf_get_videoframesize(void * context, XAuint32* height,
   303                                                             XAuint32* width, XAuint32* frameRate);
   307         XAuint32* width, XAuint32* frameRate);
   304 extern XAresult mmf_streaminformationitf_set_activestream(void * context, XAuint32 streamindex,
   308 extern XAresult mmf_streaminformationitf_set_activestream(void * context, XAuint32 streamindex,
   305                                                                 XAboolean active);
   309         XAboolean active);
   306 
   310 
   307 extern XAresult mmf_volumeitf_set_volume(void * context, XAuint32 volume);
   311 extern XAresult mmf_volumeitf_set_volume(void * context, XAuint32 volume);
   308 extern XAresult mmf_volumeitf_get_volume(void * context, XAuint32* volume);
   312 extern XAresult mmf_volumeitf_get_volume(void * context, XAuint32* volume);
   309 extern XAresult mmf_volumeitf_get_maxvolume(void * context, XAuint32* volume);
   313 extern XAresult mmf_volumeitf_get_maxvolume(void * context, XAuint32* volume);
   310 #endif /* __cplusplus */
   314 #endif /* __cplusplus */
   311 
   315 
   312 #endif /* XA_CMMFBackendEngine_H */
   316 #endif /* CMMFBackendEngine_H */