khronosfws/openmax_al/src/mmf_adaptation/xamediarecorderadaptctxmmf.c
changeset 53 eabc8c503852
parent 33 5e8b14bae8c3
equal deleted inserted replaced
48:a493a607b5bf 53:eabc8c503852
    14  * Description: MediaRecorder MMF Adaptation
    14  * Description: MediaRecorder MMF Adaptation
    15  *
    15  *
    16  */
    16  */
    17 
    17 
    18 #include <string.h>
    18 #include <string.h>
    19 #include <assert.h>
       
    20 #include "xamediarecorderadaptctxmmf.h"
    19 #include "xamediarecorderadaptctxmmf.h"
    21 #include "xaadaptationmmf.h"
    20 #include "xaadaptationmmf.h"
    22 #include "cmmfbackendengine.h"
    21 #include "cmmfbackendengine.h"
    23 #include "xaadptbasectx.h"
    22 #include "xaadptbasectx.h"
    24 
    23 
    37     XAresult res;
    36     XAresult res;
    38     DEBUG_API("->XAMediaRecorderAdaptMMF_Create");
    37     DEBUG_API("->XAMediaRecorderAdaptMMF_Create");
    39 
    38 
    40     pSelf = (XAMediaRecorderAdaptationMMFCtx*) calloc(1,
    39     pSelf = (XAMediaRecorderAdaptationMMFCtx*) calloc(1,
    41             sizeof(XAMediaRecorderAdaptationMMFCtx));
    40             sizeof(XAMediaRecorderAdaptationMMFCtx));
    42     if (pSelf)
    41     if (!pSelf)
    43         {
       
    44         if (XAAdaptationBaseMMF_Init(&(pSelf->baseObj),
       
    45                 XAMediaRecorderAdaptation) != XA_RESULT_SUCCESS)
       
    46             {
       
    47             DEBUG_ERR("Failed to init base context!!!");
       
    48             free(pSelf);
       
    49             pSelf = NULL;
       
    50             }
       
    51         else
       
    52             {
       
    53             pSelf->xaAudioSource = pAudioSrc;
       
    54             pSelf->xaVideoSource = pImageVideoSrc;
       
    55             pSelf->xaSink = pDataSnk;
       
    56             pSelf->xaRecordState = XA_RECORDSTATE_STOPPED;
       
    57             pSelf->curMirror = XA_VIDEOMIRROR_NONE;
       
    58             pSelf->curRotation = 0;
       
    59             pSelf->recModes = recModes;
       
    60             pSelf->isRecord = XA_BOOLEAN_FALSE;
       
    61 
       
    62             /* defaults from API spec */
       
    63             pSelf->imageEncSettings.width = 640;
       
    64             pSelf->imageEncSettings.height = 480;
       
    65             pSelf->imageEncSettings.compressionLevel = 0;
       
    66             pSelf->imageEncSettings.encoderId = XA_IMAGECODEC_JPEG;
       
    67             pSelf->imageEncSettings.colorFormat = XA_COLORFORMAT_UNUSED;
       
    68             /* no specified defaults for rest, determined later from container type */
       
    69             pSelf->videoEncSettings.encoderId = XA_ADAPTID_UNINITED;
       
    70             pSelf->videoEncSettings.width = 640;
       
    71             pSelf->videoEncSettings.height = 480;
       
    72             pSelf->videoEncSettings.frameRate = 15;
       
    73             pSelf->audioEncSettings.encoderId = XA_ADAPTID_UNINITED;
       
    74             pSelf->audioEncSettings.channelsIn = 2;
       
    75             pSelf->audioEncSettings.channelsOut = 2;
       
    76             pSelf->audioEncSettings.bitsPerSample = 8;
       
    77             pSelf->audioEncSettings.bitRate = 128;
       
    78             pSelf->audioEncSettings.sampleRate = 44100;
       
    79             }
       
    80         }
       
    81     else
       
    82         {
    42         {
    83         DEBUG_ERR("Failed to create XAMediaRecorderAdaptationMMFCtx !!!");
    43         DEBUG_ERR("Failed to create XAMediaRecorderAdaptationMMFCtx !!!");
       
    44         DEBUG_API("<-XAMediaRecorderAdaptMMF_Create");
    84         return NULL;
    45         return NULL;
    85         }
    46         }
    86 
    47 
    87     if (pSelf)
    48     if (XAAdaptationBaseMMF_Init(&(pSelf->baseObj),
       
    49             XAMediaRecorderAdaptation) != XA_RESULT_SUCCESS)
    88         {
    50         {
    89         res = mmf_backend_engine_init(&(pSelf->mmfContext));
    51         free(pSelf);
    90         if (!(pSelf->mmfContext) || (res != XA_RESULT_SUCCESS))
    52         DEBUG_ERR("Failed to init base context!!!");
    91             {
    53         DEBUG_API("<-XAMediaRecorderAdaptMMF_Create");
    92             DEBUG_ERR("Failed to init mmf context!!!");
    54         return NULL;
    93             free(pSelf);
    55         }
    94             pSelf = NULL;
    56 
    95             }
    57     pSelf->xaAudioSource = pAudioSrc;
       
    58     pSelf->xaVideoSource = pImageVideoSrc;
       
    59     pSelf->xaSink = pDataSnk;
       
    60     pSelf->xaRecordState = XA_RECORDSTATE_STOPPED;
       
    61     pSelf->curMirror = XA_VIDEOMIRROR_NONE;
       
    62     pSelf->curRotation = 0;
       
    63     pSelf->recModes = recModes;
       
    64     pSelf->isRecord = XA_BOOLEAN_FALSE;
       
    65 
       
    66     /* defaults from API spec */
       
    67     pSelf->imageEncSettings.width = 640;
       
    68     pSelf->imageEncSettings.height = 480;
       
    69     pSelf->imageEncSettings.compressionLevel = 0;
       
    70     pSelf->imageEncSettings.encoderId = XA_IMAGECODEC_JPEG;
       
    71     pSelf->imageEncSettings.colorFormat = XA_COLORFORMAT_UNUSED;
       
    72     /* no specified defaults for rest, determined later from container type */
       
    73     pSelf->videoEncSettings.encoderId = XA_ADAPTID_UNINITED;
       
    74     pSelf->videoEncSettings.width = 640;
       
    75     pSelf->videoEncSettings.height = 480;
       
    76     pSelf->videoEncSettings.frameRate = 15;
       
    77     pSelf->audioEncSettings.encoderId = XA_ADAPTID_UNINITED;
       
    78     pSelf->audioEncSettings.channelsIn = 2;
       
    79     pSelf->audioEncSettings.channelsOut = 2;
       
    80     pSelf->audioEncSettings.bitsPerSample = 8;
       
    81     pSelf->audioEncSettings.bitRate = 128;
       
    82     pSelf->audioEncSettings.sampleRate = 44100;
       
    83 
       
    84     res = mmf_backend_engine_init(&(pSelf->mmfContext));
       
    85     if (!(pSelf->mmfContext) || (res != XA_RESULT_SUCCESS))
       
    86         {
       
    87         free(pSelf);
       
    88         DEBUG_ERR("Failed to init mmf context!!!");
       
    89         DEBUG_API("<-XAMediaRecorderAdaptMMF_Create");
       
    90         return NULL;
    96         }
    91         }
    97 
    92 
    98     DEBUG_API("<-XAMediaRecorderAdaptMMF_Create");
    93     DEBUG_API("<-XAMediaRecorderAdaptMMF_Create");
    99     return (XAAdaptationBaseCtx*) (&pSelf->baseObj.baseObj);
    94     return (XAAdaptationBaseCtx*) (&pSelf->baseObj.baseObj);
   100     }
    95     }
   114     XAMediaRecorderAdaptationMMFCtx *pSelf;
   109     XAMediaRecorderAdaptationMMFCtx *pSelf;
   115     DEBUG_API("->XAMediaRecorderAdapt_PostInit");
   110     DEBUG_API("->XAMediaRecorderAdapt_PostInit");
   116     if(!bCtx)
   111     if(!bCtx)
   117         {
   112         {
   118         ret = XA_RESULT_PARAMETER_INVALID;
   113         ret = XA_RESULT_PARAMETER_INVALID;
       
   114         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   115         DEBUG_API("<-XAMediaRecorderAdapt_PostInit");
   119         return ret;
   116         return ret;
   120         }
   117         }
   121     
   118     
   122     pSelf = (XAMediaRecorderAdaptationMMFCtx*) bCtx;
   119     pSelf = (XAMediaRecorderAdaptationMMFCtx*) bCtx;
   123     if (pSelf->mmfContext)
   120     if (pSelf->mmfContext)
   124         {
   121         {
   125         tempUri = (XADataLocator_URI*) (pSelf->xaSink->pLocator);
   122         tempUri = (XADataLocator_URI*) (pSelf->xaSink->pLocator);
   126         tempFormat = (XADataFormat_MIME*) (pSelf->xaSink->pFormat);
   123         tempFormat = (XADataFormat_MIME*) (pSelf->xaSink->pFormat);
   127         ret = mmf_set_recorder_uri(pSelf->mmfContext, (char *) (tempUri->URI),
   124         ret = mmf_set_recorder_uri(pSelf->mmfContext, (char *) (tempUri->URI),
   128                 tempFormat->containerType);
   125                 tempFormat->containerType);
   129         if(ret == XA_RESULT_SUCCESS)
   126         if (ret != XA_RESULT_SUCCESS)
   130             {
   127             {
   131             ret = mmf_set_adapt_context(pSelf->mmfContext, &(pSelf->baseObj));
   128             DEBUG_ERR("Failed to set recorder uri on mmf!!!");
       
   129             DEBUG_API("<-XAMediaRecorderAdapt_PostInit");
       
   130             return ret;
       
   131             }
       
   132         ret = mmf_set_adapt_context(pSelf->mmfContext, &(pSelf->baseObj));
       
   133         if (ret != XA_RESULT_SUCCESS)
       
   134             {
       
   135             DEBUG_ERR("Failed to set adapt context on mmf!!!");
       
   136             DEBUG_API("<-XAMediaRecorderAdapt_PostInit");
       
   137             return ret;
   132             }
   138             }
   133         }
   139         }
   134 
       
   135     DEBUG_API("<-XAMediaRecorderAdapt_PostInit");
   140     DEBUG_API("<-XAMediaRecorderAdapt_PostInit");
   136     return ret;
   141     return ret;
   137     }
   142     }
   138 
   143 
   139 /*
   144 /*