Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 1 | /*
|
| 2 | * Copyright (C) 2011 NXP Software
|
| 3 | * Copyright (C) 2011 The Android Open Source Project
|
| 4 | *
|
| 5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 | * you may not use this file except in compliance with the License.
|
| 7 | * You may obtain a copy of the License at
|
| 8 | *
|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0
|
| 10 | *
|
| 11 | * Unless required by applicable law or agreed to in writing, software
|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 | * See the License for the specific language governing permissions and
|
| 15 | * limitations under the License.
|
| 16 | */
|
| 17 |
|
| 18 | #ifndef ANDROID_VE_PREVIEWCONTROLLER_H
|
| 19 | #define ANDROID_VE_PREVIEWCONTROLLER_H
|
| 20 |
|
| 21 | #include <utils/Log.h>
|
| 22 | #include "VideoEditorPlayer.h"
|
Rajneesh Chowdury | 1c97d9a | 2011-02-21 15:43:33 -0800 | [diff] [blame] | 23 | #include "VideoEditorAudioPlayer.h"
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 24 | #include "M4OSA_Semaphore.h"
|
| 25 | #include "M4OSA_Thread.h"
|
| 26 | #include "M4OSA_Clock.h"
|
| 27 | #include "M4OSA_Time.h"
|
| 28 | #include "M4xVSS_API.h"
|
| 29 | #include "M4xVSS_Internal.h"
|
| 30 | #include "M4VFL_transition.h"
|
| 31 | #include "VideoEditorTools.h"
|
| 32 | #include "VideoEditorThumbnailMain.h"
|
| 33 | #include "VideoEditorMain.h"
|
| 34 |
|
| 35 | #include "OMX_IVCommon.h"
|
| 36 | #include "mediaplayer.h"
|
| 37 | #include <surfaceflinger/Surface.h>
|
| 38 | #include <surfaceflinger/ISurface.h>
|
| 39 | #include <surfaceflinger/ISurfaceComposer.h>
|
| 40 | #include <surfaceflinger/SurfaceComposerClient.h>
|
| 41 | #include <media/stagefright/MediaBuffer.h>
|
| 42 | #include "PreviewRenderer.h"
|
| 43 |
|
| 44 |
|
| 45 | #define NBPLAYER_INSTANCES 2
|
| 46 |
|
| 47 | namespace android {
|
| 48 |
|
| 49 | typedef enum {
|
| 50 | VePlayerIdle=0,
|
| 51 | VePlayerBusy,
|
| 52 | VePlayerAutoStop
|
| 53 | } VePlayerState;
|
| 54 |
|
Dheeraj Sharma | 4f4efef | 2011-02-10 16:55:37 -0800 | [diff] [blame] | 55 | typedef enum {
|
| 56 | OVERLAY_UPDATE = 0,
|
| 57 | OVERLAY_CLEAR
|
| 58 | } OverlayState;
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 59 |
|
| 60 | // Callback mechanism from PreviewController to Jni */
|
Dharmaray Kundargi | e6c0750 | 2011-01-21 16:58:31 -0800 | [diff] [blame] | 61 | typedef void (*jni_progress_callback_fct)(void* cookie, M4OSA_UInt32 msgType, void *argc);
|
| 62 |
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 63 |
|
| 64 | class VideoEditorPreviewController {
|
| 65 |
|
| 66 | public:
|
| 67 | VideoEditorPreviewController();
|
| 68 | virtual ~VideoEditorPreviewController();
|
| 69 |
|
| 70 | M4OSA_ERR loadEditSettings(M4VSS3GPP_EditSettings* pSettings,
|
Dharmaray Kundargi | e6c0750 | 2011-01-21 16:58:31 -0800 | [diff] [blame] | 71 | M4xVSS_AudioMixingSettings* bgmSettings);
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 72 |
|
| 73 | M4OSA_ERR setSurface(const sp<Surface> &surface);
|
| 74 |
|
| 75 | M4OSA_ERR startPreview(M4OSA_UInt32 fromMS, M4OSA_Int32 toMs,
|
Dharmaray Kundargi | e6c0750 | 2011-01-21 16:58:31 -0800 | [diff] [blame] | 76 | M4OSA_UInt16 callBackAfterFrameCount, M4OSA_Bool loop) ;
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 77 |
|
Santosh Madhava | b2d6e0f | 2011-02-16 22:24:42 -0800 | [diff] [blame] | 78 | M4OSA_UInt32 stopPreview();
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 79 |
|
| 80 | M4OSA_ERR renderPreviewFrame(const sp<Surface> &surface,
|
Dharmaray Kundargi | e6c0750 | 2011-01-21 16:58:31 -0800 | [diff] [blame] | 81 | VideoEditor_renderPreviewFrameStr* pFrameInfo,
|
| 82 | VideoEditorCurretEditInfo *pCurrEditInfo);
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 83 |
|
Dheeraj Sharma | 9ec356a | 2011-01-24 15:02:18 -0800 | [diff] [blame] | 84 | M4OSA_ERR clearSurface(const sp<Surface> &surface,
|
| 85 | VideoEditor_renderPreviewFrameStr* pFrameInfo);
|
| 86 |
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 87 | M4OSA_Void setJniCallback(void* cookie,
|
Dharmaray Kundargi | e6c0750 | 2011-01-21 16:58:31 -0800 | [diff] [blame] | 88 | jni_progress_callback_fct callbackFct);
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 89 |
|
| 90 | M4OSA_ERR setPreviewFrameRenderingMode(M4xVSS_MediaRendering mode,
|
Dharmaray Kundargi | e6c0750 | 2011-01-21 16:58:31 -0800 | [diff] [blame] | 91 | M4VIDEOEDITING_VideoFrameSize outputVideoSize);
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 92 |
|
| 93 | private:
|
| 94 | sp<VideoEditorPlayer> mVePlayer[NBPLAYER_INSTANCES];
|
| 95 | int mCurrentPlayer; //Instance of the player currently being used
|
| 96 | sp<ISurface> mISurface;
|
| 97 | sp<Surface> mSurface;
|
| 98 | mutable Mutex mLock;
|
| 99 | M4OSA_Context mThreadContext;
|
| 100 | VePlayerState mPlayerState;
|
Dharmaray Kundargi | 3c48e41 | 2011-01-27 18:22:56 -0800 | [diff] [blame] | 101 | M4OSA_Bool mPrepareReqest;
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 102 | M4VSS3GPP_ClipSettings **mClipList; //Pointer to an array of clip settings
|
| 103 | M4OSA_UInt32 mNumberClipsInStoryBoard;
|
| 104 | M4OSA_UInt32 mNumberClipsToPreview;
|
| 105 | M4OSA_UInt32 mStartingClipIndex;
|
| 106 | M4OSA_Bool mPreviewLooping;
|
| 107 | M4OSA_UInt32 mCallBackAfterFrameCnt;
|
| 108 | M4VSS3GPP_EffectSettings* mEffectsSettings;
|
| 109 | M4OSA_UInt32 mNumberEffects;
|
| 110 | M4OSA_Int32 mCurrentClipNumber;
|
| 111 | M4OSA_UInt32 mClipTotalDuration;
|
| 112 | M4OSA_UInt32 mCurrentVideoEffect;
|
| 113 | M4xVSS_AudioMixingSettings* mBackgroundAudioSetting;
|
| 114 | M4OSA_Context mAudioMixPCMFileHandle;
|
| 115 | PreviewRenderer *mTarget;
|
| 116 | M4OSA_Context mJniCookie;
|
| 117 | jni_progress_callback_fct mJniCallback;
|
| 118 | VideoEditor_renderPreviewFrameStr mFrameStr;
|
| 119 | M4OSA_UInt32 mCurrentPlayedDuration;
|
| 120 | M4OSA_UInt32 mCurrentClipDuration;
|
| 121 | M4VIDEOEDITING_VideoFrameSize mOutputVideoSize;
|
| 122 | M4OSA_UInt32 mFirstPreviewClipBeginTime;
|
| 123 | M4OSA_UInt32 mLastPreviewClipEndTime;
|
| 124 | M4OSA_UInt32 mVideoStoryBoardTimeMsUptoFirstPreviewClip;
|
Dheeraj Sharma | 4f4efef | 2011-02-10 16:55:37 -0800 | [diff] [blame] | 125 | OverlayState mOverlayState;
|
Santosh Madhava | b2d6e0f | 2011-02-16 22:24:42 -0800 | [diff] [blame] | 126 | int mActivePlayerIndex;
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 127 |
|
| 128 | M4xVSS_MediaRendering mRenderingMode;
|
| 129 | uint32_t mOutputVideoWidth;
|
| 130 | uint32_t mOutputVideoHeight;
|
| 131 | bool bStopThreadInProgress;
|
| 132 | M4OSA_Context mSemThreadWait;
|
| 133 | bool mIsFiftiesEffectStarted;
|
| 134 |
|
Rajneesh Chowdury | 1c97d9a | 2011-02-21 15:43:33 -0800 | [diff] [blame] | 135 | sp<VideoEditorPlayer::VeAudioOutput> mVEAudioSink;
|
| 136 | VideoEditorAudioPlayer *mVEAudioPlayer;
|
| 137 |
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 138 | M4VIFI_UInt8* mFrameRGBBuffer;
|
| 139 | M4VIFI_UInt8* mFrameYUVBuffer;
|
| 140 | static M4OSA_ERR preparePlayer(void* param, int playerInstance, int index);
|
| 141 | static M4OSA_ERR threadProc(M4OSA_Void* param);
|
| 142 | static void notify(void* cookie, int msg, int ext1, int ext2);
|
| 143 |
|
| 144 | void setVideoEffectType(M4VSS3GPP_VideoEffectType type, M4OSA_Bool enable);
|
| 145 |
|
| 146 | M4OSA_ERR applyVideoEffect(M4OSA_Void * dataPtr, M4OSA_UInt32 colorFormat,
|
| 147 | M4OSA_UInt32 videoWidth, M4OSA_UInt32 videoHeight,
|
| 148 | M4OSA_UInt32 timeMs, M4OSA_Void* outPtr);
|
| 149 |
|
| 150 | M4OSA_ERR doImageRenderingMode(M4OSA_Void * dataPtr,
|
| 151 | M4OSA_UInt32 colorFormat, M4OSA_UInt32 videoWidth,
|
| 152 | M4OSA_UInt32 videoHeight, M4OSA_Void* outPtr);
|
| 153 |
|
| 154 | VideoEditorPreviewController(const VideoEditorPreviewController &);
|
| 155 | VideoEditorPreviewController &operator=(const VideoEditorPreviewController &);
|
| 156 | };
|
| 157 |
|
| 158 | }
|
| 159 |
|
| 160 | #endif //ANDROID_VE_PREVIEWCONTROLLER_H
|