| /* |
| * Copyright (C) 2011 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| #ifndef ANDROID_VE_PREVIEWCONTROLLER_H |
| #define ANDROID_VE_PREVIEWCONTROLLER_H |
| |
| #include <utils/Log.h> |
| #include "VideoEditorPlayer.h" |
| #include "VideoEditorAudioPlayer.h" |
| #include "M4OSA_Semaphore.h" |
| #include "M4OSA_Thread.h" |
| #include "M4OSA_Clock.h" |
| #include "M4OSA_Time.h" |
| #include "M4xVSS_API.h" |
| #include "M4xVSS_Internal.h" |
| #include "M4VFL_transition.h" |
| #include "VideoEditorTools.h" |
| #include "VideoEditorThumbnailMain.h" |
| #include "VideoEditorMain.h" |
| |
| #include "OMX_IVCommon.h" |
| #include "mediaplayer.h" |
| #include <surfaceflinger/Surface.h> |
| #include <surfaceflinger/ISurface.h> |
| #include <surfaceflinger/ISurfaceComposer.h> |
| #include <surfaceflinger/SurfaceComposerClient.h> |
| #include <media/stagefright/MediaBuffer.h> |
| #include "PreviewRenderer.h" |
| |
| |
| #define NBPLAYER_INSTANCES 2 |
| |
| namespace android { |
| |
| typedef enum { |
| VePlayerIdle=0, |
| VePlayerBusy, |
| VePlayerAutoStop |
| } VePlayerState; |
| |
| typedef enum { |
| OVERLAY_UPDATE = 0, |
| OVERLAY_CLEAR |
| } OverlayState; |
| |
| // Callback mechanism from PreviewController to Jni */ |
| typedef void (*jni_progress_callback_fct)(void* cookie, M4OSA_UInt32 msgType, void *argc); |
| |
| |
| class VideoEditorPreviewController { |
| |
| public: |
| VideoEditorPreviewController(); |
| virtual ~VideoEditorPreviewController(); |
| |
| M4OSA_ERR loadEditSettings(M4VSS3GPP_EditSettings* pSettings, |
| M4xVSS_AudioMixingSettings* bgmSettings); |
| |
| M4OSA_ERR setSurface(const sp<Surface> &surface); |
| |
| M4OSA_ERR startPreview(M4OSA_UInt32 fromMS, M4OSA_Int32 toMs, |
| M4OSA_UInt16 callBackAfterFrameCount, M4OSA_Bool loop) ; |
| |
| M4OSA_UInt32 stopPreview(); |
| |
| M4OSA_ERR renderPreviewFrame(const sp<Surface> &surface, |
| VideoEditor_renderPreviewFrameStr* pFrameInfo, |
| VideoEditorCurretEditInfo *pCurrEditInfo); |
| |
| M4OSA_ERR clearSurface(const sp<Surface> &surface, |
| VideoEditor_renderPreviewFrameStr* pFrameInfo); |
| |
| M4OSA_Void setJniCallback(void* cookie, |
| jni_progress_callback_fct callbackFct); |
| |
| M4OSA_ERR setPreviewFrameRenderingMode(M4xVSS_MediaRendering mode, |
| M4VIDEOEDITING_VideoFrameSize outputVideoSize); |
| |
| private: |
| sp<VideoEditorPlayer> mVePlayer[NBPLAYER_INSTANCES]; |
| int mCurrentPlayer; //Instance of the player currently being used |
| sp<Surface> mSurface; |
| mutable Mutex mLock; |
| M4OSA_Context mThreadContext; |
| VePlayerState mPlayerState; |
| M4OSA_Bool mPrepareReqest; |
| M4VSS3GPP_ClipSettings **mClipList; //Pointer to an array of clip settings |
| M4OSA_UInt32 mNumberClipsInStoryBoard; |
| M4OSA_UInt32 mNumberClipsToPreview; |
| M4OSA_UInt32 mStartingClipIndex; |
| M4OSA_Bool mPreviewLooping; |
| M4OSA_UInt32 mCallBackAfterFrameCnt; |
| M4VSS3GPP_EffectSettings* mEffectsSettings; |
| M4OSA_UInt32 mNumberEffects; |
| M4OSA_Int32 mCurrentClipNumber; |
| M4OSA_UInt32 mClipTotalDuration; |
| M4OSA_UInt32 mCurrentVideoEffect; |
| M4xVSS_AudioMixingSettings* mBackgroundAudioSetting; |
| M4OSA_Context mAudioMixPCMFileHandle; |
| PreviewRenderer *mTarget; |
| M4OSA_Context mJniCookie; |
| jni_progress_callback_fct mJniCallback; |
| VideoEditor_renderPreviewFrameStr mFrameStr; |
| M4OSA_UInt32 mCurrentPlayedDuration; |
| M4OSA_UInt32 mCurrentClipDuration; |
| M4VIDEOEDITING_VideoFrameSize mOutputVideoSize; |
| M4OSA_UInt32 mFirstPreviewClipBeginTime; |
| M4OSA_UInt32 mLastPreviewClipEndTime; |
| M4OSA_UInt32 mVideoStoryBoardTimeMsUptoFirstPreviewClip; |
| OverlayState mOverlayState; |
| int mActivePlayerIndex; |
| |
| M4xVSS_MediaRendering mRenderingMode; |
| uint32_t mOutputVideoWidth; |
| uint32_t mOutputVideoHeight; |
| bool bStopThreadInProgress; |
| M4OSA_Context mSemThreadWait; |
| bool mIsFiftiesEffectStarted; |
| |
| sp<VideoEditorPlayer::VeAudioOutput> mVEAudioSink; |
| VideoEditorAudioPlayer *mVEAudioPlayer; |
| |
| M4VIFI_UInt8* mFrameRGBBuffer; |
| M4VIFI_UInt8* mFrameYUVBuffer; |
| mutable Mutex mLockSem; |
| static M4OSA_ERR preparePlayer(void* param, int playerInstance, int index); |
| static M4OSA_ERR threadProc(M4OSA_Void* param); |
| static void notify(void* cookie, int msg, int ext1, int ext2); |
| |
| void setVideoEffectType(M4VSS3GPP_VideoEffectType type, M4OSA_Bool enable); |
| |
| M4OSA_ERR applyVideoEffect(M4OSA_Void * dataPtr, M4OSA_UInt32 colorFormat, |
| M4OSA_UInt32 videoWidth, M4OSA_UInt32 videoHeight, |
| M4OSA_UInt32 timeMs, M4OSA_Void* outPtr); |
| |
| M4OSA_ERR doImageRenderingMode(M4OSA_Void * dataPtr, |
| M4OSA_UInt32 colorFormat, M4OSA_UInt32 videoWidth, |
| M4OSA_UInt32 videoHeight, M4OSA_Void* outPtr); |
| |
| VideoEditorPreviewController(const VideoEditorPreviewController &); |
| VideoEditorPreviewController &operator=(const VideoEditorPreviewController &); |
| }; |
| |
| } |
| |
| #endif //ANDROID_VE_PREVIEWCONTROLLER_H |