Home | History | Annotate | Download | only in inc
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 /**
     17  *************************************************************************
     18  * @file    M4MCS_InternalFunctions.h
     19  * @brief   This file contains all functions declarations internal
     20  *          to the MCS.
     21  *************************************************************************
     22  */
     23 
     24 #ifndef __M4MCS_INTERNALFUNCTIONS_H__
     25 #define __M4MCS_INTERNALFUNCTIONS_H__
     26 
     27 #ifdef __cplusplus
     28 extern "C" {
     29 #endif
     30 
     31 #include "M4VPP_API.h"
     32 #include "M4ENCODER_common.h"
     33 
     34 /**
     35  **************************************************************************
     36  * M4OSA_ERR M4MCS_intApplyVPP( M4VPP_Context pContext,
     37  *                              M4VIFI_ImagePlane* pPlaneIn,
     38  *                              M4VIFI_ImagePlane* pPlaneOut)
     39  * @brief   Do the video rendering and the resize (if needed)
     40  * @note    It is called by the video encoder
     41  * @param   pContext    (IN)     VPP context, which actually is the MCS
     42  *                               internal context in our case
     43  * @param   pPlaneIn    (IN)     Contains the image
     44  * @param   pPlaneOut   (IN/OUT) Pointer to an array of 3 planes that will
     45  *                               contain the output YUV420 image
     46  * @return  M4NO_ERROR:                 No error
     47  * @return  ERR_MCS_VIDEO_DECODE_ERROR: the video decoding failed
     48  * @return  ERR_MCS_RESIZE_ERROR:       the resizing failed
     49  * @return  Any error returned by an underlaying module
     50  **************************************************************************
     51  */
     52 M4OSA_ERR M4MCS_intApplyVPP(M4VPP_Context pContext, M4VIFI_ImagePlane* pPlaneIn,
     53                             M4VIFI_ImagePlane* pPlaneOut);
     54 
     55 /**
     56  **************************************************************************
     57  * M4OSA_ERR M4MCS_SubscribeMediaAndCodec(M4MCS_Context pContext);
     58  * @brief    This function registers the reader, decoders, writers and encoders
     59  *           in the MCS.
     60  * @note
     61  * @param    pContext:    (IN) Execution context.
     62  * @return   M4NO_ERROR:        there is no error
     63  * @return   M4ERR_PARAMETER    pContext is NULL
     64  **************************************************************************
     65  */
     66 M4OSA_ERR M4MCS_subscribeMediaAndCodec(M4MCS_Context pContext);
     67 
     68 /**
     69  **************************************************************************
     70  * @brief    Clear encoders, decoders, reader and writers interfaces tables
     71  * @param    pContext            (IN/OUT) MCS context.
     72  * @return    M4NO_ERROR:            No error
     73  * @return    M4ERR_PARAMETER:    The context is null
     74  **************************************************************************
     75  */
     76 M4OSA_ERR   M4MCS_clearInterfaceTables(M4MCS_Context pContext);
     77 
     78 /**
     79  **************************************************************************
     80  * M4OSA_ERR   M4MCS_registerWriter(M4MCS_Context pContext,
     81  *                                  M4VIDEOEDITING_FileType MediaType,
     82  *                                  M4WRITER_GlobalInterface *pWtrGlobalInterface,
     83  *                                  M4WRITER_DataInterface *pWtrDataInterface)
     84  * @brief   This function will register a specific file format writer.
     85  * @note    According to the Mediatype, this function will store in the internal
     86  *          context the writer context.
     87  * @param   pContext:    (IN) Execution context.
     88  * @return  M4NO_ERROR:         there is no error
     89  * @return  M4ERR_PARAMETER     pContext,pWtrGlobalInterface or pWtrDataInterface
     90  *                              is M4OSA_NULL (debug only), or invalid MediaType
     91  **************************************************************************
     92  */
     93 M4OSA_ERR   M4MCS_registerWriter(
     94                         M4MCS_Context pContext,
     95                         M4WRITER_OutputFileType MediaType,
     96                         M4WRITER_GlobalInterface* pWtrGlobalInterface,
     97                         M4WRITER_DataInterface* pWtrDataInterface);
     98 
     99 /**
    100  ******************************************************************************
    101  * M4OSA_ERR   M4MCS_registerEncoder(   M4MCS_Context pContext,
    102  *                                      M4VIDEOEDITING_VideoFormat mediaType,
    103  *                                      M4ENCODER_GlobalInterface *pEncGlobalInterface)
    104  * @brief   This function will register a specific video encoder.
    105  * @note    According to the Mediatype, this function will store in the internal
    106  *          context the encoder context.
    107  * @param   pContext:    (IN) Execution context.
    108  * @return  M4NO_ERROR:         there is no error
    109  * @return  M4ERR_PARAMETER     pContext or pEncGlobalInterface is
    110  *                              M4OSA_NULL (debug only), or invalid MediaType
    111  ******************************************************************************
    112  */
    113 M4OSA_ERR   M4MCS_registerVideoEncoder(
    114                         M4MCS_Context pContext,
    115                         M4ENCODER_Format MediaType,
    116                         M4ENCODER_GlobalInterface *pEncGlobalInterface);
    117 
    118 /**
    119  ******************************************************************************
    120  * M4OSA_ERR   M4MCS_registerAudioEncoder(  M4MCS_Context pContext,
    121  *                                          M4ENCODER_AudioFormat mediaType,
    122  *                                          M4ENCODER_AudioGlobalInterface *pEncGlobalInterface)
    123  * @brief   This function will register a specific audio encoder.
    124  * @note    According to the Mediatype, this function will store in the internal
    125  *          context the encoder context.
    126  * @param   pContext:               (IN)   Execution context.
    127  * @param   mediaType:              (IN)   The media type.
    128  * @param   pEncGlobalInterface:    (OUT)  The encoder interface functions.
    129  * @return  M4NO_ERROR:       there is no error
    130  * @return  M4ERR_PARAMETER:  pContext or pEncGlobalInterface is
    131  *                              M4OSA_NULL (debug only)
    132  ******************************************************************************
    133  */
    134 M4OSA_ERR   M4MCS_registerAudioEncoder(
    135                         M4MCS_Context pContext,
    136                         M4ENCODER_AudioFormat MediaType,
    137                         M4ENCODER_AudioGlobalInterface *pEncGlobalInterface);
    138 
    139 /**
    140  **************************************************************************
    141  * @brief    Register reader.
    142  * @param    pContext            (IN/OUT) MCS context.
    143  * @return    M4NO_ERROR:            No error
    144  * @return    M4ERR_PARAMETER:    A parameter is null (in DEBUG only)
    145  **************************************************************************
    146  */
    147 M4OSA_ERR   M4MCS_registerReader(   M4MCS_Context pContext,
    148                                     M4READER_MediaType mediaType,
    149                                     M4READER_GlobalInterface *pRdrGlobalInterface,
    150                                     M4READER_DataInterface *pRdrDataInterface);
    151 
    152 /**
    153  **************************************************************************
    154  * @brief   Register video decoder
    155  * @param   pContext             (IN/OUT) MCS context.
    156  * @param   decoderType          (IN) Decoder type
    157  * @param   pDecoderInterface    (IN) Decoder interface.
    158  * @return  M4NO_ERROR:            No error
    159  * @return  M4ERR_PARAMETER:    A parameter is null (in DEBUG only),or the
    160  *                              decoder type is invalid
    161  **************************************************************************
    162  */
    163 M4OSA_ERR   M4MCS_registerVideoDecoder( M4MCS_Context pContext,
    164                                         M4DECODER_VideoType decoderType,
    165                                         M4DECODER_VideoInterface *pDecoderInterface);
    166 
    167 /**
    168  ************************************************************************
    169  * @brief   Register audio decoder
    170  * @note    This function is used internaly by the MCS to register Core audio decoders,
    171  * @param   context            (IN/OUT) MCS context.
    172  * @param   decoderType        (IN)     Audio decoder type
    173  * @param   pDecoderInterface  (IN)     Audio decoder interface.
    174  * @return  M4NO_ERROR:        No error
    175  * @return  M4ERR_PARAMETER:   A parameter is null, or the decoder type is invalid(in DEBUG only)
    176  ************************************************************************
    177  */
    178 M4OSA_ERR   M4MCS_registerAudioDecoder(M4MCS_Context pContext, M4AD_Type decoderType,
    179                                         M4AD_Interface *pDecoderInterface);
    180 
    181 /**
    182  ************************************************************************
    183  * @brief   Unregister writer
    184  * @param   pContext            (IN/OUT) MCS context.
    185  * @return  M4NO_ERROR:         No error
    186  * @return  M4ERR_PARAMETER:    A parameter is null (in DEBUG only)
    187  ************************************************************************
    188  */
    189 M4OSA_ERR   M4MCS_unRegisterAllWriters(M4MCS_Context pContext);
    190 
    191 /**
    192  ************************************************************************
    193  * @brief   Unregister the encoders
    194  * @param   pContext            (IN/OUT) MCS context.
    195  * @return  M4NO_ERROR:         No error
    196  * @return  M4ERR_PARAMETER:    A parameter is null (in DEBUG only)
    197  ************************************************************************
    198  */
    199 M4OSA_ERR   M4MCS_unRegisterAllEncoders(M4MCS_Context pContext);
    200 
    201 /**
    202  ************************************************************************
    203  * @brief   Unregister reader
    204  * @param   pContext            (IN/OUT) MCS context.
    205  * @return  M4NO_ERROR:         No error
    206  * @return  M4ERR_PARAMETER:    A parameter is null (in DEBUG only)
    207  ************************************************************************
    208  */
    209 M4OSA_ERR   M4MCS_unRegisterAllReaders(M4MCS_Context pContext);
    210 
    211 /**
    212  ************************************************************************
    213  * @brief   Unregister the decoders
    214  * @param   pContext            (IN/OUT) MCS context.
    215  * @return  M4NO_ERROR:         No error
    216  * @return  M4ERR_PARAMETER:    A parameter is null (in DEBUG only)
    217  ************************************************************************
    218  */
    219 M4OSA_ERR   M4MCS_unRegisterAllDecoders(M4MCS_Context pContext);
    220 
    221 /**
    222  ************************************************************************
    223  * @brief   Set current writer
    224  * @param   pContext            (IN/OUT) MCS context.
    225  * @param   mediaType           (IN) Media type.
    226  * @return  M4NO_ERROR:         No error
    227  * @return  M4ERR_PARAMETER:                    A parameter is null (in DEBUG only)
    228  * @return  M4WAR_MCS_MEDIATYPE_NOT_SUPPORTED:  Media type not supported
    229  ************************************************************************
    230  */
    231 M4OSA_ERR   M4MCS_setCurrentWriter( M4MCS_Context pContext,
    232                                     M4VIDEOEDITING_FileType mediaType);
    233 
    234 /**
    235  ************************************************************************
    236  * @brief    Set a video encoder
    237  * @param    pContext            (IN/OUT) MCS context.
    238  * @param    MediaType           (IN) Encoder type
    239  * @return    M4NO_ERROR:            No error
    240  * @return    M4ERR_PARAMETER:                    A parameter is null (in DEBUG only)
    241  * @return    M4WAR_MCS_MEDIATYPE_NOT_SUPPORTED:    Media type not supported
    242  ************************************************************************
    243  */
    244 M4OSA_ERR   M4MCS_setCurrentVideoEncoder(   M4MCS_Context pContext,
    245                                             M4VIDEOEDITING_VideoFormat mediaType);
    246 
    247 /**
    248  ************************************************************************
    249  * @brief    Set an audio encoder
    250  * @param    context            (IN/OUT) MCS context.
    251  * @param    MediaType        (IN) Encoder type
    252  * @return    M4NO_ERROR:            No error
    253  * @return    M4ERR_PARAMETER:    A parameter is null (in DEBUG only)
    254  ************************************************************************
    255  */
    256 M4OSA_ERR   M4MCS_setCurrentAudioEncoder(   M4MCS_Context pContext,
    257                                             M4VIDEOEDITING_AudioFormat mediaType);
    258 
    259 /**
    260  ************************************************************************
    261  * @brief    Set current reader
    262  * @param    pContext            (IN/OUT) MCS context.
    263  * @param    mediaType           (IN) Media type.
    264  * @return    M4NO_ERROR:        No error
    265  * @return    M4ERR_PARAMETER:   A parameter is null (in DEBUG only)
    266  * @return    M4WAR_MCS_MEDIATYPE_NOT_SUPPORTED:    Media type not supported
    267  ************************************************************************
    268  */
    269 M4OSA_ERR   M4MCS_setCurrentReader( M4MCS_Context pContext,
    270                                     M4VIDEOEDITING_FileType mediaType);
    271 
    272 /**
    273  ************************************************************************
    274  * @brief    Set a video decoder
    275  * @param    pContext           (IN/OUT) MCS context.
    276  * @param    decoderType        (IN) Decoder type
    277  * @return    M4NO_ERROR:            No error
    278  * @return    M4ERR_PARAMETER:       A parameter is null (in DEBUG only)
    279  * @return    M4WAR_MCS_MEDIATYPE_NOT_SUPPORTED:    Media type not supported
    280  ************************************************************************
    281  */
    282 M4OSA_ERR   M4MCS_setCurrentVideoDecoder(   M4MCS_Context pContext,
    283                                             M4_StreamType mediaType);
    284 
    285 /**
    286  ************************************************************************
    287  * @brief    Set an audio decoder
    288  * @param    context            (IN/OUT) MCS context.
    289  * @param    decoderType        (IN) Decoder type
    290  * @return    M4NO_ERROR:         No error
    291  * @return    M4ERR_PARAMETER:    A parameter is null (in DEBUG only)
    292  ************************************************************************
    293  */
    294 M4OSA_ERR   M4MCS_setCurrentAudioDecoder(M4MCS_Context pContext, M4_StreamType mediaType);
    295 
    296 /**
    297  ******************************************************************************
    298  * M4OSA_ERR M4MCS_intCheckAudioEffects(M4MCS_InternalContext* pContext)
    299  * @brief    Check if an effect has to be applied currently
    300  * @note     It is called by the stepEncoding function
    301  * @param    pContext    (IN)   MCS internal context
    302  * @return   M4NO_ERROR:        No error
    303  ******************************************************************************
    304  */
    305 M4OSA_ERR M4MCS_intCheckAudioEffects(M4MCS_InternalContext* pC);
    306 
    307 /**
    308  ******************************************************************************
    309  * M4OSA_ERR M4MCS_editAudioEffectFct_FadeIn()
    310  * @brief    Apply audio effect FadeIn to pPCMdata
    311  * @param    pC           (IN/OUT) Internal edit context
    312  * @param    pPCMdata     (IN/OUT) Input and Output PCM audio data
    313  * @param    uiPCMsize    (IN)     Size of pPCMdata
    314  * @param    pProgress    (IN)     Effect progress
    315  * @return   M4NO_ERROR:           No error
    316  ******************************************************************************
    317  */
    318 M4OSA_ERR M4MCS_editAudioEffectFct_FadeIn(  M4OSA_Void *pFunctionContext,
    319                                             M4OSA_Int16 *pPCMdata,
    320                                             M4OSA_UInt32 uiPCMsize,
    321                                             M4MCS_ExternalProgress *pProgress);
    322 
    323 /**
    324  ******************************************************************************
    325  * M4OSA_ERR M4MCS_editAudioEffectFct_FadeIn()
    326  * @brief    Apply audio effect FadeIn to pPCMdata
    327  * @param    pC           (IN/OUT) Internal edit context
    328  * @param    pPCMdata     (IN/OUT) Input and Output PCM audio data
    329  * @param    uiPCMsize    (IN)     Size of pPCMdata
    330  * @param    pProgress    (IN)     Effect progress
    331  * @return   M4NO_ERROR:           No error
    332  ******************************************************************************
    333  */
    334 M4OSA_ERR M4MCS_editAudioEffectFct_FadeOut( M4OSA_Void *pFunctionContext,
    335                                             M4OSA_Int16 *pPCMdata,
    336                                             M4OSA_UInt32 uiPCMsize,
    337                                             M4MCS_ExternalProgress *pProgress);
    338 
    339 #ifdef __cplusplus
    340 }
    341 #endif
    342 
    343 #endif /* __M4MCS_INTERNALFUNCTIONS_H__ */
    344 
    345