1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 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 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 #ifndef PVMF_OMX_AUDIODEC_NODE_H_INCLUDED 19 #define PVMF_OMX_AUDIODEC_NODE_H_INCLUDED 20 21 #ifndef PVMF_OMX_BASEDEC_NODE_H_INCLUDED 22 #include "pvmf_omx_basedec_node.h" 23 #endif 24 25 #ifndef PVMF_OMX_AUDIODEC_PORT_H_INCLUDED 26 #include "pvmf_omx_basedec_port.h" 27 #endif 28 29 30 #define PVMFOMXAUDIODECNODE_NUM_CMD_IN_POOL 8 31 #define PVOMXAUDIODEC_DEFAULT_SAMPLINGRATE 48000 32 #define PVOMXAUDIODEC_DEFAULT_OUTPUTPCM_TIME 200 33 #define PVOMXAUDIODEC_AMRNB_SAMPLES_PER_FRAME 160 34 #define PVOMXAUDIODEC_AMRWB_SAMPLES_PER_FRAME 320 35 #define PVOMXAUDIODEC_MP3_DEFAULT_SAMPLES_PER_FRAME 1152 36 37 struct channelSampleInfo 38 { 39 uint32 desiredChannels; 40 uint32 samplingRate; 41 uint32 bitsPerSample; 42 uint32 num_buffers; 43 uint32 buffer_size; 44 }; 45 46 47 // fwd class declaration 48 class PV_LATM_Parser; 49 50 51 /// ######################################################### 52 /// ######################################################### 53 // Key string info at the base level ("x-pvmf/audio/decoder") 54 #define PVOMXAUDIODECNODECONFIG_BASE_NUMKEYS 6 55 const PVOMXBaseDecNodeKeyStringData PVOMXAudioDecNodeConfigBaseKeys[PVOMXAUDIODECNODECONFIG_BASE_NUMKEYS] = 56 { 57 {"silenceinsertion_enable", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}, 58 {"aac_he_v1_enable", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}, 59 {"aac_he_v2_enable", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}, 60 {"format-type", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR} 61 }; 62 63 // Key string info at render ("x-pvmf/audio/render") 64 #define PVOMXAUDIODECNODECONFIG_RENDER_NUMKEYS 2 65 const PVOMXBaseDecNodeKeyStringData PVOMXAudioDecNodeConfigRenderKeys[PVOMXAUDIODECNODECONFIG_RENDER_NUMKEYS] = 66 { 67 {"sampling_rate", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}, 68 {"channels", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32} 69 }; 70 71 72 ///////////////////////////////////////////////////////////////////////////////////////// 73 /////////############################################################### 74 //// ################################################################### 75 76 //Mimetypes for the custom interface 77 #define PVMF_OMX_AUDIO_DEC_NODE_MIMETYPE "pvxxx/OMXAudioDecNode" 78 #define PVMF_BASEMIMETYPE "pvxxx" 79 80 class PVMFOMXAudioDecNode 81 : public PVMFOMXBaseDecNode 82 83 { 84 public: 85 PVMFOMXAudioDecNode(int32 aPriority); 86 ~PVMFOMXAudioDecNode(); 87 88 // From PVMFNodeInterface 89 PVMFStatus ThreadLogon(); 90 91 //**********begin PVMFMetadataExtensionInterface 92 uint32 GetNumMetadataKeys(char* query_key = NULL); 93 uint32 GetNumMetadataValues(PVMFMetadataList& aKeyList); 94 //**********End PVMFMetadataExtensionInterface 95 96 97 //============================================================================== 98 99 OMX_ERRORTYPE EventHandlerProcessing(OMX_OUT OMX_HANDLETYPE aComponent, 100 OMX_OUT OMX_PTR aAppData, 101 OMX_OUT OMX_EVENTTYPE aEvent, 102 OMX_OUT OMX_U32 aData1, 103 OMX_OUT OMX_U32 aData2, 104 OMX_OUT OMX_PTR aEventData); 105 106 // for WMA params 107 bool VerifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements); 108 109 PVMFStatus DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements); 110 void DoCapConfigSetParameters(PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP); 111 112 protected: 113 114 void DoQueryUuid(PVMFOMXBaseDecNodeCommand&); 115 void DoRequestPort(PVMFOMXBaseDecNodeCommand&); 116 void DoReleasePort(PVMFOMXBaseDecNodeCommand&); 117 PVMFStatus DoGetNodeMetadataKey(PVMFOMXBaseDecNodeCommand&); 118 PVMFStatus DoGetNodeMetadataValue(PVMFOMXBaseDecNodeCommand&); 119 bool ProcessIncomingMsg(PVMFPortInterface* aPort); 120 PVMFStatus HandlePortReEnable(); 121 122 bool InitDecoder(PVMFSharedMediaDataPtr&); 123 124 bool NegotiateComponentParameters(OMX_PTR aOutputParameters); 125 bool GetSetCodecSpecificInfo(); 126 bool QueueOutputBuffer(OsclSharedPtr<PVMFMediaDataImpl> &mediadataimplout, uint32 aDataLen); 127 128 // latm parser for AAC - LATM 129 PVMFStatus CreateLATMParser(void); 130 PVMFStatus DeleteLATMParser(void); 131 132 bool ReleaseAllPorts(); 133 134 OMX_AUDIO_CODINGTYPE iOMXAudioCompressionFormat; 135 136 // Audio parameters 137 // the output buffer size is calculated from the parameters below 138 uint32 iPCMSamplingRate; // typically 8,16,22.05,32,44.1, 48 khz 139 uint32 iNumberOfAudioChannels; // can be 1 or 2 140 uint32 iSamplesPerFrame; // number of samples per 1 frame of data (if known) per channel 141 uint32 iNumBytesPerFrame; // depends on number of samples/channel and number of channels 142 uint32 iMilliSecPerFrame; // 143 144 145 // LATM parser for AAC 146 PV_LATM_Parser *iLATMParser; 147 uint8 *iLATMConfigBuffer; 148 uint32 iLATMConfigBufferSize; 149 150 }; 151 152 153 #endif // PVMF_OMXAUDIODEC_NODE_H_INCLUDED 154 155