• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
19  * @file pvaetest_node_config.h
20  * @brief Utility to perform build configuration specific node configuration. This file
21  * is for tye single core build configurations.
22  */
23 
24 #ifndef PVAETEST_NODE_CONFIG_H_INCLUDED
25 #define PVAETEST_NODE_CONFIG_H_INCLUDED
26 
27 #ifndef OSCL_BASE_H_INCLUDED
28 #include "oscl_base.h"
29 #endif
30 #ifndef PVAETESTINPUT_H_INCLUDED
31 #include "pvaetestinput.h"
32 #endif
33 #ifndef PVMF_AUDIO_ENCNODE_EXTENSION_H_INCLUDED
34 #include "pvmf_audio_encnode_extension.h"
35 #endif
36 #ifndef TEST_PV_AUTHOR_ENGINE_TYPEDEFS_H
37 #include "test_pv_author_engine_typedefs.h"
38 #endif
39 #ifndef PV_MIME_STRING_UTILS_H_INCLUDED
40 #include "pv_mime_string_utils.h"
41 #endif
42 
43 extern const uint32 KNum20msFramesPerChunk;
44 extern const uint32 KAudioBitrate;
45 extern const uint32 KAudioBitrateWB;
46 extern const uint32 KAACAudioBitrate;
47 
48 class PVAETestNodeConfig
49 {
50     public:
51         static bool ConfigureAudioEncoder(PVInterface* aInterface, const PvmfMimeString& aMimeType, uint32 aAudioBitrate = 0)
52         {
53             if (!aInterface)
54             {
55                 // if the interface is missing, this method should not be called
56                 OSCL_ASSERT(aInterface != NULL);
57                 return false;
58             }
59 
60 
61             PVAudioEncExtensionInterface* config = OSCL_STATIC_CAST(PVAudioEncExtensionInterface*, aInterface);
62 
63             if ((pv_mime_strcmp(aMimeType.get_cstr(), (char*)KAMRNbEncMimeType) == 0) || (pv_mime_strcmp(aMimeType.get_cstr(), (char*)KAMRWbEncMimeType) == 0))
64             {
65                 if (config->SetMaxNumOutputFramesPerBuffer(KNum20msFramesPerChunk) != PVMFSuccess)
66                     return false;
67 
68                 uint32 audioBitrate = aAudioBitrate;
69 
70                 if (audioBitrate == 0)
71                 {
72                     if (pv_mime_strcmp(aMimeType.get_cstr(), (char*)KAMRNbEncMimeType) == 0)
73                         audioBitrate = KAudioBitrate;
74                     else if (pv_mime_strcmp(aMimeType.get_cstr(), (char*)KAMRWbEncMimeType) == 0)
75                         audioBitrate = KAudioBitrateWB;
76                 }
77 
78                 switch (audioBitrate)
79                 {
80                     case 4750:
81                         if (config->SetOutputBitRate(GSM_AMR_4_75) != PVMFSuccess)
82                             return false;
83                         break;
84                     case 5150:
85                         if (config->SetOutputBitRate(GSM_AMR_5_15) != PVMFSuccess)
86                             return false;
87                         break;
88                     case 5900:
89                         if (config->SetOutputBitRate(GSM_AMR_5_90) != PVMFSuccess)
90                             return false;
91                         break;
92                     case 6700:
93                         if (config->SetOutputBitRate(GSM_AMR_6_70) != PVMFSuccess)
94                             return false;
95                         break;
96                     case 7400:
97                         if (config->SetOutputBitRate(GSM_AMR_7_40) != PVMFSuccess)
98                             return false;
99                         break;
100                     case 7950:
101                         if (config->SetOutputBitRate(GSM_AMR_7_95) != PVMFSuccess)
102                             return false;
103                         break;
104                     case 10200:
105                         if (config->SetOutputBitRate(GSM_AMR_10_2) != PVMFSuccess)
106                             return false;
107                         break;
108                     case 12200:
109                         if (config->SetOutputBitRate(GSM_AMR_12_2) != PVMFSuccess)
110                             return false;
111                         break;
112 
113                     case 6600: // AMR WB bitrates start here
114                         if (config->SetOutputBitRate(GSM_AMR_6_60) != PVMFSuccess)
115                             return false;
116                         break;
117                     case 8850:
118                         if (config->SetOutputBitRate(GSM_AMR_8_85) != PVMFSuccess)
119                             return false;
120                         break;
121                     case 12650:
122                         if (config->SetOutputBitRate(GSM_AMR_12_65) != PVMFSuccess)
123                             return false;
124                         break;
125                     case 14250:
126                         if (config->SetOutputBitRate(GSM_AMR_14_25) != PVMFSuccess)
127                             return false;
128                         break;
129                     case 15850:
130                         if (config->SetOutputBitRate(GSM_AMR_15_85) != PVMFSuccess)
131                             return false;
132                         break;
133                     case 18250:
134                         if (config->SetOutputBitRate(GSM_AMR_18_25) != PVMFSuccess)
135                             return false;
136                         break;
137                     case 19850:
138                         if (config->SetOutputBitRate(GSM_AMR_19_85) != PVMFSuccess)
139                             return false;
140                         break;
141                     case 23050:
142                         if (config->SetOutputBitRate(GSM_AMR_23_05) != PVMFSuccess)
143                             return false;
144                         break;
145                     case 23850:
146                         if (config->SetOutputBitRate(GSM_AMR_23_85) != PVMFSuccess)
147                             return false;
148                         break;
149                     default:
150                         return false;
151                 }
152             }
153             else if (aMimeType == KAACADIFEncMimeType || aMimeType == KAACADTSEncMimeType)
154             {
155                 if (config->SetOutputBitRate(KAACAudioBitrate) != PVMFSuccess)
156                     return false;
157                 //config->SetOutputNumChannel();  do not set, use the input ones
158                 //config->SetOutputSamplingRate();
159             }
160 
161             return true;
162         }
163 };
164 
165 #endif // PVAETEST_NODE_CONFIG_H_INCLUDED
166 
167 
168 
169