36 #include <videoplayer2.h> |
31 #include <videoplayer2.h> |
37 #include <e32std.h> |
32 #include <e32std.h> |
38 #include <mmf/common/mmferrors.h> |
33 #include <mmf/common/mmferrors.h> |
39 #include <mmf/common/Mmfbase.h> |
34 #include <mmf/common/Mmfbase.h> |
40 #include <MMFMetadataEventConfigConstants.h> |
35 #include <MMFMetadataEventConfigConstants.h> |
|
36 #include <mmf/common/mmfstandardcustomcommands.h> |
41 #ifdef ENABLE_GRAPHICS_SURFACE_INTEGRATION |
37 #ifdef ENABLE_GRAPHICS_SURFACE_INTEGRATION |
42 #include <graphics/surface.h> //TSurfaceId |
38 #include <graphics/surface.h> //TSurfaceId |
43 #include <mmf/common/mmfvideo.h> //TVideoAspectRatio |
39 #include <mmf/common/mmfvideo.h> //TVideoAspectRatio |
44 #include <mediaclientvideodisplay.h> |
40 #include <mediaclientvideodisplay.h> |
45 #include <surfaceeventhandler.h> |
41 #include <surfaceeventhandler.h> |
46 #include <mdaaudiosampleeditor.h> |
42 #include <mdaaudiosampleeditor.h> |
|
43 #include <AudioInput.h> |
47 #include "sfmrlocaltimer.h" |
44 #include "sfmrlocaltimer.h" |
48 #endif |
45 #endif |
49 |
46 |
50 // MetaDataWrite Custom Command UID |
47 // MetaDataWrite Custom Command UID |
51 const TUid KUidMetaDataWriteCustomCommand = {0x10207af9}; |
48 const TUid KUidMetaDataWriteCustomCommand = {0x10207af9}; |
52 |
49 |
53 #define MAX_EXTENSION_SIZE 10 |
50 #define MAX_EXTENSION_SIZE 10 |
54 |
51 |
|
52 class CMarkerPositionTimer; |
|
53 class CPositionUpdateTimer; |
55 NONSHARABLE_CLASS(CMMFBackendEngine) : public CBase, |
54 NONSHARABLE_CLASS(CMMFBackendEngine) : public CBase, |
56 public MVideoPlayerUtilityObserver, |
55 public MVideoPlayerUtilityObserver, |
57 public MVideoLoadingObserver, |
56 public MVideoLoadingObserver, |
58 public MMdaAudioPlayerCallback, |
57 public MMdaAudioPlayerCallback, |
59 public MMdaObjectStateChangeObserver |
58 public MMdaObjectStateChangeObserver |
60 { |
59 { |
61 public: |
60 public: |
62 enum TFuncInUse |
61 enum TFuncInUse |
63 { |
62 { |
64 EPlay = 0, |
63 EPlay = 0, |
65 ERecord |
64 ERecord |
66 }; |
65 }; |
67 |
66 |
68 enum TPlayerInUse |
67 enum TMMFUtiltyInUse |
69 { |
68 { |
70 EVideoPlayerUtility = 0, |
69 ENoUtility, |
71 EAudioPlayerUtility, |
70 EVideoPlayerUtility, |
72 }; |
71 EAudioPlayerUtility, |
73 |
72 EAudioRecorderUtility |
74 enum TPlayerState |
73 }; |
75 { |
|
76 EPlayerClosed, |
|
77 EPlayerPaused, |
|
78 EPlayerPlaying, |
|
79 EPlayerError |
|
80 }; |
|
81 |
74 |
82 enum TRecorderState |
75 enum TRecorderState |
83 { |
76 { |
84 ERecorderNotReady = 0, |
77 ERecorderNotReady = 0, |
85 ERecorderOpen, |
78 ERecorderOpen, |
89 public: |
82 public: |
90 |
83 |
91 static CMMFBackendEngine* NewL(); |
84 static CMMFBackendEngine* NewL(); |
92 ~CMMFBackendEngine(); |
85 ~CMMFBackendEngine(); |
93 |
86 |
94 |
|
95 void InitVideoPlayerUtilityL(); |
|
96 TInt SetFileName(char* uri,XAuint32 format,TFuncInUse func); |
87 TInt SetFileName(char* uri,XAuint32 format,TFuncInUse func); |
97 void ResumePlayback(); |
88 void Close(); |
98 void PausePlayback(); |
89 void Destroy(); |
99 void StopPlayback(); |
|
100 void SetWindowHandle(void* display_info); |
|
101 void CreateAndConfigureWindowL(); |
|
102 void CloseAndDestroy(); |
|
103 void SetNativeDisplayInformation(void* display_info); |
|
104 TInt SetRecorderState(TRecorderState state, XAboolean stopCalled); |
90 TInt SetRecorderState(TRecorderState state, XAboolean stopCalled); |
105 TInt GetRecordPosition(XAuint64* position); |
91 TInt GetRecordPosition(XAuint64* position); |
106 TInt SetPositionUpdatePerioed(XAmillisecond period); |
92 TInt SetPositionUpdatePerioed(XAmillisecond period); |
107 TInt SetAdaptContext(void* adaptcontext); |
93 TInt SetAdaptContext(void* adaptcontext); |
108 TInt GetEncoderId(XAuint32* encoderId); |
94 TInt GetCodecId(XAuint32* encoderId); |
109 TInt GetDestinationBitRate(XAuint32* bitrate); |
95 TInt GetBitRate(XAuint32* bitrate); |
110 TInt GetDestinationSampleRate(XAmilliHertz* samplerate); |
96 TInt GetSampleRate(XAmilliHertz* samplerate); |
111 TInt GetDestinationChannels(XAuint32* channels); |
97 TInt GetChannels(XAuint32* channels); |
112 TInt SetDestinationBitRate(XAuint32* bitrate); |
98 TInt SetDestinationBitRate(XAuint32* bitrate); |
113 TInt SetDestinationSampleRate(XAmilliHertz* samplerate); |
99 TInt SetDestinationSampleRate(XAmilliHertz* samplerate); |
114 TInt SetDestinationChannels(XAuint32* channels); |
100 TInt SetDestinationChannels(XAuint32* channels); |
115 private: |
101 |
116 |
102 /* XAresult SetWindowHandle(void* display_info);*/ |
117 //From MVidePlayerUtilityObserver |
103 XAresult CreateAndConfigureWindowL(); |
118 void MvpuoOpenComplete(TInt aError); |
104 XAresult SetNativeDisplayInformation(void* display_info); |
119 void MvpuoFrameReady(CFbsBitmap& aFrame,TInt aError); |
105 XAresult ResumePlayback(); |
120 void MvpuoPlayComplete(TInt aError); |
106 XAresult PausePlayback(); |
121 void MvpuoEvent(const TMMFEvent& aEvent); |
107 XAresult StopPlayback(); |
122 void MvpuoPrepareComplete(TInt aError); |
108 XAresult GetPlayState(XAuint32 *pState); |
123 |
109 XAresult GetDuration(XAmillisecond *pMsec); |
|
110 XAresult GetPosition(XAmillisecond *pMsec); |
|
111 XAresult SetPlayAdaptContext(void * adaptcontext); |
|
112 XAresult RegisterCallback(xaPlayCallback cbFunction); |
|
113 XAresult SetCallbackEventsMask(XAuint32 eventflags); |
|
114 XAresult SetMarkerPosition(XAmillisecond mSec); |
|
115 XAresult ClearMarkerPosition(); |
|
116 XAresult SetPositionUpdatePeriod(XAmillisecond mSec); |
|
117 |
|
118 XAresult SetPosition(XAmillisecond pMsec); |
|
119 XAresult SetRepeats(XAboolean repeat); |
|
120 XAresult SetPlayWindow(XAmillisecond start, XAmillisecond end); |
|
121 |
|
122 XAresult GetNumStreams(XAuint32* numstreams); |
|
123 XAresult GetStreamInfo(XAuint32 streamindex, XAuint32* streamtype); |
|
124 XAresult GetVideoFrameSize(XAuint32* height, XAuint32* width, XAuint32* frameRate); |
|
125 XAresult SetActiveState(XAuint32 streamindex, XAboolean active); |
|
126 |
|
127 XAresult SetVolume(XAuint32 volume); |
|
128 XAresult GetVolume(XAuint32* volume); |
|
129 XAresult GetMaxVolume(XAuint32* maxvolume); |
124 public: |
130 public: |
125 |
131 |
126 //MMdaAudioPlayerCallback |
132 // MMdaObjectStateChangeObserver |
127 void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration); |
133 void MoscoStateChangeEvent( |
128 void MapcPlayComplete(TInt aError); |
134 CBase* aObject, |
129 |
135 TInt aPreviousState, |
130 // from MMdaObjectStateChangeObserver |
136 TInt aCurrentState, |
131 void MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt /*aErrorcCode*/); |
137 TInt aErrorcCode); |
132 |
138 |
|
139 //MMdaAudioPlayerCallback |
|
140 void MapcInitComplete( |
|
141 TInt aError, |
|
142 const TTimeIntervalMicroSeconds& aDuration); |
|
143 void MapcPlayComplete(TInt aError); |
133 |
144 |
134 private: |
145 //From MVidePlayerUtilityObserver |
135 |
146 void MvpuoOpenComplete(TInt aError); |
136 // From MRebufferCallback |
147 void MvpuoPrepareComplete(TInt aError); |
137 void MvloLoadingStarted(); |
148 void MvpuoFrameReady(CFbsBitmap& aFrame, TInt aError); |
138 void MvloLoadingComplete(); |
149 void MvpuoPlayComplete(TInt aError); |
139 |
150 void MvpuoEvent(const TMMFEvent& aEvent); |
140 private: |
151 |
141 //audio player methods |
152 // From MRebufferCallback |
142 void AudioOpenFile(); |
153 void MvloLoadingStarted(); |
143 void AudioClose(); |
154 void MvloLoadingComplete(); |
144 void AudioStop(); |
155 |
145 void AudioPause(); |
156 private: |
146 |
157 enum TPlayerState |
147 //video player methods |
158 { |
|
159 EPlayerClosed, |
|
160 EPlayerOpened, |
|
161 EPlayerPrepared, |
|
162 EPlayerPaused, |
|
163 EPlayerPlaying, |
|
164 }; |
148 |
165 |
149 private: |
166 private: |
150 CMMFBackendEngine(); |
167 CMMFBackendEngine(); |
151 void ConstructL(); |
168 void ConstructL(); |
|
169 void InitAudioPlayerUtilityL(); |
|
170 void InitVideoPlayerUtilityL(); |
|
171 void InitPlayerTimersL(); |
152 TInt DetermineAPIToUse(char *uri, TFuncInUse aFunc); |
172 TInt DetermineAPIToUse(char *uri, TFuncInUse aFunc); |
153 |
173 XAresult DoHandlePlayItfAttributesChanged(); |
154 |
174 void DoPostEvent(XAuint32 event); |
155 //RThread m_ThreadHandle; |
175 TInt InitializeURIForMMFUtil(char *uri); |
156 CVideoPlayerUtility2* iVideoPlayer; |
176 |
157 CBase* iBaseVideoPlayer; |
177 private: |
158 CBase* iBaseAudioPlayer; |
178 CVideoPlayerUtility2* iVideoPlayer; |
159 CBase* iBaseAudioRecorder; |
179 CBase* iBaseVideoPlayer; |
160 CMdaAudioPlayerUtility* iAudioPlayer; |
180 CMdaAudioPlayerUtility* iAudioPlayer; |
161 CMdaAudioRecorderUtility* iAudioRecorder; |
181 CBase* iBaseAudioPlayer; |
162 TFileName iFileName; |
182 CMdaAudioRecorderUtility* iAudioRecorder; |
163 TInt iAPIBeingUsed; |
183 CBase* iBaseAudioRecorder; |
164 TPlayerState iPlayerState; |
184 TFileName iFileName; |
165 TInt iPreviousRecordState; |
185 TInt iAPIBeingUsed; |
166 TInt iCurrentRecordState; |
186 TInt iPreviousRecordState; |
167 TInt iErrorCode; |
187 TInt iCurrentRecordState; |
168 TRecorderState iRecordState; |
188 TInt iErrorCode; |
169 LocalTimer* iPositionUpdateTimer; |
189 TRecorderState iRecordState; |
170 TUint64 iTimerDelay; |
190 LocalTimer* iPositionUpdateTimer; |
171 void* iAdaptContext; |
191 TUint64 iTimerDelay; |
172 XAuint32 iFileFormat; |
192 void* iAdaptContext; |
173 TInt iPauseSupportMP4; |
193 XAuint32 iFileFormat; |
174 CActiveSchedulerWait* iActiveSchedulerWait; |
194 TInt iPauseSupportMP4; |
175 #ifdef ENABLE_GRAPHICS_SURFACE_INTEGRATION |
195 CActiveSchedulerWait* iActiveSchedulerWait; |
|
196 CAudioInput* iaudioInputRecord; |
|
197 #ifdef USE_LOCAL_WINDOW_RESOURCES |
176 CMediaClientVideoDisplay* iMediaClientVideoDisplay; |
198 CMediaClientVideoDisplay* iMediaClientVideoDisplay; |
177 TRect m_clipRect; |
199 TRect m_clipRect; |
178 TRect m_videoExtent; |
200 TRect m_videoExtent; |
179 TRect m_cropRegion; |
201 TRect m_cropRegion; |
180 TVideoAspectRatio m_pixelAspectRatio; |
202 TVideoAspectRatio m_pixelAspectRatio; |
181 RWindow m_Window; |
203 RWindow m_Window; |
182 RWindow* m_pWindow; |
|
183 TRect m_cropRect; |
204 TRect m_cropRect; |
184 TSurfaceId m_surfaceId; |
205 TSurfaceId m_surfaceId; |
185 TVideoRotation m_rotation; |
206 TVideoRotation m_rotation; |
186 TReal32 m_scaleWidth; |
207 TReal32 m_scaleWidth; |
187 TReal32 m_scaleHeight; |
208 TReal32 m_scaleHeight; |
188 TInt m_horizPos; |
209 TInt m_horizPos; |
189 TInt m_vertPos; |
210 TInt m_vertPos; |
190 TInt m_displayId; |
211 TInt m_displayId; |
191 TBool m_bWindowReferencePassed; |
212 /*TBool m_bWindowReferencePassed;*/ |
|
213 RWsSession m_ws; |
|
214 #endif /* USE_LOCAL_WINDOW_RESOURCES */ |
|
215 |
|
216 /* Holds duration of the media clip opend for playback */ |
|
217 TTimeIntervalMicroSeconds iMediaDuration; |
|
218 /* Holds the playback position to be used for next play command */ |
|
219 TTimeIntervalMicroSeconds iPlaybackHead; |
|
220 /* Holds current XA state of media player object */ |
|
221 XAuint32 iMediaPlayerState; |
|
222 /* Owns */ |
|
223 CMarkerPositionTimer* iMarkerPositionTimer; |
|
224 CPositionUpdateTimer* iPlayItfPositionUpdateTimer; |
|
225 /* Owns */ |
192 CWsScreenDevice* m_pScr; |
226 CWsScreenDevice* m_pScr; |
193 RWsSession m_ws; |
227 /* Holds mmf state of media player object */ |
|
228 TPlayerState iMMFPlayerState; |
|
229 |
|
230 /* Property set by client */ |
|
231 XAuint32 iPlayItfEventFlags; |
|
232 /* Property set by client */ |
|
233 xaPlayCallback iPlayItfCBFunction; |
|
234 /* Property set by client */ |
|
235 XAmillisecond iMarkerPosition; |
|
236 /* Property set by client */ |
|
237 XAmillisecond iPositionUpdatePeriod; |
|
238 /* Property set by client (for file without file:///) */ |
|
239 HBufC* iUri; /* owns */ |
|
240 TPtr iUriPtr; |
|
241 /* Property set by client */ |
194 RWsSession* m_pWs; |
242 RWsSession* m_pWs; |
195 |
243 /* Property set by client */ |
196 #endif /*ENABLE_GRAPHICS_SURFACE_INTEGRATION*/ |
244 RWindow* m_pWindow; |
197 }; |
245 }; |
|
246 |
198 #else /* __cplusplus */ |
247 #else /* __cplusplus */ |
199 |
248 |
200 |
249 |
201 extern int mmf_backend_engine_init(void** engine); |
250 extern int mmf_backend_engine_init(void** engine); |
|
251 extern int mmf_backend_engine_deinit(void* engine); |
202 |
252 |
203 extern int mmf_set_recorder_uri(void* context, char* uri, XAuint32 format); |
253 extern int mmf_set_recorder_uri(void* context, char* uri, XAuint32 format); |
204 |
254 |
205 extern void mmf_set_player_uri(void* context, char* uri, XAuint32 format); |
|
206 |
|
207 extern void mmf_pause_playback(void* context); |
|
208 |
|
209 extern void mmf_resume_playback(void* context); |
|
210 |
|
211 extern void mmf_set_window_handle(void* context, void* display_infos); |
|
212 |
|
213 extern void mmf_stop_playback(void* context); |
|
214 |
255 |
215 extern void mmf_close(void* context); |
256 extern void mmf_close(void* context); |
216 |
|
217 extern void mmf_setup_native_display(void* context, void* display_info); |
|
218 |
257 |
219 extern int mmf_set_adapt_context(void* context, void* adaptcontext); |
258 extern int mmf_set_adapt_context(void* context, void* adaptcontext); |
220 |
259 |
221 extern int mmf_start_recording(void* context); |
260 extern int mmf_start_recording(void* context); |
222 |
261 |
224 |
263 |
225 extern int mmf_get_record_position(void* context, XAuint64* position); |
264 extern int mmf_get_record_position(void* context, XAuint64* position); |
226 |
265 |
227 extern int mmf_set_record_position_update_period(void* context, XAmillisecond msec); |
266 extern int mmf_set_record_position_update_period(void* context, XAmillisecond msec); |
228 |
267 |
229 extern int mmf_get_encoder_id(void* context, XAuint32* encoderId); |
268 extern int mmf_get_codec_id(void* context, XAuint32* encoderId); |
230 extern int mmf_get_destination_channels(void* context, XAuint32* channelsIn); |
269 extern int mmf_get_channels(void* context, XAuint32* channelsIn); |
231 extern int mmf_get_destination_samplerate(void* context, XAmilliHertz* sampleRate); |
270 extern int mmf_get_samplerate(void* context, XAmilliHertz* sampleRate); |
232 extern int mmf_get_destination_bitrate(void* context, XAuint32* bitRate); |
271 extern int mmf_get_bitrate(void* context, XAuint32* bitRate); |
233 extern int mmf_set_destination_channels(void* context, XAuint32* channelsIn); |
272 extern int mmf_set_destination_channels(void* context, XAuint32* channelsIn); |
234 extern int mmf_set_destination_samplerate(void* context, XAmilliHertz* sampleRate); |
273 extern int mmf_set_destination_samplerate(void* context, XAmilliHertz* sampleRate); |
235 extern int mmf_set_destination_bitrate(void* context, XAuint32* bitRate); |
274 extern int mmf_set_destination_bitrate(void* context, XAuint32* bitRate); |
236 |
275 |
|
276 extern XAresult mmf_set_play_adapt_context(void * context, void * adaptcontext); |
|
277 extern XAresult mmf_set_player_uri(void * context, char * uri, XAuint32 format); |
|
278 /*extern XAresult mmf_set_window_handle(void * context, void * display_infos);*/ |
|
279 extern XAresult mmf_setup_native_display(void * context, void * display_info); |
|
280 |
|
281 /*Functions for XAPlayItf*/ |
|
282 extern XAresult mmf_playitf_resume_playback(void * context); |
|
283 extern XAresult mmf_playitf_pause_playback(void * context); |
|
284 extern XAresult mmf_playitf_stop_playback(void * context); |
|
285 extern XAresult mmf_playitf_get_play_state(void * context, XAuint32 * pState); |
|
286 extern XAresult mmf_playitf_get_duration(void * context, XAmillisecond * pMsec); |
|
287 extern XAresult mmf_playitf_get_position(void * context, XAmillisecond * pMsec); |
|
288 extern XAresult mmf_playitf_register_callback(void * context, xaPlayCallback callback); |
|
289 extern XAresult mmf_playitf_set_callback_events_mask(void * context, XAuint32 eventflags); |
|
290 extern XAresult mmf_playitf_set_marker_position(void * context, XAmillisecond mSec); |
|
291 extern XAresult mmf_playitf_clear_marker_position(void * context); |
|
292 extern XAresult mmf_playitf_set_position_update_period(void * context, XAmillisecond mSec); |
|
293 |
|
294 extern XAresult mmf_seekitf_set_position(void * context, XAmillisecond mSec); |
|
295 extern XAresult mmf_seekitf_set_playwindow(void * context, XAmillisecond start, XAmillisecond end); |
|
296 extern XAresult mmf_seekitf_set_repeats(void * context, XAboolean repeat); |
|
297 |
|
298 extern XAresult mmf_streaminformationitf_get_numstreams(void * context, XAuint32* numstreams); |
|
299 extern XAresult mmf_streaminformationitf_get_streaminfo(void * context, XAuint32 streamindex, |
|
300 XAuint32* streamtype); |
|
301 extern XAresult mmf_streaminformationitf_get_videoframesize(void * context, XAuint32* height, |
|
302 XAuint32* width, XAuint32* frameRate); |
|
303 extern XAresult mmf_streaminformationitf_set_activestream(void * context, XAuint32 streamindex, |
|
304 XAboolean active); |
|
305 |
|
306 extern XAresult mmf_volumeitf_set_volume(void * context, XAuint32 volume); |
|
307 extern XAresult mmf_volumeitf_get_volume(void * context, XAuint32* volume); |
|
308 extern XAresult mmf_volumeitf_get_maxvolume(void * context, XAuint32* volume); |
237 #endif /* __cplusplus */ |
309 #endif /* __cplusplus */ |
238 |
310 |
239 #endif /* XA_CMMFBackendEngine_H */ |
311 #endif /* XA_CMMFBackendEngine_H */ |