• 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 pvmf_sample_port.cpp
20  * @brief Sample PVMF Port implementation
21  */
22 
23 #ifndef PVMF_FILEINPUT_PORT_H_INCLUDED
24 #include "pvmf_fileinput_port.h"
25 #endif
26 #ifndef OSCL_MEM_BASIC_FUNCTIONS_H
27 #include "oscl_mem_basic_functions.h"
28 #endif
29 #ifndef OSCL_MIME_STRING_UTILS_H
30 #include "pv_mime_string_utils.h"
31 #endif
32 #ifndef PVMF_DUMMY_FILEINPUT_NODE_H_INCLUDED
33 #include "pvmf_dummy_fileinput_node.h"
34 #endif
35 
36 #define LOG_STACK_TRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, m);
37 #define LOG_DEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, m);
38 #define LOG_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
39 
40 
41 ////////////////////////////////////////////////////////////////////////////
PVMFFileDummyInputPort(int32 aTag,PVMFNodeInterface * aNode)42 PVMFFileDummyInputPort::PVMFFileDummyInputPort(int32 aTag, PVMFNodeInterface* aNode)
43         : PvmfPortBaseImpl(aTag, aNode)
44 {
45     Construct();
46 }
47 
48 ////////////////////////////////////////////////////////////////////////////
PVMFFileDummyInputPort(int32 aTag,PVMFNodeInterface * aNode,uint32 aInCapacity,uint32 aInReserve,uint32 aInThreshold,uint32 aOutCapacity,uint32 aOutReserve,uint32 aOutThreshold)49 PVMFFileDummyInputPort::PVMFFileDummyInputPort(int32 aTag, PVMFNodeInterface* aNode
50         , uint32 aInCapacity
51         , uint32 aInReserve
52         , uint32 aInThreshold
53         , uint32 aOutCapacity
54         , uint32 aOutReserve
55         , uint32 aOutThreshold)
56         : PvmfPortBaseImpl(aTag, aNode, aInCapacity, aInReserve, aInThreshold, aOutCapacity, aOutReserve, aOutThreshold)
57 {
58     Construct();
59 }
60 
61 ////////////////////////////////////////////////////////////////////////////
Construct()62 void PVMFFileDummyInputPort::Construct()
63 {
64     iLogger = PVLogger::GetLoggerObject("PVMFFileDummyInputPort");
65     oscl_memset(&iStats, 0, sizeof(PvmfPortBaseImplStats));
66     iNumFramesGenerated = 0;
67     iTrackConfigFI = NULL;
68     iTrackConfigSizeFI = 0;
69 }
70 
71 ////////////////////////////////////////////////////////////////////////////
~PVMFFileDummyInputPort()72 PVMFFileDummyInputPort::~PVMFFileDummyInputPort()
73 {
74     Disconnect();
75     ClearMsgQueues();
76 
77     if (iTrackConfigFI)
78     {
79         oscl_free(iTrackConfigFI);
80         iTrackConfigFI = NULL;
81     }
82 }
83 
84 ////////////////////////////////////////////////////////////////////////////
85 //                  PvmiCapabilityAndConfig
86 ////////////////////////////////////////////////////////////////////////////
setObserver(PvmiConfigAndCapabilityCmdObserver * aObserver)87 OSCL_EXPORT_REF void PVMFFileDummyInputPort::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
88 {
89     // Not supported
90     OSCL_UNUSED_ARG(aObserver);
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////
getParametersSync(PvmiMIOSession session,PvmiKeyType identifier,PvmiKvp * & parameters,int & num_parameter_elements,PvmiCapabilityContext context)94 OSCL_EXPORT_REF PVMFStatus PVMFFileDummyInputPort::getParametersSync(PvmiMIOSession session,
95         PvmiKeyType identifier,
96         PvmiKvp*& parameters,
97         int& num_parameter_elements,
98         PvmiCapabilityContext context)
99 {
100     LOG_STACK_TRACE((0, "PVMFFileDummyInputPort::getParametersSync"));
101     OSCL_UNUSED_ARG(session);
102     OSCL_UNUSED_ARG(context);
103 
104 
105     num_parameter_elements = 0;
106     PVMFStatus status = PVMFFailure;
107     PVMFDummyFileInputNode* node = (PVMFDummyFileInputNode*)iPortActivityHandler;
108 
109 
110     if (pv_mime_strcmp(identifier, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0 && (iFormat == PVMF_MIME_WMV || iFormat == PVMF_MIME_WMA))
111     {
112         if (pvmiGetPortFormatSpecificInfoSync(PVMF_FORMAT_SPECIFIC_INFO_KEY, parameters) == 0)
113         {
114             return PVMFFailure;
115         }
116         else
117         {
118             num_parameter_elements = 1;
119             return PVMFSuccess;
120         }
121 
122     }
123 
124     parameters = NULL;
125     if (pv_mime_strcmp(identifier, OUTPUT_FORMATS_CAP_QUERY) == 0 ||
126             pv_mime_strcmp(identifier, OUTPUT_FORMATS_CUR_QUERY) == 0)
127     {
128         num_parameter_elements = 1;
129         status = AllocateKvp(parameters, OSCL_STATIC_CAST(PvmiKeyType, OUTPUT_FORMATS_VALTYPE), num_parameter_elements);
130         if (status != PVMFSuccess)
131         {
132             LOG_ERR((0, "PVMFFileDummyInputPort::getParametersSync: Error - AllocateKvp failed. status=%d", status));
133         }
134         else
135         {
136             parameters[0].value.pChar_value = (char*)node->iSettings.iMediaFormat.getMIMEStrPtr();
137         }
138     }
139     else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_WIDTH_CUR_QUERY) == 0)
140     {
141         num_parameter_elements = 1;
142         status = AllocateKvp(parameters, OSCL_STATIC_CAST(PvmiKeyType, VIDEO_OUTPUT_WIDTH_CUR_VALUE), num_parameter_elements);
143         if (status != PVMFSuccess)
144         {
145             LOG_ERR((0, "PVMFFileDummyInputPort::getParametersSync: Error - AllocateKvp failed. status=%d", status));
146             return status;
147         }
148 
149         parameters[0].value.uint32_value = node->iSettings.iFrameWidth;
150     }
151     else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_HEIGHT_CUR_QUERY) == 0)
152     {
153         num_parameter_elements = 1;
154         status = AllocateKvp(parameters, OSCL_STATIC_CAST(PvmiKeyType, VIDEO_OUTPUT_HEIGHT_CUR_VALUE), num_parameter_elements);
155         if (status != PVMFSuccess)
156         {
157             LOG_ERR((0, "PVMFFileDummyInputPort::getParametersSync: Error - AllocateKvp failed. status=%d", status));
158             return status;
159         }
160 
161         parameters[0].value.uint32_value = node->iSettings.iFrameHeight;
162     }
163     else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_FRAME_RATE_CUR_QUERY) == 0)
164     {
165         num_parameter_elements = 1;
166         status = AllocateKvp(parameters, OSCL_STATIC_CAST(PvmiKeyType, VIDEO_OUTPUT_FRAME_RATE_CUR_VALUE), num_parameter_elements);
167         if (status != PVMFSuccess)
168         {
169             LOG_ERR((0, "PVMFFileDummyInputPort::getParametersSync: Error - AllocateKvp failed. status=%d", status));
170             return status;
171         }
172 
173         parameters[0].value.float_value = node->iSettings.iFrameRate;
174     }
175     else if (pv_mime_strcmp(identifier, OUTPUT_TIMESCALE_CUR_QUERY) == 0)
176     {
177         num_parameter_elements = 1;
178         status = AllocateKvp(parameters, OSCL_STATIC_CAST(PvmiKeyType, OUTPUT_TIMESCALE_CUR_VALUE), num_parameter_elements);
179         if (status != PVMFSuccess)
180         {
181             LOG_ERR((0, "PVMFVideoEncPort::getParametersSync: Error - AllocateKvp failed. status=%d", status));
182             return status;
183         }
184         else
185         {
186             if ((node->iSettings.iMediaFormat).isAudio())
187             {
188                 parameters[0].value.uint32_value = node->iSettings.iSamplingFrequency;
189             }
190             else
191             {
192                 parameters[0].value.uint32_value = node->iSettings.iTimescale;
193             }
194         }
195     }
196 
197     return status;
198 }
199 
200 ////////////////////////////////////////////////////////////////////////////
releaseParameters(PvmiMIOSession session,PvmiKvp * parameters,int num_elements)201 OSCL_EXPORT_REF PVMFStatus PVMFFileDummyInputPort::releaseParameters(PvmiMIOSession session,
202         PvmiKvp* parameters,
203         int num_elements)
204 {
205     OSCL_UNUSED_ARG(session);
206     OSCL_UNUSED_ARG(num_elements);
207 
208     if (parameters)
209     {
210         iAlloc.deallocate((OsclAny*)parameters->key);
211         return PVMFSuccess;
212     }
213     else
214     {
215         return PVMFFailure;
216     }
217 }
218 
219 ////////////////////////////////////////////////////////////////////////////
createContext(PvmiMIOSession session,PvmiCapabilityContext & context)220 OSCL_EXPORT_REF void PVMFFileDummyInputPort::createContext(PvmiMIOSession session, PvmiCapabilityContext& context)
221 {
222     OSCL_UNUSED_ARG(session);
223     OSCL_UNUSED_ARG(context);
224 }
225 
226 ////////////////////////////////////////////////////////////////////////////
setContextParameters(PvmiMIOSession session,PvmiCapabilityContext & context,PvmiKvp * parameters,int num_parameter_elements)227 OSCL_EXPORT_REF void PVMFFileDummyInputPort::setContextParameters(PvmiMIOSession session,
228         PvmiCapabilityContext& context,
229         PvmiKvp* parameters, int num_parameter_elements)
230 {
231     OSCL_UNUSED_ARG(session);
232     OSCL_UNUSED_ARG(context);
233     OSCL_UNUSED_ARG(parameters);
234     OSCL_UNUSED_ARG(num_parameter_elements);
235 }
236 
237 ////////////////////////////////////////////////////////////////////////////
DeleteContext(PvmiMIOSession session,PvmiCapabilityContext & context)238 OSCL_EXPORT_REF void PVMFFileDummyInputPort::DeleteContext(PvmiMIOSession session, PvmiCapabilityContext& context)
239 {
240     OSCL_UNUSED_ARG(session);
241     OSCL_UNUSED_ARG(context);
242 }
243 
244 ////////////////////////////////////////////////////////////////////////////
setParametersSync(PvmiMIOSession session,PvmiKvp * parameters,int num_elements,PvmiKvp * & ret_kvp)245 OSCL_EXPORT_REF void PVMFFileDummyInputPort::setParametersSync(PvmiMIOSession session, PvmiKvp* parameters,
246         int num_elements, PvmiKvp*& ret_kvp)
247 {
248     OSCL_UNUSED_ARG(session);
249     PVMFStatus status = PVMFSuccess;
250     ret_kvp = NULL;
251 
252     for (int32 i = 0; i < num_elements; i++)
253     {
254         status = VerifyAndSetParameter(&(parameters[i]), true);
255         if (status != PVMFSuccess)
256         {
257             LOG_ERR((0, "PVMFFileDummyInputPort::setParametersSync: Error - VerifiyAndSetParameter failed on parameter #%d", i));
258             ret_kvp = &(parameters[i]);
259             OSCL_LEAVE(OsclErrArgument);
260         }
261     }
262 }
263 
264 ////////////////////////////////////////////////////////////////////////////
setParametersAsync(PvmiMIOSession session,PvmiKvp * parameters,int num_elements,PvmiKvp * & ret_kvp,OsclAny * context)265 OSCL_EXPORT_REF PVMFCommandId PVMFFileDummyInputPort::setParametersAsync(PvmiMIOSession session,
266         PvmiKvp* parameters,
267         int num_elements,
268         PvmiKvp*& ret_kvp,
269         OsclAny* context)
270 {
271     OSCL_UNUSED_ARG(session);
272     OSCL_UNUSED_ARG(parameters);
273     OSCL_UNUSED_ARG(num_elements);
274     OSCL_UNUSED_ARG(ret_kvp);
275     OSCL_UNUSED_ARG(context);
276     return -1;
277 }
278 
279 ////////////////////////////////////////////////////////////////////////////
getCapabilityMetric(PvmiMIOSession session)280 OSCL_EXPORT_REF uint32 PVMFFileDummyInputPort::getCapabilityMetric(PvmiMIOSession session)
281 {
282     OSCL_UNUSED_ARG(session);
283     return 0;
284 }
285 
286 ////////////////////////////////////////////////////////////////////////////
verifyParametersSync(PvmiMIOSession session,PvmiKvp * parameters,int num_elements)287 OSCL_EXPORT_REF PVMFStatus PVMFFileDummyInputPort::verifyParametersSync(PvmiMIOSession session,
288         PvmiKvp* parameters, int num_elements)
289 {
290     OSCL_UNUSED_ARG(session);
291 
292     PVMFStatus status = PVMFSuccess;
293     for (int32 i = 0; (i < num_elements) && (status == PVMFSuccess); i++)
294         status = VerifyAndSetParameter(&(parameters[i]));
295 
296     return status;
297 }
298 
299 ////////////////////////////////////////////////////////////////////////////////////////////////////////
Connect(PVMFPortInterface * aPort)300 OSCL_EXPORT_REF PVMFStatus PVMFFileDummyInputPort::Connect(PVMFPortInterface* aPort)
301 {
302 
303 
304     if (!aPort)
305     {
306         LOG_ERR((0, "PVMFFileDummyInputPort::Connect: Error - Connecting to invalid port"));
307         return PVMFErrArgument;
308     }
309 
310     if (iConnectedPort)
311     {
312         LOG_ERR((0, "PVMFFileDummyInputPort::Connect: Error - Already connected"));
313         return PVMFFailure;
314     }
315 
316     OsclAny* temp = NULL;
317     aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
318     PvmiCapabilityAndConfig* config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
319 
320     if (config != NULL)
321     {
322         if (!(pvmiSetPortFormatSpecificInfoSync(config, PVMF_FORMAT_SPECIFIC_INFO_KEY)))
323         {
324             LOG_ERR((0, "PVMFFileDummyInputPort::Connect: Error - Unable To Send Format Specific Info To Peer"));
325             return PVMFFailure;
326         }
327     }
328 
329     /*
330      * Automatically connect the peer.
331      */
332     if (aPort->PeerConnect(this) != PVMFSuccess)
333     {
334         LOG_ERR((0, "PVMFFileDummyInputPort::Connect: Error - Peer Connect failed"));
335         return PVMFFailure;
336     }
337 
338     iConnectedPort = aPort;
339 
340     PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
341     return PVMFSuccess;
342 }
343 
344 ////////////////////////////////////////////////////////////////////////////
IsFormatSupported(PVMFFormatType aFmt)345 bool PVMFFileDummyInputPort::IsFormatSupported(PVMFFormatType aFmt)
346 {
347     return ((aFmt == PVMF_MIME_YUV420)              ||
348             (aFmt == PVMF_MIME_RGB16)               ||
349             (aFmt == PVMF_MIME_M4V)             ||
350             (aFmt == PVMF_MIME_WMV)             ||
351             (aFmt == PVMF_MIME_WMA)             ||
352             (aFmt == PVMF_MIME_H2632000)                ||
353             (aFmt == PVMF_MIME_AMR_IF2)         ||
354             (aFmt == PVMF_MIME_AMR_IETF)            ||
355             (aFmt == PVMF_MIME_PCM16)               ||
356             (aFmt == PVMF_MIME_ADTS)                ||
357             (aFmt == PVMF_MIME_MPEG4_AUDIO)        ||
358             (aFmt == PVMF_MIME_LATM)                ||
359             (aFmt == PVMF_MIME_MP3)             ||
360             (aFmt == PVMF_MIME_ADIF)                ||
361             (aFmt == PVMF_MIME_AAC_SIZEHDR)     ||
362             (aFmt == PVMF_MIME_G726)                ||
363             (aFmt == PVMF_MIME_YUV420)              ||
364             (aFmt == PVMF_MIME_REAL_AUDIO));
365 }
366 
367 ////////////////////////////////////////////////////////////////////////////
FormatUpdated()368 void PVMFFileDummyInputPort::FormatUpdated()
369 {
370     PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
371                     , (0, "PVMFFileDummyInputPort::FormatUpdated %s", iFormat.getMIMEStrPtr()));
372 }
373 
374 ////////////////////////////////////////////////////////////////////////////
AllocateKvp(PvmiKvp * & aKvp,PvmiKeyType aKey,int32 aNumParams)375 PVMFStatus PVMFFileDummyInputPort::AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams)
376 {
377     LOG_STACK_TRACE((0, "PVMFFileDummyInputPort::AllocateKvp"));
378     uint8* buf = NULL;
379     uint32 keyLen = oscl_strlen(aKey) + 1;
380     int32 err = 0;
381 
382     OSCL_TRY(err,
383              buf = (uint8*)iAlloc.ALLOCATE(aNumParams * (sizeof(PvmiKvp) + keyLen));
384              if (!buf)
385              OSCL_LEAVE(OsclErrNoMemory);
386             );
387     OSCL_FIRST_CATCH_ANY(err,
388                          LOG_ERR((0, "PVMFFileDummyInputPort::AllocateKvp: Error - kvp allocation failed"));
389                          return PVMFErrNoMemory;
390                         );
391 
392     int32 i = 0;
393     PvmiKvp* curKvp = aKvp = OSCL_PLACEMENT_NEW(buf, PvmiKvp);
394     buf += sizeof(PvmiKvp);
395     for (i = 1; i < aNumParams; i++)
396     {
397         curKvp += i;
398         curKvp = OSCL_PLACEMENT_NEW(buf, PvmiKvp);
399         buf += sizeof(PvmiKvp);
400     }
401 
402     for (i = 0; i < aNumParams; i++)
403     {
404         aKvp[i].key = (char*)buf;
405         oscl_strncpy(aKvp[i].key, aKey, oscl_strlen(aKvp[i].key));
406         buf += oscl_strlen(aKvp[i].key);
407     }
408 
409     return PVMFSuccess;
410 }
411 
412 ////////////////////////////////////////////////////////////////////////////
VerifyAndSetParameter(PvmiKvp * aKvp,bool aSetParam)413 PVMFStatus PVMFFileDummyInputPort::VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam)
414 {
415     LOG_STACK_TRACE((0, "PVMFFileDummyInputPort::VerifyAndSetParameter: aKvp=0x%x, aSetParam=%d", aKvp, aSetParam));
416 
417     if (!aKvp)
418     {
419         LOG_ERR((0, "PVMFFileDummyInputPort::VerifyAndSetParameter: Error - Invalid key-value pair"));
420         return PVMFFailure;
421     }
422 
423     PVMFDummyFileInputNode* node = (PVMFDummyFileInputNode*)iPortActivityHandler;
424 
425     if (pv_mime_strcmp(aKvp->key, OUTPUT_FORMATS_VALTYPE) == 0)
426     {
427         if (aKvp->value.pChar_value == node->iSettings.iMediaFormat.getMIMEStrPtr())
428         {
429             if (aSetParam)
430                 iFormat = aKvp->value.pChar_value;
431             return PVMFSuccess;
432         }
433         else
434         {
435             LOG_ERR((0, "PVMFFileDummyInputPort::VerifyAndSetParameter: Error - Unsupported format %d",
436                      aKvp->value.uint32_value));
437             return PVMFFailure;
438         }
439     }
440 
441     LOG_ERR((0, "PVMFFileDummyInputPort::VerifyAndSetParameter: Error - Unsupported parameter"));
442     return PVMFFailure;
443 }
444 
445 //////////////////////////////////////////////////////////////////////////////////////
pvmiGetPortFormatSpecificInfoSync(const char * aFormatValType,PvmiKvp * & aKvp)446 bool PVMFFileDummyInputPort::pvmiGetPortFormatSpecificInfoSync(const char* aFormatValType,
447         PvmiKvp*& aKvp)
448 {
449     PVMFDummyFileInputNode* node = (PVMFDummyFileInputNode*)iPortActivityHandler;
450 
451     if ((iFormat == PVMF_MIME_WMV) || (iFormat == PVMF_MIME_WMA))
452     {
453         if (node->iFs.Connect() != 0) return false;
454         node->iInputFile.Open(node->iSettings.iFileName.get_cstr(), Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, node->iFs);
455         node->iInputFile.Read((OsclAny*) &iTrackConfigSizeFI, sizeof(uint8), 4);
456 
457         iTrackConfigFI = (uint8*) iAlloc.allocate(iTrackConfigSizeFI);
458         node->iInputFile.Read((OsclAny*) iTrackConfigFI, sizeof(uint8), iTrackConfigSizeFI);
459         node->iInputFile.Close();
460 
461         if (iTrackConfigSizeFI > 0)
462         {
463             OsclMemAllocator alloc;
464             aKvp->key = NULL;
465             aKvp->length = oscl_strlen(aFormatValType) + 1; // +1 for \0
466             aKvp->key = (PvmiKeyType)alloc.ALLOCATE(aKvp->length);
467             if (aKvp->key == NULL)
468             {
469                 return false;
470             }
471             oscl_strncpy(aKvp->key, aFormatValType, aKvp->length);
472 
473             aKvp->value.key_specific_value = (OsclAny*)(iTrackConfigFI);
474             aKvp->capacity = iTrackConfigSizeFI;
475         }
476         return true;
477     }
478 
479     else
480         return true;
481 
482 }
483 
484 ////////////////////////////////////////////////////////////////////////////////////////////////////
pvmiSetPortFormatSpecificInfoSync(PvmiCapabilityAndConfig * aPort,const char * aFormatValType)485 bool PVMFFileDummyInputPort::pvmiSetPortFormatSpecificInfoSync(PvmiCapabilityAndConfig *aPort,
486         const char* aFormatValType)
487 {
488     PVMFDummyFileInputNode* node = OSCL_STATIC_CAST(PVMFDummyFileInputNode*, iPortActivityHandler);
489     PvmiKvp* retKvp = NULL; // for return value
490     int32 err = 0;
491     PvmiKvp* kvpPtr = NULL;
492     if (iFormat == PVMF_MIME_WMV)
493     {
494         if (node->iFs.Connect() != 0) return false;
495         node->iInputFile.Open(node->iSettings.iFileName.get_cstr(),
496                               Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, node->iFs);
497         node->iInputFile.Read((OsclAny*) &iTrackConfigSizeFI, sizeof(uint8), 4);
498 
499         iTrackConfigFI = (uint8*)oscl_malloc(iTrackConfigSizeFI);
500         node->iInputFile.Read((OsclAny*) iTrackConfigFI, sizeof(uint8), iTrackConfigSizeFI);
501         node->iInputFile.Close();
502 
503         if (iTrackConfigSizeFI > 0)
504         {
505             OsclMemAllocator alloc;
506             PvmiKvp kvp;
507             kvp.key = NULL;
508             kvp.length = oscl_strlen(aFormatValType) + 1; // +1 for \0
509             kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
510             if (kvp.key == NULL)
511             {
512                 return false;
513             }
514             oscl_strncpy(kvp.key, aFormatValType, kvp.length);
515 
516             kvp.value.key_specific_value = (OsclAny*) iTrackConfigFI;
517             kvp.capacity = iTrackConfigSizeFI;
518             OSCL_TRY(err, aPort->setParametersSync(NULL, &kvp, 1, retKvp););
519             /* ignore the error for now */
520             alloc.deallocate((OsclAny*)(kvp.key));
521         }
522     }
523     else if (iFormat == PVMF_MIME_G726)
524     {
525         // Send a fake G726 format specific info containing number of bits per sample in the
526         // 14th byte of the info buffer.
527         if (AllocateKvp(kvpPtr, OSCL_STATIC_CAST(PvmiKeyType, aFormatValType), 1) != PVMFSuccess)
528         {
529             LOG_ERR((0, "PVMFFileDummyInputPort::pvmiSetPortFormatSpecificInfoSync: Error - AllocateKvp failed"));
530             return false;
531         }
532 
533         kvpPtr->value.key_specific_value = OSCL_MALLOC(32);
534         if (kvpPtr->value.key_specific_value == NULL)
535         {
536             LOG_ERR((0, "PVMFFileDummyInputPort::pvmiSetPortFormatSpecificInfoSync: Error - OSCL_MALLOC failed"));
537             return false;
538         }
539         oscl_memset(kvpPtr->value.key_specific_value, 0, 32);
540 
541         int16* bitsPerSamplePtr;
542         bitsPerSamplePtr = OSCL_STATIC_CAST(int16*,
543                                             (OSCL_STATIC_CAST(uint8*, kvpPtr->value.key_specific_value) + 14));
544         *bitsPerSamplePtr = (node->iSettings.iBitrate) / (node->iSettings.iSamplingFrequency);
545 
546         OSCL_TRY(err, aPort->setParametersSync(NULL, kvpPtr, 1, retKvp););
547         OSCL_FIRST_CATCH_ANY(err,
548                              LOG_ERR((0, "PVMFFileDummyInputPort::pvmiSetPortFormatSpecificInfoSync: Error - setParametersSync failed. err=%d", err));
549                              return false;
550                             );
551 
552         OSCL_FREE(kvpPtr->value.key_specific_value);
553         releaseParameters(NULL, kvpPtr, 1);
554     }
555 
556     return true;
557 }
558