summaryrefslogtreecommitdiffstats
path: root/libvideoeditor
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2012-01-27 19:01:13 -0800
committerJames Dong <jdong@google.com>2012-01-30 12:13:24 -0800
commit3d2d40ac83acbda8c161cae675c372595efd640e (patch)
tree5dfe24a7eaa228e59bff8e0258c121fffa28aaa5 /libvideoeditor
parent2985773cff8a4984ede9985cf4aad9ce655ffd45 (diff)
downloadframeworks_av-3d2d40ac83acbda8c161cae675c372595efd640e.zip
frameworks_av-3d2d40ac83acbda8c161cae675c372595efd640e.tar.gz
frameworks_av-3d2d40ac83acbda8c161cae675c372595efd640e.tar.bz2
Clean up VideoEditorPreviewController class part one:
o moved local types inside the class to avoid external exposure o use non-virtual destructor since it is not meant to be a base class o removed unused header files and moved some of the header files to .cpp file from .h file o replaced #define constants with local enums Change-Id: Ib321fc8c0379955083bc892c2ef93ed58c6c2ff5
Diffstat (limited to 'libvideoeditor')
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorPreviewController.cpp33
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorPreviewController.h119
2 files changed, 78 insertions, 74 deletions
diff --git a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
index 8c4c721..e64989c 100755
--- a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
+++ b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
@@ -14,13 +14,20 @@
* limitations under the License.
*/
-#define LOG_NDEBUG 1
-#define LOG_TAG "VideoEditorPreviewController"
+// #define LOG_NDEBUG 0
+#define LOG_TAG "PreviewController"
+#include <utils/Log.h>
+
+#include <surfaceflinger/Surface.h>
+
+#include "VideoEditorAudioPlayer.h"
+#include "PreviewRenderer.h"
+#include "M4OSA_Semaphore.h"
+#include "M4OSA_Thread.h"
#include "VideoEditorPreviewController.h"
namespace android {
-#define PREVIEW_THREAD_STACK_SIZE (65536)
VideoEditorPreviewController::VideoEditorPreviewController()
: mCurrentPlayer(0),
@@ -56,15 +63,15 @@ VideoEditorPreviewController::VideoEditorPreviewController()
mRenderingMode = M4xVSS_kBlackBorders;
mIsFiftiesEffectStarted = false;
- for (int i=0; i<NBPLAYER_INSTANCES; i++) {
+ for (int i = 0; i < kTotalNumPlayerInstances; ++i) {
mVePlayer[i] = NULL;
}
}
VideoEditorPreviewController::~VideoEditorPreviewController() {
+ ALOGV("~VideoEditorPreviewController");
M4OSA_UInt32 i = 0;
M4OSA_ERR err = M4NO_ERROR;
- ALOGV("~VideoEditorPreviewController");
// Stop the thread if its still running
if(mThreadContext != NULL) {
@@ -85,7 +92,7 @@ VideoEditorPreviewController::~VideoEditorPreviewController() {
mThreadContext = NULL;
}
- for (int playerInst=0; playerInst<NBPLAYER_INSTANCES;
+ for (int playerInst=0; playerInst<kTotalNumPlayerInstances;
playerInst++) {
if(mVePlayer[playerInst] != NULL) {
ALOGV("clearing mVePlayer %d", playerInst);
@@ -438,7 +445,7 @@ M4OSA_ERR VideoEditorPreviewController::startPreview(
}
// If already started, then stop preview first
- for(int playerInst=0; playerInst<NBPLAYER_INSTANCES; playerInst++) {
+ for(int playerInst=0; playerInst<kTotalNumPlayerInstances; playerInst++) {
if(mVePlayer[playerInst] != NULL) {
ALOGV("startPreview: stopping previously started preview playback");
stopPreview();
@@ -471,7 +478,7 @@ M4OSA_ERR VideoEditorPreviewController::startPreview(
ALOGV("startPreview: callBackAfterFrameCount = %d", callBackAfterFrameCount);
mCallBackAfterFrameCnt = callBackAfterFrameCount;
- for (int playerInst=0; playerInst<NBPLAYER_INSTANCES; playerInst++) {
+ for (int playerInst=0; playerInst<kTotalNumPlayerInstances; playerInst++) {
mVePlayer[playerInst] = new VideoEditorPlayer(mNativeWindowRenderer);
if(mVePlayer[playerInst] == NULL) {
ALOGE("startPreview:Error creating VideoEditorPlayer %d",playerInst);
@@ -542,7 +549,7 @@ M4OSA_ERR VideoEditorPreviewController::startPreview(
mVideoStoryBoardTimeMsUptoFirstPreviewClip = iIncrementedDuration;
}
- for (int playerInst=0; playerInst<NBPLAYER_INSTANCES; playerInst++) {
+ for (int playerInst=0; playerInst<kTotalNumPlayerInstances; playerInst++) {
mVePlayer[playerInst]->setAudioMixStoryBoardParam(fromMS,
mFirstPreviewClipBeginTime,
mClipList[i]->ClipProperties.uiClipAudioVolumePercentage);
@@ -605,7 +612,7 @@ M4OSA_ERR VideoEditorPreviewController::startPreview(
// Set the stacksize
err = M4OSA_threadSyncSetOption(mThreadContext, M4OSA_ThreadStackSize,
- (M4OSA_DataOption)PREVIEW_THREAD_STACK_SIZE);
+ (M4OSA_DataOption) kPreviewThreadStackSize);
if (M4NO_ERROR != err) {
ALOGE("VideoEditorPreviewController: threadSyncSetOption error %d", (int) err);
@@ -668,7 +675,7 @@ M4OSA_UInt32 VideoEditorPreviewController::stopPreview() {
}
}
- for (int playerInst=0; playerInst<NBPLAYER_INSTANCES; playerInst++) {
+ for (int playerInst=0; playerInst<kTotalNumPlayerInstances; playerInst++) {
if(mVePlayer[playerInst] != NULL) {
if(mVePlayer[playerInst]->isPlaying()) {
ALOGV("stop the player first");
@@ -1045,7 +1052,7 @@ M4OSA_ERR VideoEditorPreviewController::threadProc(M4OSA_Void* param) {
pController->mCurrentClipNumber);
// Reset the story board timestamp inside the player
- for (int playerInst=0; playerInst<NBPLAYER_INSTANCES;
+ for (int playerInst=0; playerInst<kTotalNumPlayerInstances;
playerInst++) {
pController->mVePlayer[playerInst]->resetJniCallbackTimeStamp();
}
@@ -1249,7 +1256,7 @@ void VideoEditorPreviewController::notify(
pController->mNumberClipsToPreview) {
pController->mPrepareReqest = M4OSA_TRUE;
pController->mCurrentPlayer++;
- if (pController->mCurrentPlayer >= NBPLAYER_INSTANCES) {
+ if (pController->mCurrentPlayer >= kTotalNumPlayerInstances) {
pController->mCurrentPlayer = 0;
}
// Prepare the first clip to be played
diff --git a/libvideoeditor/lvpp/VideoEditorPreviewController.h b/libvideoeditor/lvpp/VideoEditorPreviewController.h
index b4537ec..1756f32 100755
--- a/libvideoeditor/lvpp/VideoEditorPreviewController.h
+++ b/libvideoeditor/lvpp/VideoEditorPreviewController.h
@@ -17,87 +17,78 @@
#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);
+struct Surface;
+struct PreviewRenderer;
class VideoEditorPreviewController {
public:
VideoEditorPreviewController();
- virtual ~VideoEditorPreviewController();
+ ~VideoEditorPreviewController();
- M4OSA_ERR loadEditSettings(M4VSS3GPP_EditSettings* pSettings,
- M4xVSS_AudioMixingSettings* bgmSettings);
+ M4OSA_ERR loadEditSettings(
+ M4VSS3GPP_EditSettings* pSettings,
+ M4xVSS_AudioMixingSettings* bgmSettings);
- M4OSA_ERR setSurface(const sp<Surface> &surface);
+ M4OSA_ERR setSurface(const sp<Surface>& surface);
- M4OSA_ERR startPreview(M4OSA_UInt32 fromMS, M4OSA_Int32 toMs,
- M4OSA_UInt16 callBackAfterFrameCount, M4OSA_Bool loop) ;
+ 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 renderPreviewFrame(
+ const sp<Surface>& surface,
+ VideoEditor_renderPreviewFrameStr* pFrameInfo,
+ VideoEditorCurretEditInfo *pCurrEditInfo);
- M4OSA_ERR clearSurface(const sp<Surface> &surface,
- VideoEditor_renderPreviewFrameStr* pFrameInfo);
+ M4OSA_ERR clearSurface(
+ const sp<Surface>& surface,
+ VideoEditor_renderPreviewFrameStr* pFrameInfo);
- M4OSA_Void setJniCallback(void* cookie,
- jni_progress_callback_fct callbackFct);
+ M4OSA_Void setJniCallback(
+ void* cookie,
+ jni_progress_callback_fct callbackFct);
- status_t setPreviewFrameRenderingMode(M4xVSS_MediaRendering mode,
- M4VIDEOEDITING_VideoFrameSize outputVideoSize);
+ status_t setPreviewFrameRenderingMode(
+ M4xVSS_MediaRendering mode,
+ M4VIDEOEDITING_VideoFrameSize outputVideoSize);
private:
- sp<VideoEditorPlayer> mVePlayer[NBPLAYER_INSTANCES];
- int mCurrentPlayer; //Instance of the player currently being used
+ enum {
+ kTotalNumPlayerInstances = 2,
+ kPreviewThreadStackSize = 65536,
+ };
+
+ typedef enum {
+ VePlayerIdle = 0,
+ VePlayerBusy,
+ VePlayerAutoStop
+ } PlayerState;
+
+ typedef enum {
+ OVERLAY_UPDATE = 0,
+ OVERLAY_CLEAR
+ } OverlayState;
+
+ sp<VideoEditorPlayer> mVePlayer[kTotalNumPlayerInstances];
+ int mCurrentPlayer; // player instance currently being used
sp<Surface> mSurface;
mutable Mutex mLock;
M4OSA_Context mThreadContext;
- VePlayerState mPlayerState;
+ PlayerState mPlayerState;
M4OSA_Bool mPrepareReqest;
- M4VSS3GPP_ClipSettings **mClipList; //Pointer to an array of clip settings
+ M4VSS3GPP_ClipSettings **mClipList;
M4OSA_UInt32 mNumberClipsInStoryBoard;
M4OSA_UInt32 mNumberClipsToPreview;
M4OSA_UInt32 mStartingClipIndex;
@@ -137,24 +128,30 @@ private:
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 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);
+ M4OSA_ERR doImageRenderingMode(
+ M4OSA_Void * dataPtr,
+ M4OSA_UInt32 colorFormat, M4OSA_UInt32 videoWidth,
+ M4OSA_UInt32 videoHeight, M4OSA_Void* outPtr);
+ // Don't call me!
VideoEditorPreviewController(const VideoEditorPreviewController &);
- VideoEditorPreviewController &operator=(const VideoEditorPreviewController &);
+ VideoEditorPreviewController &operator=(
+ const VideoEditorPreviewController &);
};
}
-#endif //ANDROID_VE_PREVIEWCONTROLLER_H
+#endif // ANDROID_VE_PREVIEWCONTROLLER_H