videoeditor JNI files on honeycomb
Change-Id: I2e6a23ae918fda4fb1bc4c2c938efd546991b58c
This commit is contained in:
92
media/jni/mediaeditor/Android.mk
Executable file
92
media/jni/mediaeditor/Android.mk
Executable file
@@ -0,0 +1,92 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES:= \
|
||||
VideoEditorMain.cpp \
|
||||
VideoEditorClasses.cpp \
|
||||
VideoEditorOsal.cpp \
|
||||
VideoEditorJava.cpp \
|
||||
VideoEditorPropertiesMain.cpp \
|
||||
VideoEditorThumbnailMain.cpp \
|
||||
VideoBrowserMain.c
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(TOP)/frameworks/base/core/jni \
|
||||
$(TOP)/frameworks/base/include \
|
||||
$(TOP)/frameworks/base/include/media \
|
||||
$(TOP)/frameworks/base/media/libmediaplayerservice \
|
||||
$(TOP)/frameworks/base/media/libstagefright \
|
||||
$(TOP)/frameworks/base/media/libstagefright/include \
|
||||
$(TOP)/frameworks/base/media/libstagefright/rtsp \
|
||||
$(JNI_H_INCLUDE) \
|
||||
$(call include-path-for, corecg graphics) \
|
||||
$(TOP)/external/opencore/extern_libs_v2/khronos/openmax/include \
|
||||
$(TOP)/external/opencore/android \
|
||||
$(TOP)/vendor/qcom/proprietary/qdsp6/mm-core/omxcore/inc \
|
||||
$(TOP)/frameworks/base/core/jni/mediaeditor \
|
||||
$(TOP)/frameworks/media/libvideoeditor/vss/inc \
|
||||
$(TOP)/frameworks/media/libvideoeditor/vss/common/inc \
|
||||
$(TOP)/frameworks/media/libvideoeditor/vss/mcs/inc \
|
||||
$(TOP)/frameworks/media/libvideoeditor/vss/stagefrightshells/inc \
|
||||
$(TOP)/frameworks/media/libvideoeditor/lvpp \
|
||||
$(TOP)/frameworks/media/libvideoeditor/osal/inc
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libcutils \
|
||||
libutils \
|
||||
libandroid_runtime \
|
||||
libnativehelper \
|
||||
libmedia \
|
||||
libbinder \
|
||||
libstagefright \
|
||||
libstagefright_omx \
|
||||
libsurfaceflinger_client \
|
||||
libvideoeditorplayer
|
||||
|
||||
|
||||
LOCAL_CFLAGS += \
|
||||
-DUSE_STAGEFRIGHT_CODECS \
|
||||
-DUSE_STAGEFRIGHT_AUDIODEC \
|
||||
-DUSE_STAGEFRIGHT_VIDEODEC \
|
||||
-DUSE_STAGEFRIGHT_AUDIOENC \
|
||||
-DUSE_STAGEFRIGHT_VIDEOENC \
|
||||
-DUSE_STAGEFRIGHT_READERS \
|
||||
-DUSE_STAGEFRIGHT_3GPP_READER
|
||||
|
||||
|
||||
LOCAL_LDFLAGS += -fuse-ld=bfd
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := \
|
||||
libvideoeditor_core \
|
||||
libstagefright_color_conversion \
|
||||
libvideoeditor_3gpwriter \
|
||||
libvideoeditor_mcs \
|
||||
libvideoeditor_videofilters \
|
||||
libvideoeditor_stagefrightshells \
|
||||
libvideoeditor_osal
|
||||
|
||||
LOCAL_MODULE:= libvideoeditor_jni
|
||||
|
||||
# Don't prelink this library. For more efficient code, you may want
|
||||
# to add this library to the prelink map and set this to true.
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
|
||||
LOCAL_MODULE_TAGS := eng development
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
131
media/jni/mediaeditor/VideoBrowserInternal.h
Executable file
131
media/jni/mediaeditor/VideoBrowserInternal.h
Executable file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 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 VIDEO_BROWSER_INTERNAL_H
|
||||
#define VIDEO_BROWSER_INTERNAL_H
|
||||
|
||||
#include "VideoBrowserMain.h"
|
||||
|
||||
#include "M4READER_Common.h"
|
||||
#include "M4DECODER_Common.h"
|
||||
|
||||
|
||||
#define VIDEO_BROWSER_BGR565
|
||||
|
||||
|
||||
#define VIDEO_BROWSER_PREDECODE_TIME 2000 /* In miliseconds */
|
||||
|
||||
/*---------------------------- MACROS ----------------------------*/
|
||||
#define CHECK_PTR(fct, p, err, errValue) \
|
||||
{ \
|
||||
if (M4OSA_NULL == p) \
|
||||
{ \
|
||||
err = errValue ; \
|
||||
M4OSA_TRACE1_1("" #fct "(L%d): " #p " is NULL, returning " #errValue "", __LINE__) ; \
|
||||
goto fct##_cleanUp; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define CHECK_ERR(fct, err) \
|
||||
{ \
|
||||
if (M4OSA_ERR_IS_ERROR(err)) \
|
||||
{ \
|
||||
M4OSA_TRACE1_2("" #fct "(L%d): ERROR 0x%.8x returned", __LINE__,err) ; \
|
||||
goto fct##_cleanUp; \
|
||||
} \
|
||||
else if (M4OSA_ERR_IS_WARNING(err)) \
|
||||
{ \
|
||||
M4OSA_TRACE2_2("" #fct "(L%d): WARNING 0x%.8x returned", __LINE__,err) ; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define CHECK_STATE(fct, state, pC) \
|
||||
{ \
|
||||
if (state != pC->m_state) \
|
||||
{ \
|
||||
M4OSA_TRACE1_1("" #fct " called in bad state %d", pC->m_state) ; \
|
||||
err = M4ERR_STATE ; \
|
||||
goto fct##_cleanUp; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SAFE_FREE(p) \
|
||||
{ \
|
||||
if (M4OSA_NULL != p) \
|
||||
{ \
|
||||
M4OSA_free((M4OSA_MemAddr32)p) ; \
|
||||
p = M4OSA_NULL ; \
|
||||
} \
|
||||
}
|
||||
|
||||
/*--- Video Browser state ---*/
|
||||
typedef enum
|
||||
{
|
||||
VideoBrowser_kVBCreating,
|
||||
VideoBrowser_kVBOpened,
|
||||
VideoBrowser_kVBBrowsing
|
||||
} VideoBrowser_videoBrowerState;
|
||||
|
||||
|
||||
/*--- Video Browser execution context. ---*/
|
||||
typedef struct
|
||||
{
|
||||
VideoBrowser_videoBrowerState m_state ;
|
||||
VideoBrowser_videoBrowerDrawMode m_drawmode;
|
||||
|
||||
M4OSA_Context g_hbmp2;
|
||||
M4OSA_Context dc;
|
||||
M4OSA_Int16* g_bmPixels2;
|
||||
|
||||
/*--- Reader parameters ---*/
|
||||
M4OSA_FileReadPointer m_fileReadPtr;
|
||||
M4READER_GlobalInterface* m_3gpReader ;
|
||||
M4READER_DataInterface* m_3gpData ;
|
||||
M4READER_MediaType m_mediaType ;
|
||||
M4OSA_Context m_pReaderCtx ;
|
||||
|
||||
M4_StreamHandler* m_pStreamHandler ;
|
||||
M4_AccessUnit m_accessUnit ;
|
||||
|
||||
/*--- Decoder parameters ---*/
|
||||
M4DECODER_VideoInterface* m_pDecoder ;
|
||||
M4OSA_Context m_pDecoderCtx ;
|
||||
|
||||
/*--- Common display parameters ---*/
|
||||
M4OSA_UInt32 m_x ;
|
||||
M4OSA_UInt32 m_y ;
|
||||
M4VIFI_ImagePlane m_outputPlane[3] ;
|
||||
|
||||
/*--- Current browsing time ---*/
|
||||
M4OSA_UInt32 m_currentCTS ;
|
||||
|
||||
/*--- Platform dependent display parameters ---*/
|
||||
M4OSA_Context m_pCoreContext ;
|
||||
|
||||
/*--- Callback function settings ---*/
|
||||
videoBrowser_Callback m_pfCallback;
|
||||
M4OSA_Void* m_pCallbackUserData;
|
||||
|
||||
/*--- Codec Loader core context ---*/
|
||||
M4OSA_Context m_pCodecLoaderContext;
|
||||
|
||||
/*--- Required color type ---*/
|
||||
VideoBrowser_VideoColorType m_frameColorType;
|
||||
|
||||
} VideoBrowserContext;
|
||||
|
||||
#endif /* VIDEO_BROWSER_INTERNAL_H */
|
||||
593
media/jni/mediaeditor/VideoBrowserMain.c
Executable file
593
media/jni/mediaeditor/VideoBrowserMain.c
Executable file
@@ -0,0 +1,593 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include "VideoEditorVideoDecoder.h"
|
||||
#include "VideoEditor3gpReader.h"
|
||||
|
||||
#include <utils/Log.h>
|
||||
#include "VideoBrowserInternal.h"
|
||||
#include "LVOSA_FileReader_optim.h"
|
||||
|
||||
//#define M4OSA_TRACE_LEVEL 1
|
||||
#if (M4OSA_TRACE_LEVEL >= 1)
|
||||
#undef M4OSA_TRACE1_0
|
||||
#undef M4OSA_TRACE1_1
|
||||
#undef M4OSA_TRACE1_2
|
||||
#undef M4OSA_TRACE1_3
|
||||
|
||||
#define M4OSA_TRACE1_0(a) __android_log_print(ANDROID_LOG_INFO, "Thumbnail", a);
|
||||
#define M4OSA_TRACE1_1(a,b) __android_log_print(ANDROID_LOG_INFO, "Thumbnail", a,b);
|
||||
#define M4OSA_TRACE1_2(a,b,c) __android_log_print(ANDROID_LOG_INFO, "Thumbnail", a,b,c);
|
||||
#define M4OSA_TRACE1_3(a,b,c,d) __android_log_print(ANDROID_LOG_INFO, "Thumbnail", a,b,c,d);
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* M4OSA_ERR videoBrowserSetWindow(
|
||||
* M4OSA_Context pContext, M4OSA_UInt32 x,
|
||||
* M4OSA_UInt32 y, M4OSA_UInt32 dx, M4OSA_UInt32 dy);
|
||||
* @brief This function sets the size and the position of the display.
|
||||
* @param pContext (IN) : Video Browser context
|
||||
* @param pPixelArray (IN) : Array to hold the video frame.
|
||||
* @param x (IN) : Horizontal position of the top left
|
||||
* corner
|
||||
* @param y (IN) : Vertical position of the top left corner
|
||||
* @param dx (IN) : Width of the display window
|
||||
* @param dy (IN) : Height of the video window
|
||||
* @return M4NO_ERROR / M4ERR_PARAMETER / M4ERR_STATE / M4ERR_ALLOC
|
||||
******************************************************************************/
|
||||
M4OSA_ERR videoBrowserSetWindow(
|
||||
M4OSA_Context pContext,
|
||||
M4OSA_Int32 *pPixelArray,
|
||||
M4OSA_UInt32 x, M4OSA_UInt32 y,
|
||||
M4OSA_UInt32 dx, M4OSA_UInt32 dy)
|
||||
{
|
||||
VideoBrowserContext* pC = (VideoBrowserContext*)pContext;
|
||||
M4OSA_ERR err = M4NO_ERROR;
|
||||
|
||||
M4OSA_TRACE2_5("videoBrowserSetWindow: entering with 0x%x %d %d %d %d ",
|
||||
pContext, x, y, dx, dy);
|
||||
|
||||
/*--- Sanity checks ---*/
|
||||
CHECK_PTR(videoBrowserSetWindow, pContext, err, M4ERR_PARAMETER);
|
||||
CHECK_PTR(videoBrowserSetWindow, pPixelArray, err, M4ERR_PARAMETER);
|
||||
CHECK_STATE(videoBrowserSetWindow, VideoBrowser_kVBOpened, pC);
|
||||
|
||||
pC->m_outputPlane[0].u_topleft = 0;
|
||||
|
||||
pC->m_outputPlane[0].u_height = dy;
|
||||
pC->m_outputPlane[0].u_width = dx;
|
||||
pC->m_x = x;
|
||||
pC->m_y = y;
|
||||
|
||||
if (pC->m_frameColorType == VideoBrowser_kGB565) {
|
||||
pC->m_outputPlane[0].u_stride = pC->m_outputPlane[0].u_width << 1;
|
||||
pC->m_outputPlane[0].pac_data = (M4OSA_UInt8*)M4OSA_malloc(
|
||||
pC->m_outputPlane[0].u_stride * pC->m_outputPlane[0].u_height,
|
||||
VIDEOBROWSER, (M4OSA_Char *)"output plane");
|
||||
|
||||
CHECK_PTR(videoBrowserSetWindow,
|
||||
pC->m_outputPlane[0].pac_data, err, M4ERR_ALLOC);
|
||||
}
|
||||
else if (pC->m_frameColorType == VideoBrowser_kYUV420) {
|
||||
pC->m_outputPlane[0].u_stride = pC->m_outputPlane[0].u_width;
|
||||
pC->m_outputPlane[1].u_height = pC->m_outputPlane[0].u_height >> 1;
|
||||
pC->m_outputPlane[1].u_width = pC->m_outputPlane[0].u_width >> 1;
|
||||
pC->m_outputPlane[1].u_topleft = 0;
|
||||
pC->m_outputPlane[1].u_stride = pC->m_outputPlane[1].u_width;
|
||||
|
||||
pC->m_outputPlane[2].u_height = pC->m_outputPlane[0].u_height >> 1;
|
||||
pC->m_outputPlane[2].u_width = pC->m_outputPlane[0].u_width >> 1;
|
||||
pC->m_outputPlane[2].u_topleft = 0;
|
||||
pC->m_outputPlane[2].u_stride = pC->m_outputPlane[2].u_width;
|
||||
|
||||
pC->m_outputPlane[0].pac_data = (M4OSA_UInt8*)pPixelArray;
|
||||
|
||||
CHECK_PTR(videoBrowserSetWindow,
|
||||
pC->m_outputPlane[0].pac_data, err, M4ERR_ALLOC);
|
||||
|
||||
pC->m_outputPlane[1].pac_data =
|
||||
pC->m_outputPlane[0].pac_data +
|
||||
(pC->m_outputPlane[0].u_stride * pC->m_outputPlane[0].u_height);
|
||||
|
||||
pC->m_outputPlane[2].pac_data =
|
||||
pC->m_outputPlane[1].pac_data +
|
||||
(pC->m_outputPlane[1].u_stride * pC->m_outputPlane[1].u_height);
|
||||
}
|
||||
|
||||
|
||||
M4OSA_TRACE2_0("videoBrowserSetWindow returned NO ERROR");
|
||||
return M4NO_ERROR;
|
||||
|
||||
videoBrowserSetWindow_cleanUp:
|
||||
|
||||
M4OSA_TRACE2_1("videoBrowserSetWindow returned 0x%x", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* @brief This function allocates the resources needed for browsing a video file
|
||||
* @param ppContext (OUT): Pointer on a context filled by this function.
|
||||
* @param pURL (IN) : Path of File to browse
|
||||
* @param DrawMode (IN) : Indicate which method is used to draw (Direct draw etc...)
|
||||
* @param pfCallback (IN) : Callback function to be called when a frame must be displayed
|
||||
* @param pCallbackData (IN) : User defined data that will be passed as parameter of the callback
|
||||
* @param clrType (IN) : Required color type.
|
||||
* @return M4NO_ERROR / M4ERR_PARAMETER / M4ERR_STATE / M4ERR_ALLOC
|
||||
******************************************************************************/
|
||||
M4OSA_ERR videoBrowserCreate(
|
||||
M4OSA_Context* ppContext,
|
||||
M4OSA_Char* pURL,
|
||||
M4OSA_UInt32 DrawMode,
|
||||
M4OSA_FileReadPointer* ptrF,
|
||||
videoBrowser_Callback pfCallback,
|
||||
M4OSA_Void* pCallbackData,
|
||||
VideoBrowser_VideoColorType clrType)
|
||||
{
|
||||
VideoBrowserContext* pContext = M4OSA_NULL;
|
||||
M4READER_MediaFamily mediaFamily = M4READER_kMediaFamilyUnknown;
|
||||
M4_StreamHandler* pStreamHandler = M4OSA_NULL;
|
||||
M4_VideoStreamHandler* pVideoStreamHandler = M4OSA_NULL;
|
||||
M4DECODER_VideoType decoderType;
|
||||
M4DECODER_OutputFilter FilterOption;
|
||||
|
||||
M4OSA_Bool deb = M4OSA_TRUE;
|
||||
M4OSA_ERR err = M4NO_ERROR;
|
||||
|
||||
M4OSA_TRACE1_2(
|
||||
"videoBrowserCreate: entering with 0x%x 0x%x", ppContext, pURL);
|
||||
|
||||
/*--- Sanity checks ---*/
|
||||
CHECK_PTR(videoBrowserCreate, ppContext, err, M4ERR_PARAMETER);
|
||||
*ppContext = M4OSA_NULL ;
|
||||
CHECK_PTR(videoBrowserCreate, pURL, err, M4ERR_PARAMETER);
|
||||
|
||||
/*--- Create context ---*/
|
||||
pContext = (VideoBrowserContext*)M4OSA_malloc(
|
||||
sizeof(VideoBrowserContext),
|
||||
VIDEOBROWSER, (M4OSA_Char*)"Video browser context");
|
||||
|
||||
CHECK_PTR(videoBrowserCreate, pContext,err, M4ERR_ALLOC);
|
||||
M4OSA_memset((M4OSA_MemAddr8)pContext, sizeof(VideoBrowserContext), 0);
|
||||
|
||||
/*--- Initialize the context parameters ---*/
|
||||
pContext->m_state = VideoBrowser_kVBCreating ;
|
||||
pContext->m_frameColorType = clrType;
|
||||
|
||||
/*--- Copy the file reader functions ---*/
|
||||
M4OSA_memcpy((M4OSA_MemAddr8)&pContext->m_fileReadPtr,
|
||||
(M4OSA_MemAddr8)ptrF,
|
||||
sizeof(M4OSA_FileReadPointer)) ;
|
||||
|
||||
/* PR#SP00013 DGR bug 13 : first frame is not visible */
|
||||
pContext->m_drawmode = DrawMode;
|
||||
|
||||
|
||||
/* Retrieve the 3gp reader interface */
|
||||
VideoEditor3gpReader_getInterface(&pContext->m_mediaType,
|
||||
&pContext->m_3gpReader, &pContext->m_3gpData);
|
||||
|
||||
CHECK_PTR(videoBrowserCreate, pContext->m_3gpReader, err, M4ERR_ALLOC);
|
||||
CHECK_PTR(videoBrowserCreate, pContext->m_3gpData, err, M4ERR_ALLOC);
|
||||
|
||||
/*--- Create the file reader ---*/
|
||||
err = pContext->m_3gpReader->m_pFctCreate(&pContext->m_pReaderCtx);
|
||||
CHECK_ERR(videoBrowserCreate, err);
|
||||
CHECK_PTR(videoBrowserCreate, pContext->m_pReaderCtx, err, M4ERR_ALLOC);
|
||||
pContext->m_3gpData->m_readerContext = pContext->m_pReaderCtx;
|
||||
|
||||
/*--- Set the OSAL file reader functions ---*/
|
||||
err = pContext->m_3gpReader->m_pFctSetOption(
|
||||
pContext->m_pReaderCtx,
|
||||
M4READER_kOptionID_SetOsaFileReaderFctsPtr,
|
||||
(M4OSA_DataOption)(&pContext->m_fileReadPtr));
|
||||
|
||||
CHECK_ERR(videoBrowserCreate, err) ;
|
||||
|
||||
/*--- Open the file ---*/
|
||||
err = pContext->m_3gpReader->m_pFctOpen(pContext->m_pReaderCtx, pURL);
|
||||
CHECK_ERR(videoBrowserCreate, err) ;
|
||||
|
||||
/*--- Try to find a video stream ---*/
|
||||
while (err == M4NO_ERROR)
|
||||
{
|
||||
err = pContext->m_3gpReader->m_pFctGetNextStream(
|
||||
pContext->m_pReaderCtx, &mediaFamily, &pStreamHandler);
|
||||
|
||||
/*in case we found a bifs stream or something else...*/
|
||||
if ((err == M4ERR_READER_UNKNOWN_STREAM_TYPE) ||
|
||||
(err == M4WAR_TOO_MUCH_STREAMS))
|
||||
{
|
||||
err = M4NO_ERROR;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (err != M4WAR_NO_MORE_STREAM)
|
||||
{
|
||||
if (M4READER_kMediaFamilyVideo != mediaFamily)
|
||||
{
|
||||
err = M4NO_ERROR;
|
||||
continue;
|
||||
}
|
||||
|
||||
pContext->m_pStreamHandler = pStreamHandler;
|
||||
|
||||
err = pContext->m_3gpReader->m_pFctReset(
|
||||
pContext->m_pReaderCtx, pContext->m_pStreamHandler);
|
||||
|
||||
CHECK_ERR(videoBrowserCreate, err);
|
||||
|
||||
err = pContext->m_3gpReader->m_pFctFillAuStruct(
|
||||
pContext->m_pReaderCtx,
|
||||
pContext->m_pStreamHandler,
|
||||
&pContext->m_accessUnit);
|
||||
|
||||
CHECK_ERR(videoBrowserCreate, err);
|
||||
|
||||
pVideoStreamHandler =
|
||||
(M4_VideoStreamHandler*)pContext->m_pStreamHandler;
|
||||
|
||||
switch (pContext->m_pStreamHandler->m_streamType)
|
||||
{
|
||||
case M4DA_StreamTypeVideoMpeg4:
|
||||
case M4DA_StreamTypeVideoH263:
|
||||
{
|
||||
pContext->m_pCodecLoaderContext = M4OSA_NULL;
|
||||
decoderType = M4DECODER_kVideoTypeMPEG4;
|
||||
|
||||
err = VideoEditorVideoDecoder_getInterface_MPEG4(
|
||||
&decoderType, &pContext->m_pDecoder);
|
||||
|
||||
CHECK_ERR(videoBrowserCreate, err) ;
|
||||
|
||||
err = pContext->m_pDecoder->m_pFctCreate(
|
||||
&pContext->m_pDecoderCtx,
|
||||
pContext->m_pStreamHandler,
|
||||
pContext->m_3gpData,
|
||||
&pContext->m_accessUnit,
|
||||
pContext->m_pCodecLoaderContext) ;
|
||||
|
||||
CHECK_ERR(videoBrowserCreate, err) ;
|
||||
}
|
||||
break;
|
||||
|
||||
case M4DA_StreamTypeVideoMpeg4Avc:
|
||||
{
|
||||
pContext->m_pCodecLoaderContext = M4OSA_NULL;
|
||||
|
||||
decoderType = M4DECODER_kVideoTypeAVC;
|
||||
err = VideoEditorVideoDecoder_getInterface_H264(
|
||||
&decoderType, &pContext->m_pDecoder);
|
||||
CHECK_ERR(videoBrowserCreate, err) ;
|
||||
|
||||
err = pContext->m_pDecoder->m_pFctCreate(
|
||||
&pContext->m_pDecoderCtx,
|
||||
pContext->m_pStreamHandler,
|
||||
pContext->m_3gpData,
|
||||
&pContext->m_accessUnit,
|
||||
pContext->m_pCodecLoaderContext) ;
|
||||
|
||||
CHECK_ERR(videoBrowserCreate, err) ;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
err = M4ERR_VB_MEDIATYPE_NOT_SUPPORTED;
|
||||
goto videoBrowserCreate_cleanUp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (err == M4WAR_NO_MORE_STREAM)
|
||||
{
|
||||
err = M4NO_ERROR ;
|
||||
}
|
||||
|
||||
if (M4OSA_NULL == pContext->m_pStreamHandler)
|
||||
{
|
||||
err = M4ERR_VB_NO_VIDEO ;
|
||||
goto videoBrowserCreate_cleanUp ;
|
||||
}
|
||||
|
||||
err = pContext->m_pDecoder->m_pFctSetOption(
|
||||
pContext->m_pDecoderCtx,
|
||||
M4DECODER_kOptionID_DeblockingFilter,
|
||||
(M4OSA_DataOption)&deb);
|
||||
|
||||
if (err == M4WAR_DEBLOCKING_FILTER_NOT_IMPLEMENTED)
|
||||
{
|
||||
err = M4NO_ERROR;
|
||||
}
|
||||
CHECK_ERR(videoBrowserCreate, err);
|
||||
|
||||
FilterOption.m_pFilterUserData = M4OSA_NULL;
|
||||
|
||||
|
||||
if (pContext->m_frameColorType == VideoBrowser_kGB565) {
|
||||
FilterOption.m_pFilterFunction =
|
||||
(M4OSA_Void*)M4VIFI_ResizeBilinearYUV420toBGR565;
|
||||
}
|
||||
else if (pContext->m_frameColorType == VideoBrowser_kYUV420) {
|
||||
FilterOption.m_pFilterFunction =
|
||||
(M4OSA_Void*)M4VIFI_ResizeBilinearYUV420toYUV420;
|
||||
}
|
||||
else {
|
||||
err = M4ERR_PARAMETER;
|
||||
goto videoBrowserCreate_cleanUp;
|
||||
}
|
||||
|
||||
err = pContext->m_pDecoder->m_pFctSetOption(
|
||||
pContext->m_pDecoderCtx,
|
||||
M4DECODER_kOptionID_OutputFilter,
|
||||
(M4OSA_DataOption)&FilterOption);
|
||||
|
||||
CHECK_ERR(videoBrowserCreate, err);
|
||||
|
||||
/* store the callback details */
|
||||
pContext->m_pfCallback = pfCallback;
|
||||
pContext->m_pCallbackUserData = pCallbackData;
|
||||
/* store the callback details */
|
||||
|
||||
pContext->m_state = VideoBrowser_kVBOpened;
|
||||
*ppContext = pContext;
|
||||
|
||||
M4OSA_TRACE1_0("videoBrowserCreate returned NO ERROR");
|
||||
return M4NO_ERROR;
|
||||
|
||||
videoBrowserCreate_cleanUp:
|
||||
|
||||
if (M4OSA_NULL != pContext)
|
||||
{
|
||||
if (M4OSA_NULL != pContext->m_pDecoderCtx)
|
||||
{
|
||||
pContext->m_pDecoder->m_pFctDestroy(pContext->m_pDecoderCtx);
|
||||
pContext->m_pDecoderCtx = M4OSA_NULL;
|
||||
}
|
||||
|
||||
if (M4OSA_NULL != pContext->m_pReaderCtx)
|
||||
{
|
||||
pContext->m_3gpReader->m_pFctClose(pContext->m_pReaderCtx);
|
||||
pContext->m_3gpReader->m_pFctDestroy(pContext->m_pReaderCtx);
|
||||
pContext->m_pReaderCtx = M4OSA_NULL;
|
||||
}
|
||||
SAFE_FREE(pContext->m_pDecoder);
|
||||
SAFE_FREE(pContext->m_3gpReader);
|
||||
SAFE_FREE(pContext->m_3gpData);
|
||||
SAFE_FREE(pContext);
|
||||
}
|
||||
|
||||
M4OSA_TRACE2_1("videoBrowserCreate returned 0x%x", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* M4OSA_ERR videoBrowserCleanUp(M4OSA_Context pContext);
|
||||
* @brief This function frees the resources needed for browsing a
|
||||
* video file.
|
||||
* @param pContext (IN) : Video browser context
|
||||
* @return M4NO_ERROR / M4ERR_PARAMETER / M4ERR_STATE
|
||||
******************************************************************************/
|
||||
M4OSA_ERR videoBrowserCleanUp(M4OSA_Context pContext)
|
||||
{
|
||||
VideoBrowserContext* pC = (VideoBrowserContext*)pContext;
|
||||
M4OSA_ERR err = M4NO_ERROR;
|
||||
|
||||
M4OSA_TRACE2_1("videoBrowserCleanUp: entering with 0x%x", pContext);
|
||||
|
||||
/*--- Sanity checks ---*/
|
||||
CHECK_PTR(videoBrowserCleanUp, pContext, err, M4ERR_PARAMETER);
|
||||
|
||||
if (M4OSA_NULL != pC->m_pDecoderCtx)
|
||||
{
|
||||
pC->m_pDecoder->m_pFctDestroy(pC->m_pDecoderCtx);
|
||||
pC->m_pDecoderCtx = M4OSA_NULL ;
|
||||
}
|
||||
|
||||
if (M4OSA_NULL != pC->m_pReaderCtx)
|
||||
{
|
||||
pC->m_3gpReader->m_pFctClose(pC->m_pReaderCtx) ;
|
||||
pC->m_3gpReader->m_pFctDestroy(pC->m_pReaderCtx);
|
||||
pC->m_pReaderCtx = M4OSA_NULL;
|
||||
}
|
||||
|
||||
SAFE_FREE(pC->m_pDecoder);
|
||||
SAFE_FREE(pC->m_3gpReader);
|
||||
SAFE_FREE(pC->m_3gpData);
|
||||
|
||||
if (pC->m_frameColorType != VideoBrowser_kYUV420) {
|
||||
SAFE_FREE(pC->m_outputPlane[0].pac_data);
|
||||
}
|
||||
SAFE_FREE(pC);
|
||||
|
||||
M4OSA_TRACE2_0("videoBrowserCleanUp returned NO ERROR");
|
||||
return M4NO_ERROR;
|
||||
|
||||
videoBrowserCleanUp_cleanUp:
|
||||
|
||||
M4OSA_TRACE2_1("videoBrowserCleanUp returned 0x%x", err);
|
||||
return err;
|
||||
}
|
||||
/******************************************************************************
|
||||
* M4OSA_ERR videoBrowserPrepareFrame(
|
||||
* M4OSA_Context pContext, M4OSA_UInt32* pTime);
|
||||
* @brief This function prepares the frame.
|
||||
* @param pContext (IN) : Video browser context
|
||||
* @param pTime (IN/OUT) : Pointer on the time to reach. Updated
|
||||
* by this function with the reached time
|
||||
* @return M4NO_ERROR / M4ERR_PARAMETER / M4ERR_STATE / M4ERR_ALLOC
|
||||
******************************************************************************/
|
||||
M4OSA_ERR videoBrowserPrepareFrame(M4OSA_Context pContext, M4OSA_UInt32* pTime)
|
||||
{
|
||||
VideoBrowserContext* pC = (VideoBrowserContext*)pContext;
|
||||
M4OSA_ERR err = M4NO_ERROR;
|
||||
M4OSA_UInt32 targetTime = 0;
|
||||
M4OSA_UInt32 jumpTime = 0;
|
||||
M4_MediaTime timeMS = 0;
|
||||
M4OSA_Int32 rapTime = 0;
|
||||
M4OSA_Bool isBackward = M4OSA_FALSE;
|
||||
M4OSA_Bool bJumpNeeded = M4OSA_FALSE;
|
||||
|
||||
|
||||
/*--- Sanity checks ---*/
|
||||
CHECK_PTR(videoBrowserPrepareFrame, pContext, err, M4ERR_PARAMETER);
|
||||
CHECK_PTR(videoBrowserPrepareFrame, pTime, err, M4ERR_PARAMETER);
|
||||
|
||||
targetTime = *pTime ;
|
||||
|
||||
/*--- Check the state, if this is the first call to this function
|
||||
we move to the state "browsing" ---*/
|
||||
if (VideoBrowser_kVBOpened == pC->m_state)
|
||||
{
|
||||
pC->m_state = VideoBrowser_kVBBrowsing;
|
||||
}
|
||||
else if (VideoBrowser_kVBBrowsing != pC->m_state)
|
||||
{
|
||||
err = M4ERR_STATE ;
|
||||
goto videoBrowserPrepareFrame_cleanUp;
|
||||
}
|
||||
|
||||
/*--- Check the duration ---*/
|
||||
/*--- If we jump backward, we need to jump ---*/
|
||||
if (targetTime < pC->m_currentCTS)
|
||||
{
|
||||
isBackward = M4OSA_TRUE;
|
||||
bJumpNeeded = M4OSA_TRUE;
|
||||
}
|
||||
/*--- If we jumpt to a time greater than "currentTime" + "predecodeTime"
|
||||
we need to jump ---*/
|
||||
else if (targetTime > (pC->m_currentCTS + VIDEO_BROWSER_PREDECODE_TIME))
|
||||
{
|
||||
bJumpNeeded = M4OSA_TRUE;
|
||||
}
|
||||
|
||||
if (M4OSA_TRUE == bJumpNeeded)
|
||||
{
|
||||
rapTime = targetTime;
|
||||
/*--- Retrieve the previous RAP time ---*/
|
||||
err = pC->m_3gpReader->m_pFctGetPrevRapTime(
|
||||
pC->m_pReaderCtx, pC->m_pStreamHandler, &rapTime);
|
||||
|
||||
CHECK_ERR(videoBrowserPrepareFrame, err);
|
||||
|
||||
jumpTime = rapTime;
|
||||
|
||||
err = pC->m_3gpReader->m_pFctJump(pC->m_pReaderCtx,
|
||||
pC->m_pStreamHandler,
|
||||
(M4OSA_Int32*)&jumpTime);
|
||||
CHECK_ERR(videoBrowserPrepareFrame, err);
|
||||
}
|
||||
|
||||
timeMS = (M4_MediaTime)targetTime;
|
||||
err = pC->m_pDecoder->m_pFctDecode(
|
||||
pC->m_pDecoderCtx, &timeMS, bJumpNeeded);
|
||||
|
||||
if ((err != M4NO_ERROR) && (err != M4WAR_NO_MORE_AU))
|
||||
{
|
||||
return err;
|
||||
}
|
||||
|
||||
// FIXME:
|
||||
// Not sure that I understand why we need a second jump logic here
|
||||
if ((timeMS >= pC->m_currentCTS) && (M4OSA_TRUE == isBackward))
|
||||
{
|
||||
jumpTime = rapTime;
|
||||
err = pC->m_3gpReader->m_pFctJump(
|
||||
pC->m_pReaderCtx, pC->m_pStreamHandler, (M4OSA_Int32*)&jumpTime);
|
||||
|
||||
CHECK_ERR(videoBrowserPrepareFrame, err);
|
||||
|
||||
timeMS = (M4_MediaTime)rapTime;
|
||||
err = pC->m_pDecoder->m_pFctDecode(
|
||||
pC->m_pDecoderCtx, &timeMS, M4OSA_TRUE);
|
||||
|
||||
if ((err != M4NO_ERROR) && (err != M4WAR_NO_MORE_AU))
|
||||
{
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
err = pC->m_pDecoder->m_pFctRender(
|
||||
pC->m_pDecoderCtx, &timeMS, pC->m_outputPlane, M4OSA_TRUE);
|
||||
|
||||
if (M4WAR_VIDEORENDERER_NO_NEW_FRAME == err)
|
||||
{
|
||||
err = M4NO_ERROR;
|
||||
}
|
||||
CHECK_ERR(videoBrowserPrepareFrame, err) ;
|
||||
|
||||
pC->m_currentCTS = (M4OSA_UInt32)timeMS;
|
||||
|
||||
*pTime = pC->m_currentCTS;
|
||||
|
||||
return M4NO_ERROR;
|
||||
|
||||
videoBrowserPrepareFrame_cleanUp:
|
||||
|
||||
if ((M4WAR_INVALID_TIME == err) || (M4WAR_NO_MORE_AU == err))
|
||||
{
|
||||
err = M4NO_ERROR;
|
||||
}
|
||||
else if (M4OSA_NULL != pC)
|
||||
{
|
||||
pC->m_currentCTS = 0;
|
||||
}
|
||||
|
||||
M4OSA_TRACE2_1("videoBrowserPrepareFrame returned 0x%x", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* M4OSA_ERR videoBrowserDisplayCurrentFrame(M4OSA_Context pContext);
|
||||
* @brief This function displays the current frame.
|
||||
* @param pContext (IN) : Video browser context
|
||||
* @return M4NO_ERROR / M4ERR_PARAMETER / M4ERR_STATE / M4ERR_ALLOC
|
||||
******************************************************************************/
|
||||
M4OSA_ERR videoBrowserDisplayCurrentFrame(M4OSA_Context pContext)
|
||||
{
|
||||
VideoBrowserContext* pC = (VideoBrowserContext*)pContext ;
|
||||
M4OSA_ERR err = M4NO_ERROR ;
|
||||
|
||||
/*--- Sanity checks ---*/
|
||||
CHECK_PTR(videoBrowserDisplayCurrentFrame, pContext, err, M4ERR_PARAMETER);
|
||||
|
||||
// Request display of the frame
|
||||
pC->m_pfCallback((M4OSA_Context) pC, // VB context
|
||||
VIDEOBROWSER_DISPLAY_FRAME, // action requested
|
||||
M4NO_ERROR, // error code
|
||||
(M4OSA_Void*) &(pC->m_outputPlane[0]), // image to be displayed
|
||||
(M4OSA_Void*) pC->m_pCallbackUserData); // user-provided data
|
||||
|
||||
#ifdef DUMPTOFILE
|
||||
{
|
||||
M4OSA_Context fileContext;
|
||||
M4OSA_Char* fileName = "/sdcard/textBuffer_RGB565.rgb";
|
||||
M4OSA_fileWriteOpen(&fileContext, (M4OSA_Void*) fileName,
|
||||
M4OSA_kFileWrite | M4OSA_kFileCreate);
|
||||
|
||||
M4OSA_fileWriteData(fileContext,
|
||||
(M4OSA_MemAddr8) pC->m_outputPlane[0].pac_data,
|
||||
pC->m_outputPlane[0].u_height*pC->m_outputPlane[0].u_width*2);
|
||||
|
||||
M4OSA_fileWriteClose(fileContext);
|
||||
}
|
||||
#endif
|
||||
|
||||
M4OSA_TRACE2_0("videoBrowserDisplayCurrentFrame returned NO ERROR") ;
|
||||
return M4NO_ERROR;
|
||||
|
||||
videoBrowserDisplayCurrentFrame_cleanUp:
|
||||
|
||||
M4OSA_TRACE2_1("videoBrowserDisplayCurrentFrame returned 0x%x", err) ;
|
||||
return err;
|
||||
}
|
||||
163
media/jni/mediaeditor/VideoBrowserMain.h
Executable file
163
media/jni/mediaeditor/VideoBrowserMain.h
Executable file
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* 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 VIDEO_BROWSER_MAIN_H
|
||||
#define VIDEO_BROWSER_MAIN_H
|
||||
|
||||
/**
|
||||
************************************************************************
|
||||
* @file VideoBrowserMain.h
|
||||
* @brief Video browser Interface functions
|
||||
************************************************************************
|
||||
*/
|
||||
|
||||
#define VIDEOBROWSER 0x423
|
||||
|
||||
#include "M4OSA_Memory.h"
|
||||
#include "M4OSA_CharStar.h"
|
||||
#include "M4OSA_OptionID.h"
|
||||
#include "M4OSA_Debug.h"
|
||||
#include "M4VIFI_FiltersAPI.h"
|
||||
#include "M4OSA_FileReader.h"
|
||||
|
||||
|
||||
/**
|
||||
************************************************************************
|
||||
* @brief Error codes definition.
|
||||
* @note These value are the Browser engine specific error codes.
|
||||
************************************************************************
|
||||
*/
|
||||
#define M4ERR_VB_MEDIATYPE_NOT_SUPPORTED M4OSA_ERR_CREATE(M4_ERR, VIDEOBROWSER, 0x01)
|
||||
#define M4ERR_VB_NO_VIDEO M4OSA_ERR_CREATE(M4_ERR, VIDEOBROWSER, 0x02)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Video Browser draw mode, extension for angle based bliting can be done
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
VideoBrowser_kVBNormalBliting
|
||||
} VideoBrowser_videoBrowerDrawMode;
|
||||
|
||||
|
||||
/*--- Video Browser output frame color type ---*/
|
||||
typedef enum
|
||||
{
|
||||
VideoBrowser_kYUV420,
|
||||
VideoBrowser_kGB565
|
||||
} VideoBrowser_VideoColorType;
|
||||
|
||||
/**
|
||||
************************************************************************
|
||||
* enumeration VideoBrowser_Notification
|
||||
* @brief Video Browser notification type.
|
||||
* @note This callback mechanism must be used to wait the completion of an asynchronous
|
||||
* operation, before calling another API function.
|
||||
************************************************************************
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/**
|
||||
* A frame is ready to be displayed, it should be displayed in the callback function
|
||||
* pCbData type = M4VIFI_ImagePlane*
|
||||
*/
|
||||
VIDEOBROWSER_DISPLAY_FRAME = 0x00000001,
|
||||
VIDEOBROWSER_NOTIFICATION_NONE = 0xffffffff
|
||||
}VideoBrowser_Notification;
|
||||
|
||||
|
||||
/**
|
||||
************************************************************************
|
||||
* @brief videoBrowser_Callback type definition
|
||||
* @param pInstance (IN) Video Browser context.
|
||||
* @param notificationID (IN) Id of the callback which generated the error
|
||||
* @param errCode (IN) Error code from the core
|
||||
* @param pCbData (IN) pointer to data associated wit the callback.
|
||||
* @param pCbUserData (IN) pointer to application user data passed in init.
|
||||
* @note This callback mechanism is used to request display of an image
|
||||
************************************************************************
|
||||
*/
|
||||
typedef M4OSA_Void (*videoBrowser_Callback) (M4OSA_Context pInstance,
|
||||
VideoBrowser_Notification notificationID,
|
||||
M4OSA_ERR errCode,
|
||||
M4OSA_Void* pCbData,
|
||||
M4OSA_Void* pCallbackUserData);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* @brief This function allocates the resources needed for browsing a video file.
|
||||
* @param ppContext (OUT): Pointer on a context filled by this function.
|
||||
* @param pURL (IN) : Path of File to browse
|
||||
* @param DrawMode (IN) : Indicate which method is used to draw (Direct draw etc...)
|
||||
* @param pfCallback (IN) : Callback function to be called when a frame must be displayed
|
||||
* @param pCallbackData (IN) : User defined data that will be passed as parameter of the callback
|
||||
* @param clrType (IN) : Required color type.
|
||||
* @return M4NO_ERROR / M4ERR_PARAMETER / M4ERR_STATE / M4ERR_ALLOC
|
||||
******************************************************************************/
|
||||
M4OSA_ERR videoBrowserCreate(M4OSA_Context* ppContext, M4OSA_Char* pURL,
|
||||
M4OSA_UInt32 DrawMode,
|
||||
M4OSA_FileReadPointer* ptrF,
|
||||
videoBrowser_Callback pfCallback,
|
||||
M4OSA_Void* pCallbackData,
|
||||
VideoBrowser_VideoColorType clrType);
|
||||
|
||||
/******************************************************************************
|
||||
* @brief This function frees the resources needed for browsing a video file.
|
||||
* @param pContext (IN) : Video browser context
|
||||
* @return M4NO_ERROR / M4ERR_PARAMETER / M4ERR_STATE
|
||||
******************************************************************************/
|
||||
M4OSA_ERR videoBrowserCleanUp(M4OSA_Context pContext) ;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* @brief This function allocates the resources needed for browsing a video file.
|
||||
* @param pContext (IN) : Video browser context
|
||||
* @param pTime (IN/OUT) : Pointer on the time to reach. Updated by
|
||||
* this function with the reached time
|
||||
* @return M4NO_ERROR / M4ERR_PARAMETER / M4ERR_STATE / M4ERR_ALLOC
|
||||
******************************************************************************/
|
||||
M4OSA_ERR videoBrowserPrepareFrame(M4OSA_Context pContext, M4OSA_UInt32* pTime);
|
||||
|
||||
/******************************************************************************
|
||||
* @brief This function sets the size and the position of the display.
|
||||
* @param pContext (IN) : Video Browser context
|
||||
* @param pixelArray (IN) : Array to hold the video frame.
|
||||
* @param x (IN) : Horizontal position of the top left corner
|
||||
* @param y (IN) : Vertical position of the top left corner
|
||||
* @param dx (IN) : Width of the display window
|
||||
* @param dy (IN) : Height of the video window
|
||||
* @return M4NO_ERROR / M4ERR_PARAMETER / M4ERR_STATE / M4ERR_ALLOC
|
||||
******************************************************************************/
|
||||
M4OSA_ERR videoBrowserSetWindow(M4OSA_Context pContext, M4OSA_Int32* pixelArray,
|
||||
M4OSA_UInt32 x, M4OSA_UInt32 y,
|
||||
M4OSA_UInt32 dx, M4OSA_UInt32 dy);
|
||||
|
||||
/******************************************************************************
|
||||
* @brief This function displays the current frame.
|
||||
* @param pContext (IN) : Video browser context
|
||||
* @return M4NO_ERROR / M4ERR_PARAMETER / M4ERR_STATE / M4ERR_ALLOC
|
||||
******************************************************************************/
|
||||
M4OSA_ERR videoBrowserDisplayCurrentFrame(M4OSA_Context pContext);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* VIDEO_BROWSER_MAIN_H */
|
||||
3174
media/jni/mediaeditor/VideoEditorClasses.cpp
Executable file
3174
media/jni/mediaeditor/VideoEditorClasses.cpp
Executable file
File diff suppressed because it is too large
Load Diff
589
media/jni/mediaeditor/VideoEditorClasses.h
Executable file
589
media/jni/mediaeditor/VideoEditorClasses.h
Executable file
@@ -0,0 +1,589 @@
|
||||
/*
|
||||
* 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 VIDEO_EDITOR_CLASSES_H
|
||||
#define VIDEO_EDITOR_CLASSES_H
|
||||
|
||||
#include <VideoEditorJava.h>
|
||||
#include <VideoEditorClasses.h>
|
||||
/**
|
||||
************************************************************************
|
||||
* @file VideoEditorClasses.h
|
||||
* @brief Interface for JNI methods/defines that have specific
|
||||
* access to class, objects and method Ids defined in Java layer
|
||||
************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
extern "C" {
|
||||
#include <M4xVSS_API.h>
|
||||
#include <M4VSS3GPP_API.h>
|
||||
#include <M4VSS3GPP_ErrorCodes.h>
|
||||
#include <M4MCS_ErrorCodes.h>
|
||||
#include <M4READER_Common.h>
|
||||
#include <M4WRITER_common.h>
|
||||
};
|
||||
|
||||
/*
|
||||
* Java layer class/object name strings
|
||||
*/
|
||||
#define PACKAGE_NAME "android/media/videoeditor"
|
||||
|
||||
#define MANUAL_EDIT_ENGINE_CLASS_NAME PACKAGE_NAME"/MediaArtistNativeHelper"
|
||||
#define MEDIA_PROPERTIES_ENGINE_CLASS_NAME PACKAGE_NAME"/MediaArtistNativeHelper"
|
||||
|
||||
#define AUDIO_FORMAT_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$AudioFormat"
|
||||
#define RESULTS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$Results"
|
||||
#define VERSION_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$Version"
|
||||
#define AUDIO_SAMPLING_FREQUENCY_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$AudioSamplingFrequency"
|
||||
#define BITRATE_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$Bitrate"
|
||||
#define ERROR_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$Result"
|
||||
#define FILE_TYPE_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$FileType"
|
||||
#define MEDIA_RENDERING_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$MediaRendering"
|
||||
#define VIDEO_FORMAT_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$VideoFormat"
|
||||
#define VIDEO_FRAME_RATE_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$VideoFrameRate"
|
||||
#define VIDEO_FRAME_SIZE_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$VideoFrameSize"
|
||||
#define VIDEO_PROFILE_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$VideoProfile"
|
||||
#define ALPHA_MAGIC_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$AlphaMagicSettings"
|
||||
#define AUDIO_EFFECT_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$AudioEffect"
|
||||
#define AUDIO_TRANSITION_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$AudioTransition"
|
||||
#define BACKGROUND_MUSIC_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$BackgroundMusicSettings"
|
||||
#define CLIP_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$ClipSettings"
|
||||
#define EDIT_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$EditSettings"
|
||||
#define EFFECT_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$EffectSettings"
|
||||
#define SLIDE_DIRECTION_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$SlideDirection"
|
||||
#define SLIDE_TRANSITION_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$SlideTransitionSettings"
|
||||
#define TRANSITION_BEHAVIOUR_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$TransitionBehaviour"
|
||||
#define TRANSITION_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$TransitionSettings"
|
||||
#define VIDEO_EFFECT_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$VideoEffect"
|
||||
#define VIDEO_TRANSITION_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$VideoTransition"
|
||||
#define PREVIEW_CLIPS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$PreviewClips"
|
||||
#define PREVIEW_SETTING_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$PreviewSettings"
|
||||
#define PREVIEW_PROPERTIES_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$PreviewClipProperties"
|
||||
#define AUDIO_SETTINGS_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$AudioSettings"
|
||||
#define PROPERTIES_CLASS_NAME MANUAL_EDIT_ENGINE_CLASS_NAME"$Properties"
|
||||
|
||||
#define TASK_IDLE 0
|
||||
#define TASK_LOADING_SETTINGS 1
|
||||
#define TASK_ENCODING 2
|
||||
|
||||
/*
|
||||
* File type enum
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
VideoEditClasses_kFileType_3GPP,
|
||||
VideoEditClasses_kFileType_MP4,
|
||||
VideoEditClasses_kFileType_AMR,
|
||||
VideoEditClasses_kFileType_MP3,
|
||||
VideoEditClasses_kFileType_PCM,
|
||||
VideoEditClasses_kFileType_JPG,
|
||||
VideoEditClasses_kFileType_GIF,
|
||||
VideoEditClasses_kFileType_PNG,
|
||||
VideoEditClasses_kFileType_Unsupported
|
||||
} VideoEditClasses_FileType;
|
||||
|
||||
/*
|
||||
* Alpha magic transition structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
jfieldID file;
|
||||
jfieldID blendingPercent;
|
||||
jfieldID invertRotation;
|
||||
jfieldID rgbWidth;
|
||||
jfieldID rgbHeight;
|
||||
} VideoEditJava_AlphaMagicFieldIds;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
jfieldID file;
|
||||
jfieldID fileType;
|
||||
jfieldID insertionTime;
|
||||
jfieldID volumePercent;
|
||||
jfieldID beginLoop;
|
||||
jfieldID endLoop;
|
||||
jfieldID enableDucking;
|
||||
jfieldID duckingThreshold;
|
||||
jfieldID lowVolume;
|
||||
jfieldID isLooping;
|
||||
} VideoEditJava_BackgroundMusicFieldIds;
|
||||
/*
|
||||
* Structure to hold media properties from native layer
|
||||
*/
|
||||
typedef struct {
|
||||
M4OSA_UInt32 uiClipDuration;
|
||||
VideoEditClasses_FileType FileType;
|
||||
M4VIDEOEDITING_VideoFormat VideoStreamType;
|
||||
M4OSA_UInt32 uiClipVideoDuration;
|
||||
M4OSA_UInt32 uiVideoBitrate;
|
||||
M4OSA_UInt32 uiVideoWidth;
|
||||
M4OSA_UInt32 uiVideoHeight;
|
||||
M4OSA_Float fAverageFrameRate;
|
||||
M4VIDEOEDITING_VideoProfileAndLevel ProfileAndLevel;
|
||||
M4VIDEOEDITING_AudioFormat AudioStreamType;
|
||||
M4OSA_UInt32 uiClipAudioDuration;
|
||||
M4OSA_UInt32 uiAudioBitrate;
|
||||
M4OSA_UInt32 uiNbChannels;
|
||||
M4OSA_UInt32 uiSamplingFrequency;
|
||||
} VideoEditPropClass_Properties;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
jfieldID duration;
|
||||
jfieldID fileType;
|
||||
jfieldID videoFormat;
|
||||
jfieldID videoDuration;
|
||||
jfieldID videoBitrate;
|
||||
jfieldID width;
|
||||
jfieldID height;
|
||||
jfieldID averageFrameRate;
|
||||
jfieldID profileAndLevel;
|
||||
jfieldID audioFormat;
|
||||
jfieldID audioDuration;
|
||||
jfieldID audioBitrate;
|
||||
jfieldID audioChannels;
|
||||
jfieldID audioSamplingFrequency;
|
||||
} VideoEditJava_PropertiesFieldIds;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
jfieldID clipPath;
|
||||
jfieldID fileType;
|
||||
jfieldID beginCutTime;
|
||||
jfieldID endCutTime;
|
||||
jfieldID beginCutPercent;
|
||||
jfieldID endCutPercent;
|
||||
jfieldID panZoomEnabled;
|
||||
jfieldID panZoomPercentStart;
|
||||
jfieldID panZoomTopLeftXStart;
|
||||
jfieldID panZoomTopLeftYStart;
|
||||
jfieldID panZoomPercentEnd;
|
||||
jfieldID panZoomTopLeftXEnd;
|
||||
jfieldID panZoomTopLeftYEnd;
|
||||
jfieldID mediaRendering;
|
||||
jfieldID rgbFileWidth;
|
||||
jfieldID rgbFileHeight;
|
||||
} VideoEditJava_ClipSettingsFieldIds;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
jfieldID clipSettingsArray;
|
||||
jfieldID transitionSettingsArray;
|
||||
jfieldID effectSettingsArray;
|
||||
jfieldID videoFrameRate;
|
||||
jfieldID outputFile;
|
||||
jfieldID videoFrameSize;
|
||||
jfieldID videoFormat;
|
||||
jfieldID audioFormat;
|
||||
jfieldID audioSamplingFreq;
|
||||
jfieldID maxFileSize;
|
||||
jfieldID audioChannels;
|
||||
jfieldID videoBitrate;
|
||||
jfieldID audioBitrate;
|
||||
jfieldID backgroundMusicSettings;
|
||||
jfieldID primaryTrackVolume;
|
||||
} VideoEditJava_EditSettingsFieldIds;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
jfieldID startTime;
|
||||
jfieldID duration;
|
||||
jfieldID videoEffectType;
|
||||
jfieldID audioEffectType;
|
||||
jfieldID startPercent;
|
||||
jfieldID durationPercent;
|
||||
jfieldID framingFile;
|
||||
jfieldID framingBuffer;
|
||||
jfieldID bitmapType;
|
||||
jfieldID width;
|
||||
jfieldID height;
|
||||
jfieldID topLeftX;
|
||||
jfieldID topLeftY;
|
||||
jfieldID framingResize;
|
||||
jfieldID framingScaledSize;
|
||||
jfieldID text;
|
||||
jfieldID textRenderingData;
|
||||
jfieldID textBufferWidth;
|
||||
jfieldID textBufferHeight;
|
||||
jfieldID fiftiesFrameRate;
|
||||
jfieldID rgb16InputColor;
|
||||
jfieldID alphaBlendingStartPercent;
|
||||
jfieldID alphaBlendingMiddlePercent;
|
||||
jfieldID alphaBlendingEndPercent;
|
||||
jfieldID alphaBlendingFadeInTimePercent;
|
||||
jfieldID alphaBlendingFadeOutTimePercent;
|
||||
} VideoEditJava_EffectSettingsFieldIds;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
jfieldID context;
|
||||
} VideoEditJava_EngineFieldIds;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
jfieldID direction;
|
||||
} VideoEditJava_SlideTransitionSettingsFieldIds;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
jfieldID duration;
|
||||
jfieldID videoTransitionType;
|
||||
jfieldID audioTransitionType;
|
||||
jfieldID transitionBehaviour;
|
||||
jfieldID alphaSettings;
|
||||
jfieldID slideSettings;
|
||||
} VideoEditJava_TransitionSettingsFieldIds;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
jfieldID major;
|
||||
jfieldID minor;
|
||||
jfieldID revision;
|
||||
} VideoEditJava_VersionFieldIds;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
jmethodID onProgressUpdate;
|
||||
} VideoEditJava_EngineMethodIds;
|
||||
|
||||
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(AudioEffect )
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(AudioFormat )
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(AudioSamplingFrequency)
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(AudioTransition )
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(Bitrate )
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(Engine )
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(Error )
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(FileType )
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(MediaRendering )
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(SlideDirection )
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(TransitionBehaviour )
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(VideoEffect )
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(VideoFormat )
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(VideoFrameRate )
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(VideoFrameSize )
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(VideoProfile )
|
||||
VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(VideoTransition )
|
||||
|
||||
|
||||
VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(AlphaMagic )
|
||||
VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(BackgroundMusic )
|
||||
VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(ClipSettings )
|
||||
VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(ClipSettings )
|
||||
VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(EditSettings )
|
||||
VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(EffectSettings )
|
||||
VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(Engine )
|
||||
VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(SlideTransitionSettings )
|
||||
VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(TransitionSettings )
|
||||
VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(Version )
|
||||
|
||||
VIDEOEDIT_JAVA_DECLARE_METHOD_CLASS(Engine )
|
||||
|
||||
/*
|
||||
* Init all Edit settings related structures
|
||||
*/
|
||||
void
|
||||
videoEditClasses_init(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv);
|
||||
/**
|
||||
************************************************************************
|
||||
* @brief Media Properties init function.
|
||||
* @param pResult (OUT) Pointer to hold result
|
||||
* @param pEnv (IN) JVM Interface pointer
|
||||
************************************************************************
|
||||
*/
|
||||
void
|
||||
videoEditPropClass_init(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv);
|
||||
/**
|
||||
************************************************************************
|
||||
* @brief Interface to populate Media Properties.
|
||||
* @param pResult (IN/OUT) Pointer to hold result
|
||||
* @param pEnv (IN) JVM Interface pointer
|
||||
* @param pProperties (IN) Media propeties structure pointer
|
||||
* @param pObject (OUT) Java object to hold media
|
||||
* properties for java layer.
|
||||
************************************************************************
|
||||
*/
|
||||
void
|
||||
videoEditPropClass_createProperties(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
VideoEditPropClass_Properties* pProperties,
|
||||
jobject* pObject);
|
||||
|
||||
/**
|
||||
************************************************************************
|
||||
* @brief Interface to log/display media properties.
|
||||
* @param pProperties (IN) Pointer holding media properties
|
||||
* @param indentation (IN) Indentation to follow in display
|
||||
************************************************************************
|
||||
*/
|
||||
void
|
||||
videoEditPropClass_logProperties(
|
||||
VideoEditPropClass_Properties* pProperties,
|
||||
int indentation);
|
||||
|
||||
/*
|
||||
* Get alpha magic transition settings
|
||||
*/
|
||||
void
|
||||
videoEditClasses_getAlphaMagicSettings(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jobject object,
|
||||
M4xVSS_AlphaMagicSettings** ppSettings);
|
||||
|
||||
/*
|
||||
* Free alpha magic transition settings structure
|
||||
*/
|
||||
void
|
||||
videoEditClasses_freeAlphaMagicSettings(
|
||||
M4xVSS_AlphaMagicSettings** ppSettings);
|
||||
|
||||
/*
|
||||
* Log alpha magic transition settings
|
||||
*/
|
||||
void
|
||||
videoEditClasses_logAlphaMagicSettings(
|
||||
M4xVSS_AlphaMagicSettings* pSettings,
|
||||
int indentation);
|
||||
|
||||
/*
|
||||
* Get Background Track settings
|
||||
*/
|
||||
void
|
||||
videoEditClasses_getBackgroundMusicSettings(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jobject object,
|
||||
M4xVSS_BGMSettings** ppSettings);
|
||||
|
||||
/*
|
||||
* Free Background Track settings structure
|
||||
*/
|
||||
void
|
||||
videoEditClasses_freeBackgroundMusicSettings(
|
||||
M4xVSS_BGMSettings** ppSettings);
|
||||
|
||||
/*
|
||||
* Log Background Track settings
|
||||
*/
|
||||
void
|
||||
videoEditClasses_logBackgroundMusicSettings(
|
||||
M4xVSS_BGMSettings* pSettings,
|
||||
int indentation);
|
||||
|
||||
/*
|
||||
* Log clip properties
|
||||
*/
|
||||
void
|
||||
videoEditClasses_logClipProperties(
|
||||
M4VIDEOEDITING_ClipProperties* pProperties,
|
||||
int indentation);
|
||||
|
||||
/*
|
||||
* Get clip settings from Java
|
||||
*/
|
||||
void
|
||||
videoEditClasses_getClipSettings(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jobject object,
|
||||
M4VSS3GPP_ClipSettings** ppSettings);
|
||||
/**
|
||||
************************************************************************
|
||||
* @brief Interface function to retrieve media properties for a given
|
||||
* file.
|
||||
* @param pEnv (IN) Pointer holding media properties
|
||||
* @param thiz (IN) Indentation to follow in display
|
||||
* @param file (IN) File path for which media properties has
|
||||
* to be retrieved.
|
||||
************************************************************************
|
||||
*/
|
||||
jobject
|
||||
videoEditProp_getProperties(
|
||||
JNIEnv* pEnv,
|
||||
jobject thiz,
|
||||
jstring file);
|
||||
|
||||
/*
|
||||
* Create/Set the clip settings to java Object
|
||||
*/
|
||||
void
|
||||
videoEditClasses_createClipSettings(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
M4VSS3GPP_ClipSettings* pSettings,
|
||||
jobject* pObject);
|
||||
|
||||
/*
|
||||
* Free clip settings structure
|
||||
*/
|
||||
void
|
||||
videoEditClasses_freeClipSettings(
|
||||
M4VSS3GPP_ClipSettings** ppSettings);
|
||||
|
||||
/*
|
||||
* Log clip settings structure
|
||||
*/
|
||||
void
|
||||
videoEditClasses_logClipSettings(
|
||||
M4VSS3GPP_ClipSettings* pSettings,
|
||||
int indentation);
|
||||
|
||||
/*
|
||||
* Get Edit settings from Java
|
||||
*/
|
||||
void
|
||||
videoEditClasses_getEditSettings(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jobject object,
|
||||
M4VSS3GPP_EditSettings** ppSettings,
|
||||
bool flag);
|
||||
|
||||
/*
|
||||
* Free Edit Settings structure
|
||||
*/
|
||||
void
|
||||
videoEditClasses_freeEditSettings(
|
||||
M4VSS3GPP_EditSettings** ppSettings);
|
||||
|
||||
/*
|
||||
* Log Edit settings structure
|
||||
*/
|
||||
void
|
||||
videoEditClasses_logEditSettings(
|
||||
M4VSS3GPP_EditSettings* pSettings,
|
||||
int indentation);
|
||||
|
||||
/*
|
||||
* Get Effect settings from Java
|
||||
*/
|
||||
void
|
||||
videoEditClasses_getEffectSettings(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jobject object,
|
||||
M4VSS3GPP_EffectSettings* pSettings);
|
||||
|
||||
/*
|
||||
* Free Effect settings structure
|
||||
*/
|
||||
void
|
||||
videoEditClasses_freeEffectSettings(
|
||||
M4VSS3GPP_EffectSettings* pSettings);
|
||||
|
||||
/*
|
||||
* Log Effect settings
|
||||
*/
|
||||
void
|
||||
videoEditClasses_logEffectSettings(
|
||||
M4VSS3GPP_EffectSettings* pSettings,
|
||||
int indentation);
|
||||
|
||||
/*
|
||||
* Get Transition-Sliding settings from Java
|
||||
*/
|
||||
void
|
||||
videoEditClasses_getSlideTransitionSettings(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jobject object,
|
||||
M4xVSS_SlideTransitionSettings** ppSettings);
|
||||
|
||||
/*
|
||||
* Free Transition-Sliding structure
|
||||
*/
|
||||
void
|
||||
videoEditClasses_freeSlideTransitionSettings(
|
||||
M4xVSS_SlideTransitionSettings** ppSettings);
|
||||
|
||||
/*
|
||||
* Free Transition-Sliding structure
|
||||
*/
|
||||
void
|
||||
videoEditClasses_logSlideTransitionSettings(
|
||||
M4xVSS_SlideTransitionSettings* pSettings,
|
||||
int indentation);
|
||||
|
||||
/*
|
||||
* Get Transition settings from Java
|
||||
*/
|
||||
void
|
||||
videoEditClasses_getTransitionSettings(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jobject object,
|
||||
M4VSS3GPP_TransitionSettings** ppSettings);
|
||||
|
||||
/*
|
||||
* Free Transition settings structure
|
||||
*/
|
||||
void
|
||||
videoEditClasses_freeTransitionSettings(
|
||||
M4VSS3GPP_TransitionSettings** ppSettings);
|
||||
|
||||
/*
|
||||
* Log Transition settings
|
||||
*/
|
||||
void
|
||||
videoEditClasses_logTransitionSettings(
|
||||
M4VSS3GPP_TransitionSettings* pSettings,
|
||||
int indentation);
|
||||
|
||||
/*
|
||||
* Set version information to Java object
|
||||
*/
|
||||
void
|
||||
videoEditClasses_createVersion(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
M4_VersionInfo* pVersionInfo,
|
||||
jobject* pObject);
|
||||
|
||||
/*
|
||||
* Log Version information
|
||||
*/
|
||||
void
|
||||
videoEditClasses_logVersion(
|
||||
M4_VersionInfo* pVersionInfo,
|
||||
int indentation);
|
||||
|
||||
|
||||
void*
|
||||
videoEditClasses_getContext(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jobject object);
|
||||
|
||||
void
|
||||
videoEditClasses_setContext(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jobject object,
|
||||
void* pContext);
|
||||
|
||||
|
||||
#endif // VIDEO_EDITOR_CLASSES_H
|
||||
|
||||
885
media/jni/mediaeditor/VideoEditorJava.cpp
Executable file
885
media/jni/mediaeditor/VideoEditorJava.cpp
Executable file
@@ -0,0 +1,885 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <VideoEditorClasses.h>
|
||||
#include <VideoEditorJava.h>
|
||||
#include <VideoEditorLogging.h>
|
||||
#include <VideoEditorOsal.h>
|
||||
|
||||
extern "C" {
|
||||
#include <M4OSA_CharStar.h>
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
videoEditJava_checkAndThrowIllegalArgumentException(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
bool condition,
|
||||
const char* pMessage)
|
||||
{
|
||||
// Check if the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Check if the condition is true.
|
||||
if (condition)
|
||||
{
|
||||
// Log the exception.
|
||||
VIDEOEDIT_LOG_EXCEPTION(ANDROID_LOG_ERROR, "VIDEO_EDITOR_JAVA",\
|
||||
"videoEditJava_checkAndThrowIllegalArgumentException, %s", pMessage);
|
||||
|
||||
// Reset the result flag.
|
||||
(*pResult) = false;
|
||||
|
||||
// Throw an exception.
|
||||
jniThrowException(pEnv, "java/lang/IllegalArgumentException", pMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
videoEditJava_checkAndThrowRuntimeException(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
bool condition,
|
||||
M4OSA_ERR result)
|
||||
{
|
||||
const char* pMessage = NULL;
|
||||
|
||||
// Check if the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Check if the condition is true.
|
||||
if (condition)
|
||||
{
|
||||
// Get the error string.
|
||||
pMessage = videoEditJava_getErrorName(result);
|
||||
|
||||
// Log the exception.
|
||||
VIDEOEDIT_LOG_EXCEPTION(ANDROID_LOG_ERROR, "VIDEO_EDITOR_JAVA",
|
||||
"videoEditJava_checkAndThrowRuntimeException, %s", pMessage);
|
||||
|
||||
// Reset the result flag.
|
||||
(*pResult) = false;
|
||||
|
||||
// Throw an exception.
|
||||
jniThrowException(pEnv, "java/lang/RuntimeException", pMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
videoEditJava_checkAndThrowIllegalStateException(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
bool condition,
|
||||
const char* pMessage)
|
||||
{
|
||||
// Check if the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Check if the condition is true.
|
||||
if (condition)
|
||||
{
|
||||
// Log the exception.
|
||||
VIDEOEDIT_LOG_EXCEPTION(ANDROID_LOG_ERROR, "VIDEO_EDITOR_JAVA",
|
||||
"videoEditJava_checkAndThrowIllegalStateException, %s", pMessage);
|
||||
|
||||
// Reset the result flag.
|
||||
(*pResult) = false;
|
||||
|
||||
// Throw an exception.
|
||||
jniThrowException(pEnv, "java/lang/IllegalStateException", pMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
videoEditJava_getClass(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
const char* pName,
|
||||
jclass* pClazz)
|
||||
{
|
||||
// Only look for the class if locating the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Log the function call.
|
||||
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA",
|
||||
"videoEditJava_getClass(%s)", pName);
|
||||
|
||||
// Look up the class.
|
||||
jclass clazz = pEnv->FindClass(pName);
|
||||
|
||||
// Clear any resulting exceptions.
|
||||
pEnv->ExceptionClear();
|
||||
|
||||
// Check if the class could be located.
|
||||
if (NULL != clazz)
|
||||
{
|
||||
// Return the class.
|
||||
(*pClazz) = clazz;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reset the result flag.
|
||||
(*pResult) = false;
|
||||
|
||||
// Log the error.
|
||||
VIDEOEDIT_LOG_EXCEPTION(ANDROID_LOG_ERROR, "VIDEO_EDITOR_JAVA",
|
||||
"videoEditJava_getClass, error: unable to locate class %s", pName);
|
||||
|
||||
// Throw an exception.
|
||||
jniThrowException(pEnv, "java/lang/ClassNotFoundException",
|
||||
"unable to locate class");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
videoEditJava_getMethodId(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jclass clazz,
|
||||
const char* pName,
|
||||
const char* pType,
|
||||
jmethodID* pMethodId)
|
||||
{
|
||||
// Only look for the class if locating the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Log the function call.
|
||||
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA",
|
||||
"videoEditJava_getMethodId(%s,%s)", pName, pType);
|
||||
|
||||
// Look up the method id.
|
||||
jmethodID methodId = pEnv->GetMethodID(clazz, pName, pType);
|
||||
|
||||
// Clear any resulting exceptions.
|
||||
pEnv->ExceptionClear();
|
||||
|
||||
// Check if the method could be located.
|
||||
if (NULL != methodId)
|
||||
{
|
||||
// Return the method id.
|
||||
(*pMethodId) = methodId;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reset the result flag.
|
||||
(*pResult) = false;
|
||||
|
||||
// Log the error.
|
||||
VIDEOEDIT_LOG_EXCEPTION(ANDROID_LOG_ERROR, "VIDEO_EDITOR_JAVA",
|
||||
"videoEditJava_getMethodId, error: unable to locate method %s with type %s",
|
||||
pName, pType);
|
||||
|
||||
// Throw an exception.
|
||||
jniThrowException(pEnv, "java/lang/NoSuchMethodException", "unable to locate method");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
videoEditJava_getFieldId(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jclass clazz,
|
||||
const char* pName,
|
||||
const char* pType,
|
||||
jfieldID* pFieldId)
|
||||
{
|
||||
// Only look for the class if locating the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Log the function call.
|
||||
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA",
|
||||
"videoEditJava_getFieldId(%s,%s)", pName, pType);
|
||||
|
||||
// Look up the field id.
|
||||
jfieldID fieldId = pEnv->GetFieldID(clazz, pName, pType);
|
||||
|
||||
// Clear any resulting exceptions.
|
||||
pEnv->ExceptionClear();
|
||||
|
||||
// Check if the field could be located.
|
||||
if (NULL != fieldId)
|
||||
{
|
||||
// Return the field id.
|
||||
(*pFieldId) = fieldId;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reset the result flag.
|
||||
(*pResult) = false;
|
||||
|
||||
// Log the error.
|
||||
VIDEOEDIT_LOG_EXCEPTION(ANDROID_LOG_ERROR, "VIDEO_EDITOR_JAVA",
|
||||
"videoEditJava_getFieldId, error: unable to locate field %s with type %s",
|
||||
pName, pType);
|
||||
|
||||
// Throw an exception.
|
||||
jniThrowException(pEnv, "java/lang/NoSuchFieldException", "unable to locate field");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
videoEditJava_getObject(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jobject object,
|
||||
jfieldID objectFieldId,
|
||||
jobject* pObject)
|
||||
{
|
||||
// Only retrieve the array object and size if the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Log the function call.
|
||||
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA",
|
||||
"videoEditJava_getObject()");
|
||||
|
||||
// Retrieve the object.
|
||||
(*pObject) = pEnv->GetObjectField(object, objectFieldId);
|
||||
|
||||
// Clear any resulting exceptions.
|
||||
pEnv->ExceptionClear();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
videoEditJava_getArray(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jobject object,
|
||||
jfieldID arrayFieldId,
|
||||
jobjectArray* pArray,
|
||||
jsize* pArraySize)
|
||||
{
|
||||
// Only retrieve the array object and size if the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Log the function call.
|
||||
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA", "videoEditJava_getArray()");
|
||||
|
||||
// Retrieve the array object.
|
||||
jobjectArray array = (jobjectArray)pEnv->GetObjectField(object, arrayFieldId);
|
||||
jsize arraySize = 0;
|
||||
|
||||
// Clear any resulting exceptions.
|
||||
pEnv->ExceptionClear();
|
||||
|
||||
// Check if the array could be retrieved.
|
||||
if (NULL != array)
|
||||
{
|
||||
// Retrieve the array size.
|
||||
arraySize = pEnv->GetArrayLength(array);
|
||||
}
|
||||
|
||||
// Return the array and its size.
|
||||
(*pArray) = array;
|
||||
(*pArraySize) = arraySize;
|
||||
}
|
||||
}
|
||||
|
||||
void*
|
||||
videoEditJava_getString(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jobject object,
|
||||
jfieldID stringFieldId,
|
||||
M4OSA_UInt32* pLength)
|
||||
{
|
||||
void* pString = M4OSA_NULL;
|
||||
jstring string = NULL;
|
||||
M4OSA_UInt32 length = 0;
|
||||
M4OSA_Char* pLocal = M4OSA_NULL;
|
||||
M4OSA_ERR result = M4NO_ERROR;
|
||||
|
||||
// Check if the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Log the function call.
|
||||
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA", "videoEditJava_getString()");
|
||||
|
||||
// Check if an object containing a string was specified.
|
||||
if (NULL != stringFieldId)
|
||||
{
|
||||
// Retrieve the string object.
|
||||
string = (jstring)pEnv->GetObjectField(object, stringFieldId);
|
||||
|
||||
// Clear any resulting exceptions.
|
||||
pEnv->ExceptionClear();
|
||||
}
|
||||
else
|
||||
{
|
||||
// The string itself was specified.
|
||||
string = (jstring)object;
|
||||
}
|
||||
|
||||
// Check if the string could be retrieved.
|
||||
if (NULL != string)
|
||||
{
|
||||
// Get a local copy of the string.
|
||||
pLocal = (M4OSA_Char*)pEnv->GetStringUTFChars(string, M4OSA_NULL);
|
||||
if (M4OSA_NULL != pLocal)
|
||||
{
|
||||
// Determine the length of the path
|
||||
// (add one extra character for the zero terminator).
|
||||
length = M4OSA_chrLength(pLocal) + 1;
|
||||
|
||||
// Allocate memory for the string.
|
||||
pString = videoEditOsal_alloc(pResult, pEnv, length, "String");
|
||||
if (*pResult)
|
||||
{
|
||||
// Copy the string.
|
||||
result = M4OSA_chrNCopy((M4OSA_Char*)pString, pLocal, length);
|
||||
|
||||
// Check if the copy succeeded.
|
||||
videoEditJava_checkAndThrowRuntimeException(pResult, pEnv,
|
||||
(M4NO_ERROR != result), result);
|
||||
|
||||
// Check if the string could not be copied.
|
||||
if (!(*pResult))
|
||||
{
|
||||
// Free the allocated memory.
|
||||
videoEditOsal_free(pString);
|
||||
pString = M4OSA_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Release the local copy of the string.
|
||||
pEnv->ReleaseStringUTFChars(string, (const char *)pLocal);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the string was empty or could be copied.
|
||||
if (*pResult)
|
||||
{
|
||||
// Check if the length was requested.
|
||||
if (M4OSA_NULL != pLength)
|
||||
{
|
||||
// Return the length.
|
||||
(*pLength) = length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return the string.
|
||||
return(pString);
|
||||
}
|
||||
|
||||
void
|
||||
videoEditJava_getStaticIntField(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jclass clazz,
|
||||
const char* pName,
|
||||
int* pValue)
|
||||
{
|
||||
// Only look for the class if locating the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Log the function call.
|
||||
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA",
|
||||
"videoEditJava_getStaticIntField(%s)", pName);
|
||||
|
||||
// Look up the field id.
|
||||
jfieldID fieldId = pEnv->GetStaticFieldID(clazz, pName, "I");
|
||||
|
||||
// Clear any resulting exceptions.
|
||||
pEnv->ExceptionClear();
|
||||
|
||||
// Check if the field could be located.
|
||||
if (NULL != fieldId)
|
||||
{
|
||||
// Retrieve the field value.
|
||||
(*pValue) = pEnv->GetStaticIntField(clazz, fieldId);
|
||||
|
||||
// Log the value.
|
||||
VIDEOEDIT_LOG_EXCEPTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA",
|
||||
"videoEditJava_getStaticIntField, %s = %d", pName, (*pValue));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reset the result flag.
|
||||
(*pResult) = false;
|
||||
|
||||
// Log the error.
|
||||
VIDEOEDIT_LOG_EXCEPTION(ANDROID_LOG_ERROR, "VIDEO_EDITOR_JAVA",
|
||||
"videoEditJava_getStaticIntField, error: unable to locate field %s", pName);
|
||||
|
||||
// Throw an exception.
|
||||
jniThrowException(pEnv, "java/lang/NoSuchFieldException",
|
||||
"unable to locate static field");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
videoEditJava_initConstantClass(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
VideoEditJava_ConstantsClass* pClass)
|
||||
{
|
||||
bool gotten = true;
|
||||
jclass clazz = NULL;
|
||||
int index = 0;
|
||||
|
||||
// Check if the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Log the function call.
|
||||
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA",
|
||||
"videoEditJava_initConstantClass(%s)", pClass->pName);
|
||||
|
||||
// Only initialize the class once.
|
||||
if (!pClass->initialized)
|
||||
{
|
||||
// Look up the class.
|
||||
videoEditJava_getClass(pResult, pEnv, pClass->pName, &clazz);
|
||||
|
||||
// Loop over the constants.
|
||||
for (index = 0; index < pClass->count; index++)
|
||||
{
|
||||
// Look up the constant.
|
||||
videoEditJava_getStaticIntField(pResult, pEnv, clazz,
|
||||
pClass->pConstants[index].pName,
|
||||
&pClass->pConstants[index].java);
|
||||
}
|
||||
|
||||
// Check if all constants could be located.
|
||||
if (*pResult)
|
||||
{
|
||||
// Set the initialized flag.
|
||||
pClass->initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
videoEditJava_getConstantClassName(
|
||||
const VideoEditJava_ConstantsClass* pClass,
|
||||
int value,
|
||||
VideoEditJava_UnknownConstant unknown)
|
||||
{
|
||||
const char* pName = M4OSA_NULL;
|
||||
int index = 0;
|
||||
|
||||
// Loop over the list with constants.
|
||||
for (index = 0;
|
||||
((M4OSA_NULL == pName) && (index < pClass->count));
|
||||
index++)
|
||||
{
|
||||
// Check if the specified value matches the c value of the constant.
|
||||
if (value == pClass->pConstants[index].c)
|
||||
{
|
||||
// Set the name.
|
||||
pName = pClass->pConstants[index].pName;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if no constant was found.
|
||||
if (M4OSA_NULL == pName)
|
||||
{
|
||||
// Check if a function was specified to handle this case.
|
||||
if (M4OSA_NULL != unknown)
|
||||
{
|
||||
// Pass the constant to the specified unknown function.
|
||||
pName = unknown(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the description to a default value.
|
||||
pName = "<unknown>";
|
||||
}
|
||||
}
|
||||
|
||||
// Return the result.
|
||||
return(pName);
|
||||
}
|
||||
|
||||
const char*
|
||||
videoEditJava_getConstantClassString(
|
||||
const VideoEditJava_ConstantsClass* pClass,
|
||||
int value,
|
||||
VideoEditJava_UnknownConstant unknown)
|
||||
{
|
||||
const char* pString = M4OSA_NULL;
|
||||
int index = 0;
|
||||
|
||||
// Loop over the list with constants.
|
||||
for (index = 0;
|
||||
((M4OSA_NULL == pString) && (index < pClass->count));
|
||||
index++)
|
||||
{
|
||||
// Check if the specified value matches the c value of the constant.
|
||||
if (value == pClass->pConstants[index].c)
|
||||
{
|
||||
// Set the description.
|
||||
pString = pClass->pConstants[index].pDescription;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if no constant was found.
|
||||
if (M4OSA_NULL == pString)
|
||||
{
|
||||
// Check if a function was specified to handle this case.
|
||||
if (M4OSA_NULL != unknown)
|
||||
{
|
||||
// Pass the constant to the specified unknown function.
|
||||
pString = unknown(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the description to a default value.
|
||||
pString = "<unknown>";
|
||||
}
|
||||
}
|
||||
|
||||
// Return the result.
|
||||
return(pString);
|
||||
}
|
||||
|
||||
int
|
||||
videoEditJava_getConstantClassJavaToC(
|
||||
bool* pResult,
|
||||
const VideoEditJava_ConstantsClass* pClass,
|
||||
int value)
|
||||
{
|
||||
bool gotten = false;
|
||||
int index = 0;
|
||||
|
||||
// Check if the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Loop over the list with constants.
|
||||
for (index = 0; ((!gotten) && (index < pClass->count)); index++)
|
||||
{
|
||||
// Check if the specified value matches the java value of the constant.
|
||||
if (value == pClass->pConstants[index].java)
|
||||
{
|
||||
// Set the value to the c value.
|
||||
value = pClass->pConstants[index].c;
|
||||
|
||||
// Set the gotten flag.
|
||||
gotten = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the value was not found.
|
||||
if (!gotten)
|
||||
{
|
||||
(*pResult) = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the translated value.
|
||||
return(value);
|
||||
}
|
||||
|
||||
int
|
||||
videoEditJava_getConstantClassJavaToC(
|
||||
bool* pResult,
|
||||
const VideoEditJava_ConstantsClass* pClass,
|
||||
int value,
|
||||
int unknown)
|
||||
{
|
||||
bool gotten = false;
|
||||
int index = 0;
|
||||
|
||||
// Check if the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Loop over the list with constants.
|
||||
for (index = 0; ((!gotten) && (index < pClass->count)); index++)
|
||||
{
|
||||
// Check if the specified value matches the java value of the constant.
|
||||
if (value == pClass->pConstants[index].java)
|
||||
{
|
||||
// Set the value to the c value.
|
||||
value = pClass->pConstants[index].c;
|
||||
|
||||
// Set the gotten flag.
|
||||
gotten = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If the constant was not found, look for the specified unknown.
|
||||
if (!gotten)
|
||||
{
|
||||
// Set the value to the c value.
|
||||
value = unknown;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the translated value.
|
||||
return(value);
|
||||
}
|
||||
|
||||
int
|
||||
videoEditJava_getConstantClassCToJava(
|
||||
const VideoEditJava_ConstantsClass* pClass,
|
||||
int value)
|
||||
{
|
||||
bool gotten = false;
|
||||
int index = 0;
|
||||
|
||||
// Loop over the list with constants.
|
||||
for (index = 0; ((!gotten) && (index < pClass->count)); index++)
|
||||
{
|
||||
// Check if the specified value matches the c value of the constant.
|
||||
if (value == pClass->pConstants[index].c)
|
||||
{
|
||||
// Set the value to the java value.
|
||||
value = pClass->pConstants[index].java;
|
||||
|
||||
// Set the gotten flag.
|
||||
gotten = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the translated value.
|
||||
return(value);
|
||||
}
|
||||
|
||||
int
|
||||
videoEditJava_getConstantClassCToJava(
|
||||
const VideoEditJava_ConstantsClass* pClass,
|
||||
int value,
|
||||
int unknown)
|
||||
{
|
||||
bool gotten = false;
|
||||
int index = 0;
|
||||
|
||||
// Loop over the list with constants.
|
||||
for (index = 0; ((!gotten) && (index < pClass->count)); index++)
|
||||
{
|
||||
// Check if the specified value matches the c value of the constant.
|
||||
if (value == pClass->pConstants[index].c)
|
||||
{
|
||||
// Set the value to the java value.
|
||||
value = pClass->pConstants[index].java;
|
||||
|
||||
// Set the gotten flag.
|
||||
gotten = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If the constant was not found, look for the specified unknown.
|
||||
if (!gotten)
|
||||
{
|
||||
// Loop over the list with constants.
|
||||
for (index = 0; ((!gotten) && (index < pClass->count)); index++)
|
||||
{
|
||||
// Check if the specified value matches the java value of the constant.
|
||||
if (unknown == pClass->pConstants[index].c)
|
||||
{
|
||||
// Set the value to the c value.
|
||||
value = pClass->pConstants[index].java;
|
||||
|
||||
// Set the gotten flag.
|
||||
gotten = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return the translated value.
|
||||
return(value);
|
||||
}
|
||||
|
||||
void
|
||||
videoEditJava_initFieldClass(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
VideoEditJava_FieldsClass* pClass)
|
||||
{
|
||||
bool gotten = true;
|
||||
jclass clazz = NULL;
|
||||
int index = 0;
|
||||
|
||||
// Check if the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Log the function call.
|
||||
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA",
|
||||
"videoEditJava_initFieldClass(%s)", pClass->pName);
|
||||
|
||||
// Only initialize the class once.
|
||||
if (!pClass->initialized)
|
||||
{
|
||||
// Look up the class.
|
||||
videoEditJava_getClass(pResult, pEnv, pClass->pName, &clazz);
|
||||
|
||||
// Loop over the fields.
|
||||
for (index = 0; index < pClass->count; index++)
|
||||
{
|
||||
// Look up the field id.
|
||||
videoEditJava_getFieldId(
|
||||
pResult,
|
||||
pEnv,
|
||||
clazz,
|
||||
pClass->pFields[index].pName,
|
||||
pClass->pFields[index].pType,
|
||||
&pClass->pFields[index].fieldId);
|
||||
}
|
||||
|
||||
// Check if all fields could be located.
|
||||
if (*pResult)
|
||||
{
|
||||
// Set the initialized flag.
|
||||
pClass->initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
videoEditJava_fieldClassClass(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
const VideoEditJava_FieldsClass* pClass,
|
||||
jclass* pClazz)
|
||||
{
|
||||
// Check if the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Check if the class is initialized.
|
||||
videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv, (!pClass->initialized),
|
||||
"field class not initialized");
|
||||
|
||||
// Get the class.
|
||||
videoEditJava_getClass(pResult, pEnv, pClass->pName, pClazz);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
videoEditJava_fieldClassFieldIds(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
const VideoEditJava_FieldsClass* pClass,
|
||||
int count,
|
||||
VideoEditJava_FieldIds* pIds)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
// Check if the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Check if the class is initialized.
|
||||
videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv, (!pClass->initialized),
|
||||
"field class not initialized");
|
||||
|
||||
// Check if the number of fields matches.
|
||||
videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,
|
||||
(pClass->count != count),
|
||||
"field class type mismatch");
|
||||
|
||||
// Check if the class and object are valid.
|
||||
if (*pResult)
|
||||
{
|
||||
// Loop over the class fields.
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
// Copy the field ids.
|
||||
pIds->fieldIds[index] = pClass->pFields[index].fieldId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
videoEditJava_initMethodClass(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
VideoEditJava_MethodsClass* pClass)
|
||||
{
|
||||
bool gotten = true;
|
||||
jclass clazz = NULL;
|
||||
int index = 0;
|
||||
|
||||
// Check if the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Log the function call.
|
||||
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_JAVA",
|
||||
"videoEditJava_initMethodClass(%s)", pClass->pName);
|
||||
|
||||
// Only initialize the class once.
|
||||
if (!pClass->initialized)
|
||||
{
|
||||
// Look up the class.
|
||||
videoEditJava_getClass(pResult, pEnv, pClass->pName, &clazz);
|
||||
|
||||
// Loop over the methods.
|
||||
for (index = 0; index < pClass->count; index++)
|
||||
{
|
||||
// Look up the method id.
|
||||
videoEditJava_getMethodId(
|
||||
pResult,
|
||||
pEnv,
|
||||
clazz,
|
||||
pClass->pMethods[index].pName,
|
||||
pClass->pMethods[index].pType,
|
||||
&pClass->pMethods[index].methodId);
|
||||
}
|
||||
|
||||
// Check if all methods could be located.
|
||||
if (*pResult)
|
||||
{
|
||||
// Set the initialized flag.
|
||||
pClass->initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
videoEditJava_methodClassMethodIds(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
const VideoEditJava_MethodsClass* pClass,
|
||||
int count,
|
||||
VideoEditJava_MethodIds* pIds)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
// Check if the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Check if the class is initialized.
|
||||
videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv, (!pClass->initialized),
|
||||
"method class not initialized");
|
||||
|
||||
// Check if the number of methods matches.
|
||||
videoEditJava_checkAndThrowIllegalArgumentException(pResult, pEnv,\
|
||||
(pClass->count != count),
|
||||
"method class type mismatch");
|
||||
|
||||
// Check if the class and object are valid.
|
||||
if (*pResult)
|
||||
{
|
||||
// Loop over the class methods.
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
// Copy the method ids.
|
||||
pIds->methodIds[index] = pClass->pMethods[index].methodId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
506
media/jni/mediaeditor/VideoEditorJava.h
Executable file
506
media/jni/mediaeditor/VideoEditorJava.h
Executable file
@@ -0,0 +1,506 @@
|
||||
/*
|
||||
* 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 VIDEO_EDiTOR_JAVA_H
|
||||
#define VIDEO_EDiTOR_JAVA_H
|
||||
|
||||
#include <jni.h>
|
||||
#include <JNIHelp.h>
|
||||
|
||||
/**
|
||||
************************************************************************
|
||||
* @file VideoEditorJava.h
|
||||
* @brief Interface for JNI methods that have specific access to
|
||||
* class, objects and method Ids defined in Java layer
|
||||
************************************************************************
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#include <M4OSA_Types.h>
|
||||
#include <M4OSA_Error.h>
|
||||
}
|
||||
|
||||
#define VIDEOEDIT_JAVA_CONSTANT_INIT(m_name, m_c) \
|
||||
{ m_name, \
|
||||
0, \
|
||||
m_c, \
|
||||
#m_c }
|
||||
|
||||
#define VIDEOEDIT_JAVA_DEFINE_CONSTANTS(m_class) \
|
||||
static \
|
||||
VideoEditJava_Constant g##m_class##Constants [] =
|
||||
|
||||
#define VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS( \
|
||||
m_class, \
|
||||
m_name, \
|
||||
m_unknownName, \
|
||||
m_unknownString) \
|
||||
\
|
||||
static VideoEditJava_ConstantsClass g##m_class##ConstantsClass = \
|
||||
{ m_name, \
|
||||
&g##m_class##Constants[0], \
|
||||
(sizeof(g##m_class##Constants) / sizeof(VideoEditJava_Constant)), \
|
||||
false \
|
||||
}; \
|
||||
\
|
||||
\
|
||||
void videoEditJava_init##m_class##Constants( \
|
||||
bool* pResult, \
|
||||
JNIEnv* pEnv) \
|
||||
{ \
|
||||
videoEditJava_initConstantClass( \
|
||||
pResult, \
|
||||
pEnv, \
|
||||
&g##m_class##ConstantsClass); \
|
||||
} \
|
||||
\
|
||||
const char* videoEditJava_get##m_class##Name( \
|
||||
int value) \
|
||||
{ \
|
||||
return(videoEditJava_getConstantClassName( \
|
||||
&g##m_class##ConstantsClass, \
|
||||
value, \
|
||||
m_unknownName)); \
|
||||
} \
|
||||
\
|
||||
const char* videoEditJava_get##m_class##String( \
|
||||
int value) \
|
||||
{ \
|
||||
return(videoEditJava_getConstantClassString( \
|
||||
&g##m_class##ConstantsClass, \
|
||||
value, \
|
||||
m_unknownString)); \
|
||||
} \
|
||||
\
|
||||
int \
|
||||
videoEditJava_get##m_class##JavaToC( \
|
||||
bool* pResult, \
|
||||
int value) \
|
||||
{ \
|
||||
return(videoEditJava_getConstantClassJavaToC( \
|
||||
pResult, \
|
||||
&g##m_class##ConstantsClass, \
|
||||
value)); \
|
||||
} \
|
||||
\
|
||||
int \
|
||||
videoEditJava_get##m_class##JavaToC( \
|
||||
bool* pResult, \
|
||||
int value, \
|
||||
int unknown) \
|
||||
{ \
|
||||
return(videoEditJava_getConstantClassJavaToC( \
|
||||
pResult, \
|
||||
&g##m_class##ConstantsClass, \
|
||||
value, \
|
||||
unknown)); \
|
||||
} \
|
||||
\
|
||||
int \
|
||||
videoEditJava_get##m_class##CToJava( \
|
||||
int value) \
|
||||
{ \
|
||||
return(videoEditJava_getConstantClassCToJava( \
|
||||
&g##m_class##ConstantsClass, \
|
||||
value)); \
|
||||
} \
|
||||
\
|
||||
int \
|
||||
videoEditJava_get##m_class##CToJava( \
|
||||
int value, \
|
||||
int unknown) \
|
||||
{ \
|
||||
return(videoEditJava_getConstantClassCToJava( \
|
||||
&g##m_class##ConstantsClass, \
|
||||
value, \
|
||||
unknown)); \
|
||||
}
|
||||
|
||||
|
||||
#define VIDEOEDIT_JAVA_DECLARE_CONSTANT_CLASS(m_class) \
|
||||
void \
|
||||
videoEditJava_init##m_class##Constants( \
|
||||
bool* pResult, \
|
||||
JNIEnv* pEnv); \
|
||||
\
|
||||
const char* \
|
||||
videoEditJava_get##m_class##Name( \
|
||||
int value); \
|
||||
\
|
||||
const char* \
|
||||
videoEditJava_get##m_class##String( \
|
||||
int value); \
|
||||
\
|
||||
int \
|
||||
videoEditJava_get##m_class##JavaToC( \
|
||||
bool* pResult, \
|
||||
int value, \
|
||||
int unknown); \
|
||||
\
|
||||
int \
|
||||
videoEditJava_get##m_class##JavaToC( \
|
||||
bool* pResult, \
|
||||
int value); \
|
||||
\
|
||||
int \
|
||||
videoEditJava_get##m_class##CToJava( \
|
||||
int value); \
|
||||
\
|
||||
int \
|
||||
videoEditJava_get##m_class##CToJava( \
|
||||
int value, \
|
||||
int unknown);
|
||||
|
||||
#define VIDEOEDIT_JAVA_FIELD_INIT(m_name, m_type) \
|
||||
{ m_name, \
|
||||
m_type, \
|
||||
NULL }
|
||||
|
||||
#define VIDEOEDIT_JAVA_DEFINE_FIELDS(m_class) \
|
||||
static \
|
||||
VideoEditJava_Field g##m_class##Fields [] =
|
||||
|
||||
#define VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(m_class, m_name) \
|
||||
static VideoEditJava_FieldsClass g##m_class##FieldsClass = \
|
||||
{ m_name, \
|
||||
&g##m_class##Fields[0], \
|
||||
(sizeof(g##m_class##Fields) / sizeof(VideoEditJava_Field)), \
|
||||
false }; \
|
||||
\
|
||||
void \
|
||||
videoEditJava_init##m_class##Fields( \
|
||||
bool* pResult, \
|
||||
JNIEnv* pEnv) \
|
||||
{ \
|
||||
videoEditJava_initFieldClass( \
|
||||
pResult, \
|
||||
pEnv, \
|
||||
&g##m_class##FieldsClass); \
|
||||
} \
|
||||
\
|
||||
void \
|
||||
videoEditJava_get##m_class##Class( \
|
||||
bool* pResult, \
|
||||
JNIEnv* pEnv, \
|
||||
jclass* pClazz) \
|
||||
{ \
|
||||
videoEditJava_fieldClassClass( \
|
||||
pResult, \
|
||||
pEnv, \
|
||||
&g##m_class##FieldsClass, \
|
||||
pClazz); \
|
||||
} \
|
||||
\
|
||||
void \
|
||||
videoEditJava_get##m_class##FieldIds( \
|
||||
bool* pResult, \
|
||||
JNIEnv* pEnv, \
|
||||
VideoEditJava_##m_class##FieldIds* pIds) \
|
||||
{ \
|
||||
videoEditJava_fieldClassFieldIds( \
|
||||
pResult, \
|
||||
pEnv, \
|
||||
&g##m_class##FieldsClass, \
|
||||
(sizeof(VideoEditJava_##m_class##FieldIds) / \
|
||||
sizeof(jfieldID)), \
|
||||
(VideoEditJava_FieldIds*)pIds); \
|
||||
}
|
||||
|
||||
#define VIDEOEDIT_JAVA_DECLARE_FIELD_CLASS(m_class) \
|
||||
void \
|
||||
videoEditJava_init##m_class##Fields( \
|
||||
bool* pResult, \
|
||||
JNIEnv* pEnv); \
|
||||
\
|
||||
void \
|
||||
videoEditJava_get##m_class##Class( \
|
||||
bool* pResult, \
|
||||
JNIEnv* pEnv, \
|
||||
jclass* pClazz); \
|
||||
\
|
||||
void \
|
||||
videoEditJava_get##m_class##FieldIds( \
|
||||
bool* pResult, \
|
||||
JNIEnv* pEnv, \
|
||||
VideoEditJava_##m_class##FieldIds* pIds);
|
||||
|
||||
|
||||
#define VIDEOEDIT_JAVA_METHOD_INIT(m_name, m_type) \
|
||||
{ m_name, \
|
||||
m_type, \
|
||||
NULL }
|
||||
|
||||
#define VIDEOEDIT_JAVA_DEFINE_METHODS(m_class) \
|
||||
static \
|
||||
VideoEditJava_Method g##m_class##Methods [] =
|
||||
|
||||
#define VIDEOEDIT_JAVA_DEFINE_METHOD_CLASS(m_class, m_name) \
|
||||
static VideoEditJava_MethodsClass g##m_class##MethodsClass = \
|
||||
{ m_name, \
|
||||
&g##m_class##Methods[0], \
|
||||
(sizeof(g##m_class##Methods) / sizeof(VideoEditJava_Method)), \
|
||||
false }; \
|
||||
\
|
||||
void \
|
||||
videoEditJava_init##m_class##Methods( \
|
||||
bool* pResult, \
|
||||
JNIEnv* pEnv) \
|
||||
{ \
|
||||
videoEditJava_initMethodClass( \
|
||||
pResult, \
|
||||
pEnv, \
|
||||
&g##m_class##MethodsClass); \
|
||||
} \
|
||||
\
|
||||
void \
|
||||
videoEditJava_get##m_class##MethodIds( \
|
||||
bool* pResult, \
|
||||
JNIEnv* pEnv, \
|
||||
VideoEditJava_##m_class##MethodIds* pIds) \
|
||||
{ \
|
||||
videoEditJava_methodClassMethodIds( \
|
||||
pResult, \
|
||||
pEnv, \
|
||||
&g##m_class##MethodsClass, \
|
||||
(sizeof(VideoEditJava_##m_class##MethodIds) / \
|
||||
sizeof(jmethodID)), \
|
||||
(VideoEditJava_MethodIds*)pIds); \
|
||||
}
|
||||
|
||||
#define VIDEOEDIT_JAVA_DECLARE_METHOD_CLASS(m_class) \
|
||||
void \
|
||||
videoEditJava_init##m_class##Methods( \
|
||||
bool* pResult, \
|
||||
JNIEnv* pEnv); \
|
||||
\
|
||||
void \
|
||||
videoEditJava_get##m_class##MethodIds( \
|
||||
bool* pResult, \
|
||||
JNIEnv* pEnv, \
|
||||
VideoEditJava_##m_class##MethodIds* pIds);
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* pName;
|
||||
int java;
|
||||
int c;
|
||||
const char* pDescription;
|
||||
} VideoEditJava_Constant;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* pName;
|
||||
VideoEditJava_Constant* pConstants;
|
||||
int count;
|
||||
bool initialized;
|
||||
} VideoEditJava_ConstantsClass;
|
||||
|
||||
typedef const char* (*VideoEditJava_UnknownConstant)(int constant);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* pName;
|
||||
const char* pType;
|
||||
jfieldID fieldId;
|
||||
} VideoEditJava_Field;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* pName;
|
||||
VideoEditJava_Field* pFields;
|
||||
int count;
|
||||
bool initialized;
|
||||
} VideoEditJava_FieldsClass;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
jfieldID fieldIds[];
|
||||
} VideoEditJava_FieldIds;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* pName;
|
||||
const char* pType;
|
||||
jmethodID methodId;
|
||||
} VideoEditJava_Method;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* pName;
|
||||
VideoEditJava_Method* pMethods;
|
||||
int count;
|
||||
bool initialized;
|
||||
} VideoEditJava_MethodsClass;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
jmethodID methodIds[];
|
||||
} VideoEditJava_MethodIds;
|
||||
|
||||
void
|
||||
videoEditJava_checkAndThrowIllegalArgumentException(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
bool condition,
|
||||
const char* pMessage);
|
||||
|
||||
void
|
||||
videoEditJava_checkAndThrowRuntimeException(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
bool condition,
|
||||
M4OSA_ERR result);
|
||||
|
||||
void
|
||||
videoEditJava_checkAndThrowIllegalStateException(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
bool condition,
|
||||
const char* pMessage);
|
||||
|
||||
void
|
||||
videoEditJava_getClass(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
const char* pName,
|
||||
jclass* pClazz);
|
||||
|
||||
void
|
||||
videoEditJava_getMethodId(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jclass clazz,
|
||||
const char* pName,
|
||||
const char* pType,
|
||||
jmethodID* pMethodId);
|
||||
|
||||
void videoEditJava_getFieldId(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jclass clazz,
|
||||
const char* pName,
|
||||
const char* pType,
|
||||
jfieldID* pFieldId);
|
||||
|
||||
void videoEditJava_getObject(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jobject object,
|
||||
jfieldID objectFieldId,
|
||||
jobject* pObject);
|
||||
|
||||
void videoEditJava_getArray(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jobject object,
|
||||
jfieldID arrayFieldId,
|
||||
jobjectArray* pArray,
|
||||
jsize* pArraySize);
|
||||
|
||||
void* videoEditJava_getString(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
jobject object,
|
||||
jfieldID stringFieldId,
|
||||
M4OSA_UInt32* pLength);
|
||||
|
||||
void videoEditJava_getStaticIntField(
|
||||
bool* pResult,
|
||||
JNIEnv* env,
|
||||
jclass clazz,
|
||||
const char* pName,
|
||||
int* pValue);
|
||||
|
||||
void
|
||||
videoEditJava_initConstantClass(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
VideoEditJava_ConstantsClass* pClass);
|
||||
|
||||
const char*
|
||||
videoEditJava_getConstantClassName(
|
||||
const VideoEditJava_ConstantsClass* pClass,
|
||||
int value,
|
||||
VideoEditJava_UnknownConstant unknown);
|
||||
|
||||
const char*
|
||||
videoEditJava_getConstantClassString(
|
||||
const VideoEditJava_ConstantsClass* pClass,
|
||||
int value,
|
||||
VideoEditJava_UnknownConstant unknown);
|
||||
|
||||
int
|
||||
videoEditJava_getConstantClassJavaToC(
|
||||
bool* pResult,
|
||||
const VideoEditJava_ConstantsClass* pClass,
|
||||
int value);
|
||||
|
||||
int
|
||||
videoEditJava_getConstantClassJavaToC(
|
||||
bool* pResult,
|
||||
const VideoEditJava_ConstantsClass* pClass,
|
||||
int value,
|
||||
int unknown);
|
||||
|
||||
int
|
||||
videoEditJava_getConstantClassCToJava(
|
||||
const VideoEditJava_ConstantsClass* pClass,
|
||||
int value);
|
||||
|
||||
int
|
||||
videoEditJava_getConstantClassCToJava(
|
||||
const VideoEditJava_ConstantsClass* pClass,
|
||||
int value,
|
||||
int unknown);
|
||||
|
||||
void
|
||||
videoEditJava_initFieldClass(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
VideoEditJava_FieldsClass* pClass);
|
||||
|
||||
void
|
||||
videoEditJava_fieldClassClass(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
const VideoEditJava_FieldsClass* pClass,
|
||||
jclass* pClazz);
|
||||
|
||||
void
|
||||
videoEditJava_fieldClassFieldIds(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
const VideoEditJava_FieldsClass* pClass,
|
||||
int count,
|
||||
VideoEditJava_FieldIds* pIds);
|
||||
|
||||
void
|
||||
videoEditJava_initMethodClass(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
VideoEditJava_MethodsClass* pClass);
|
||||
|
||||
void
|
||||
videoEditJava_methodClassMethodIds(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
const VideoEditJava_MethodsClass* pClass,
|
||||
int count,
|
||||
VideoEditJava_MethodIds* pIds);
|
||||
|
||||
#endif // VIDEO_EDiTOR_JAVA_H
|
||||
|
||||
55
media/jni/mediaeditor/VideoEditorLogging.h
Executable file
55
media/jni/mediaeditor/VideoEditorLogging.h
Executable file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 VIDEO_EDITOR_LOGGING_H
|
||||
#define VIDEO_EDITOR_LOGGING_H
|
||||
|
||||
//#define VIDEOEDIT_LOGGING_ENABLED
|
||||
|
||||
#define VIDEOEDIT_LOG_INDENTATION (3)
|
||||
|
||||
#ifdef VIDEOEDIT_LOGGING_ENABLED
|
||||
|
||||
#define VIDEOEDIT_LOG_ALLOCATION __android_log_print
|
||||
#define VIDEOEDIT_LOG_API __android_log_print
|
||||
#define VIDEOEDIT_LOG_ERROR __android_log_print
|
||||
#define VIDEOEDIT_LOG_EXCEPTION __android_log_print
|
||||
#define VIDEOEDIT_LOG_FUNCTION __android_log_print
|
||||
#define VIDEOEDIT_LOG_RESULT(x,y, ...) LOGI(y, __VA_ARGS__ )
|
||||
#define VIDEOEDIT_LOG_SETTING __android_log_print
|
||||
#define VIDEOEDIT_LOG_EDIT_SETTINGS(m_settings) videoEditClasses_logEditSettings\
|
||||
(m_settings, VIDEOEDIT_LOG_INDENTATION)
|
||||
#define VIDEOEDIT_PROP_LOG_PROPERTIES(m_properties) videoEditPropClass_logProperties\
|
||||
(m_properties, VIDEOEDIT_LOG_INDENTATION)
|
||||
#define VIDEOEDIT_PROP_LOG_RESULT __android_log_print
|
||||
|
||||
#else
|
||||
|
||||
#define VIDEOEDIT_LOG_ALLOCATION (void)
|
||||
#define VIDEOEDIT_LOG_API (void)
|
||||
#define VIDEOEDIT_LOG_ERROR (void)
|
||||
#define VIDEOEDIT_LOG_EXCEPTION (void)
|
||||
#define VIDEOEDIT_LOG_FUNCTION (void)
|
||||
#define VIDEOEDIT_LOG_RESULT (void)
|
||||
#define VIDEOEDIT_LOG_SETTING (void)
|
||||
#define VIDEOEDIT_LOG_EDIT_SETTINGS(m_settings) (void)m_settings
|
||||
#define VIDEOEDIT_PROP_LOG_PROPERTIES(m_properties) (void)m_properties
|
||||
#define VIDEOEDIT_PROP_LOG_RESULT (void)
|
||||
|
||||
#endif
|
||||
|
||||
#endif // VIDEO_EDITOR_LOGGING_H
|
||||
|
||||
3056
media/jni/mediaeditor/VideoEditorMain.cpp
Executable file
3056
media/jni/mediaeditor/VideoEditorMain.cpp
Executable file
File diff suppressed because it is too large
Load Diff
69
media/jni/mediaeditor/VideoEditorMain.h
Executable file
69
media/jni/mediaeditor/VideoEditorMain.h
Executable file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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 __VIDEO_EDITOR_API_H__
|
||||
#define __VIDEO_EDITOR_API_H__
|
||||
|
||||
#include "M4OSA_Types.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MSG_TYPE_PROGRESS_INDICATION, /* Playback progress indication event*/
|
||||
MSG_TYPE_PLAYER_ERROR, /* Playback error*/
|
||||
MSG_TYPE_PREVIEW_END, /* Preview of clips is complete */
|
||||
} progress_callback_msg_type;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
M4OSA_Void *pFile; /** PCM file path */
|
||||
M4OSA_Bool bRemoveOriginal; /** If true, the original audio track
|
||||
is not taken into account */
|
||||
M4OSA_UInt32 uiNbChannels; /** Number of channels (1=mono, 2=stereo) of BGM clip*/
|
||||
M4OSA_UInt32 uiSamplingFrequency; /** Sampling audio frequency (8000 for amr, 16000 or
|
||||
more for aac) of BGM clip*/
|
||||
M4OSA_UInt32 uiExtendedSamplingFrequency; /** Extended frequency for AAC+,
|
||||
eAAC+ streams of BGM clip*/
|
||||
M4OSA_UInt32 uiAddCts; /** Time, in milliseconds, at which the added
|
||||
audio track is inserted */
|
||||
M4OSA_UInt32 uiAddVolume; /** Volume, in percentage, of the added audio track */
|
||||
M4OSA_UInt32 beginCutMs;
|
||||
M4OSA_UInt32 endCutMs;
|
||||
M4OSA_Int32 fileType;
|
||||
M4OSA_Bool bLoop; /** Looping on/off **/
|
||||
/* Audio ducking */
|
||||
M4OSA_UInt32 uiInDucking_threshold; /** Threshold value at which
|
||||
background music shall duck */
|
||||
M4OSA_UInt32 uiInDucking_lowVolume; /** lower the background track to
|
||||
this factor of current level */
|
||||
M4OSA_Bool bInDucking_enable; /** enable ducking */
|
||||
M4OSA_UInt32 uiBTChannelCount; /** channel count for BT */
|
||||
M4OSA_Void *pPCMFilePath;
|
||||
} M4xVSS_AudioMixingSettings;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
M4OSA_Void *pBuffer; /* YUV420 buffer of frame to be rendered*/
|
||||
M4OSA_UInt32 timeMs; /* time stamp of the frame to be rendered*/
|
||||
M4OSA_UInt32 uiSurfaceWidth; /* Surface display width*/
|
||||
M4OSA_UInt32 uiSurfaceHeight; /* Surface display height*/
|
||||
M4OSA_UInt32 uiFrameWidth; /* Frame width*/
|
||||
M4OSA_UInt32 uiFrameHeight; /* Frame height*/
|
||||
M4OSA_Bool bApplyEffect; /* Apply video effects before render*/
|
||||
M4OSA_UInt32 clipBeginCutTime; /* Clip begin cut time relative to storyboard */
|
||||
M4OSA_UInt32 clipEndCutTime; /* Clip end cut time relative to storyboard */
|
||||
|
||||
} VideoEditor_renderPreviewFrameStr;
|
||||
#endif /*__VIDEO_EDITOR_API_H__*/
|
||||
359
media/jni/mediaeditor/VideoEditorOsal.cpp
Executable file
359
media/jni/mediaeditor/VideoEditorOsal.cpp
Executable file
@@ -0,0 +1,359 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <VideoEditorJava.h>
|
||||
#include <VideoEditorLogging.h>
|
||||
#include <VideoEditorOsal.h>
|
||||
|
||||
extern "C" {
|
||||
#include <M4OSA_Clock.h>
|
||||
#include <M4OSA_CharStar.h>
|
||||
#include <M4OSA_FileCommon.h>
|
||||
#include <M4OSA_FileReader.h>
|
||||
#include <M4OSA_FileWriter.h>
|
||||
#include <M4OSA_Memory.h>
|
||||
#include <M4OSA_String.h>
|
||||
#include <M4OSA_Thread.h>
|
||||
#include <M4xVSS_API.h>
|
||||
#include <M4VSS3GPP_ErrorCodes.h>
|
||||
#include <M4MCS_ErrorCodes.h>
|
||||
#include <M4READER_Common.h>
|
||||
#include <M4WRITER_common.h>
|
||||
#include <M4VSS3GPP_API.h>
|
||||
#include <M4DECODER_Common.h>
|
||||
};
|
||||
|
||||
|
||||
#define VIDEOEDIT_OSAL_RESULT_STRING_MAX (32)
|
||||
|
||||
#define VIDEOEDIT_OSAL_RESULT_INIT(m_result) { m_result, #m_result }
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
M4OSA_ERR result;
|
||||
const char* pName;
|
||||
} VideoEdit_Osal_Result;
|
||||
|
||||
static const VideoEdit_Osal_Result gkRESULTS[] =
|
||||
{
|
||||
// M4OSA_Clock.h
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_TIMESCALE_TOO_BIG ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_CLOCK_BAD_REF_YEAR ),
|
||||
|
||||
// M4OSA_Error.h
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4NO_ERROR ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_PARAMETER ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_STATE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_ALLOC ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_BAD_CONTEXT ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_CONTEXT_FAILED ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_BAD_STREAM_ID ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_BAD_OPTION_ID ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_WRITE_ONLY ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_READ_ONLY ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_NOT_IMPLEMENTED ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_UNSUPPORTED_MEDIA_TYPE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_NO_DATA_YET ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_NO_MORE_STREAM ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_INVALID_TIME ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_NO_MORE_AU ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_TIME_OUT ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_BUFFER_FULL ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_REDIRECT ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_TOO_MUCH_STREAMS ),
|
||||
|
||||
// M4OSA_FileCommon.h
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_FILE_NOT_FOUND ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_FILE_LOCKED ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_FILE_BAD_MODE_ACCESS ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_FILE_INVALID_POSITION ),
|
||||
|
||||
// M4OSA_String.h
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_STR_BAD_STRING ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_STR_CONV_FAILED ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_STR_OVERFLOW ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_STR_BAD_ARGS ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_STR_OVERFLOW ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_STR_NOT_FOUND ),
|
||||
|
||||
// M4OSA_Thread.h
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_THREAD_NOT_STARTED ),
|
||||
|
||||
// M4xVSS_API.h
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_WAR_ANALYZING_DONE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_WAR_PREVIEW_READY ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_WAR_SAVING_DONE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_WAR_TRANSCODING_NECESSARY ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_WAR_OUTPUTFILESIZE_EXCEED ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_JPG_TOO_BIG ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4xVSSWAR_BUFFER_OUT_TOO_SMALL ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4xVSSERR_NO_MORE_SPACE ),
|
||||
|
||||
// M4VSS3GPP_ErrorCodes.h
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INVALID_FILE_TYPE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INVALID_EFFECT_KIND ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INVALID_VIDEO_EFFECT_TYPE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INVALID_AUDIO_EFFECT_TYPE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INVALID_VIDEO_TRANSITION_TYPE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INVALID_AUDIO_TRANSITION_TYPE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INVALID_VIDEO_ENCODING_FRAME_RATE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_EXTERNAL_EFFECT_NULL ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_EXTERNAL_TRANSITION_NULL ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_BEGIN_CUT_LARGER_THAN_DURATION ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_BEGIN_CUT_LARGER_THAN_END_CUT ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_OVERLAPPING_TRANSITIONS ),
|
||||
#ifdef M4VSS3GPP_ERR_ANALYSIS_DATA_SIZE_TOO_SMALL
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_ANALYSIS_DATA_SIZE_TOO_SMALL ),
|
||||
#endif
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INVALID_3GPP_FILE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_UNSUPPORTED_INPUT_VIDEO_FORMAT ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_UNSUPPORTED_INPUT_AUDIO_FORMAT ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_AMR_EDITING_UNSUPPORTED ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INPUT_VIDEO_AU_TOO_LARGE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INPUT_AUDIO_AU_TOO_LARGE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INPUT_AUDIO_CORRUPTED_AU ),
|
||||
#ifdef M4VSS3GPP_ERR_INPUT_AUDIO_CORRUPTED_AMR_AU
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INPUT_AUDIO_CORRUPTED_AMR_AU ),
|
||||
#endif
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_ENCODER_ACCES_UNIT_ERROR ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_EDITING_UNSUPPORTED_VIDEO_FORMAT ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_EDITING_UNSUPPORTED_H263_PROFILE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_EDITING_UNSUPPORTED_MPEG4_PROFILE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_EDITING_UNSUPPORTED_MPEG4_RVLC ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_EDITING_UNSUPPORTED_AUDIO_FORMAT ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_EDITING_NO_SUPPORTED_STREAM_IN_FILE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_EDITING_NO_SUPPORTED_VIDEO_STREAM_IN_FILE),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INVALID_CLIP_ANALYSIS_VERSION ),
|
||||
#ifdef M4VSS3GPP_ERR_INVALID_CLIP_ANALYSIS_PLATFORM
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INVALID_CLIP_ANALYSIS_PLATFORM ),
|
||||
#endif
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INCOMPATIBLE_VIDEO_FORMAT ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INCOMPATIBLE_VIDEO_FRAME_SIZE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INCOMPATIBLE_VIDEO_TIME_SCALE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INCOMPATIBLE_VIDEO_DATA_PARTITIONING ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_UNSUPPORTED_MP3_ASSEMBLY ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_WAR_INCOMPATIBLE_AUDIO_STREAM_TYPE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_WAR_INCOMPATIBLE_AUDIO_NB_OF_CHANNELS ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_WAR_INCOMPATIBLE_AUDIO_SAMPLING_FREQUENCY ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_NO_SUPPORTED_STREAM_IN_FILE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_ADDVOLUME_EQUALS_ZERO ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_ADDCTS_HIGHER_THAN_VIDEO_DURATION ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_UNDEFINED_AUDIO_TRACK_FILE_FORMAT ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_UNSUPPORTED_ADDED_AUDIO_STREAM ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_AUDIO_MIXING_UNSUPPORTED ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_FEATURE_UNSUPPORTED_WITH_AUDIO_TRACK ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_AUDIO_CANNOT_BE_MIXED ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INPUT_CLIP_IS_NOT_A_3GPP ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_BEGINLOOP_HIGHER_ENDLOOP ),
|
||||
#ifdef M4VSS3GPP_ERR_AUDIO_MIXING_MP3_UNSUPPORTED
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_AUDIO_MIXING_MP3_UNSUPPORTED ),
|
||||
#endif
|
||||
#ifdef M4VSS3GPP_ERR_FEATURE_UNSUPPORTED_WITH_AAC
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_FEATURE_UNSUPPORTED_WITH_AAC ),
|
||||
#endif
|
||||
#ifdef M4VSS3GPP_ERR_ONLY_AMRNB_INPUT_CAN_BE_MIXED
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_ONLY_AMRNB_INPUT_CAN_BE_MIXED ),
|
||||
#endif
|
||||
#ifdef M4VSS3GPP_ERR_FEATURE_UNSUPPORTED_WITH_EVRC
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_FEATURE_UNSUPPORTED_WITH_EVRC ),
|
||||
#endif
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_H263_PROFILE_NOT_SUPPORTED ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_NO_SUPPORTED_VIDEO_STREAM_IN_FILE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_INTERNAL_STATE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_LUMA_FILTER_ERROR ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_CURTAIN_FILTER_ERROR ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_TRANSITION_FILTER_ERROR ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_AUDIO_DECODER_INIT_FAILED ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_AUDIO_DECODED_PCM_SIZE_ISSUE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4VSS3GPP_ERR_OUTPUT_FILE_TYPE_ERROR ),
|
||||
|
||||
// M4MCS_ErrorCodes.h
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_WAR_TRANSCODING_DONE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_WAR_MEDIATYPE_NOT_SUPPORTED ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_INPUT_FILE_CONTAINS_NO_SUPPORTED_STREAM ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_INVALID_INPUT_FILE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_UNDEFINED_OUTPUT_VIDEO_FORMAT ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_UNDEFINED_OUTPUT_VIDEO_FRAME_SIZE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_UNDEFINED_OUTPUT_VIDEO_FRAME_RATE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_UNDEFINED_OUTPUT_AUDIO_FORMAT ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_INVALID_VIDEO_FRAME_SIZE_FOR_H263 ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_INVALID_VIDEO_FRAME_RATE_FOR_H263 ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_DURATION_IS_NULL ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_H263_FORBIDDEN_IN_MP4_FILE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_H263_PROFILE_NOT_SUPPORTED ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_INVALID_AAC_SAMPLING_FREQUENCY ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_AUDIO_CONVERSION_FAILED ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_BEGIN_CUT_LARGER_THAN_DURATION ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_BEGIN_CUT_EQUALS_END_CUT ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_END_CUT_SMALLER_THAN_BEGIN_CUT ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_MAXFILESIZE_TOO_SMALL ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_VIDEOBITRATE_TOO_LOW ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_AUDIOBITRATE_TOO_LOW ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_VIDEOBITRATE_TOO_HIGH ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_AUDIOBITRATE_TOO_HIGH ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_OUTPUT_FILE_SIZE_TOO_SMALL ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4MCS_ERR_NOMORE_SPACE ),
|
||||
|
||||
// M4READER_Common.h
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_READER_UNKNOWN_STREAM_TYPE ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_READER_NO_METADATA ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_READER_INFORMATION_NOT_PRESENT ),
|
||||
|
||||
// M4WRITER_Common.h
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_WRITER_STOP_REQ ),
|
||||
// M4DECODER_Common.h
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_VIDEORENDERER_NO_NEW_FRAME ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4WAR_DEBLOCKING_FILTER_NOT_IMPLEMENTED ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_DECODER_H263_PROFILE_NOT_SUPPORTED ),
|
||||
VIDEOEDIT_OSAL_RESULT_INIT(M4ERR_DECODER_H263_NOT_BASELINE )
|
||||
};
|
||||
|
||||
static const int gkRESULTS_COUNT = (sizeof(gkRESULTS) / sizeof(VideoEdit_Osal_Result));
|
||||
|
||||
#ifdef OSAL_MEM_LEAK_DEBUG
|
||||
static int gAllocatedBlockCount = 0;
|
||||
#endif
|
||||
|
||||
const char*
|
||||
videoEditOsal_getResultString(
|
||||
M4OSA_ERR result)
|
||||
{
|
||||
static char string[VIDEOEDIT_OSAL_RESULT_STRING_MAX] = "";
|
||||
const char* pString = M4OSA_NULL;
|
||||
int index = 0;
|
||||
|
||||
// Loop over the list with constants.
|
||||
for (index = 0;
|
||||
((M4OSA_NULL == pString) && (index < gkRESULTS_COUNT));
|
||||
index++)
|
||||
{
|
||||
// Check if the specified result matches.
|
||||
if (result == gkRESULTS[index].result)
|
||||
{
|
||||
// Set the description.
|
||||
pString = gkRESULTS[index].pName;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if no result was found.
|
||||
if (M4OSA_NULL == pString)
|
||||
{
|
||||
// Set the description to a default value.
|
||||
M4OSA_chrSPrintf((M4OSA_Char *)string, sizeof(string) - 1,
|
||||
(M4OSA_Char*)"<unknown(0x%08X)>", result);
|
||||
pString = string;
|
||||
}
|
||||
|
||||
// Return the result.
|
||||
return(pString);
|
||||
}
|
||||
|
||||
void *
|
||||
videoEditOsal_alloc(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
size_t size,
|
||||
const char* pDescription)
|
||||
{
|
||||
void *pData = M4OSA_NULL;
|
||||
|
||||
// Check if the previous action succeeded.
|
||||
if (*pResult)
|
||||
{
|
||||
// Allocate memory for the settings.
|
||||
pData = (M4VSS3GPP_EditSettings*)M4OSA_malloc(size, 0, (M4OSA_Char*)pDescription);
|
||||
if (M4OSA_NULL != pData)
|
||||
{
|
||||
// Reset the allocated memory.
|
||||
M4OSA_memset((M4OSA_MemAddr8)pData, size, 0);
|
||||
#ifdef OSAL_MEM_LEAK_DEBUG
|
||||
// Update the allocated block count.
|
||||
gAllocatedBlockCount++;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reset the result flag.
|
||||
(*pResult) = false;
|
||||
|
||||
// Log the error.
|
||||
VIDEOEDIT_LOG_ERROR(ANDROID_LOG_ERROR, "VIDEO_EDITOR_OSAL", "videoEditOsal_alloc,\
|
||||
error: unable to allocate memory for %s", pDescription);
|
||||
|
||||
// Throw an exception.
|
||||
jniThrowException(pEnv, "java/lang/OutOfMemoryError", "unable to allocate memory");
|
||||
}
|
||||
}
|
||||
|
||||
// Return the allocated memory.
|
||||
return(pData);
|
||||
}
|
||||
|
||||
void
|
||||
videoEditOsal_free(
|
||||
void* pData)
|
||||
{
|
||||
// Check if memory was allocated.
|
||||
if (M4OSA_NULL != pData)
|
||||
{
|
||||
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_OSAL", "videoEditOsal_free()");
|
||||
|
||||
// Log the API call.
|
||||
VIDEOEDIT_LOG_API(ANDROID_LOG_INFO, "VIDEO_EDITOR_OSAL", "M4OSA_free()");
|
||||
|
||||
// Free the memory.
|
||||
M4OSA_free((M4OSA_MemAddr32)pData);
|
||||
#ifdef OSAL_MEM_LEAK_DEBUG
|
||||
// Update the allocated block count.
|
||||
gAllocatedBlockCount--;
|
||||
|
||||
// Log the number of allocated blocks.
|
||||
VIDEOEDIT_LOG_ALLOCATION(ANDROID_LOG_ERROR, "VIDEO_EDITOR_OSAL", "allocated, %d blocks",\
|
||||
gAllocatedBlockCount);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
videoEditOsal_getFilePointers ( M4OSA_FileReadPointer *pOsaFileReadPtr,
|
||||
M4OSA_FileWriterPointer *pOsaFileWritePtr)
|
||||
{
|
||||
if (pOsaFileReadPtr != M4OSA_NULL)
|
||||
{
|
||||
// Initialize the filereader function pointers.
|
||||
pOsaFileReadPtr->openRead = M4OSA_fileReadOpen;
|
||||
pOsaFileReadPtr->readData = M4OSA_fileReadData;
|
||||
pOsaFileReadPtr->seek = M4OSA_fileReadSeek;
|
||||
pOsaFileReadPtr->closeRead = M4OSA_fileReadClose;
|
||||
pOsaFileReadPtr->setOption = M4OSA_fileReadSetOption;
|
||||
pOsaFileReadPtr->getOption = M4OSA_fileReadGetOption;
|
||||
}
|
||||
|
||||
if (pOsaFileWritePtr != M4OSA_NULL)
|
||||
{
|
||||
// Initialize the filewriter function pointers.
|
||||
pOsaFileWritePtr->openWrite = M4OSA_fileWriteOpen;
|
||||
pOsaFileWritePtr->writeData = M4OSA_fileWriteData;
|
||||
pOsaFileWritePtr->seek = M4OSA_fileWriteSeek;
|
||||
pOsaFileWritePtr->Flush = M4OSA_fileWriteFlush;
|
||||
pOsaFileWritePtr->closeWrite = M4OSA_fileWriteClose;
|
||||
pOsaFileWritePtr->setOption = M4OSA_fileWriteSetOption;
|
||||
pOsaFileWritePtr->getOption = M4OSA_fileWriteGetOption;
|
||||
}
|
||||
}
|
||||
|
||||
65
media/jni/mediaeditor/VideoEditorOsal.h
Executable file
65
media/jni/mediaeditor/VideoEditorOsal.h
Executable file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 VIDEO_EDITOR_OSAL_H
|
||||
#define VIDEO_EDITOR_OSAL_H
|
||||
|
||||
#include <jni.h>
|
||||
#include <JNIHelp.h>
|
||||
|
||||
extern "C" {
|
||||
#include <M4OSA_Error.h>
|
||||
#include <M4OSA_Thread.h>
|
||||
#include <M4OSA_FileReader.h>
|
||||
#include <M4OSA_FileWriter.h>
|
||||
};
|
||||
|
||||
const char*
|
||||
videoEditOsal_getResultString(
|
||||
M4OSA_ERR result);
|
||||
|
||||
void*
|
||||
videoEditOsal_alloc(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
size_t size,
|
||||
const char* pDescription);
|
||||
|
||||
void
|
||||
videoEditOsal_free(
|
||||
void* pData);
|
||||
|
||||
void
|
||||
videoEditOsal_startThread(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
int stackSize,
|
||||
M4OSA_ThreadDoIt callback,
|
||||
M4OSA_Context* pContext,
|
||||
void* pParam);
|
||||
|
||||
void
|
||||
videoEditOsal_stopThread(
|
||||
bool* pResult,
|
||||
JNIEnv* pEnv,
|
||||
M4OSA_Context* pContext);
|
||||
|
||||
void
|
||||
videoEditOsal_getFilePointers ( M4OSA_FileReadPointer *pOsaFileReadPtr,
|
||||
M4OSA_FileWriterPointer *pOsaFileWritePtr);
|
||||
|
||||
#endif // VIDEO_EDITOR_OSAL_H
|
||||
|
||||
502
media/jni/mediaeditor/VideoEditorPropertiesMain.cpp
Executable file
502
media/jni/mediaeditor/VideoEditorPropertiesMain.cpp
Executable file
@@ -0,0 +1,502 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <utils/Log.h>
|
||||
#include <utils/threads.h>
|
||||
#include <VideoEditorClasses.h>
|
||||
#include <VideoEditorJava.h>
|
||||
#include <VideoEditorOsal.h>
|
||||
#include <VideoEditorLogging.h>
|
||||
#include <VideoEditorOsal.h>
|
||||
#include <marker.h>
|
||||
|
||||
extern "C" {
|
||||
#include <M4OSA_Clock.h>
|
||||
#include <M4OSA_CharStar.h>
|
||||
#include <M4OSA_Error.h>
|
||||
#include <M4OSA_FileCommon.h>
|
||||
#include <M4OSA_FileReader.h>
|
||||
#include <M4OSA_FileWriter.h>
|
||||
#include <M4OSA_Memory.h>
|
||||
#include <M4OSA_String.h>
|
||||
#include <M4OSA_Thread.h>
|
||||
#include <M4VSS3GPP_API.h>
|
||||
#include <M4VSS3GPP_ErrorCodes.h>
|
||||
#include <M4MCS_API.h>
|
||||
#include <M4MCS_ErrorCodes.h>
|
||||
#include <M4MDP_API.h>
|
||||
#include <M4READER_Common.h>
|
||||
#include <M4WRITER_common.h>
|
||||
#include <M4DECODER_Common.h>
|
||||
#include <M4AD_Common.h>
|
||||
};
|
||||
|
||||
extern "C" M4OSA_ERR M4MCS_open_normalMode(
|
||||
M4MCS_Context pContext,
|
||||
M4OSA_Void* pFileIn,
|
||||
M4VIDEOEDITING_FileType InputFileType,
|
||||
M4OSA_Void* pFileOut,
|
||||
M4OSA_Void* pTempFile);
|
||||
|
||||
jobject videoEditProp_getProperties(
|
||||
JNIEnv* pEnv,
|
||||
jobject thiz,
|
||||
jstring file);
|
||||
|
||||
static void
|
||||
getFileAndMediaTypeFromExtension (
|
||||
M4OSA_Char* pExtension,
|
||||
VideoEditClasses_FileType *pFileType,
|
||||
M4VIDEOEDITING_FileType *pClipType);
|
||||
|
||||
static M4OSA_ERR
|
||||
getClipProperties( JNIEnv* pEnv,
|
||||
jobject thiz,
|
||||
M4OSA_Char* pFile,
|
||||
M4VIDEOEDITING_FileType clipType,
|
||||
M4VIDEOEDITING_ClipProperties* pClipProperties);
|
||||
|
||||
M4OSA_UInt32
|
||||
VideoEdit_chrCompare(M4OSA_Char* pStrIn1,
|
||||
M4OSA_Char* pStrIn2,
|
||||
M4OSA_Int32* pCmpResult);
|
||||
|
||||
jobject videoEditProp_getProperties(
|
||||
JNIEnv* pEnv,
|
||||
jobject thiz,
|
||||
jstring file)
|
||||
{
|
||||
bool gotten = true;
|
||||
M4OSA_Char* pFile = M4OSA_NULL;
|
||||
M4OSA_Char* pExtension = M4OSA_NULL;
|
||||
M4OSA_UInt32 index = 0;
|
||||
M4OSA_Int32 cmpResult = 0;
|
||||
VideoEditPropClass_Properties* pProperties = M4OSA_NULL;
|
||||
M4VIDEOEDITING_ClipProperties* pClipProperties = M4OSA_NULL;
|
||||
M4OSA_ERR result = M4NO_ERROR;
|
||||
M4MCS_Context context = M4OSA_NULL;
|
||||
M4OSA_FilePosition size = 0;
|
||||
M4OSA_UInt32 width = 0;
|
||||
M4OSA_UInt32 height = 0;
|
||||
jobject properties = NULL;
|
||||
M4OSA_Context pOMXContext = M4OSA_NULL;
|
||||
M4DECODER_VideoInterface* pOMXVidDecoderInterface = M4OSA_NULL;
|
||||
M4AD_Interface* pOMXAudDecoderInterface = M4OSA_NULL;
|
||||
|
||||
bool initialized = true;
|
||||
VideoEditClasses_FileType fileType = VideoEditClasses_kFileType_Unsupported;
|
||||
M4VIDEOEDITING_FileType clipType = M4VIDEOEDITING_kFileType_Unsupported;
|
||||
|
||||
VIDEOEDIT_LOG_API(
|
||||
ANDROID_LOG_INFO, "VIDEO_EDITOR_PROPERTIES",
|
||||
"videoEditProp_getProperties()");
|
||||
|
||||
// Add a text marker (the condition must always be true).
|
||||
ADD_TEXT_MARKER_FUN(NULL != pEnv)
|
||||
|
||||
// Initialize the classes.
|
||||
videoEditPropClass_init(&initialized, (JNIEnv*)pEnv);
|
||||
|
||||
// Validate the tempPath parameter.
|
||||
videoEditJava_checkAndThrowIllegalArgumentException(
|
||||
&gotten, pEnv, (NULL == file), "file is null");
|
||||
|
||||
// Get the file path.
|
||||
pFile = (M4OSA_Char *)videoEditJava_getString(
|
||||
&gotten, pEnv, file, NULL, M4OSA_NULL);
|
||||
|
||||
result = M4OSA_fileReadOpen(&context, (M4OSA_Void*)pFile, M4OSA_kFileRead);
|
||||
videoEditJava_checkAndThrowIllegalArgumentException(&gotten, pEnv,
|
||||
(M4NO_ERROR != result), "file not found");
|
||||
if(M4NO_ERROR != result)
|
||||
return(properties);
|
||||
result = M4OSA_fileReadClose(context);
|
||||
context = M4OSA_NULL;
|
||||
|
||||
// Check if the file path is valid.
|
||||
if (gotten)
|
||||
{
|
||||
// Retrieve the extension.
|
||||
result = M4OSA_chrReverseFindChar(pFile, '.', &pExtension);
|
||||
if ((M4NO_ERROR == result) && (M4OSA_NULL != pExtension))
|
||||
{
|
||||
// Skip the dot.
|
||||
pExtension++;
|
||||
|
||||
// Get the file type and Media type from extension
|
||||
getFileAndMediaTypeFromExtension(
|
||||
pExtension ,&fileType, &clipType);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the file type could be determined.
|
||||
videoEditJava_checkAndThrowIllegalArgumentException(
|
||||
&gotten, pEnv,
|
||||
(VideoEditClasses_kFileType_Unsupported == fileType),
|
||||
"file type is not supported");
|
||||
|
||||
// Allocate a new properties structure.
|
||||
pProperties = (VideoEditPropClass_Properties*)videoEditOsal_alloc(
|
||||
&gotten, pEnv,
|
||||
sizeof(VideoEditPropClass_Properties), "Properties");
|
||||
|
||||
// Check if the context is valid and allocation succeeded
|
||||
// (required because of dereferencing of pProperties).
|
||||
if (gotten)
|
||||
{
|
||||
// Check if this type of file needs to be analyzed using MCS.
|
||||
if ((VideoEditClasses_kFileType_MP3 == fileType) ||
|
||||
(VideoEditClasses_kFileType_MP4 == fileType) ||
|
||||
(VideoEditClasses_kFileType_3GPP == fileType) ||
|
||||
(VideoEditClasses_kFileType_AMR == fileType) ||
|
||||
(VideoEditClasses_kFileType_PCM == fileType))
|
||||
{
|
||||
// Allocate a new clip properties structure.
|
||||
pClipProperties =
|
||||
(M4VIDEOEDITING_ClipProperties*)videoEditOsal_alloc(
|
||||
&gotten, pEnv,
|
||||
sizeof(M4VIDEOEDITING_ClipProperties), "ClipProperties");
|
||||
|
||||
// Check if allocation succeeded (required because of
|
||||
// dereferencing of pClipProperties).
|
||||
if (gotten)
|
||||
{
|
||||
// Add a code marker (the condition must always be true).
|
||||
ADD_CODE_MARKER_FUN(NULL != pClipProperties)
|
||||
|
||||
// Log the API call.
|
||||
VIDEOEDIT_LOG_API(
|
||||
ANDROID_LOG_INFO, "VIDEO_EDITOR_PROPERTIES",
|
||||
"getClipProperties");
|
||||
|
||||
// Get Video clip properties
|
||||
result = getClipProperties(
|
||||
pEnv, thiz, pFile, clipType, pClipProperties);
|
||||
|
||||
// Check if the creation succeeded.
|
||||
videoEditJava_checkAndThrowIllegalArgumentException(
|
||||
&gotten, pEnv,(M4NO_ERROR != result),
|
||||
"Invalid File or File not found");
|
||||
|
||||
if (pClipProperties->uiVideoWidth >= 1920)
|
||||
{
|
||||
result = M4MCS_ERR_INPUT_FILE_CONTAINS_NO_SUPPORTED_STREAM;
|
||||
videoEditJava_checkAndThrowIllegalArgumentException(
|
||||
&gotten, pEnv, (M4NO_ERROR != result),
|
||||
"HD Content (1080p) is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the properties could be retrieved.
|
||||
if (gotten)
|
||||
{
|
||||
// Set the properties.
|
||||
pProperties->uiClipDuration = pClipProperties->uiClipDuration;
|
||||
if (M4VIDEOEDITING_kFileType_Unsupported == pClipProperties->FileType)
|
||||
{
|
||||
pProperties->FileType = VideoEditClasses_kFileType_Unsupported;
|
||||
}
|
||||
else
|
||||
{
|
||||
pProperties->FileType = fileType;
|
||||
}
|
||||
pProperties->VideoStreamType = pClipProperties->VideoStreamType;
|
||||
pProperties->uiClipVideoDuration = pClipProperties->uiClipVideoDuration;
|
||||
pProperties->uiVideoBitrate = pClipProperties->uiVideoBitrate;
|
||||
pProperties->uiVideoWidth = pClipProperties->uiVideoWidth;
|
||||
pProperties->uiVideoHeight = pClipProperties->uiVideoHeight;
|
||||
pProperties->fAverageFrameRate = pClipProperties->fAverageFrameRate;
|
||||
pProperties->ProfileAndLevel = pClipProperties->ProfileAndLevel;
|
||||
pProperties->AudioStreamType = pClipProperties->AudioStreamType;
|
||||
pProperties->uiClipAudioDuration = pClipProperties->uiClipAudioDuration;
|
||||
pProperties->uiAudioBitrate = pClipProperties->uiAudioBitrate;
|
||||
pProperties->uiNbChannels = pClipProperties->uiNbChannels;
|
||||
pProperties->uiSamplingFrequency = pClipProperties->uiSamplingFrequency;
|
||||
}
|
||||
|
||||
// Free the clip properties.
|
||||
videoEditOsal_free(pClipProperties);
|
||||
pClipProperties = M4OSA_NULL;
|
||||
}
|
||||
else if ((VideoEditClasses_kFileType_JPG == fileType) ||
|
||||
(VideoEditClasses_kFileType_GIF == fileType) ||
|
||||
(VideoEditClasses_kFileType_PNG == fileType))
|
||||
{
|
||||
pProperties->uiClipDuration = 0;
|
||||
pProperties->FileType = fileType;
|
||||
pProperties->VideoStreamType = M4VIDEOEDITING_kNoneVideo;
|
||||
pProperties->uiClipVideoDuration = 0;
|
||||
pProperties->uiVideoBitrate = 0;
|
||||
pProperties->uiVideoWidth = width;
|
||||
pProperties->uiVideoHeight = height;
|
||||
pProperties->fAverageFrameRate = 0.0f;
|
||||
pProperties->ProfileAndLevel = M4VIDEOEDITING_kProfile_and_Level_Out_Of_Range;
|
||||
pProperties->AudioStreamType = M4VIDEOEDITING_kNoneAudio;
|
||||
pProperties->uiClipAudioDuration = 0;
|
||||
pProperties->uiAudioBitrate = 0;
|
||||
pProperties->uiNbChannels = 0;
|
||||
pProperties->uiSamplingFrequency = 0;
|
||||
|
||||
// Added for Handling invalid paths and non existent image files
|
||||
// Open the file for reading.
|
||||
result = M4OSA_fileReadOpen(&context, (M4OSA_Void*)pFile, M4OSA_kFileRead);
|
||||
if (M4NO_ERROR != result)
|
||||
{
|
||||
pProperties->FileType = VideoEditClasses_kFileType_Unsupported;
|
||||
}
|
||||
result = M4OSA_fileReadClose(context);
|
||||
context = M4OSA_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a properties object.
|
||||
videoEditPropClass_createProperties(&gotten, pEnv, pProperties, &properties);
|
||||
|
||||
// Log the properties.
|
||||
VIDEOEDIT_PROP_LOG_PROPERTIES(pProperties);
|
||||
|
||||
// Free the properties.
|
||||
videoEditOsal_free(pProperties);
|
||||
pProperties = M4OSA_NULL;
|
||||
|
||||
// Free the file path.
|
||||
videoEditOsal_free(pFile);
|
||||
pFile = M4OSA_NULL;
|
||||
|
||||
// Add a text marker (the condition must always be true).
|
||||
ADD_TEXT_MARKER_FUN(NULL != pEnv)
|
||||
|
||||
// Return the Properties object.
|
||||
return(properties);
|
||||
}
|
||||
|
||||
static void getFileAndMediaTypeFromExtension (
|
||||
M4OSA_Char *pExtension,
|
||||
VideoEditClasses_FileType *pFileType,
|
||||
M4VIDEOEDITING_FileType *pClipType)
|
||||
{
|
||||
M4OSA_Char extension[5] = {0, 0, 0, 0, 0};
|
||||
VideoEditClasses_FileType fileType =
|
||||
VideoEditClasses_kFileType_Unsupported;
|
||||
|
||||
M4VIDEOEDITING_FileType clipType =
|
||||
M4VIDEOEDITING_kFileType_Unsupported;
|
||||
|
||||
M4OSA_UInt32 index = 0;
|
||||
M4OSA_ERR result = M4NO_ERROR;
|
||||
M4OSA_Int32 cmpResult = 0;
|
||||
M4OSA_UInt32 extLength = M4OSA_chrLength(pExtension);
|
||||
|
||||
// Assign default
|
||||
*pFileType = VideoEditClasses_kFileType_Unsupported;
|
||||
*pClipType = M4VIDEOEDITING_kFileType_Unsupported;
|
||||
|
||||
// Check if the length of the extension is valid.
|
||||
if ((3 == extLength) || (4 == extLength))
|
||||
{
|
||||
// Convert the extension to lowercase.
|
||||
for (index = 0; index < extLength ; index++)
|
||||
{
|
||||
extension[index] = M4OSA_chrToLower(pExtension[index]);
|
||||
}
|
||||
|
||||
// Check if the extension is ".mp3".
|
||||
if (!(VideoEdit_chrCompare(extension, (M4OSA_Char*)"mp3", &cmpResult)))
|
||||
{
|
||||
*pFileType = VideoEditClasses_kFileType_MP3;
|
||||
*pClipType = M4VIDEOEDITING_kFileType_MP3;
|
||||
} // Check if the extension is ".mp4".
|
||||
else if (!(VideoEdit_chrCompare(extension, (M4OSA_Char*)"mp4", &cmpResult)))
|
||||
{
|
||||
*pFileType = VideoEditClasses_kFileType_MP4;
|
||||
*pClipType = M4VIDEOEDITING_kFileType_MP4;
|
||||
}
|
||||
// Check if the extension is ".3gp".
|
||||
else if (!(VideoEdit_chrCompare(extension, (M4OSA_Char*)"3gp", &cmpResult)))
|
||||
{
|
||||
*pFileType = VideoEditClasses_kFileType_3GPP;
|
||||
*pClipType = M4VIDEOEDITING_kFileType_3GPP;
|
||||
}
|
||||
// Check if the extension is ".3gp".
|
||||
else if (!(VideoEdit_chrCompare(extension, (M4OSA_Char*)"m4a", &cmpResult)))
|
||||
{
|
||||
*pFileType = VideoEditClasses_kFileType_3GPP;
|
||||
*pClipType = M4VIDEOEDITING_kFileType_3GPP;
|
||||
}
|
||||
// Check if the extension is ".3gpp".
|
||||
else if (!(VideoEdit_chrCompare(extension, (M4OSA_Char*)"3gpp", &cmpResult)))
|
||||
{
|
||||
*pFileType = VideoEditClasses_kFileType_3GPP;
|
||||
*pClipType = M4VIDEOEDITING_kFileType_3GPP;
|
||||
}
|
||||
// Check if the extension is ".amr".
|
||||
else if (!(VideoEdit_chrCompare(extension, (M4OSA_Char*)"amr", &cmpResult)))
|
||||
{
|
||||
|
||||
*pFileType = VideoEditClasses_kFileType_AMR;
|
||||
*pClipType = M4VIDEOEDITING_kFileType_AMR;
|
||||
}
|
||||
// Check if the extension is ".pcm".
|
||||
else if (!(VideoEdit_chrCompare(extension, (M4OSA_Char*)"pcm", &cmpResult)))
|
||||
{
|
||||
*pFileType = VideoEditClasses_kFileType_PCM;
|
||||
*pClipType = M4VIDEOEDITING_kFileType_PCM;
|
||||
}
|
||||
// Check if the extension is ".jpg".
|
||||
else if (!(VideoEdit_chrCompare(extension, (M4OSA_Char*)"jpg", &cmpResult)))
|
||||
{
|
||||
*pFileType = VideoEditClasses_kFileType_JPG;
|
||||
}
|
||||
// Check if the extension is ".jpeg".
|
||||
else if (!(VideoEdit_chrCompare(extension, (M4OSA_Char*)"jpeg", &cmpResult)))
|
||||
{
|
||||
*pFileType = VideoEditClasses_kFileType_JPG;
|
||||
}
|
||||
// Check if the extension is ".gif".
|
||||
else if (!(VideoEdit_chrCompare(extension, (M4OSA_Char*)"gif", &cmpResult)))
|
||||
{
|
||||
*pFileType = VideoEditClasses_kFileType_GIF;
|
||||
}
|
||||
// Check if the extension is ".png".
|
||||
else if (!(VideoEdit_chrCompare(extension, (M4OSA_Char*)"png", &cmpResult)))
|
||||
{
|
||||
*pFileType = VideoEditClasses_kFileType_PNG;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static M4OSA_ERR getClipProperties(
|
||||
JNIEnv* pEnv,
|
||||
jobject thiz,
|
||||
M4OSA_Char* pFile,
|
||||
M4VIDEOEDITING_FileType clipType,
|
||||
M4VIDEOEDITING_ClipProperties* pClipProperties)
|
||||
{
|
||||
bool gotten = true;
|
||||
M4OSA_ERR result = M4NO_ERROR;
|
||||
M4OSA_ERR resultAbort = M4NO_ERROR;
|
||||
M4MCS_Context context = M4OSA_NULL;
|
||||
|
||||
M4OSA_FileReadPointer fileReadPtr =
|
||||
{ M4OSA_NULL, M4OSA_NULL, M4OSA_NULL,
|
||||
M4OSA_NULL, M4OSA_NULL, M4OSA_NULL };
|
||||
|
||||
M4OSA_FileWriterPointer fileWritePtr =
|
||||
{ M4OSA_NULL, M4OSA_NULL, M4OSA_NULL,
|
||||
M4OSA_NULL, M4OSA_NULL, M4OSA_NULL, M4OSA_NULL };
|
||||
|
||||
// Initialize the OSAL file system function pointers.
|
||||
videoEditOsal_getFilePointers(&fileReadPtr , &fileWritePtr);
|
||||
|
||||
// Log the API call.
|
||||
VIDEOEDIT_LOG_API(
|
||||
ANDROID_LOG_INFO, "VIDEO_EDITOR_PROPERTIES",\
|
||||
"getClipProperties - M4MCS_init()");
|
||||
|
||||
// Initialize the MCS context.
|
||||
result = M4MCS_init(&context, &fileReadPtr, &fileWritePtr);
|
||||
|
||||
// Log the result.
|
||||
VIDEOEDIT_PROP_LOG_RESULT(
|
||||
ANDROID_LOG_INFO, "VIDEO_EDITOR_PROPERTIES", "%s",
|
||||
videoEditOsal_getResultString(result));
|
||||
|
||||
// Check if the creation succeeded.
|
||||
videoEditJava_checkAndThrowRuntimeException(
|
||||
&gotten, pEnv, (M4NO_ERROR != result), result);
|
||||
|
||||
// Check if opening the MCS context succeeded.
|
||||
if (gotten)
|
||||
{
|
||||
// Log the API call.
|
||||
VIDEOEDIT_LOG_API(
|
||||
ANDROID_LOG_INFO, "VIDEO_EDITOR_PROPERTIES",
|
||||
"getClipProperties - M4MCS_open_normalMode()");
|
||||
|
||||
// Open the MCS in the normal opening mode to
|
||||
// retrieve the exact duration
|
||||
result = M4MCS_open_normalMode(
|
||||
context, pFile, clipType, M4OSA_NULL, M4OSA_NULL);
|
||||
|
||||
// Log the result.
|
||||
VIDEOEDIT_PROP_LOG_RESULT(
|
||||
ANDROID_LOG_INFO, "VIDEO_EDITOR_PROPERTIES", "%s",
|
||||
videoEditOsal_getResultString(result));
|
||||
|
||||
// Check if the creation succeeded.
|
||||
videoEditJava_checkAndThrowRuntimeException(
|
||||
&gotten, pEnv, (M4NO_ERROR != result), result);
|
||||
|
||||
// Check if the MCS could be opened.
|
||||
if (gotten)
|
||||
{
|
||||
// Log the API call.
|
||||
VIDEOEDIT_LOG_API(
|
||||
ANDROID_LOG_INFO, "VIDEO_EDITOR_PROPERTIES",
|
||||
"getClipProperties - M4MCS_getInputFileProperties()");
|
||||
|
||||
// Get the properties.
|
||||
result = M4MCS_getInputFileProperties(context, pClipProperties);
|
||||
|
||||
// Log the result.
|
||||
VIDEOEDIT_PROP_LOG_RESULT(
|
||||
ANDROID_LOG_INFO, "VIDEO_EDITOR_PROPERTIES", "%s",
|
||||
videoEditOsal_getResultString(result));
|
||||
|
||||
// Check if the creation succeeded.
|
||||
videoEditJava_checkAndThrowRuntimeException(
|
||||
&gotten, pEnv, (M4NO_ERROR != result), result);
|
||||
}
|
||||
|
||||
// Log the API call.
|
||||
VIDEOEDIT_LOG_API(
|
||||
ANDROID_LOG_INFO, "VIDEO_EDITOR_PROPERTIES",
|
||||
"getClipProperties - M4MCS_abort()");
|
||||
|
||||
// Close the MCS session.
|
||||
resultAbort = M4MCS_abort(context);
|
||||
|
||||
if (result == M4NO_ERROR) {
|
||||
// Log the result.
|
||||
VIDEOEDIT_PROP_LOG_RESULT(
|
||||
ANDROID_LOG_INFO, "VIDEO_EDITOR_PROPERTIES", "%s",
|
||||
videoEditOsal_getResultString(resultAbort));
|
||||
|
||||
// Check if the abort succeeded.
|
||||
videoEditJava_checkAndThrowRuntimeException(
|
||||
&gotten, pEnv, (M4NO_ERROR != resultAbort), resultAbort);
|
||||
result = resultAbort;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
M4OSA_UInt32
|
||||
VideoEdit_chrCompare(M4OSA_Char* pStrIn1,
|
||||
M4OSA_Char* pStrIn2,
|
||||
M4OSA_Int32* pCmpResult)
|
||||
{
|
||||
M4OSA_chrCompare(pStrIn1, pStrIn2, pCmpResult);
|
||||
return *pCmpResult;
|
||||
}
|
||||
|
||||
|
||||
330
media/jni/mediaeditor/VideoEditorThumbnailMain.cpp
Executable file
330
media/jni/mediaeditor/VideoEditorThumbnailMain.cpp
Executable file
@@ -0,0 +1,330 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#include <jni.h>
|
||||
#include <JNIHelp.h>
|
||||
#include <utils/Log.h>
|
||||
#include "VideoBrowserMain.h"
|
||||
#include "VideoBrowserInternal.h"
|
||||
|
||||
#if (M4OSA_TRACE_LEVEL >= 1)
|
||||
#undef M4OSA_TRACE1_0
|
||||
#undef M4OSA_TRACE1_1
|
||||
#undef M4OSA_TRACE1_2
|
||||
#undef M4OSA_TRACE1_3
|
||||
|
||||
#define M4OSA_TRACE1_0(a) __android_log_print(ANDROID_LOG_INFO, "Thumbnail", a);
|
||||
#define M4OSA_TRACE1_1(a,b) __android_log_print(ANDROID_LOG_INFO, "Thumbnail", a,b);
|
||||
#define M4OSA_TRACE1_2(a,b,c) __android_log_print(ANDROID_LOG_INFO, "Thumbnail", a,b,c);
|
||||
#define M4OSA_TRACE1_3(a,b,c,d) __android_log_print(ANDROID_LOG_INFO, "Thumbnail", a,b,c,d);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Memory format of 'ARGB8888' in skia is RGBA, so ABGR in 32bit little-endian packed format
|
||||
* bitmap format is rgb565
|
||||
*/
|
||||
// RED GREEN BLUE ALPHA
|
||||
#define RGB565toSKCOLOR(c) ( (((c)&0xF800)>>8) | (((c)&0x7E0)<<5) | (((c)&0x1F)<<19) | 0xFF000000)
|
||||
|
||||
#define GetIntField(env, obj, name) env->GetIntField(obj,\
|
||||
env->GetFieldID(env->GetObjectClass(obj), name, "I"))
|
||||
|
||||
extern "C" M4OSA_ERR NXPSW_FileReaderOptim_init(M4OSA_Void *lowLevel_functionPointers,
|
||||
M4OSA_Void *optimized_functionPointers);
|
||||
|
||||
/*
|
||||
* Video Browser execution context.
|
||||
* Based on request for RGB565 or RGB888, m_dst16 or m_dst32
|
||||
* will be initialized and used
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
M4OSA_Context m_pVideoBrowser;
|
||||
M4OSA_UInt32 m_previousTime;
|
||||
M4OSA_Int32* m_dst32;
|
||||
M4OSA_Int16* m_dst16;
|
||||
unsigned int m_width;
|
||||
unsigned int m_height;
|
||||
M4OSA_Bool m_bRender;
|
||||
} ThumbnailContext;
|
||||
|
||||
/**
|
||||
************************************************************************
|
||||
* @brief Interface to retrieve the thumbnail pixels
|
||||
* @param pContext (IN) Thumbnail Context.
|
||||
* @param width (IN) Width of thumbnail
|
||||
* @param height (IN) Height of thumbnail
|
||||
* @param pTimeMS (IN/OUT)Time stamp at which thumbnail is retrieved.
|
||||
************************************************************************
|
||||
*/
|
||||
M4OSA_ERR ThumbnailGetPixels(const M4OSA_Context pContext,
|
||||
M4OSA_Int32* pixelArray,
|
||||
M4OSA_UInt32 width, M4OSA_UInt32 height,
|
||||
M4OSA_UInt32* pTimeMS);
|
||||
|
||||
|
||||
/**
|
||||
************************************************************************
|
||||
* @brief Video browser callback, called when a frame must be displayed
|
||||
* @param pInstance (IN) Thumbnail context.
|
||||
* @param notificationID (IN) Id of the callback which generated the error
|
||||
* @param errCode (IN) Error code from the Core
|
||||
* @param pCbData (IN) pointer to data associated wit the callback.
|
||||
* @param pCbUserData (IN) pointer to application user data passed in init.
|
||||
* @note This callback mechanism is used to request display of an image
|
||||
************************************************************************
|
||||
*/
|
||||
M4OSA_Void VBcallback( M4OSA_Context pInstance,
|
||||
VideoBrowser_Notification notificationID,
|
||||
M4OSA_ERR errCode, M4OSA_Void* pCbData,
|
||||
M4OSA_Void* pCallbackUserData)
|
||||
{
|
||||
M4OSA_UInt32 i, j;
|
||||
M4OSA_ERR err;
|
||||
|
||||
M4OSA_TRACE3_0("inside VBcallback");
|
||||
M4VIFI_ImagePlane* pPlane=NULL;
|
||||
M4OSA_UInt16* src=NULL;
|
||||
ThumbnailContext* pC = NULL;
|
||||
|
||||
CHECK_PTR(VBcallback, pCbData, err, M4ERR_PARAMETER);
|
||||
CHECK_PTR(VBcallback, pInstance,err, M4ERR_PARAMETER);
|
||||
|
||||
pC = (ThumbnailContext*)pCallbackUserData ;
|
||||
CHECK_PTR(VBcallback, pC->m_pVideoBrowser, err, M4ERR_PARAMETER);
|
||||
|
||||
pPlane = (M4VIFI_ImagePlane*)pCbData;
|
||||
src = (M4OSA_UInt16*)pPlane->pac_data;
|
||||
|
||||
if (pC->m_dst32 != NULL)
|
||||
{
|
||||
M4OSA_Int32* dst = pC->m_dst32;
|
||||
|
||||
for (j = 0; j < pPlane->u_height; j++)
|
||||
{
|
||||
for (i = 0; i < pPlane->u_width; i++)
|
||||
{
|
||||
dst[i] = RGB565toSKCOLOR(src[i]);
|
||||
}
|
||||
for (i = pPlane->u_width; i < pC->m_width; i++)
|
||||
{
|
||||
dst[i] = 0;
|
||||
}
|
||||
src = (M4OSA_UInt16*)((M4OSA_UInt8*)src + pPlane->u_stride);
|
||||
dst += pC->m_width;
|
||||
}
|
||||
}
|
||||
else if (pC->m_dst16 != NULL)
|
||||
{
|
||||
M4OSA_Int16* dst = pC->m_dst16;
|
||||
|
||||
for (j = 0; j < pPlane->u_height; j++)
|
||||
{
|
||||
M4OSA_memcpy((M4OSA_MemAddr8 )dst, (M4OSA_MemAddr8 )src, pPlane->u_stride);
|
||||
for (i = pPlane->u_width; i < pC->m_width; i++)
|
||||
{
|
||||
dst[i] = 0;
|
||||
}
|
||||
src = (M4OSA_UInt16*)((M4OSA_UInt8*)src + pPlane->u_stride);
|
||||
dst += pC->m_width;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECK_PTR(VBcallback, NULL, err, M4ERR_PARAMETER);
|
||||
}
|
||||
|
||||
VBcallback_cleanUp:
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
M4OSA_ERR ThumbnailOpen(M4OSA_Context *pPContext,
|
||||
const M4OSA_Char *pString,
|
||||
M4OSA_Bool bRender)
|
||||
{
|
||||
|
||||
M4OSA_ERR err;
|
||||
ThumbnailContext *pContext = M4OSA_NULL;
|
||||
VideoBrowser_VideoColorType vbColorType;
|
||||
|
||||
CHECK_PTR(ThumbnailOpen, pString, err, M4ERR_BAD_CONTEXT);
|
||||
|
||||
/*--- Create context ---*/
|
||||
pContext = (ThumbnailContext*)M4OSA_malloc(sizeof(ThumbnailContext), VIDEOBROWSER,
|
||||
(M4OSA_Char*)"Thumbnail context") ;
|
||||
M4OSA_TRACE3_1("context value is = %d",pContext);
|
||||
CHECK_PTR(ThumbnailOpen, pContext, err, M4ERR_ALLOC);
|
||||
|
||||
M4OSA_memset((M4OSA_MemAddr8)pContext, sizeof(ThumbnailContext), 0);
|
||||
|
||||
M4OSA_FileReadPointer optFP;
|
||||
M4OSA_FileReadPointer llFP;
|
||||
|
||||
NXPSW_FileReaderOptim_init(&llFP, &optFP);
|
||||
M4OSA_TRACE1_2("ThumbnailOpen: entering videoBrowserCreate with 0x%x %s",
|
||||
&pContext->m_pVideoBrowser, pString) ;
|
||||
|
||||
pContext->m_bRender = bRender;
|
||||
if (bRender == M4OSA_TRUE) {
|
||||
//Open is called for rendering the frame.
|
||||
//So set YUV420 as the output color format.
|
||||
vbColorType = VideoBrowser_kYUV420;
|
||||
} else {
|
||||
//Open is called for thumbnail Extraction
|
||||
//So set BGR565 as the output.
|
||||
vbColorType = VideoBrowser_kGB565;
|
||||
}
|
||||
|
||||
err = videoBrowserCreate(&pContext->m_pVideoBrowser, (M4OSA_Char*)pString,
|
||||
VideoBrowser_kVBNormalBliting, &optFP, VBcallback, pContext, vbColorType);
|
||||
|
||||
M4OSA_TRACE1_1("err value is = 0x%x",err);
|
||||
CHECK_ERR(ThumbnailOpen, err);
|
||||
CHECK_PTR(ThumbnailOpen, pContext->m_pVideoBrowser, err, M4ERR_ALLOC);
|
||||
|
||||
*pPContext = pContext;
|
||||
M4OSA_TRACE1_1("context value is = %d",*pPContext);
|
||||
|
||||
return M4NO_ERROR;
|
||||
|
||||
ThumbnailOpen_cleanUp:
|
||||
|
||||
M4OSA_TRACE1_0("i am inside cleanUP");
|
||||
if (M4OSA_NULL != pContext)
|
||||
{
|
||||
if (M4OSA_NULL != pContext->m_pVideoBrowser)
|
||||
{
|
||||
videoBrowserCleanUp(pContext->m_pVideoBrowser) ;
|
||||
}
|
||||
M4OSA_free((M4OSA_MemAddr32)pContext) ;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
M4OSA_ERR ThumbnailGetPixels(const M4OSA_Context pContext,
|
||||
M4OSA_Int32* pixelArray,
|
||||
M4OSA_UInt32 width, M4OSA_UInt32 height,
|
||||
M4OSA_UInt32* pTimeMS)
|
||||
{
|
||||
M4OSA_ERR err;
|
||||
|
||||
ThumbnailContext* pC = (ThumbnailContext*)pContext;
|
||||
|
||||
if ((pC->m_width != width) || (pC->m_height != height))
|
||||
{
|
||||
err = videoBrowserSetWindow(pC->m_pVideoBrowser, pixelArray,
|
||||
0, 0, width, height);
|
||||
CHECK_ERR(ThumbnailGetPixels, err);
|
||||
pC->m_width = width;
|
||||
pC->m_height = height;
|
||||
}
|
||||
|
||||
// Alter the pTimeMS to a valid value at which a frame is found
|
||||
// m_currentCTS has the actual frame time stamp just ahead of the
|
||||
// pTimeMS supplied.
|
||||
if ((((VideoBrowserContext*)pC->m_pVideoBrowser)->m_currentCTS != 0) &&
|
||||
(*pTimeMS >= pC->m_previousTime) &&
|
||||
(*pTimeMS < ((VideoBrowserContext*)pC->m_pVideoBrowser)->m_currentCTS))
|
||||
{
|
||||
pC->m_previousTime = *pTimeMS;
|
||||
*pTimeMS = ((VideoBrowserContext*)pC->m_pVideoBrowser)->m_currentCTS;
|
||||
}
|
||||
else
|
||||
{
|
||||
pC->m_previousTime = *pTimeMS;
|
||||
}
|
||||
|
||||
err = videoBrowserPrepareFrame(pC->m_pVideoBrowser, pTimeMS);
|
||||
CHECK_ERR(ThumbnailGetPixels, err);
|
||||
|
||||
if (pC->m_bRender != M4OSA_TRUE) {
|
||||
err = videoBrowserDisplayCurrentFrame(pC->m_pVideoBrowser);
|
||||
CHECK_ERR(ThumbnailGetPixels, err);
|
||||
}
|
||||
|
||||
ThumbnailGetPixels_cleanUp:
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
M4OSA_ERR ThumbnailGetPixels32(const M4OSA_Context pContext,
|
||||
M4OSA_Int32* pixelArray, M4OSA_UInt32 width,
|
||||
M4OSA_UInt32 height, M4OSA_UInt32* timeMS)
|
||||
{
|
||||
|
||||
M4OSA_ERR err = M4NO_ERROR;
|
||||
|
||||
ThumbnailContext* pC = (ThumbnailContext*)pContext;
|
||||
|
||||
CHECK_PTR(ThumbnailGetPixels32, pC->m_pVideoBrowser, err, M4ERR_ALLOC) ;
|
||||
CHECK_PTR(ThumbnailGetPixels32, pixelArray, err, M4ERR_ALLOC) ;
|
||||
|
||||
pC->m_dst16 = NULL;
|
||||
pC->m_dst32 = pixelArray;
|
||||
|
||||
err = ThumbnailGetPixels(pContext, pixelArray, width, height, timeMS);
|
||||
|
||||
ThumbnailGetPixels32_cleanUp:
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
M4OSA_ERR ThumbnailGetPixels16(const M4OSA_Context pContext,
|
||||
M4OSA_Int16* pixelArray, M4OSA_UInt32 width,
|
||||
M4OSA_UInt32 height, M4OSA_UInt32* timeMS)
|
||||
{
|
||||
M4OSA_ERR err = M4NO_ERROR;
|
||||
|
||||
ThumbnailContext* pC = (ThumbnailContext*)pContext;
|
||||
|
||||
CHECK_PTR(ThumbnailGetPixels16, pC->m_pVideoBrowser, err, M4ERR_ALLOC);
|
||||
CHECK_PTR(ThumbnailGetPixels16, pixelArray, err, M4ERR_ALLOC);
|
||||
|
||||
pC->m_dst16 = pixelArray;
|
||||
pC->m_dst32 = NULL;
|
||||
|
||||
err = ThumbnailGetPixels(pContext, (M4OSA_Int32*)pixelArray, width, height, timeMS);
|
||||
|
||||
ThumbnailGetPixels16_cleanUp:
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
void ThumbnailClose(const M4OSA_Context pContext)
|
||||
{
|
||||
M4OSA_ERR err;
|
||||
|
||||
ThumbnailContext* pC = (ThumbnailContext*)pContext;
|
||||
|
||||
CHECK_PTR(ThumbnailClose, pC, err, M4ERR_ALLOC);
|
||||
|
||||
if (M4OSA_NULL != pC)
|
||||
{
|
||||
if (M4OSA_NULL != pC->m_pVideoBrowser)
|
||||
{
|
||||
videoBrowserCleanUp(pC->m_pVideoBrowser);
|
||||
}
|
||||
M4OSA_free((M4OSA_MemAddr32)pC);
|
||||
}
|
||||
|
||||
ThumbnailClose_cleanUp:
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
76
media/jni/mediaeditor/VideoEditorThumbnailMain.h
Executable file
76
media/jni/mediaeditor/VideoEditorThumbnailMain.h
Executable file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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 VIDEOEDITOR_THUMBNAIL_MAIN_H
|
||||
#define VIDEOEDITOR_THUMBNAIL_MAIN_H
|
||||
|
||||
/**
|
||||
************************************************************************
|
||||
* @file VideoEditorThumbnailMain.h
|
||||
* @brief Thumbnail extract interface.
|
||||
************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
************************************************************************
|
||||
* @brief Interface to open a Thumbnail session.
|
||||
* @param pContext (OUT) Thumbnail Context.
|
||||
* @param pString (IN) File path from which thumbnail will be
|
||||
* retrieved
|
||||
* @param M4OSA_Bool (IN) true if this is for rendering at native layer.
|
||||
************************************************************************
|
||||
*/
|
||||
M4OSA_ERR ThumbnailOpen(M4OSA_Context *pPContext,
|
||||
const M4OSA_Char *pString,
|
||||
M4OSA_Bool bRender);
|
||||
|
||||
/**
|
||||
************************************************************************
|
||||
* @brief Interface to retrieve a RGB888 format thumbnail pixels
|
||||
* @param pContext (IN) Thumbnail Context.
|
||||
* @param pixelArray (OUT) Pointer to array in which pixels data to return
|
||||
* @param width (IN) Width of thumbnail
|
||||
* @param height (IN) Height of thumbnail
|
||||
* @param pTimeMS (IN/OUT)Time stamp at which thumbnail is retrieved.
|
||||
************************************************************************
|
||||
*/
|
||||
M4OSA_ERR ThumbnailGetPixels32(const M4OSA_Context pContext,
|
||||
M4OSA_Int32* pixelArray, M4OSA_UInt32 width,
|
||||
M4OSA_UInt32 height, M4OSA_UInt32 *timeMS);
|
||||
|
||||
/**
|
||||
************************************************************************
|
||||
* @brief Interface to retrieve a RGB565 format thumbnail pixels
|
||||
* @param pContext (IN) Thumbnail Context.
|
||||
* @param pixelArray (OUT) Pointer to array in which pixcel data to return
|
||||
* @param width (IN) Width of thumbnail
|
||||
* @param height (IN) Height of thumbnail
|
||||
* @param pTimeMS (IN/OUT)Time stamp at which thumbnail is retrieved.
|
||||
************************************************************************
|
||||
*/
|
||||
M4OSA_ERR ThumbnailGetPixels16(const M4OSA_Context pContext,
|
||||
M4OSA_Int16* pixelArray, M4OSA_UInt32 width,
|
||||
M4OSA_UInt32 height, M4OSA_UInt32 *timeMS);
|
||||
|
||||
/**
|
||||
************************************************************************
|
||||
* @brief Interface to close the Thumbnail session.
|
||||
* @param pContext (IN) Thumbnail Context.
|
||||
************************************************************************
|
||||
*/
|
||||
void ThumbnailClose(const M4OSA_Context pContext);
|
||||
|
||||
#endif // VIDEOEDITOR_THUMBNAIL_MAIN_H
|
||||
Reference in New Issue
Block a user