blob: b2b510f218949a9ed920aa4ab2872e5f61ec4e5b [file] [log] [blame]
/*************************************************************************************
* INTEL CONFIDENTIAL
* Copyright 2011 Intel Corporation All Rights Reserved.
* The source code contained or described herein and all documents related
* to the source code ("Material") are owned by Intel Corporation or its
* suppliers or licensors. Title to the Material remains with Intel
* Corporation or its suppliers and licensors. The Material contains trade
* secrets and proprietary and confidential information of Intel or its
* suppliers and licensors. The Material is protected by worldwide copyright
* and trade secret laws and treaty provisions. No part of the Material may
* be used, copied, reproduced, modified, published, uploaded, posted,
* transmitted, distributed, or disclosed in any way without Intel's prior
* express written permission.
*
* No license under any patent, copyright, trade secret or other intellectual
* property right is granted to or conferred upon you by disclosure or delivery
* of the Materials, either expressly, by implication, inducement, estoppel or
* otherwise. Any license under such intellectual property rights must be express
* and approved by Intel in writing.
************************************************************************************/
/*
* 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.
*/
/**
*************************************************************************
* @file VideoEditorBuffer.h
* @brief StageFright shell Buffer
*************************************************************************
*/
#ifndef VIDEOEDITOR_BUFFER_H
#define VIDEOEDITOR_BUFFER_H
#include "M4OSA_Types.h"
#include "M4OSA_Debug.h"
#include "M4OSA_Memory.h"
#include "M4OSA_CharStar.h"
#include "M4_Utils.h"
#include "LV_Macros.h"
#include <media/stagefright/MediaBuffer.h>
using namespace android;
/*--- Core id for VIDEOEDITOR Buffer allocations ---*/
#define VIDEOEDITOR_BUFFER_EXTERNAL 0x012F
/* ----- errors -----*/
#define M4ERR_NO_BUFFER_AVAILABLE \
M4OSA_ERR_CREATE(M4_ERR,VIDEOEDITOR_BUFFER_EXTERNAL,0x000001)
#define M4ERR_NO_BUFFER_MATCH \
M4OSA_ERR_CREATE(M4_ERR,VIDEOEDITOR_BUFFER_EXTERNAL,0x000002)
typedef enum {
VIDEOEDITOR_BUFFER_kEmpty = 0,
VIDEOEDITOR_BUFFER_kFilled,
} VIDEOEDITOR_BUFFER_State;
/**
************************************************************************
* Structure LVOMX_BUFFER_Buffer
* @brief One OMX Buffer and data related to it
************************************************************************
*/
typedef struct {
MediaBuffer* mBuffer; /**< Pointer to the data for intel platform*/
M4OSA_UInt32 size;
VIDEOEDITOR_BUFFER_State state; /**< Buffer state */
M4OSA_UInt32 idx; /**< Index of the buffer inside the pool */
M4_MediaTime buffCTS; /**< Time stamp of the buffer */
} VIDEOEDITOR_BUFFER_Buffer;
/**
************************************************************************
* Structure LVOMX_BUFFER_Pool
* @brief Structure to manage buffers
************************************************************************
*/
typedef struct {
VIDEOEDITOR_BUFFER_Buffer* pNXPBuffer;
M4OSA_UInt32 NB;
M4OSA_Char* poolName;
} VIDEOEDITOR_BUFFER_Pool;
#ifdef __cplusplus
extern "C"
{
#endif //__cplusplus
/**
************************************************************************
M4OSA_ERR VIDEOEDITOR_BUFFER_allocatePool(VIDEOEDITOR_BUFFER_Pool** ppool,
* M4OSA_UInt32 nbBuffers)
* @brief Allocate a pool of nbBuffers buffers
*
* @param ppool : IN The buffer pool to create
* @param nbBuffers : IN The number of buffers in the pool
* @param poolName : IN a name given to the pool
* @return Error code
************************************************************************
*/
M4OSA_ERR VIDEOEDITOR_BUFFER_allocatePool(VIDEOEDITOR_BUFFER_Pool** ppool,
M4OSA_UInt32 nbBuffers, M4OSA_Char* poolName);
/**
************************************************************************
M4OSA_ERR VIDEOEDITOR_BUFFER_freePool(LVOMX_BUFFER_Pool* ppool)
* @brief Deallocate a buffer pool
*
* @param ppool : IN The buffer pool to free
* @return Error code
************************************************************************
*/
M4OSA_ERR VIDEOEDITOR_BUFFER_freePool(VIDEOEDITOR_BUFFER_Pool* ppool);
/**
************************************************************************
M4OSA_ERR VIDEOEDITOR_BUFFER_freePool_Ext(LVOMX_BUFFER_Pool* ppool)
* @brief Deallocate a buffer pool
*
* @param ppool : IN The buffer pool to free
* @return Error code
************************************************************************
*/
M4OSA_ERR VIDEOEDITOR_BUFFER_freePool_Ext(VIDEOEDITOR_BUFFER_Pool* ppool);
/**
************************************************************************
M4OSA_ERR VIDEOEDITOR_BUFFER_getBuffer(VIDEOEDITOR_BUFFER_Pool* ppool,
* VIDEOEDITOR_BUFFER_Buffer** pNXPBuffer)
* @brief Returns a buffer in a given state
*
* @param ppool : IN The buffer pool
* @param desiredState : IN The buffer state
* @param pNXPBuffer : IN The selected buffer
* @return Error code
************************************************************************
*/
M4OSA_ERR VIDEOEDITOR_BUFFER_getBuffer(VIDEOEDITOR_BUFFER_Pool* ppool,
VIDEOEDITOR_BUFFER_State desiredState,
VIDEOEDITOR_BUFFER_Buffer** pNXPBuffer);
/**
************************************************************************
void VIDEOEDITOR_BUFFER_getBufferForDecoder(VIDEOEDITOR_BUFFER_Pool* ppool,
* VIDEOEDITOR_BUFFER_Buffer** pNXPBuffer)
* @brief Make sure there are buffers for decoder
*
* @param ppool : IN The buffer pool
* @param desiredState : IN The buffer state
* @return Error code
************************************************************************
*/
void VIDEOEDITOR_BUFFER_getBufferForDecoder(VIDEOEDITOR_BUFFER_Pool* ppool);
M4OSA_ERR VIDEOEDITOR_BUFFER_initPoolBuffers(VIDEOEDITOR_BUFFER_Pool* ppool,
M4OSA_UInt32 lSize);
M4OSA_ERR VIDEOEDITOR_BUFFER_initPoolBuffers_Ext(VIDEOEDITOR_BUFFER_Pool* ppool,
M4OSA_UInt32 lSize);
M4OSA_ERR VIDEOEDITOR_BUFFER_getOldestBuffer(VIDEOEDITOR_BUFFER_Pool *pool,
VIDEOEDITOR_BUFFER_State desiredState,
VIDEOEDITOR_BUFFER_Buffer** pNXPBuffer);
#ifdef __cplusplus
}
#endif //__cplusplus
#endif /*VIDEOEDITOR_BUFFER_H*/