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 #include "pv_omxcomponent.h" 19 #include "pv_omxdefs.h" 20 #include "oscl_types.h" 21 22 #if PROXY_INTERFACE 23 #include "omx_proxy_interface.h" 24 #endif 25 26 27 OmxComponentBase::OmxComponentBase() : 28 OsclActiveObject(OsclActiveObject::EPriorityNominal, "OMXComponent") 29 { 30 //Flag to call BufferMgmtFunction in the Run() when the component state is executing 31 iBufferExecuteFlag = OMX_FALSE; 32 ipAppPriv = NULL; 33 34 iLogger = PVLogger::GetLoggerObject("OmxComponentBase"); 35 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : constructed")); 36 37 ipCallbacks = NULL; 38 iCallbackData = NULL; 39 iState = OMX_StateLoaded; 40 41 ipCoreDescriptor = NULL; 42 iNumInputBuffer = 0; 43 44 ipFrameDecodeBuffer = NULL; 45 iPartialFrameAssembly = OMX_FALSE; 46 iIsInputBufferEnded = OMX_TRUE; 47 iEndofStream = OMX_FALSE; 48 ipTempInputBuffer = NULL; 49 iTempInputBufferLength = 0; 50 51 ipTargetComponent = NULL; 52 iTargetMarkData = NULL; 53 ipTempTargetComponent = NULL; 54 iTempTargetMarkData = NULL; 55 56 iNewInBufferRequired = OMX_TRUE; 57 iNewOutBufRequired = OMX_TRUE; 58 59 iTempConsumedLength = 0; 60 iOutBufferCount = 0; 61 iCodecReady = OMX_FALSE; 62 ipInputCurrBuffer = NULL; 63 iInputCurrBufferSize = 0; 64 iInputCurrLength = 0; 65 iFrameCount = 0; 66 iStateTransitionFlag = OMX_FALSE; 67 iEndOfFrameFlag = OMX_FALSE; 68 ipInputBuffer = NULL; 69 ipOutputBuffer = NULL; 70 71 iOutputFrameLength = 0; 72 iNumPorts = 0; 73 iCompressedFormatPortNum = OMX_PORT_INPUTPORT_INDEX; 74 ipComponentProxy = NULL; 75 76 ipPorts = NULL; 77 78 //Indicate whether component has been already initialized */ 79 iIsInit = OMX_FALSE; 80 81 iGroupPriority = 0; 82 iGroupID = 0; 83 84 iComponentRoleFlag = OMX_FALSE; 85 ipMark = NULL; 86 87 iEosProcessing = OMX_FALSE; 88 iFirstFragment = OMX_FALSE; 89 iFrameTimestamp = 0; 90 iSamplesPerFrame = 0; 91 iSilenceInsertionInProgress = OMX_FALSE; 92 iSilenceFramesNeeded = 0; 93 iIsFirstOutputFrame = OMX_TRUE; 94 iInputBufferRemainingBytes = 0; 95 iResizePending = OMX_FALSE; 96 97 ipTempOutBufferForPortReconfig = NULL; 98 iSizeOutBufferForPortReconfig = 0; 99 iSendOutBufferAfterPortReconfigFlag = OMX_FALSE; 100 iTimestampOutBufferForPortReconfig = (OMX_TICKS)0; 101 iOutputMicroSecPerFrame = (OMX_TICKS)0; 102 } 103 104 105 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::ConstructBaseComponent(OMX_PTR pAppData) 106 { 107 OSCL_UNUSED_ARG(pAppData); 108 OMX_U32 ii, jj; 109 110 if (iNumPorts) 111 { 112 if (ipPorts) 113 { 114 oscl_free(ipPorts); 115 ipPorts = NULL; 116 } 117 118 ipPorts = (ComponentPortType**) oscl_calloc(iNumPorts, sizeof(ComponentPortType*)); 119 if (!ipPorts) 120 { 121 return OMX_ErrorInsufficientResources; 122 } 123 124 for (ii = 0; ii < iNumPorts; ii++) 125 { 126 ipPorts[ii] = (ComponentPortType*) oscl_calloc(1, sizeof(ComponentPortType)); 127 if (!ipPorts[ii]) 128 { 129 return OMX_ErrorInsufficientResources; 130 } 131 132 ipPorts[ii]->TransientState = OMX_StateMax; 133 SetHeader(&ipPorts[ii]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); 134 ipPorts[ii]->PortParam.nPortIndex = ii; 135 136 /** Allocate and initialize buffer Queue */ 137 ipPorts[ii]->pBufferQueue = (QueueType*) oscl_malloc(sizeof(QueueType)); 138 139 if (NULL == ipPorts[ii]->pBufferQueue) 140 { 141 return OMX_ErrorInsufficientResources; 142 } 143 144 if (OMX_ErrorNone != QueueInit(ipPorts[ii]->pBufferQueue)) 145 { 146 return OMX_ErrorInsufficientResources; 147 } 148 149 for (jj = 0; jj < OMX_PORT_NUMBER_FORMATS_SUPPORTED; jj++) 150 { 151 oscl_memset(&ipPorts[ii]->VideoParam[jj], 0, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); 152 } 153 } 154 155 SetPortFlushFlag(iNumPorts, -1, OMX_FALSE); 156 SetNumBufferFlush(iNumPorts, -1, OMX_FALSE); 157 } 158 159 160 iCodecReady = OMX_FALSE; 161 ipCallbacks = NULL; 162 iCallbackData = NULL; 163 iState = OMX_StateLoaded; 164 ipTempInputBuffer = NULL; 165 iTempInputBufferLength = 0; 166 iNumInputBuffer = 0; 167 iPartialFrameAssembly = OMX_FALSE; 168 iEndofStream = OMX_FALSE; 169 iIsInputBufferEnded = OMX_TRUE; 170 iNewOutBufRequired = OMX_TRUE; 171 iEosProcessing = OMX_FALSE; 172 iRepositionFlag = OMX_FALSE; 173 iIsFirstOutputFrame = OMX_TRUE; 174 iMarkPropagate = OMX_FALSE; 175 ipTempOutBufferForPortReconfig = NULL; 176 iSendOutBufferAfterPortReconfigFlag = OMX_FALSE; 177 iSizeOutBufferForPortReconfig = 0; 178 iComponentRoleFlag = OMX_FALSE; 179 180 181 /* Initialize the asynchronous command Queue */ 182 if (ipCoreDescriptor) 183 { 184 oscl_free(ipCoreDescriptor); 185 ipCoreDescriptor = NULL; 186 } 187 188 ipCoreDescriptor = (CoreDescriptorType*) oscl_malloc(sizeof(CoreDescriptorType)); 189 if (NULL == ipCoreDescriptor) 190 { 191 return OMX_ErrorInsufficientResources; 192 } 193 194 ipCoreDescriptor->pMessageQueue = NULL; 195 ipCoreDescriptor->pMessageQueue = (QueueType*) oscl_malloc(sizeof(QueueType)); 196 if (NULL == ipCoreDescriptor->pMessageQueue) 197 { 198 return OMX_ErrorInsufficientResources; 199 } 200 201 if (OMX_ErrorNone != QueueInit(ipCoreDescriptor->pMessageQueue)) 202 { 203 return OMX_ErrorInsufficientResources; 204 } 205 206 /** Default parameters setting */ 207 iIsInit = OMX_FALSE; 208 iGroupPriority = 0; 209 iGroupID = 0; 210 ipMark = NULL; 211 212 SetHeader(&iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE)); 213 214 iOutBufferCount = 0; 215 iStateTransitionFlag = OMX_FALSE; 216 iEndOfFrameFlag = OMX_FALSE; 217 iFirstFragment = OMX_FALSE; 218 219 //Will be used in case of partial frame assembly 220 ipInputCurrBuffer = NULL; 221 iInputCurrBufferSize = 0; 222 ipAppPriv->CompHandle = &iOmxComponent; 223 224 return OMX_ErrorNone; 225 } 226 227 228 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::DestroyBaseComponent() 229 { 230 OMX_U32 ii; 231 232 /*Deinitialize and free ports semaphores and Queue*/ 233 for (ii = 0; ii < iNumPorts; ii++) 234 { 235 if (NULL != ipPorts[ii]->pBufferQueue) 236 { 237 QueueDeinit(ipPorts[ii]->pBufferQueue); 238 oscl_free(ipPorts[ii]->pBufferQueue); 239 ipPorts[ii]->pBufferQueue = NULL; 240 } 241 /*Free port*/ 242 if (NULL != ipPorts[ii]) 243 { 244 oscl_free(ipPorts[ii]); 245 ipPorts[ii] = NULL; 246 } 247 } 248 249 if (ipPorts) 250 { 251 oscl_free(ipPorts); 252 ipPorts = NULL; 253 } 254 255 iState = OMX_StateLoaded; 256 257 //Free the temp output buffer 258 if (ipTempOutBufferForPortReconfig) 259 { 260 oscl_free(ipTempOutBufferForPortReconfig); 261 ipTempOutBufferForPortReconfig = NULL; 262 iSizeOutBufferForPortReconfig = 0; 263 } 264 265 if (ipInputCurrBuffer) 266 { 267 oscl_free(ipInputCurrBuffer); 268 ipInputCurrBuffer = NULL; 269 iInputCurrBufferSize = 0; 270 } 271 272 if (ipTempInputBuffer) 273 { 274 oscl_free(ipTempInputBuffer); 275 ipTempInputBuffer = NULL; 276 } 277 278 if (NULL != ipCoreDescriptor) 279 { 280 281 if (NULL != ipCoreDescriptor->pMessageQueue) 282 { 283 /* De-initialize the asynchronous command queue */ 284 QueueDeinit(ipCoreDescriptor->pMessageQueue); 285 oscl_free(ipCoreDescriptor->pMessageQueue); 286 ipCoreDescriptor->pMessageQueue = NULL; 287 } 288 289 oscl_free(ipCoreDescriptor); 290 ipCoreDescriptor = NULL; 291 } 292 293 return OMX_ErrorNone; 294 } 295 296 297 /********************* 298 * 299 * Component verfication routines 300 * 301 **********************/ 302 303 OSCL_EXPORT_REF void OmxComponentBase::SetHeader(OMX_PTR aHeader, OMX_U32 aSize) 304 { 305 OMX_VERSIONTYPE* pVersion = (OMX_VERSIONTYPE*)((OMX_STRING) aHeader + sizeof(OMX_U32)); 306 *((OMX_U32*) aHeader) = aSize; 307 308 pVersion->s.nVersionMajor = SPECVERSIONMAJOR; 309 pVersion->s.nVersionMinor = SPECVERSIONMINOR; 310 pVersion->s.nRevision = SPECREVISION; 311 pVersion->s.nStep = SPECSTEP; 312 } 313 314 315 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::CheckHeader(OMX_PTR aHeader, OMX_U32 aSize) 316 { 317 OMX_VERSIONTYPE* pVersion = (OMX_VERSIONTYPE*)((OMX_STRING) aHeader + sizeof(OMX_U32)); 318 319 if (NULL == aHeader) 320 { 321 return OMX_ErrorBadParameter; 322 } 323 324 if (*((OMX_U32*) aHeader) != aSize) 325 { 326 return OMX_ErrorBadParameter; 327 } 328 329 if (pVersion->s.nVersionMajor != SPECVERSIONMAJOR || 330 pVersion->s.nVersionMinor != SPECVERSIONMINOR || 331 pVersion->s.nRevision != SPECREVISION || 332 pVersion->s.nStep != SPECSTEP) 333 { 334 return OMX_ErrorVersionMismatch; 335 } 336 337 return OMX_ErrorNone; 338 } 339 340 341 /** 342 * This function verify component state and structure header 343 */ 344 OMX_ERRORTYPE OmxComponentBase::ParameterSanityCheck( 345 OMX_IN OMX_HANDLETYPE hComponent, 346 OMX_IN OMX_U32 nPortIndex, 347 OMX_IN OMX_PTR pStructure, 348 OMX_IN size_t size) 349 { 350 OSCL_UNUSED_ARG(hComponent); 351 if (iState != OMX_StateLoaded && 352 iState != OMX_StateWaitForResources) 353 { 354 return OMX_ErrorIncorrectStateOperation; 355 } 356 357 if (nPortIndex >= iNumPorts) 358 { 359 return OMX_ErrorBadPortIndex; 360 } 361 362 return CheckHeader(pStructure, size); 363 } 364 365 /** 366 * Set/Reset Port Flush Flag 367 */ 368 void OmxComponentBase::SetPortFlushFlag(OMX_S32 NumPorts, OMX_S32 index, OMX_BOOL value) 369 { 370 OMX_S32 ii; 371 372 if (-1 == index) 373 { 374 for (ii = 0; ii < NumPorts; ii++) 375 { 376 ipPorts[ii]->IsPortFlushed = value; 377 } 378 } 379 else 380 { 381 ipPorts[index]->IsPortFlushed = value; 382 } 383 384 } 385 386 /** 387 * Set Number of Buffer Flushed with the value Specified 388 */ 389 void OmxComponentBase::SetNumBufferFlush(OMX_S32 NumPorts, OMX_S32 index, OMX_S32 value) 390 { 391 OMX_S32 ii; 392 393 if (-1 == index) 394 { 395 // For all ComponentPort 396 for (ii = 0; ii < NumPorts; ii++) 397 { 398 ipPorts[ii]->NumBufferFlushed = value; 399 } 400 } 401 else 402 { 403 ipPorts[index]->NumBufferFlushed = value; 404 } 405 } 406 407 408 OSCL_EXPORT_REF OMX_BOOL OmxComponentBase::ParseFullAVCFramesIntoNALs(OMX_BUFFERHEADERTYPE* aInputBuffer) 409 { 410 OSCL_UNUSED_ARG(aInputBuffer); 411 412 // we should never arrive here if this is not an AVC component, since iOMXComponentUsesFullAVCFrames (which is tested before calling this function) 413 // should only be set for an AVC component 414 415 OSCL_ASSERT(OMX_FALSE); 416 417 return OMX_FALSE; 418 } 419 420 /** This function assembles multiple input buffers into 421 * one frame with the marker flag OMX_BUFFERFLAG_ENDOFFRAME set 422 */ 423 OMX_BOOL OmxComponentBase::AssemblePartialFrames(OMX_BUFFERHEADERTYPE* aInputBuffer) 424 { 425 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AssemblePartialFrames IN")); 426 427 QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue; 428 429 ComponentPortType* pInPort = ipPorts[OMX_PORT_INPUTPORT_INDEX]; 430 OMX_U32 BytesToCopy = 0; 431 432 ipInputBuffer = aInputBuffer; 433 434 if (!iPartialFrameAssembly) 435 { 436 if (iNumInputBuffer > 0) 437 { 438 if (ipInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) 439 { 440 iInputCurrLength = ipInputBuffer->nFilledLen; 441 442 //Only applicable for H.264 component 443 #ifdef INSERT_NAL_START_CODE 444 // this is the case of 1 full NAL in 1 buffer 445 // if start codes are inserted, skip the start code 446 iInputCurrLength = ipInputBuffer->nFilledLen - 4; 447 ipInputBuffer->nOffset += 4; 448 #endif 449 ipFrameDecodeBuffer = ipInputBuffer->pBuffer + ipInputBuffer->nOffset; 450 //capture the timestamp to be send to the corresponding output buffer 451 iFrameTimestamp = ipInputBuffer->nTimeStamp; 452 } 453 else 454 { 455 iInputCurrLength = 0; 456 iPartialFrameAssembly = OMX_TRUE; 457 iFirstFragment = OMX_TRUE; 458 iFrameTimestamp = ipInputBuffer->nTimeStamp; 459 ipFrameDecodeBuffer = ipInputCurrBuffer; 460 } 461 462 } 463 else 464 { 465 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AssemblePartialFrames ERROR")); 466 return OMX_FALSE; 467 } 468 469 } 470 471 //Assembling of partial frame will be done based on OMX_BUFFERFLAG_ENDOFFRAME flag marked 472 if (iPartialFrameAssembly) 473 { 474 while (iNumInputBuffer > 0) 475 { 476 if (OMX_FALSE == iFirstFragment) 477 { 478 /* If the timestamp of curr fragment doesn't match with previous, 479 * discard the previous fragments & start reconstructing from new 480 */ 481 if (iFrameTimestamp != ipInputBuffer->nTimeStamp) 482 { 483 iInputCurrLength = 0; 484 iPartialFrameAssembly = OMX_TRUE; 485 iFirstFragment = OMX_TRUE; 486 iFrameTimestamp = ipInputBuffer->nTimeStamp; 487 ipFrameDecodeBuffer = ipInputCurrBuffer; 488 489 //Send a stream corrupt callback 490 OMX_COMPONENTTYPE *pHandle = &iOmxComponent; 491 (*(ipCallbacks->EventHandler)) 492 (pHandle, 493 iCallbackData, 494 OMX_EventError, 495 OMX_ErrorStreamCorrupt, 496 0, 497 NULL); 498 } 499 } 500 501 #ifdef INSERT_NAL_START_CODE 502 else 503 { 504 // this is the case of a partial NAL in 1 buffer 505 // this is the first fragment of a nal 506 507 // if start codes are inserted, skip the start code 508 ipInputBuffer->nFilledLen -= 4; 509 ipInputBuffer->nOffset += 4; 510 } 511 #endif 512 513 if ((ipInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) != 0) 514 { 515 break; 516 } 517 518 // check if the buffer size can take the new piece, or it needs to expand 519 BytesToCopy = ipInputBuffer->nFilledLen; 520 521 if (iInputCurrBufferSize < (iInputCurrLength + BytesToCopy)) 522 { 523 // allocate new partial frame buffer 524 OMX_U8* pTempNewBuffer = NULL; 525 pTempNewBuffer = (OMX_U8*) oscl_malloc(sizeof(OMX_U8) * (iInputCurrLength + BytesToCopy)); 526 527 // in the event that new buffer cannot be allocated 528 if (NULL == pTempNewBuffer) 529 { 530 // copy into what space is available, and let the decoder complain 531 BytesToCopy = iInputCurrLength - iInputCurrBufferSize; 532 } 533 else 534 { 535 536 // copy contents of the old buffer into the new one 537 oscl_memcpy(pTempNewBuffer, ipInputCurrBuffer, iInputCurrBufferSize); 538 // free the old buffer 539 if (ipInputCurrBuffer) 540 { 541 oscl_free(ipInputCurrBuffer); 542 } 543 // assign new one 544 ipInputCurrBuffer = pTempNewBuffer; 545 iInputCurrBufferSize = (iInputCurrLength + BytesToCopy); 546 ipFrameDecodeBuffer = ipInputCurrBuffer + iInputCurrLength; 547 } 548 } 549 550 iInputCurrLength += BytesToCopy; 551 oscl_memcpy(ipFrameDecodeBuffer, (ipInputBuffer->pBuffer + ipInputBuffer->nOffset), BytesToCopy); // copy buffer data 552 ipFrameDecodeBuffer += BytesToCopy; // move the ptr 553 554 ipInputBuffer->nFilledLen = 0; 555 556 ReturnInputBuffer(ipInputBuffer, pInPort); 557 ipInputBuffer = NULL; 558 559 iFirstFragment = OMX_FALSE; 560 561 if (iNumInputBuffer > 0) 562 { 563 ipInputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue); 564 if (NULL == ipInputBuffer) 565 { 566 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AssemblePartialFrames ERROR DeQueue() returned NULL")); 567 return OMX_FALSE; 568 } 569 570 if (ipInputBuffer->nFlags & OMX_BUFFERFLAG_EOS) 571 { 572 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AssemblePartialFrames EndOfStream arrived")); 573 iEndofStream = OMX_TRUE; 574 } 575 } 576 } 577 578 // if we broke out of the while loop because of lack of buffers, then return and wait for more input buffers 579 if (0 == iNumInputBuffer) 580 { 581 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AssemblePartialFrames OUT")); 582 return OMX_FALSE; 583 } 584 else 585 { 586 // we have found the buffer that is the last piece of the frame. 587 // Copy the buffer, but do not release it yet (this will be done after decoding for consistency) 588 589 BytesToCopy = ipInputBuffer->nFilledLen; 590 // check if the buffer size can take the new piece, or it needs to expand 591 if (iInputCurrBufferSize < (iInputCurrLength + BytesToCopy)) 592 { 593 // allocate new partial frame buffer 594 OMX_U8* pTempNewBuffer = NULL; 595 pTempNewBuffer = (OMX_U8*) oscl_malloc(sizeof(OMX_U8) * (iInputCurrLength + BytesToCopy)); 596 597 // if you cannot allocate new buffer, just copy what data you can 598 if (NULL == pTempNewBuffer) 599 { 600 BytesToCopy = iInputCurrBufferSize - iInputCurrLength; 601 } 602 else 603 { 604 605 // copy contents of the old one into new one 606 oscl_memcpy(pTempNewBuffer, ipInputCurrBuffer, iInputCurrBufferSize); 607 // free the old buffer 608 if (ipInputCurrBuffer) 609 { 610 oscl_free(ipInputCurrBuffer); 611 } 612 // assign new one 613 ipInputCurrBuffer = pTempNewBuffer; 614 iInputCurrBufferSize = (iInputCurrLength + BytesToCopy); 615 ipFrameDecodeBuffer = ipInputCurrBuffer + iInputCurrLength; 616 } 617 } 618 619 iInputCurrLength += BytesToCopy; 620 oscl_memcpy(ipFrameDecodeBuffer, (ipInputBuffer->pBuffer + ipInputBuffer->nOffset), BytesToCopy); // copy buffer data 621 ipFrameDecodeBuffer += BytesToCopy; // move the ptr 622 623 ipFrameDecodeBuffer = ipInputCurrBuffer; // reset the pointer back to beginning of assembly buffer 624 iPartialFrameAssembly = OMX_FALSE; // we have finished with assembling the frame, so this is not needed any more 625 } 626 } 627 628 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AssemblePartialFrames OUT")); 629 return OMX_TRUE; 630 } 631 632 633 OSCL_EXPORT_REF void OmxComponentBase::ReturnInputBuffer(OMX_BUFFERHEADERTYPE* pInputBuffer, ComponentPortType* pPort) 634 { 635 OSCL_UNUSED_ARG(pPort); 636 OMX_COMPONENTTYPE* pHandle = &iOmxComponent; 637 638 if (iNumInputBuffer) 639 { 640 iNumInputBuffer--; 641 } 642 643 //Callback for releasing the input buffer 644 (*(ipCallbacks->EmptyBufferDone)) 645 (pHandle, iCallbackData, pInputBuffer); 646 647 } 648 649 /** 650 * Returns Output Buffer back to the IL client 651 */ 652 OSCL_EXPORT_REF void OmxComponentBase::ReturnOutputBuffer(OMX_BUFFERHEADERTYPE* pOutputBuffer, 653 ComponentPortType *pPort) 654 { 655 OMX_COMPONENTTYPE* pHandle = &iOmxComponent; 656 657 //Callback for sending back the output buffer 658 (*(ipCallbacks->FillBufferDone)) 659 (pHandle, iCallbackData, pOutputBuffer); 660 661 if (iOutBufferCount) 662 { 663 iOutBufferCount--; 664 } 665 666 pPort->NumBufferFlushed++; 667 iNewOutBufRequired = OMX_TRUE; 668 } 669 670 671 /** Flushes all the buffers under processing by the given port. 672 * This function is called due to a state change of the component, typically 673 * @param PortIndex the ID of the port to be flushed 674 */ 675 676 OMX_ERRORTYPE OmxComponentBase::FlushPort(OMX_S32 PortIndex) 677 { 678 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FlushPort IN")); 679 680 OMX_COMPONENTTYPE* pHandle = &iOmxComponent; 681 682 683 QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue; 684 QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue; 685 686 OMX_BUFFERHEADERTYPE* pOutputBuff; 687 OMX_BUFFERHEADERTYPE* pInputBuff; 688 689 if (OMX_PORT_INPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex) 690 { 691 iPartialFrameAssembly = OMX_FALSE; 692 693 //Release all the input buffers in queue 694 while ((GetQueueNumElem(pInputQueue) > 0)) 695 { 696 pInputBuff = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue); 697 if (NULL == pInputBuff) 698 { 699 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FlushPort ERROR DeQueue() returned NULL")); 700 return OMX_ErrorUndefined; 701 } 702 (*(ipCallbacks->EmptyBufferDone)) 703 (pHandle, iCallbackData, pInputBuff); 704 iNumInputBuffer--; 705 } 706 707 //Release the current buffer that is being processed by the component. 708 if (iNumInputBuffer > 0 && ipInputBuffer && (OMX_FALSE == iIsInputBufferEnded)) 709 { 710 (*(ipCallbacks->EmptyBufferDone)) 711 (pHandle, iCallbackData, ipInputBuffer); 712 iNumInputBuffer--; 713 714 iIsInputBufferEnded = OMX_TRUE; 715 iInputCurrLength = 0; 716 } 717 } 718 719 if (OMX_PORT_OUTPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex) 720 { 721 //Release the current output buffer if present that is being processed by the component. 722 if ((OMX_FALSE == iNewOutBufRequired) && (iOutBufferCount > 0)) 723 { 724 if (ipOutputBuffer) 725 { 726 (*(ipCallbacks->FillBufferDone)) 727 (pHandle, iCallbackData, ipOutputBuffer); 728 iOutBufferCount--; 729 iNewOutBufRequired = OMX_TRUE; 730 } 731 } 732 733 //Release all other output buffers in queue 734 while ((GetQueueNumElem(pOutputQueue) > 0)) 735 { 736 pOutputBuff = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue); 737 if (NULL == pOutputBuff) 738 { 739 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FlushPort ERROR DeQueue() returned NULL")); 740 return OMX_ErrorUndefined; 741 } 742 743 pOutputBuff->nFilledLen = 0; 744 (*(ipCallbacks->FillBufferDone)) 745 (pHandle, iCallbackData, pOutputBuff); 746 iOutBufferCount--; 747 } 748 749 } 750 751 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FlushPort OUT")); 752 return OMX_ErrorNone; 753 } 754 755 /** 756 * Disable Single Port 757 */ 758 void OmxComponentBase::DisableSinglePort(OMX_U32 PortIndex) 759 { 760 ipPorts[PortIndex]->PortParam.bEnabled = OMX_FALSE; 761 762 if (PORT_IS_POPULATED(ipPorts[PortIndex]) && OMX_TRUE == iIsInit) 763 { 764 iStateTransitionFlag = OMX_TRUE; 765 return; 766 } 767 768 ipPorts[PortIndex]->NumBufferFlushed = 0; 769 } 770 771 772 /** Disables the specified port. This function is called due to a request by the IL client 773 * @param PortIndex the ID of the port to be disabled 774 */ 775 OMX_ERRORTYPE OmxComponentBase::DisablePort(OMX_S32 PortIndex) 776 { 777 778 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DisablePort IN")); 779 OMX_U32 ii; 780 781 if (-1 == PortIndex) 782 { 783 for (ii = 0; ii < iNumPorts; ii++) 784 { 785 ipPorts[ii]->IsPortFlushed = OMX_TRUE; 786 } 787 788 /*Flush all ports*/ 789 FlushPort(PortIndex); 790 791 for (ii = 0; ii < iNumPorts; ii++) 792 { 793 ipPorts[ii]->IsPortFlushed = OMX_FALSE; 794 } 795 } 796 else 797 { 798 /*Flush the port specified*/ 799 ipPorts[PortIndex]->IsPortFlushed = OMX_TRUE; 800 FlushPort(PortIndex); 801 ipPorts[PortIndex]->IsPortFlushed = OMX_FALSE; 802 } 803 804 /*Disable ports*/ 805 if (PortIndex != -1) 806 { 807 DisableSinglePort(PortIndex); 808 } 809 else 810 { 811 for (ii = 0; ii < iNumPorts; ii++) 812 { 813 DisableSinglePort(ii); 814 } 815 } 816 817 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DisablePort OUT")); 818 819 return OMX_ErrorNone; 820 } 821 822 /** 823 * Enable Single Port 824 */ 825 void OmxComponentBase::EnableSinglePort(OMX_U32 PortIndex) 826 { 827 ipPorts[PortIndex]->PortParam.bEnabled = OMX_TRUE; 828 829 if (!PORT_IS_POPULATED(ipPorts[PortIndex]) && OMX_TRUE == iIsInit) 830 { 831 iStateTransitionFlag = OMX_TRUE; 832 return; 833 } 834 } 835 836 /** Enables the specified port. This function is called due to a request by the IL client 837 * @param PortIndex the ID of the port to be enabled 838 */ 839 OMX_ERRORTYPE OmxComponentBase::EnablePort(OMX_S32 PortIndex) 840 { 841 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EnablePort IN")); 842 843 OMX_U32 ii; 844 845 /*Enable port/s*/ 846 if (PortIndex != -1) 847 { 848 EnableSinglePort(PortIndex); 849 } 850 else 851 { 852 for (ii = 0; ii < iNumPorts; ii++) 853 { 854 EnableSinglePort(ii); 855 } 856 } 857 858 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EnablePort OUT")); 859 return OMX_ErrorNone; 860 } 861 862 //Not implemented & supported in case of base profile components 863 864 OMX_ERRORTYPE OmxComponentBase::TunnelRequest( 865 OMX_IN OMX_HANDLETYPE hComp, 866 OMX_IN OMX_U32 nPort, 867 OMX_IN OMX_HANDLETYPE hTunneledComp, 868 OMX_IN OMX_U32 nTunneledPort, 869 OMX_INOUT OMX_TUNNELSETUPTYPE* pTunnelSetup) 870 { 871 OSCL_UNUSED_ARG(hComp); 872 OSCL_UNUSED_ARG(nPort); 873 OSCL_UNUSED_ARG(hTunneledComp); 874 OSCL_UNUSED_ARG(nTunneledPort); 875 OSCL_UNUSED_ARG(pTunnelSetup); 876 877 return OMX_ErrorNotImplemented; 878 } 879 880 881 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentGetConfig( 882 OMX_IN OMX_HANDLETYPE hComponent, 883 OMX_IN OMX_INDEXTYPE nIndex, 884 OMX_INOUT OMX_PTR pComponentConfigStructure) 885 { 886 887 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 888 OMX_ERRORTYPE Status; 889 890 if (NULL == pOpenmaxAOType) 891 { 892 return OMX_ErrorBadParameter; 893 } 894 895 Status = pOpenmaxAOType->GetConfig(hComponent, nIndex, pComponentConfigStructure); 896 return Status; 897 } 898 899 900 901 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::GetConfig( 902 OMX_IN OMX_HANDLETYPE hComponent, 903 OMX_IN OMX_INDEXTYPE nIndex, 904 OMX_INOUT OMX_PTR pComponentConfigStructure) 905 { 906 OSCL_UNUSED_ARG(hComponent); 907 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : GetConfig IN")); 908 909 OMX_U32 PortIndex; 910 OMX_CONFIG_INTRAREFRESHVOPTYPE* pVideoIFrame; 911 OMX_CONFIG_FRAMERATETYPE* pFrameRateType; 912 OMX_VIDEO_CONFIG_BITRATETYPE* pConfigBitRateType; 913 914 if (NULL == pComponentConfigStructure) 915 { 916 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : GetConfig error bad parameter")); 917 return OMX_ErrorBadParameter; 918 } 919 920 switch (nIndex) 921 { 922 case OMX_IndexConfigVideoIntraVOPRefresh: 923 { 924 pVideoIFrame = (OMX_CONFIG_INTRAREFRESHVOPTYPE*) pComponentConfigStructure; 925 if (pVideoIFrame->nPortIndex != iCompressedFormatPortNum) 926 { 927 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : GetConfig error bad port index for OMX_IndexConfigVideoIntraVOPRefresh")); 928 return OMX_ErrorBadPortIndex; 929 } 930 PortIndex = pVideoIFrame->nPortIndex; 931 oscl_memcpy(pVideoIFrame, &ipPorts[PortIndex]->VideoIFrame, sizeof(OMX_CONFIG_INTRAREFRESHVOPTYPE)); 932 SetHeader(pVideoIFrame, sizeof(OMX_CONFIG_INTRAREFRESHVOPTYPE)); 933 } 934 break; 935 936 case OMX_IndexConfigVideoFramerate: 937 { 938 pFrameRateType = (OMX_CONFIG_FRAMERATETYPE*) pComponentConfigStructure; 939 if (pFrameRateType->nPortIndex != iCompressedFormatPortNum) 940 { 941 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : GetConfig error bad port index for OMX_IndexConfigVideoFramerate")); 942 return OMX_ErrorBadPortIndex; 943 } 944 PortIndex = pFrameRateType->nPortIndex; 945 oscl_memcpy(pFrameRateType, &ipPorts[PortIndex]->VideoConfigFrameRateType, sizeof(OMX_CONFIG_FRAMERATETYPE)); 946 SetHeader(pFrameRateType, sizeof(OMX_CONFIG_FRAMERATETYPE)); 947 } 948 break; 949 950 case OMX_IndexConfigVideoBitrate: 951 { 952 pConfigBitRateType = (OMX_VIDEO_CONFIG_BITRATETYPE*) pComponentConfigStructure; 953 if (pConfigBitRateType->nPortIndex != iCompressedFormatPortNum) 954 { 955 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : GetConfig error bad port index for OMX_IndexConfigVideoBitrate")); 956 return OMX_ErrorBadPortIndex; 957 } 958 PortIndex = pConfigBitRateType->nPortIndex; 959 oscl_memcpy(pConfigBitRateType, &ipPorts[PortIndex]->VideoConfigBitRateType, sizeof(OMX_VIDEO_CONFIG_BITRATETYPE)); 960 SetHeader(pConfigBitRateType, sizeof(OMX_VIDEO_CONFIG_BITRATETYPE)); 961 } 962 break; 963 default: 964 { 965 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : GetParameter error Unsupported Index")); 966 return OMX_ErrorUnsupportedIndex; 967 } 968 969 } 970 971 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : GetConfig OUT")); 972 973 return OMX_ErrorNone; 974 } 975 976 977 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentSetConfig( 978 OMX_IN OMX_HANDLETYPE hComponent, 979 OMX_IN OMX_INDEXTYPE nIndex, 980 OMX_IN OMX_PTR pComponentConfigStructure) 981 { 982 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 983 OMX_ERRORTYPE Status; 984 985 if (NULL == pOpenmaxAOType) 986 { 987 return OMX_ErrorBadParameter; 988 } 989 990 Status = pOpenmaxAOType->SetConfig(hComponent, nIndex, pComponentConfigStructure); 991 return Status; 992 } 993 994 995 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::SetConfig( 996 OMX_IN OMX_HANDLETYPE hComponent, 997 OMX_IN OMX_INDEXTYPE nIndex, 998 OMX_IN OMX_PTR pComponentConfigStructure) 999 { 1000 OSCL_UNUSED_ARG(hComponent); 1001 OSCL_UNUSED_ARG(nIndex); 1002 OSCL_UNUSED_ARG(pComponentConfigStructure); 1003 1004 return OMX_ErrorNotImplemented; 1005 } 1006 1007 1008 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentGetExtensionIndex( 1009 OMX_IN OMX_HANDLETYPE hComponent, 1010 OMX_IN OMX_STRING cParameterName, 1011 OMX_OUT OMX_INDEXTYPE* pIndexType) 1012 { 1013 OSCL_UNUSED_ARG(hComponent); 1014 OSCL_UNUSED_ARG(cParameterName); 1015 OSCL_UNUSED_ARG(pIndexType); 1016 1017 return OMX_ErrorNotImplemented; 1018 } 1019 1020 1021 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentGetState( 1022 OMX_IN OMX_HANDLETYPE hComponent, 1023 OMX_OUT OMX_STATETYPE* pState) 1024 { 1025 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 1026 1027 pOpenmaxAOType->GetState(pState); 1028 1029 return OMX_ErrorNone; 1030 } 1031 1032 1033 void OmxComponentBase::GetState(OMX_OUT OMX_STATETYPE* pState) 1034 { 1035 *pState = iState; 1036 } 1037 1038 1039 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentGetParameter( 1040 OMX_IN OMX_HANDLETYPE hComponent, 1041 OMX_IN OMX_INDEXTYPE nParamIndex, 1042 OMX_INOUT OMX_PTR ComponentParameterStructure) 1043 { 1044 1045 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 1046 OMX_ERRORTYPE Status; 1047 1048 if (NULL == pOpenmaxAOType) 1049 { 1050 return OMX_ErrorBadParameter; 1051 } 1052 1053 Status = pOpenmaxAOType->GetParameter(hComponent, nParamIndex, ComponentParameterStructure); 1054 return Status; 1055 1056 } 1057 1058 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentSetParameter( 1059 OMX_IN OMX_HANDLETYPE hComponent, 1060 OMX_IN OMX_INDEXTYPE nParamIndex, 1061 OMX_IN OMX_PTR ComponentParameterStructure) 1062 { 1063 1064 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 1065 OMX_ERRORTYPE Status; 1066 1067 if (NULL == pOpenmaxAOType) 1068 { 1069 return OMX_ErrorBadParameter; 1070 } 1071 1072 Status = pOpenmaxAOType->SetParameter(hComponent, nParamIndex, ComponentParameterStructure); 1073 1074 return Status; 1075 } 1076 1077 1078 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentUseBuffer( 1079 OMX_IN OMX_HANDLETYPE hComponent, 1080 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, 1081 OMX_IN OMX_U32 nPortIndex, 1082 OMX_IN OMX_PTR pAppPrivate, 1083 OMX_IN OMX_U32 nSizeBytes, 1084 OMX_IN OMX_U8* pBuffer) 1085 { 1086 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 1087 OMX_ERRORTYPE Status; 1088 1089 if (NULL == pOpenmaxAOType) 1090 { 1091 return OMX_ErrorBadParameter; 1092 } 1093 1094 Status = pOpenmaxAOType->UseBuffer(hComponent, ppBufferHdr, nPortIndex, pAppPrivate, nSizeBytes, pBuffer); 1095 1096 return Status; 1097 } 1098 1099 1100 OMX_ERRORTYPE OmxComponentBase::UseBuffer( 1101 OMX_IN OMX_HANDLETYPE hComponent, 1102 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, 1103 OMX_IN OMX_U32 nPortIndex, 1104 OMX_IN OMX_PTR pAppPrivate, 1105 OMX_IN OMX_U32 nSizeBytes, 1106 OMX_IN OMX_U8* pBuffer) 1107 { 1108 OSCL_UNUSED_ARG(hComponent); 1109 1110 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer IN")); 1111 ComponentPortType* pBaseComponentPort; 1112 OMX_U32 ii; 1113 1114 if (nPortIndex >= iNumPorts) 1115 { 1116 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer error bad port index")); 1117 return OMX_ErrorBadPortIndex; 1118 } 1119 1120 pBaseComponentPort = ipPorts[nPortIndex]; 1121 1122 if (pBaseComponentPort->TransientState != OMX_StateIdle) 1123 { 1124 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer error incorrect state")); 1125 return OMX_ErrorIncorrectStateTransition; 1126 } 1127 1128 if (NULL == pBaseComponentPort->pBuffer) 1129 { 1130 pBaseComponentPort->pBuffer = (OMX_BUFFERHEADERTYPE**) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_BUFFERHEADERTYPE*)); 1131 if (NULL == pBaseComponentPort->pBuffer) 1132 { 1133 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer error insufficient resources")); 1134 return OMX_ErrorInsufficientResources; 1135 } 1136 1137 pBaseComponentPort->BufferState = (OMX_U32*) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_U32)); 1138 if (NULL == pBaseComponentPort->BufferState) 1139 { 1140 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer error insufficient resources")); 1141 return OMX_ErrorInsufficientResources; 1142 } 1143 } 1144 1145 for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++) 1146 { 1147 if (!(pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) && 1148 !(pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED)) 1149 { 1150 pBaseComponentPort->pBuffer[ii] = (OMX_BUFFERHEADERTYPE*) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE)); 1151 if (NULL == pBaseComponentPort->pBuffer[ii]) 1152 { 1153 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer error insufficient resources")); 1154 return OMX_ErrorInsufficientResources; 1155 } 1156 SetHeader(pBaseComponentPort->pBuffer[ii], sizeof(OMX_BUFFERHEADERTYPE)); 1157 pBaseComponentPort->pBuffer[ii]->pBuffer = pBuffer; 1158 pBaseComponentPort->pBuffer[ii]->nAllocLen = nSizeBytes; 1159 pBaseComponentPort->pBuffer[ii]->nFilledLen = 0; 1160 pBaseComponentPort->pBuffer[ii]->nOffset = 0; 1161 pBaseComponentPort->pBuffer[ii]->nFlags = 0; 1162 pBaseComponentPort->pBuffer[ii]->pPlatformPrivate = pBaseComponentPort; 1163 pBaseComponentPort->pBuffer[ii]->pAppPrivate = pAppPrivate; 1164 pBaseComponentPort->pBuffer[ii]->nTickCount = 0; 1165 pBaseComponentPort->pBuffer[ii]->nTimeStamp = 0; 1166 pBaseComponentPort->pBuffer[ii]->hMarkTargetComponent = NULL; 1167 *ppBufferHdr = pBaseComponentPort->pBuffer[ii]; 1168 if (OMX_DirInput == pBaseComponentPort->PortParam.eDir) 1169 { 1170 pBaseComponentPort->pBuffer[ii]->nInputPortIndex = nPortIndex; 1171 pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = iNumPorts; // here is assigned a non-valid port index 1172 } 1173 else 1174 { 1175 pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = nPortIndex; 1176 pBaseComponentPort->pBuffer[ii]->nInputPortIndex = iNumPorts; // here is assigned a non-valid port index 1177 } 1178 pBaseComponentPort->BufferState[ii] |= BUFFER_ASSIGNED; 1179 pBaseComponentPort->BufferState[ii] |= HEADER_ALLOCATED; 1180 pBaseComponentPort->NumAssignedBuffers++; 1181 if (pBaseComponentPort->PortParam.nBufferCountActual == pBaseComponentPort->NumAssignedBuffers) 1182 { 1183 pBaseComponentPort->PortParam.bPopulated = OMX_TRUE; 1184 1185 if (OMX_TRUE == iStateTransitionFlag) 1186 { 1187 //Reschedule the AO for a state change (Loaded->Idle) if its pending on buffer allocation 1188 RunIfNotReady(); 1189 iStateTransitionFlag = OMX_FALSE; 1190 } 1191 } 1192 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer OUT")); 1193 return OMX_ErrorNone; 1194 } 1195 } 1196 1197 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer OUT")); 1198 return OMX_ErrorNone; 1199 } 1200 1201 1202 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentAllocateBuffer( 1203 OMX_IN OMX_HANDLETYPE hComponent, 1204 OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer, 1205 OMX_IN OMX_U32 nPortIndex, 1206 OMX_IN OMX_PTR pAppPrivate, 1207 OMX_IN OMX_U32 nSizeBytes) 1208 { 1209 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 1210 OMX_ERRORTYPE Status; 1211 1212 if (NULL == pOpenmaxAOType) 1213 { 1214 return OMX_ErrorBadParameter; 1215 } 1216 1217 Status = pOpenmaxAOType->AllocateBuffer(hComponent, pBuffer, nPortIndex, pAppPrivate, nSizeBytes); 1218 1219 return Status; 1220 } 1221 1222 1223 OMX_ERRORTYPE OmxComponentBase::AllocateBuffer( 1224 OMX_IN OMX_HANDLETYPE hComponent, 1225 OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer, 1226 OMX_IN OMX_U32 nPortIndex, 1227 OMX_IN OMX_PTR pAppPrivate, 1228 OMX_IN OMX_U32 nSizeBytes) 1229 { 1230 OSCL_UNUSED_ARG(hComponent); 1231 1232 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer IN")); 1233 1234 ComponentPortType* pBaseComponentPort; 1235 OMX_U32 ii; 1236 1237 if (nPortIndex >= iNumPorts) 1238 { 1239 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer error bad port index")); 1240 return OMX_ErrorBadPortIndex; 1241 } 1242 1243 pBaseComponentPort = ipPorts[nPortIndex]; 1244 1245 if (pBaseComponentPort->TransientState != OMX_StateIdle) 1246 { 1247 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer error incorrect state")); 1248 return OMX_ErrorIncorrectStateTransition; 1249 } 1250 1251 if (NULL == pBaseComponentPort->pBuffer) 1252 { 1253 pBaseComponentPort->pBuffer = (OMX_BUFFERHEADERTYPE**) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_BUFFERHEADERTYPE*)); 1254 if (NULL == pBaseComponentPort->pBuffer) 1255 { 1256 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer error insufficient resources")); 1257 return OMX_ErrorInsufficientResources; 1258 } 1259 1260 pBaseComponentPort->BufferState = (OMX_U32*) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_U32)); 1261 if (NULL == pBaseComponentPort->BufferState) 1262 { 1263 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer error insufficient resources")); 1264 return OMX_ErrorInsufficientResources; 1265 } 1266 } 1267 1268 for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++) 1269 { 1270 if (!(pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) && 1271 !(pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED)) 1272 { 1273 pBaseComponentPort->pBuffer[ii] = (OMX_BUFFERHEADERTYPE*) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE)); 1274 if (NULL == pBaseComponentPort->pBuffer[ii]) 1275 { 1276 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer error insufficient resources")); 1277 return OMX_ErrorInsufficientResources; 1278 } 1279 SetHeader(pBaseComponentPort->pBuffer[ii], sizeof(OMX_BUFFERHEADERTYPE)); 1280 /* allocate the buffer */ 1281 pBaseComponentPort->pBuffer[ii]->pBuffer = (OMX_BYTE) oscl_malloc(nSizeBytes); 1282 if (NULL == pBaseComponentPort->pBuffer[ii]->pBuffer) 1283 { 1284 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer error insufficient resources")); 1285 return OMX_ErrorInsufficientResources; 1286 } 1287 pBaseComponentPort->pBuffer[ii]->nAllocLen = nSizeBytes; 1288 pBaseComponentPort->pBuffer[ii]->nFlags = 0; 1289 pBaseComponentPort->pBuffer[ii]->pPlatformPrivate = pBaseComponentPort; 1290 pBaseComponentPort->pBuffer[ii]->pAppPrivate = pAppPrivate; 1291 *pBuffer = pBaseComponentPort->pBuffer[ii]; 1292 pBaseComponentPort->BufferState[ii] |= BUFFER_ALLOCATED; 1293 pBaseComponentPort->BufferState[ii] |= HEADER_ALLOCATED; 1294 1295 if (OMX_DirInput == pBaseComponentPort->PortParam.eDir) 1296 { 1297 pBaseComponentPort->pBuffer[ii]->nInputPortIndex = nPortIndex; 1298 // here is assigned a non-valid port index 1299 pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = iNumPorts; 1300 } 1301 else 1302 { 1303 // here is assigned a non-valid port index 1304 pBaseComponentPort->pBuffer[ii]->nInputPortIndex = iNumPorts; 1305 pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = nPortIndex; 1306 } 1307 1308 pBaseComponentPort->NumAssignedBuffers++; 1309 1310 if (pBaseComponentPort->PortParam.nBufferCountActual == pBaseComponentPort->NumAssignedBuffers) 1311 { 1312 pBaseComponentPort->PortParam.bPopulated = OMX_TRUE; 1313 1314 if (OMX_TRUE == iStateTransitionFlag) 1315 { 1316 //Reschedule the AO for a state change (Loaded->Idle) if its pending on buffer allocation 1317 RunIfNotReady(); 1318 iStateTransitionFlag = OMX_FALSE; 1319 } 1320 } 1321 1322 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer OUT")); 1323 return OMX_ErrorNone; 1324 } 1325 } 1326 1327 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer OUT")); 1328 return OMX_ErrorInsufficientResources; 1329 } 1330 1331 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentFreeBuffer( 1332 OMX_IN OMX_HANDLETYPE hComponent, 1333 OMX_IN OMX_U32 nPortIndex, 1334 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 1335 { 1336 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 1337 OMX_ERRORTYPE Status; 1338 1339 if (NULL == pOpenmaxAOType) 1340 { 1341 return OMX_ErrorBadParameter; 1342 } 1343 1344 Status = pOpenmaxAOType->FreeBuffer(hComponent, nPortIndex, pBuffer); 1345 1346 return Status; 1347 } 1348 1349 1350 OMX_ERRORTYPE OmxComponentBase::FreeBuffer( 1351 OMX_IN OMX_HANDLETYPE hComponent, 1352 OMX_IN OMX_U32 nPortIndex, 1353 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 1354 { 1355 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FreeBuffer IN")); 1356 1357 ComponentPortType* pBaseComponentPort; 1358 1359 OMX_U32 ii; 1360 OMX_BOOL FoundBuffer; 1361 1362 if (nPortIndex >= iNumPorts) 1363 { 1364 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FreeBuffer error bad port index")); 1365 return OMX_ErrorBadPortIndex; 1366 } 1367 1368 pBaseComponentPort = ipPorts[nPortIndex]; 1369 1370 if (pBaseComponentPort->TransientState != OMX_StateLoaded 1371 && pBaseComponentPort->TransientState != OMX_StateInvalid) 1372 { 1373 1374 (*(ipCallbacks->EventHandler)) 1375 (hComponent, 1376 iCallbackData, 1377 OMX_EventError, /* The command was completed */ 1378 OMX_ErrorPortUnpopulated, /* The commands was a OMX_CommandStateSet */ 1379 nPortIndex, /* The State has been changed in message->MessageParam2 */ 1380 NULL); 1381 } 1382 1383 for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++) 1384 { 1385 if ((pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) && 1386 (pBaseComponentPort->pBuffer[ii]->pBuffer == pBuffer->pBuffer)) 1387 { 1388 1389 pBaseComponentPort->NumAssignedBuffers--; 1390 oscl_free(pBuffer->pBuffer); 1391 pBuffer->pBuffer = NULL; 1392 1393 if (pBaseComponentPort->BufferState[ii] & HEADER_ALLOCATED) 1394 { 1395 oscl_free(pBuffer); 1396 pBuffer = NULL; 1397 } 1398 pBaseComponentPort->BufferState[ii] = BUFFER_FREE; 1399 break; 1400 } 1401 else if ((pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED) && 1402 (pBaseComponentPort->pBuffer[ii] == pBuffer)) 1403 { 1404 1405 pBaseComponentPort->NumAssignedBuffers--; 1406 1407 if (pBaseComponentPort->BufferState[ii] & HEADER_ALLOCATED) 1408 { 1409 oscl_free(pBuffer); 1410 pBuffer = NULL; 1411 } 1412 1413 pBaseComponentPort->BufferState[ii] = BUFFER_FREE; 1414 break; 1415 } 1416 } 1417 1418 FoundBuffer = OMX_FALSE; 1419 1420 for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++) 1421 { 1422 if (pBaseComponentPort->BufferState[ii] != BUFFER_FREE) 1423 { 1424 FoundBuffer = OMX_TRUE; 1425 break; 1426 } 1427 } 1428 if (!FoundBuffer) 1429 { 1430 pBaseComponentPort->PortParam.bPopulated = OMX_FALSE; 1431 1432 if (OMX_TRUE == iStateTransitionFlag) 1433 { 1434 //Reschedule the AO for a state change (Idle->Loaded) if its pending on buffer de-allocation 1435 RunIfNotReady(); 1436 iStateTransitionFlag = OMX_FALSE; 1437 1438 //Reset the decoding flags while freeing buffers 1439 if (OMX_PORT_INPUTPORT_INDEX == nPortIndex) 1440 { 1441 iIsInputBufferEnded = OMX_TRUE; 1442 iTempInputBufferLength = 0; 1443 iTempConsumedLength = 0; 1444 iNewInBufferRequired = OMX_TRUE; 1445 } 1446 else if (OMX_PORT_OUTPUTPORT_INDEX == nPortIndex) 1447 { 1448 iNewOutBufRequired = OMX_TRUE; 1449 } 1450 } 1451 1452 if (NULL != pBaseComponentPort->pBuffer) 1453 { 1454 oscl_free(pBaseComponentPort->pBuffer); 1455 pBaseComponentPort->pBuffer = NULL; 1456 oscl_free(pBaseComponentPort->BufferState); 1457 pBaseComponentPort->BufferState = NULL; 1458 } 1459 } 1460 1461 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FreeBuffer OUT")); 1462 return OMX_ErrorNone; 1463 } 1464 1465 1466 /** Set Callbacks. It stores in the component private structure the pointers to the user application callbacs 1467 * @param hComponent the handle of the component 1468 * @param ipCallbacks the OpenMAX standard structure that holds the callback pointers 1469 * @param pAppData a pointer to a private structure, not covered by OpenMAX standard, in needed 1470 */ 1471 1472 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentSetCallbacks( 1473 OMX_IN OMX_HANDLETYPE hComponent, 1474 OMX_IN OMX_CALLBACKTYPE* pCallbacks, 1475 OMX_IN OMX_PTR pAppData) 1476 { 1477 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 1478 OMX_ERRORTYPE Status; 1479 1480 if (NULL == pOpenmaxAOType) 1481 { 1482 return OMX_ErrorBadParameter; 1483 } 1484 1485 Status = pOpenmaxAOType->SetCallbacks(hComponent, pCallbacks, pAppData); 1486 1487 return Status; 1488 } 1489 1490 1491 OMX_ERRORTYPE OmxComponentBase::SetCallbacks( 1492 OMX_IN OMX_HANDLETYPE hComponent, 1493 OMX_IN OMX_CALLBACKTYPE* pCallbacks, 1494 OMX_IN OMX_PTR pAppData) 1495 { 1496 OSCL_UNUSED_ARG(hComponent); 1497 1498 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SetCallbacks")); 1499 ipCallbacks = pCallbacks; 1500 iCallbackData = pAppData; 1501 1502 return OMX_ErrorNone; 1503 } 1504 1505 1506 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentSendCommand( 1507 OMX_IN OMX_HANDLETYPE hComponent, 1508 OMX_IN OMX_COMMANDTYPE Cmd, 1509 OMX_IN OMX_U32 nParam, 1510 OMX_IN OMX_PTR pCmdData) 1511 { 1512 1513 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 1514 OMX_ERRORTYPE Status; 1515 1516 if (NULL == pOpenmaxAOType) 1517 { 1518 return OMX_ErrorBadParameter; 1519 } 1520 1521 Status = pOpenmaxAOType->SendCommand(hComponent, Cmd, nParam, pCmdData); 1522 1523 return Status; 1524 } 1525 1526 OMX_ERRORTYPE OmxComponentBase::SendCommand( 1527 OMX_IN OMX_HANDLETYPE hComponent, 1528 OMX_IN OMX_COMMANDTYPE Cmd, 1529 OMX_IN OMX_S32 nParam, 1530 OMX_IN OMX_PTR pCmdData) 1531 { 1532 1533 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand IN")); 1534 1535 OMX_U32 ii; 1536 OMX_ERRORTYPE ErrMsgHandler = OMX_ErrorNone; 1537 QueueType* pMessageQueue; 1538 CoreMessage* Message = NULL; 1539 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 1540 1541 pMessageQueue = ipCoreDescriptor->pMessageQueue; 1542 1543 if (OMX_StateInvalid == iState) 1544 { 1545 ErrMsgHandler = OMX_ErrorInvalidState; 1546 } 1547 1548 switch (Cmd) 1549 { 1550 case OMX_CommandStateSet: 1551 { 1552 Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage)); 1553 1554 if (NULL == Message) 1555 { 1556 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error insufficient resources")); 1557 return OMX_ErrorInsufficientResources; 1558 } 1559 1560 Message->pComponent = (OMX_COMPONENTTYPE *) hComponent; 1561 Message->MessageType = SENDCOMMAND_MSG_TYPE; 1562 Message->MessageParam1 = OMX_CommandStateSet; 1563 Message->MessageParam2 = nParam; 1564 Message->pCmdData = pCmdData; 1565 1566 if ((OMX_StateIdle == nParam) && (OMX_StateLoaded == iState)) 1567 { 1568 ErrMsgHandler = pOpenmaxAOType->ComponentInit(); 1569 1570 if (OMX_ErrorNone != ErrMsgHandler) 1571 { 1572 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error component init")); 1573 return OMX_ErrorInsufficientResources; 1574 } 1575 for (ii = 0; ii < iNumPorts; ii++) 1576 { 1577 ipPorts[ii]->TransientState = OMX_StateIdle; 1578 } 1579 } 1580 else if ((OMX_StateLoaded == nParam) && (OMX_StateIdle == iState)) 1581 { 1582 for (ii = 0; ii < iNumPorts; ii++) 1583 { 1584 if (PORT_IS_ENABLED(ipPorts[ii])) 1585 { 1586 ipPorts[ii]->TransientState = OMX_StateLoaded; 1587 } 1588 } 1589 } 1590 else if (OMX_StateInvalid == nParam) 1591 { 1592 for (ii = 0; ii < iNumPorts; ii++) 1593 { 1594 if (PORT_IS_ENABLED(ipPorts[ii])) 1595 { 1596 ipPorts[ii]->TransientState = OMX_StateInvalid; 1597 } 1598 } 1599 } 1600 else if (((OMX_StateIdle == nParam) || (OMX_StatePause == nParam)) 1601 && (OMX_StateExecuting == iState)) 1602 { 1603 iBufferExecuteFlag = OMX_FALSE; 1604 } 1605 1606 } 1607 break; 1608 1609 case OMX_CommandFlush: 1610 { 1611 Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage)); 1612 1613 if (NULL == Message) 1614 { 1615 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error insufficient resources")); 1616 return OMX_ErrorInsufficientResources; 1617 } 1618 1619 Message->pComponent = (OMX_COMPONENTTYPE *) hComponent; 1620 Message->MessageType = SENDCOMMAND_MSG_TYPE; 1621 Message->MessageParam1 = OMX_CommandFlush; 1622 Message->MessageParam2 = nParam; 1623 Message->pCmdData = pCmdData; 1624 1625 if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts)) 1626 { 1627 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error bad port index")); 1628 return OMX_ErrorBadPortIndex; 1629 } 1630 1631 //If component is in Idle state, just queue the command and don't do anything else 1632 if (iState == OMX_StateIdle) 1633 { 1634 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand Flush command in Idle state")); 1635 break; 1636 } 1637 1638 if ((iState != OMX_StateExecuting) && (iState != OMX_StatePause)) 1639 { 1640 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error incorrect state")); 1641 ErrMsgHandler = OMX_ErrorIncorrectStateOperation; 1642 break; 1643 1644 } 1645 1646 SetPortFlushFlag(iNumPorts, nParam, OMX_TRUE); 1647 SetNumBufferFlush(iNumPorts, -1, 0); 1648 } 1649 break; 1650 1651 case OMX_CommandPortDisable: 1652 { 1653 if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts)) 1654 { 1655 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error bad port index")); 1656 return OMX_ErrorBadPortIndex; 1657 } 1658 1659 iResizePending = OMX_FALSE; // reset the flag to enable processing 1660 iSendOutBufferAfterPortReconfigFlag = OMX_TRUE; 1661 1662 1663 if (-1 == nParam) 1664 { 1665 for (ii = 0; ii < iNumPorts; ii++) 1666 { 1667 if (!PORT_IS_ENABLED(ipPorts[ii])) 1668 { 1669 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error incorrect state")); 1670 ErrMsgHandler = OMX_ErrorIncorrectStateOperation; 1671 break; 1672 } 1673 else 1674 { 1675 ipPorts[ii]->TransientState = OMX_StateLoaded; 1676 } 1677 } 1678 } 1679 else 1680 { 1681 if (!PORT_IS_ENABLED(ipPorts[nParam])) 1682 { 1683 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error incorrect state")); 1684 ErrMsgHandler = OMX_ErrorIncorrectStateOperation; 1685 break; 1686 } 1687 else 1688 { 1689 ipPorts[nParam]->TransientState = OMX_StateLoaded; 1690 } 1691 } 1692 1693 Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage)); 1694 if (NULL == Message) 1695 { 1696 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error insufficient resources")); 1697 return OMX_ErrorInsufficientResources; 1698 } 1699 1700 Message->pComponent = (OMX_COMPONENTTYPE *) hComponent; 1701 if (OMX_ErrorNone == ErrMsgHandler) 1702 { 1703 Message->MessageType = SENDCOMMAND_MSG_TYPE; 1704 Message->MessageParam2 = nParam; 1705 } 1706 else 1707 { 1708 Message->MessageType = ERROR_MSG_TYPE; 1709 Message->MessageParam2 = ErrMsgHandler; 1710 } 1711 Message->MessageParam1 = OMX_CommandPortDisable; 1712 Message->pCmdData = pCmdData; 1713 } 1714 break; 1715 1716 1717 case OMX_CommandPortEnable: 1718 { 1719 if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts)) 1720 { 1721 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error bad port index")); 1722 return OMX_ErrorBadPortIndex; 1723 } 1724 1725 if (-1 == nParam) 1726 { 1727 for (ii = 0; ii < iNumPorts; ii++) 1728 { 1729 if (PORT_IS_ENABLED(ipPorts[ii])) 1730 { 1731 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error incorrect state")); 1732 ErrMsgHandler = OMX_ErrorIncorrectStateOperation; 1733 break; 1734 } 1735 else 1736 { 1737 ipPorts[ii]->TransientState = OMX_StateIdle; 1738 } 1739 } 1740 } 1741 else 1742 { 1743 if (PORT_IS_ENABLED(ipPorts[nParam])) 1744 { 1745 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error incorrect state")); 1746 ErrMsgHandler = OMX_ErrorIncorrectStateOperation; 1747 break; 1748 } 1749 else 1750 { 1751 ipPorts[nParam]->TransientState = OMX_StateIdle; 1752 } 1753 } 1754 1755 Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage)); 1756 if (NULL == Message) 1757 { 1758 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error insufficient resources")); 1759 return OMX_ErrorInsufficientResources; 1760 } 1761 1762 Message->pComponent = (OMX_COMPONENTTYPE *) hComponent; 1763 if (OMX_ErrorNone == ErrMsgHandler) 1764 { 1765 Message->MessageType = SENDCOMMAND_MSG_TYPE; 1766 } 1767 else 1768 { 1769 Message->MessageType = ERROR_MSG_TYPE; 1770 } 1771 1772 Message->MessageParam1 = OMX_CommandPortEnable; 1773 Message->MessageParam2 = nParam; 1774 Message->pCmdData = pCmdData; 1775 } 1776 break; 1777 1778 1779 case OMX_CommandMarkBuffer: 1780 { 1781 if ((iState != OMX_StateExecuting) && (iState != OMX_StatePause)) 1782 { 1783 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error incorrect state")); 1784 ErrMsgHandler = OMX_ErrorIncorrectStateOperation; 1785 break; 1786 } 1787 1788 if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts)) 1789 { 1790 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error bad port index")); 1791 return OMX_ErrorBadPortIndex; 1792 } 1793 1794 Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage)); 1795 if (NULL == Message) 1796 { 1797 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error insufficient resources")); 1798 return OMX_ErrorInsufficientResources; 1799 } 1800 Message->pComponent = (OMX_COMPONENTTYPE *) hComponent; 1801 Message->MessageType = SENDCOMMAND_MSG_TYPE; 1802 Message->MessageParam1 = OMX_CommandMarkBuffer; 1803 Message->MessageParam2 = nParam; 1804 Message->pCmdData = pCmdData; 1805 } 1806 break; 1807 1808 1809 default: 1810 { 1811 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error unsupported index")); 1812 ErrMsgHandler = OMX_ErrorUnsupportedIndex; 1813 } 1814 break; 1815 } 1816 1817 if (OMX_ErrorNone != Queue(pMessageQueue, Message)) 1818 { 1819 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error, Queuing command failed")); 1820 return OMX_ErrorInsufficientResources; 1821 } 1822 1823 RunIfNotReady(); 1824 1825 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand OUT")); 1826 return ErrMsgHandler; 1827 } 1828 1829 1830 1831 /* This routine will reset all the buffers and flag associated with decoding 1832 * when receiving a flush command on the respective port*/ 1833 void OmxComponentBase::ResetAfterFlush(OMX_S32 PortIndex) 1834 { 1835 1836 if (OMX_PORT_INPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex) 1837 { 1838 iIsInputBufferEnded = OMX_TRUE; 1839 iEndofStream = OMX_FALSE; 1840 iNewInBufferRequired = OMX_TRUE; 1841 iPartialFrameAssembly = OMX_FALSE; 1842 iTempInputBufferLength = 0; 1843 iTempConsumedLength = 0; 1844 iInputBufferRemainingBytes = 0; 1845 iInputCurrLength = 0; 1846 1847 //Assume for this state transition that reposition command has come 1848 iRepositionFlag = OMX_TRUE; 1849 //Reset the silence insertion logic also 1850 iSilenceInsertionInProgress = OMX_FALSE; 1851 } 1852 1853 if (OMX_PORT_OUTPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex) 1854 { 1855 iNewOutBufRequired = OMX_TRUE; 1856 } 1857 1858 return; 1859 } 1860 1861 1862 /** This is called by the OMX core in its message processing 1863 * thread context upon a component request. A request is made 1864 * by the component when some asynchronous services are needed: 1865 * 1) A SendCommand() is to be processed 1866 * 2) An error needs to be notified 1867 * \param Message, the message that has been passed to core 1868 */ 1869 1870 OMX_ERRORTYPE OmxComponentBase::MessageHandler(CoreMessage* Message) 1871 { 1872 1873 OMX_COMPONENTTYPE* pHandle = &iOmxComponent; 1874 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*) iOmxComponent.pComponentPrivate; 1875 OMX_U32 ii; 1876 OMX_ERRORTYPE ErrorType = OMX_ErrorNone; 1877 1878 1879 /** Dealing with a SendCommand call. 1880 * -MessageParam1 contains the command to execute 1881 * -MessageParam2 contains the parameter of the command 1882 * (destination state in case of a state change command). 1883 */ 1884 1885 OMX_STATETYPE orig_state = iState; 1886 if (SENDCOMMAND_MSG_TYPE == Message->MessageType) 1887 { 1888 switch (Message->MessageParam1) 1889 { 1890 case OMX_CommandStateSet: 1891 { 1892 /* Do the actual state change */ 1893 ErrorType = DoStateSet(Message->MessageParam2); 1894 1895 if (OMX_TRUE == iStateTransitionFlag) 1896 { 1897 return OMX_ErrorNone; 1898 } 1899 1900 //Do not send the callback now till the State gets changed 1901 if (ErrorType != OMX_ErrorNone) 1902 { 1903 (*(ipCallbacks->EventHandler)) 1904 (pHandle, 1905 iCallbackData, 1906 OMX_EventError, /* The command was completed */ 1907 ErrorType, /* The commands was a OMX_CommandStateSet */ 1908 0, /* The iState has been changed in Message->MessageParam2 */ 1909 NULL); 1910 } 1911 else 1912 { 1913 /* And run the callback */ 1914 (*(ipCallbacks->EventHandler)) 1915 (pHandle, 1916 iCallbackData, 1917 OMX_EventCmdComplete, /* The command was completed */ 1918 OMX_CommandStateSet, /* The commands was a OMX_CommandStateSet */ 1919 Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */ 1920 NULL); 1921 } 1922 } 1923 break; 1924 1925 case OMX_CommandFlush: 1926 { 1927 //If the component is in Idle state, send the command complete callback 1928 //without any processing as the ports are empty of buffers anyway 1929 if (OMX_StateIdle == iState) 1930 { 1931 if (-1 == Message->MessageParam2) 1932 { 1933 /*Flush all port*/ 1934 for (ii = 0; ii < iNumPorts; ii++) 1935 { 1936 (*(ipCallbacks->EventHandler)) 1937 (pHandle, 1938 iCallbackData, 1939 OMX_EventCmdComplete, /* The command was completed */ 1940 OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */ 1941 ii, /* The iState has been changed in Message->MessageParam2 */ 1942 NULL); 1943 } 1944 } 1945 else 1946 { 1947 /*Flush input/output port*/ 1948 (*(ipCallbacks->EventHandler)) 1949 (pHandle, 1950 iCallbackData, 1951 OMX_EventCmdComplete, /* The command was completed */ 1952 OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */ 1953 Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */ 1954 NULL); 1955 } 1956 1957 // Break from here as we don't want to do any further processing 1958 // for this command 1959 break; 1960 } 1961 1962 1963 /*Flush ports*/ 1964 ErrorType = FlushPort(Message->MessageParam2); 1965 1966 SetNumBufferFlush(iNumPorts, -1, 0); 1967 1968 ResetAfterFlush(Message->MessageParam2); 1969 1970 //If Flush Command has come at the input port, reset the individual component as well 1971 if (OMX_PORT_INPUTPORT_INDEX == Message->MessageParam2 1972 || OMX_PORT_ALLPORT_INDEX == Message->MessageParam2) 1973 { 1974 /* Component specific flush routine for input buffer where individual components 1975 * may set/reset some flags/buffer lengths if required.*/ 1976 1977 pOpenmaxAOType->ResetComponent(); 1978 } 1979 1980 if (ErrorType != OMX_ErrorNone) 1981 { 1982 (*(ipCallbacks->EventHandler)) 1983 (pHandle, 1984 iCallbackData, 1985 OMX_EventError, /* The command was completed */ 1986 ErrorType, /* The commands was a OMX_CommandStateSet */ 1987 0, /* The iState has been changed in Message->MessageParam2 */ 1988 NULL); 1989 } 1990 else 1991 { 1992 if (-1 == Message->MessageParam2) 1993 { 1994 /*Flush all port*/ 1995 for (ii = 0; ii < iNumPorts; ii++) 1996 { 1997 (*(ipCallbacks->EventHandler)) 1998 (pHandle, 1999 iCallbackData, 2000 OMX_EventCmdComplete, /* The command was completed */ 2001 OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */ 2002 ii, /* The iState has been changed in Message->MessageParam2 */ 2003 NULL); 2004 } 2005 } 2006 else 2007 { 2008 /*Flush input/output port*/ 2009 (*(ipCallbacks->EventHandler)) 2010 (pHandle, 2011 iCallbackData, 2012 OMX_EventCmdComplete, /* The command was completed */ 2013 OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */ 2014 Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */ 2015 NULL); 2016 } 2017 } 2018 SetPortFlushFlag(iNumPorts, -1, OMX_FALSE); 2019 } 2020 break; 2021 2022 case OMX_CommandPortDisable: 2023 { 2024 /** This condition is added to pass the tests, it is not significant for the environment */ 2025 ErrorType = DisablePort(Message->MessageParam2); 2026 if (OMX_TRUE == iStateTransitionFlag) 2027 { 2028 return OMX_ErrorNone; 2029 } 2030 2031 if (ErrorType != OMX_ErrorNone) 2032 { 2033 (*(ipCallbacks->EventHandler)) 2034 (pHandle, 2035 iCallbackData, 2036 OMX_EventError, /* The command was completed */ 2037 ErrorType, /* The commands was a OMX_CommandStateSet */ 2038 0, /* The iState has been changed in Message->MessageParam2 */ 2039 NULL); 2040 } 2041 else 2042 { 2043 if (-1 == Message->MessageParam2) 2044 { 2045 /*Disable all ports*/ 2046 for (ii = 0; ii < iNumPorts; ii++) 2047 { 2048 (*(ipCallbacks->EventHandler)) 2049 (pHandle, 2050 iCallbackData, 2051 OMX_EventCmdComplete, /* The command was completed */ 2052 OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */ 2053 ii, /* The iState has been changed in Message->MessageParam2 */ 2054 NULL); 2055 } 2056 } 2057 else 2058 { 2059 (*(ipCallbacks->EventHandler)) 2060 (pHandle, 2061 iCallbackData, 2062 OMX_EventCmdComplete, /* The command was completed */ 2063 OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */ 2064 Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */ 2065 NULL); 2066 } 2067 } 2068 } 2069 break; 2070 2071 case OMX_CommandPortEnable: 2072 { 2073 ErrorType = EnablePort(Message->MessageParam2); 2074 if (OMX_TRUE == iStateTransitionFlag) 2075 { 2076 return OMX_ErrorNone; 2077 } 2078 2079 if (ErrorType != OMX_ErrorNone) 2080 { 2081 (*(ipCallbacks->EventHandler)) 2082 (pHandle, 2083 iCallbackData, 2084 OMX_EventError, /* The command was completed */ 2085 ErrorType, /* The commands was a OMX_CommandStateSet */ 2086 0, /* The State has been changed in Message->MessageParam2 */ 2087 NULL); 2088 } 2089 else 2090 { 2091 if (Message->MessageParam2 != -1) 2092 { 2093 (*(ipCallbacks->EventHandler)) 2094 (pHandle, 2095 iCallbackData, 2096 OMX_EventCmdComplete, /* The command was completed */ 2097 OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */ 2098 Message->MessageParam2, /* The State has been changed in Message->MessageParam2 */ 2099 NULL); 2100 } 2101 else 2102 { 2103 for (ii = 0; ii < iNumPorts; ii++) 2104 { 2105 (*(ipCallbacks->EventHandler)) 2106 (pHandle, 2107 iCallbackData, 2108 OMX_EventCmdComplete, /* The command was completed */ 2109 OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */ 2110 ii, /* The State has been changed in Message->MessageParam2 */ 2111 NULL); 2112 } 2113 } 2114 } 2115 } 2116 break; 2117 2118 case OMX_CommandMarkBuffer: 2119 { 2120 ipMark = (OMX_MARKTYPE *)Message->pCmdData; 2121 } 2122 break; 2123 2124 default: 2125 { 2126 2127 } 2128 break; 2129 } 2130 /* Dealing with an asynchronous error condition 2131 */ 2132 } 2133 2134 if (orig_state != OMX_StateInvalid) 2135 { 2136 ErrorType = OMX_ErrorNone; 2137 } 2138 2139 return ErrorType; 2140 } 2141 2142 /** Changes the state of a component taking proper actions depending on 2143 * the transiotion requested 2144 * \param aDestinationState the requested target state. 2145 */ 2146 2147 OMX_ERRORTYPE OmxComponentBase::DoStateSet(OMX_U32 aDestinationState) 2148 { 2149 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, 2150 (0, "OmxComponentBase : DoStateSet IN : iState (%i) aDestinationState (%i)", iState, aDestinationState)); 2151 2152 OMX_ERRORTYPE ErrorType = OMX_ErrorNone; 2153 OMX_U32 ii; 2154 2155 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*) iOmxComponent.pComponentPrivate; 2156 2157 if (OMX_StateLoaded == aDestinationState) 2158 { 2159 switch (iState) 2160 { 2161 case OMX_StateInvalid: 2162 { 2163 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error invalid state")); 2164 return OMX_ErrorInvalidState; 2165 } 2166 2167 case OMX_StateWaitForResources: 2168 { 2169 iState = OMX_StateLoaded; 2170 } 2171 break; 2172 2173 case OMX_StateLoaded: 2174 { 2175 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error same state")); 2176 return OMX_ErrorSameState; 2177 } 2178 2179 case OMX_StateIdle: 2180 { 2181 for (ii = 0; ii < iNumPorts; ii++) 2182 { 2183 if (PORT_IS_ENABLED(ipPorts[ii]) && PORT_IS_POPULATED(ipPorts[ii])) 2184 { 2185 iStateTransitionFlag = OMX_TRUE; 2186 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet Waiting port to be de-populated")); 2187 return OMX_ErrorNone; 2188 } 2189 } 2190 2191 iState = OMX_StateLoaded; 2192 2193 iNumInputBuffer = 0; 2194 iOutBufferCount = 0; 2195 iPartialFrameAssembly = OMX_FALSE; 2196 iEndofStream = OMX_FALSE; 2197 iIsInputBufferEnded = OMX_TRUE; 2198 iNewOutBufRequired = OMX_TRUE; 2199 iNewInBufferRequired = OMX_TRUE; 2200 iFirstFragment = OMX_FALSE; 2201 2202 pOpenmaxAOType->ComponentDeInit(); 2203 } 2204 break; 2205 2206 default: 2207 { 2208 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error incorrect state")); 2209 return OMX_ErrorIncorrectStateTransition; 2210 } 2211 } 2212 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet OUT")); 2213 return OMX_ErrorNone; 2214 } 2215 2216 if (OMX_StateWaitForResources == aDestinationState) 2217 { 2218 switch (iState) 2219 { 2220 case OMX_StateInvalid: 2221 { 2222 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error invalid state")); 2223 return OMX_ErrorInvalidState; 2224 } 2225 2226 case OMX_StateLoaded: 2227 { 2228 iState = OMX_StateWaitForResources; 2229 } 2230 break; 2231 2232 case OMX_StateWaitForResources: 2233 { 2234 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error same state")); 2235 return OMX_ErrorSameState; 2236 } 2237 2238 default: 2239 { 2240 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error incorrect state")); 2241 return OMX_ErrorIncorrectStateTransition; 2242 } 2243 } 2244 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet OUT")); 2245 return OMX_ErrorNone; 2246 } 2247 2248 if (OMX_StateIdle == aDestinationState) 2249 { 2250 switch (iState) 2251 { 2252 case OMX_StateInvalid: 2253 { 2254 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error invalid state")); 2255 return OMX_ErrorInvalidState; 2256 } 2257 2258 case OMX_StateWaitForResources: 2259 { 2260 iState = OMX_StateIdle; 2261 } 2262 break; 2263 2264 case OMX_StateLoaded: 2265 { 2266 for (ii = 0; ii < iNumPorts; ii++) 2267 { 2268 if (PORT_IS_ENABLED(ipPorts[ii]) && !PORT_IS_POPULATED(ipPorts[ii])) 2269 { 2270 iStateTransitionFlag = OMX_TRUE; 2271 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet Waiting port to be populated")); 2272 return OMX_ErrorNone; 2273 } 2274 } 2275 2276 iState = OMX_StateIdle; 2277 2278 //Used in case of partial frame assembly 2279 if (!ipInputCurrBuffer) 2280 { 2281 //Keep the size of temp buffer double to be on safer side 2282 iInputCurrBufferSize = 2 * sizeof(uint8) * (ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize); 2283 2284 ipInputCurrBuffer = (OMX_U8*) oscl_malloc(iInputCurrBufferSize); 2285 if (NULL == ipInputCurrBuffer) 2286 { 2287 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error insufficient resources")); 2288 return OMX_ErrorInsufficientResources; 2289 } 2290 2291 } 2292 2293 //Used when the buffers are not marked with EndOfFrame flag 2294 if (!ipTempInputBuffer) 2295 { 2296 ipTempInputBuffer = (OMX_U8*) oscl_malloc(iInputCurrBufferSize); 2297 if (NULL == ipTempInputBuffer) 2298 { 2299 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error insufficient resources")); 2300 return OMX_ErrorInsufficientResources; 2301 } 2302 } 2303 2304 iTempInputBufferLength = 0; 2305 iTempConsumedLength = 0; 2306 iInputBufferRemainingBytes = 0; 2307 } 2308 break; 2309 2310 case OMX_StateIdle: 2311 { 2312 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error same state")); 2313 return OMX_ErrorSameState; 2314 } 2315 2316 //Both the below cases have same body 2317 case OMX_StateExecuting: 2318 case OMX_StatePause: 2319 { 2320 SetNumBufferFlush(iNumPorts, -1, 0); 2321 SetPortFlushFlag(iNumPorts, -1, OMX_TRUE); 2322 2323 ComponentPortType* pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX]; 2324 2325 //Return all the buffers if still occupied 2326 QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue; 2327 2328 while ((iNumInputBuffer > 0) && (GetQueueNumElem(pInputQueue) > 0)) 2329 { 2330 FlushPort(OMX_PORT_INPUTPORT_INDEX); 2331 } 2332 2333 // if a buffer was previously dequeued, it wasnt freed in above loop. return it now 2334 if (iNumInputBuffer > 0) 2335 { 2336 ipInputBuffer->nFilledLen = 0; 2337 ReturnInputBuffer(ipInputBuffer, pInPort); 2338 iNewInBufferRequired = OMX_TRUE; 2339 iIsInputBufferEnded = OMX_TRUE; 2340 iInputCurrLength = 0; 2341 ipInputBuffer = NULL; 2342 } 2343 2344 //Return all the buffers if still occupied 2345 while ((iNumInputBuffer > 0)) 2346 { 2347 FlushPort(OMX_PORT_INPUTPORT_INDEX); 2348 } 2349 2350 //Return all the output buffers if still occupied 2351 while (iOutBufferCount > 0) 2352 { 2353 FlushPort(OMX_PORT_OUTPUTPORT_INDEX); 2354 } 2355 2356 //Call the reset funstion here to reset the flags and buffer length variables 2357 ResetAfterFlush(OMX_PORT_ALLPORT_INDEX); 2358 2359 2360 SetPortFlushFlag(iNumPorts, -1, OMX_FALSE); 2361 SetNumBufferFlush(iNumPorts, -1, 0); 2362 2363 pOpenmaxAOType->ResetComponent(); 2364 2365 iState = OMX_StateIdle; 2366 } 2367 break; 2368 2369 default: 2370 { 2371 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error incorrect state")); 2372 return OMX_ErrorIncorrectStateTransition; 2373 } 2374 } 2375 2376 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet OUT")); 2377 return ErrorType; 2378 } 2379 2380 if (OMX_StatePause == aDestinationState) 2381 { 2382 switch (iState) 2383 { 2384 case OMX_StateInvalid: 2385 { 2386 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error invalid state")); 2387 return OMX_ErrorInvalidState; 2388 } 2389 2390 case OMX_StatePause: 2391 { 2392 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error same state")); 2393 return OMX_ErrorSameState; 2394 } 2395 2396 //Falling through to the next case 2397 case OMX_StateExecuting: 2398 case OMX_StateIdle: 2399 { 2400 iState = OMX_StatePause; 2401 } 2402 break; 2403 2404 default: 2405 { 2406 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error incorrect state")); 2407 return OMX_ErrorIncorrectStateTransition; 2408 } 2409 } 2410 2411 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet OUT")); 2412 return OMX_ErrorNone; 2413 } 2414 2415 if (OMX_StateExecuting == aDestinationState) 2416 { 2417 switch (iState) 2418 { 2419 case OMX_StateInvalid: 2420 { 2421 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error invalid state")); 2422 return OMX_ErrorInvalidState; 2423 } 2424 2425 case OMX_StateIdle: 2426 { 2427 iState = OMX_StateExecuting; 2428 } 2429 break; 2430 2431 case OMX_StatePause: 2432 { 2433 iState = OMX_StateExecuting; 2434 /* A trigger to start the processing of buffers when component 2435 * transitions to executing from pause, as it is already 2436 * holding the required buffers 2437 */ 2438 RunIfNotReady(); 2439 } 2440 break; 2441 2442 case OMX_StateExecuting: 2443 { 2444 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error same state")); 2445 return OMX_ErrorSameState; 2446 } 2447 2448 default: 2449 { 2450 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error incorrect state")); 2451 return OMX_ErrorIncorrectStateTransition; 2452 } 2453 } 2454 2455 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet OUT")); 2456 return OMX_ErrorNone; 2457 } 2458 2459 if (OMX_StateInvalid == aDestinationState) 2460 { 2461 switch (iState) 2462 { 2463 case OMX_StateInvalid: 2464 { 2465 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error invalid state")); 2466 return OMX_ErrorInvalidState; 2467 } 2468 2469 default: 2470 { 2471 iState = OMX_StateInvalid; 2472 if (iIsInit != OMX_FALSE) 2473 { 2474 pOpenmaxAOType->ComponentDeInit(); 2475 } 2476 } 2477 break; 2478 } 2479 2480 if (iIsInit != OMX_FALSE) 2481 { 2482 pOpenmaxAOType->ComponentDeInit(); 2483 } 2484 2485 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error invalid state")); 2486 return OMX_ErrorInvalidState; 2487 } 2488 2489 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet OUT")); 2490 return OMX_ErrorNone; 2491 } 2492 2493 2494 2495 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentEmptyThisBuffer( 2496 OMX_IN OMX_HANDLETYPE hComponent, 2497 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 2498 { 2499 2500 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate; 2501 OMX_ERRORTYPE Status; 2502 2503 if (NULL == pOpenmaxAOType) 2504 { 2505 return OMX_ErrorBadParameter; 2506 } 2507 2508 Status = pOpenmaxAOType->EmptyThisBuffer(hComponent, pBuffer); 2509 2510 return Status; 2511 2512 } 2513 2514 2515 OMX_ERRORTYPE OmxComponentBase::EmptyThisBuffer( 2516 OMX_IN OMX_HANDLETYPE hComponent, 2517 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 2518 2519 { 2520 OSCL_UNUSED_ARG(hComponent); 2521 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer IN")); 2522 //Do not queue buffers if component is in invalid state 2523 if (OMX_StateInvalid == iState) 2524 { 2525 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer error invalid state")); 2526 return OMX_ErrorInvalidState; 2527 } 2528 2529 if ((OMX_StateIdle == iState) || (OMX_StatePause == iState) || (OMX_StateExecuting == iState)) 2530 { 2531 OMX_U32 PortIndex; 2532 QueueType* pInputQueue; 2533 OMX_ERRORTYPE ErrorType = OMX_ErrorNone; 2534 2535 PortIndex = pBuffer->nInputPortIndex; 2536 2537 //Validate the port index & Queue the buffers available only at the input port 2538 if (PortIndex >= iNumPorts || 2539 ipPorts[PortIndex]->PortParam.eDir != OMX_DirInput) 2540 { 2541 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer error bad port index")); 2542 return OMX_ErrorBadPortIndex; 2543 } 2544 2545 //Port should be in enabled state before accepting buffers 2546 if (!PORT_IS_ENABLED(ipPorts[PortIndex])) 2547 { 2548 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer error incorrect state")); 2549 return OMX_ErrorIncorrectStateOperation; 2550 } 2551 2552 /* The number of buffers the component can queue at a time 2553 * depends upon the number of buffers allocated/assigned on the input port 2554 */ 2555 if (iNumInputBuffer == (ipPorts[PortIndex]->NumAssignedBuffers)) 2556 { 2557 RunIfNotReady(); 2558 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer error incorrect state")); 2559 return OMX_ErrorIncorrectStateOperation; 2560 } 2561 2562 //Finally after passing all the conditions, queue the buffer in Input queue 2563 pInputQueue = ipPorts[PortIndex]->pBufferQueue; 2564 2565 if ((ErrorType = CheckHeader(pBuffer, sizeof(OMX_BUFFERHEADERTYPE))) != OMX_ErrorNone) 2566 { 2567 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer error check header failed")); 2568 return ErrorType; 2569 } 2570 2571 if (OMX_ErrorNone != Queue(pInputQueue, pBuffer)) 2572 { 2573 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer error, Queuing buffer failed")); 2574 return OMX_ErrorInsufficientResources; 2575 } 2576 iNumInputBuffer++; 2577 2578 //Signal the AO about the incoming buffer 2579 RunIfNotReady(); 2580 } 2581 else 2582 { 2583 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer error incorrect state")); 2584 //This macro is not accepted in any other state except the three mentioned above 2585 return OMX_ErrorIncorrectStateOperation; 2586 } 2587 2588 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer OUT")); 2589 2590 return OMX_ErrorNone; 2591 } 2592 2593 2594 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentFillThisBuffer( 2595 OMX_IN OMX_HANDLETYPE hComponent, 2596 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 2597 { 2598 2599 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 2600 OMX_ERRORTYPE Status; 2601 2602 if (NULL == pOpenmaxAOType) 2603 { 2604 return OMX_ErrorBadParameter; 2605 } 2606 2607 Status = pOpenmaxAOType->FillThisBuffer(hComponent, pBuffer); 2608 2609 return Status; 2610 } 2611 2612 OMX_ERRORTYPE OmxComponentBase::FillThisBuffer( 2613 OMX_IN OMX_HANDLETYPE hComponent, 2614 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 2615 2616 { 2617 OSCL_UNUSED_ARG(hComponent); 2618 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FillThisBuffer IN")); 2619 2620 OMX_U32 PortIndex; 2621 2622 QueueType* pOutputQueue; 2623 OMX_ERRORTYPE ErrorType = OMX_ErrorNone; 2624 2625 PortIndex = pBuffer->nOutputPortIndex; 2626 //Validate the port index & Queue the buffers available only at the output port 2627 if (PortIndex >= iNumPorts || 2628 ipPorts[PortIndex]->PortParam.eDir != OMX_DirOutput) 2629 { 2630 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FillThisBuffer error bad port index")); 2631 return OMX_ErrorBadPortIndex; 2632 } 2633 2634 pOutputQueue = ipPorts[PortIndex]->pBufferQueue; 2635 if (iState != OMX_StateExecuting && 2636 iState != OMX_StatePause && 2637 iState != OMX_StateIdle) 2638 { 2639 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FillThisBuffer error invalid state")); 2640 return OMX_ErrorInvalidState; 2641 } 2642 2643 //Port should be in enabled state before accepting buffers 2644 if (!PORT_IS_ENABLED(ipPorts[PortIndex])) 2645 { 2646 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FillThisBuffer error incorrect state")); 2647 return OMX_ErrorIncorrectStateOperation; 2648 } 2649 2650 if ((ErrorType = CheckHeader(pBuffer, sizeof(OMX_BUFFERHEADERTYPE))) != OMX_ErrorNone) 2651 { 2652 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FillThisBuffer error check header failed")); 2653 return ErrorType; 2654 } 2655 2656 //Queue the buffer in output queue 2657 if (OMX_ErrorNone != Queue(pOutputQueue, pBuffer)) 2658 { 2659 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FillThisBuffer error, queuing buffer failed")); 2660 return OMX_ErrorInsufficientResources; 2661 } 2662 2663 iOutBufferCount++; 2664 2665 //Signal the AO about the incoming buffer 2666 RunIfNotReady(); 2667 2668 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FillThisBuffer OUT")); 2669 2670 return OMX_ErrorNone; 2671 } 2672 2673 2674 /** This is the central function for buffers processing and decoding. 2675 * It is called through the Run() of active object when the component is in executing state 2676 * and is signalled each time a new buffer is available on the given ports 2677 * This function will process the input buffers & return output buffers 2678 */ 2679 2680 OSCL_EXPORT_REF void OmxComponentBase::BufferMgmtFunction() 2681 { 2682 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction IN")); 2683 2684 OMX_COMPONENTTYPE* pHandle = &iOmxComponent; 2685 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*) iOmxComponent.pComponentPrivate; 2686 2687 QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue; 2688 QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue; 2689 ComponentPortType* pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX]; 2690 2691 OMX_BOOL PartialFrameReturn, Status; 2692 2693 /* Don't dequeue any further buffer after endofstream buffer has been dequeued 2694 * till we send the callback and reset the flag back to false 2695 */ 2696 if (OMX_FALSE == iEndofStream) 2697 { 2698 //More than one frame can't be dequeued in case of outbut blocked 2699 if ((OMX_TRUE == iIsInputBufferEnded) && (GetQueueNumElem(pInputQueue) > 0)) 2700 { 2701 ipInputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue); 2702 if (NULL == ipInputBuffer) 2703 { 2704 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction ERROR DeQueue() returned NULL")); 2705 return; 2706 } 2707 2708 if (ipInputBuffer->nFlags & OMX_BUFFERFLAG_EOS) 2709 { 2710 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction EndOfStream arrived")); 2711 iEndofStream = OMX_TRUE; 2712 } 2713 2714 // To do: test this second condition newly added 2715 if ((ipInputBuffer->nFilledLen != 0) || 2716 ((OMX_TRUE == iEndofStream) && (OMX_TRUE == iPartialFrameAssembly))) 2717 { 2718 // if we already started assembling frames, it means 2719 // we didn't get marker bit yet, but may be getting it 2720 // when the first frame assembly is over 2721 // If so, we'll set iEndOfFrameFlag to TRUE in BufferMgmtWithoutMarker assembly 2722 if (0 == iFrameCount && iPartialFrameAssembly == OMX_FALSE) 2723 { 2724 //Set the marker flag (iEndOfFrameFlag) if first frame has the EndOfFrame flag marked. 2725 if ((ipInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) != 0) 2726 { 2727 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction EndOfFrame flag present")); 2728 iEndOfFrameFlag = OMX_TRUE; 2729 } 2730 2731 /* This routine will allocate the internal input buffers that are required to 2732 * assemble partial frames in both with and without marker mode for H.263 decoder component. 2733 * The size of partial frame assembly buffer will be in proportion to the W & H of the clip. 2734 * We require maximum of first 12 bytes of data (this will be checked */ 2735 2736 2737 if (OMX_ErrorNone != pOpenmaxAOType->ReAllocatePartialAssemblyBuffers(ipInputBuffer)) 2738 { 2739 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction Error Memory Re-allocation of partial frame assembly buffer failed, OUT")); 2740 return; 2741 } 2742 2743 } 2744 2745 /* This condition will be true if OMX_BUFFERFLAG_ENDOFFRAME flag is 2746 * not marked in all the input buffers 2747 */ 2748 if (!iEndOfFrameFlag) 2749 { 2750 Status = pOpenmaxAOType->BufferMgmtWithoutMarker(); 2751 if (OMX_FALSE == Status) 2752 { 2753 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction OUT")); 2754 return; 2755 } 2756 2757 } 2758 //If OMX_BUFFERFLAG_ENDOFFRAME flag is marked, come here 2759 else 2760 { 2761 if (iPVCapabilityFlags.iOMXComponentUsesFullAVCFrames && (OMX_PORT_INPUTPORT_INDEX == iCompressedFormatPortNum)) 2762 { 2763 // since full frames are sent, there will never be partial frame assembly, 2764 // but we do need to parse the frames into NALs to send to the decoder 2765 PartialFrameReturn = ParseFullAVCFramesIntoNALs(ipInputBuffer); 2766 } 2767 else 2768 { 2769 PartialFrameReturn = AssemblePartialFrames(ipInputBuffer); 2770 } 2771 if (OMX_FALSE == PartialFrameReturn) 2772 { 2773 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction OUT")); 2774 return; 2775 } 2776 iIsInputBufferEnded = OMX_FALSE; 2777 2778 ipTargetComponent = (OMX_COMPONENTTYPE*) ipInputBuffer->hMarkTargetComponent; 2779 2780 iTargetMarkData = ipInputBuffer->pMarkData; 2781 if (ipTargetComponent == (OMX_COMPONENTTYPE*) pHandle) 2782 { 2783 (*(ipCallbacks->EventHandler)) 2784 (pHandle, 2785 iCallbackData, 2786 OMX_EventMark, 2787 1, 2788 0, 2789 ipInputBuffer->pMarkData); 2790 } 2791 } 2792 2793 /* This routine will take care of any audio component specific tasks like 2794 -> Reading the input buffer timestamp 2795 -> Checking for Silence insertion 2796 -> Repostioning implementation etc 2797 */ 2798 if (OMX_TRUE == iIsAudioComponent) 2799 { 2800 pOpenmaxAOType->SyncWithInputTimestamp(); 2801 } 2802 2803 2804 } //end braces for if (ipInputBuffer->nFilledLen != 0) 2805 else 2806 { 2807 //Reschedule the AO if there are more buffers in queue 2808 if ((GetQueueNumElem(pInputQueue) > 0) && 2809 ((GetQueueNumElem(pOutputQueue) > 0) || (OMX_FALSE == iNewOutBufRequired))) 2810 { 2811 RunIfNotReady(); 2812 } 2813 2814 ReturnInputBuffer(ipInputBuffer, pInPort); 2815 ipInputBuffer = NULL; 2816 } 2817 2818 } //end braces for if ((OMX_TRUE == iIsInputBufferEnded) && (GetQueueNumElem(pInputQueue) > 0)) 2819 } //if (OMX_FALSE == iEndofStream) 2820 2821 2822 //Component specific Encode/Decode routine 2823 pOpenmaxAOType->ProcessData(); 2824 2825 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction OUT")); 2826 return; 2827 } 2828 2829 2830 OSCL_EXPORT_REF OMX_BOOL OmxComponentBase::BufferMgmtWithoutMarker() 2831 { 2832 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker IN")); 2833 2834 ComponentPortType* pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX]; 2835 QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue; 2836 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*) iOmxComponent.pComponentPrivate; 2837 2838 2839 /* If the buffer has enough data or EndofStream is true, and 2840 * partial frame assembly is not turned on, process the buffer independently */ 2841 2842 if (((ipInputBuffer->nFilledLen >= (iInputCurrBufferSize >> 1)) || (iEndofStream == OMX_TRUE)) 2843 && (OMX_FALSE == iPartialFrameAssembly)) 2844 { 2845 //This is a new piece of buffer, process it independently 2846 if (iNumInputBuffer > 0) 2847 { 2848 iInputCurrLength = ipInputBuffer->nFilledLen; 2849 ipFrameDecodeBuffer = ipInputBuffer->pBuffer + ipInputBuffer->nOffset; 2850 iFrameTimestamp = ipInputBuffer->nTimeStamp; 2851 2852 /* Components not implementing ComponentBufferMgmtWithoutMarker(), will reset 2853 * iIsInputBufferEnded flag in the below routine */ 2854 pOpenmaxAOType->ProcessInBufferFlag(); 2855 } 2856 else 2857 { 2858 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker OUT")); 2859 return OMX_FALSE; // nothing to decode 2860 } 2861 } 2862 else 2863 { 2864 if (!iPartialFrameAssembly) 2865 { 2866 iInputCurrLength = 0; 2867 ipFrameDecodeBuffer = ipInputCurrBuffer; 2868 } 2869 2870 while (iNumInputBuffer > 0) 2871 { 2872 int32 BytesToCopy = ipInputBuffer->nFilledLen; 2873 2874 if ((iInputCurrLength + BytesToCopy) > iInputCurrBufferSize) 2875 { 2876 // allocate new partial frame buffers 2877 OMX_U8* pTempNewBuffer = NULL; 2878 pTempNewBuffer = (OMX_U8*) oscl_malloc(sizeof(OMX_U8) * (iInputCurrLength + BytesToCopy)); 2879 2880 if (NULL != pTempNewBuffer) 2881 { 2882 // copy contents of the old buffer into the new one 2883 oscl_memcpy(pTempNewBuffer, ipTempInputBuffer, iTempInputBufferLength); 2884 // free the old buffer 2885 if (ipTempInputBuffer) 2886 { 2887 oscl_free(ipTempInputBuffer); 2888 } 2889 // assign new one 2890 ipTempInputBuffer = pTempNewBuffer; 2891 2892 pTempNewBuffer = NULL; 2893 pTempNewBuffer = (OMX_U8*) oscl_malloc(sizeof(OMX_U8) * (iInputCurrLength + BytesToCopy)); 2894 2895 // in the event that new buffer cannot be allocated 2896 if (NULL == pTempNewBuffer) 2897 { 2898 // copy into what space is available, and let the decoder complain 2899 BytesToCopy = iInputCurrLength - iInputCurrBufferSize; 2900 } 2901 else 2902 { 2903 // copy contents of the old buffer into the new one 2904 oscl_memcpy(pTempNewBuffer, ipInputCurrBuffer, iInputCurrBufferSize); 2905 // free the old buffer 2906 if (ipInputCurrBuffer) 2907 { 2908 oscl_free(ipInputCurrBuffer); 2909 } 2910 // assign new memory location 2911 ipInputCurrBuffer = pTempNewBuffer; 2912 iInputCurrBufferSize = (iInputCurrLength + BytesToCopy); 2913 ipFrameDecodeBuffer = ipInputCurrBuffer + iInputCurrLength; 2914 } 2915 } 2916 //No memory to allocate ipTempInputBuffer 2917 else 2918 { 2919 // copy into what space is available, and let the decoder complain 2920 BytesToCopy = iInputCurrLength - iInputCurrBufferSize; 2921 } 2922 } 2923 2924 oscl_memcpy(ipFrameDecodeBuffer, (ipInputBuffer->pBuffer + ipInputBuffer->nOffset), BytesToCopy); 2925 ipFrameDecodeBuffer += ipInputBuffer->nFilledLen; // move the ptr 2926 iInputCurrLength += BytesToCopy; 2927 2928 iFrameTimestamp = ipInputBuffer->nTimeStamp; 2929 2930 // check if we've encountered end of frame flag while trying to assemble the very first frame 2931 if ((0 == iFrameCount) && ((ipInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) != 0)) 2932 { 2933 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker EndOfFrameFlag finally arrived")); 2934 iEndOfFrameFlag = OMX_TRUE; 2935 } 2936 2937 if ((iInputCurrLength >= (iInputCurrBufferSize >> 1)) 2938 || (OMX_TRUE == iEndofStream) || (OMX_TRUE == iEndOfFrameFlag)) 2939 { 2940 break; 2941 } 2942 2943 //Set the filled len to zero to indicate buffer is fully consumed 2944 ipInputBuffer->nFilledLen = 0; 2945 ReturnInputBuffer(ipInputBuffer, pInPort); 2946 ipInputBuffer = NULL; 2947 2948 if (iNumInputBuffer > 0) 2949 { 2950 ipInputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue); 2951 if (NULL == ipInputBuffer) 2952 { 2953 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker Error, Input buffer Dequeue returned NULL")); 2954 return OMX_FALSE; 2955 } 2956 2957 if (ipInputBuffer->nFlags & OMX_BUFFERFLAG_EOS) 2958 { 2959 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker EndOfStream arrived")); 2960 iEndofStream = OMX_TRUE; 2961 } 2962 } 2963 } 2964 2965 if (iEndOfFrameFlag) 2966 { 2967 // if we have encountered end of frame, 1st frame has been assembled 2968 // and we can switch to "end of frame flag" mode 2969 iIsInputBufferEnded = OMX_FALSE; 2970 iNewInBufferRequired = OMX_FALSE; 2971 ipFrameDecodeBuffer = ipInputCurrBuffer; // rewind buffer ptr to beginning of inputcurrbuffer 2972 iPartialFrameAssembly = OMX_FALSE; 2973 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker Found end of frame flag - OUT")); 2974 return OMX_TRUE; 2975 2976 } 2977 2978 if ((((iInputCurrLength + iTempInputBufferLength) < (iInputCurrBufferSize >> 1))) 2979 && (OMX_TRUE != iEndofStream)) 2980 { 2981 iPartialFrameAssembly = OMX_TRUE; 2982 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker OUT")); 2983 return OMX_FALSE; 2984 } 2985 else 2986 { 2987 ipFrameDecodeBuffer = ipInputCurrBuffer; 2988 iPartialFrameAssembly = OMX_FALSE; 2989 2990 /* Components not implementing ComponentBufferMgmtWithoutMarker(), will reset 2991 * iIsInputBufferEnded flag in the below routine */ 2992 pOpenmaxAOType->ProcessInBufferFlag(); 2993 } 2994 2995 } 2996 2997 2998 //Different components may choose to do some extra processing here. 2999 //e.g. video components and also amr component copies the collected data into temp input buffers here. 3000 pOpenmaxAOType->ComponentBufferMgmtWithoutMarker(); 3001 3002 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker OUT")); 3003 return OMX_TRUE; 3004 3005 } 3006 3007 3008 3009 //Propagate here the buffer mark through output port in case of BufferMgmtWithoutMarker 3010 OSCL_EXPORT_REF void OmxComponentBase::ComponentBufferMgmtWithoutMarker() 3011 { 3012 OMX_COMPONENTTYPE* pHandle = &iOmxComponent; 3013 3014 ipTargetComponent = (OMX_COMPONENTTYPE*) ipInputBuffer->hMarkTargetComponent; 3015 3016 iTargetMarkData = ipInputBuffer->pMarkData; 3017 if (ipTargetComponent == (OMX_COMPONENTTYPE*) pHandle) 3018 { 3019 (*(ipCallbacks->EventHandler)) 3020 (pHandle, 3021 iCallbackData, 3022 OMX_EventMark, 3023 1, 3024 0, 3025 ipInputBuffer->pMarkData); 3026 } 3027 } 3028 3029 3030 /* A part of buffer management without marker routine, this function will 3031 * copy the current input buffer into a big temporary buffer, so that 3032 * an incomplete/partial frame is never passed to the decoder library for decode 3033 */ 3034 OSCL_EXPORT_REF void OmxComponentBase::TempInputBufferMgmtWithoutMarker() 3035 { 3036 OMX_COMPONENTTYPE* pHandle = &iOmxComponent; 3037 ComponentPortType* pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX]; 3038 OMX_U32 TempInputBufferSize = iInputCurrBufferSize; 3039 3040 if (iTempInputBufferLength < (TempInputBufferSize >> 1)) 3041 { 3042 oscl_memmove(ipTempInputBuffer, &ipTempInputBuffer[iTempConsumedLength], iTempInputBufferLength); 3043 iIsInputBufferEnded = OMX_TRUE; 3044 iTempConsumedLength = 0; 3045 } 3046 3047 if ((iTempInputBufferLength + iTempConsumedLength + iInputCurrLength) 3048 <= TempInputBufferSize) 3049 { 3050 oscl_memcpy(&ipTempInputBuffer[iTempInputBufferLength + iTempConsumedLength], ipFrameDecodeBuffer, iInputCurrLength); 3051 iTempInputBufferLength += iInputCurrLength; 3052 3053 if (iTempInputBufferLength + (TempInputBufferSize >> 1) <= TempInputBufferSize) 3054 { 3055 iNewInBufferRequired = OMX_TRUE; 3056 } 3057 else 3058 { 3059 iNewInBufferRequired = OMX_FALSE; 3060 } 3061 3062 ipTargetComponent = (OMX_COMPONENTTYPE*) ipInputBuffer->hMarkTargetComponent; 3063 3064 iTargetMarkData = ipInputBuffer->pMarkData; 3065 if (ipTargetComponent == (OMX_COMPONENTTYPE*) pHandle) 3066 { 3067 (*(ipCallbacks->EventHandler)) 3068 (pHandle, 3069 iCallbackData, 3070 OMX_EventMark, 3071 1, 3072 0, 3073 ipInputBuffer->pMarkData); 3074 } 3075 ipInputBuffer->nFilledLen = 0; 3076 ReturnInputBuffer(ipInputBuffer, pInPort); 3077 ipInputBuffer = NULL; 3078 3079 } 3080 3081 if (iTempInputBufferLength >= (TempInputBufferSize >> 1)) 3082 { 3083 iIsInputBufferEnded = OMX_FALSE; 3084 } 3085 } 3086 3087 3088 3089 OSCL_EXPORT_REF void OmxComponentBase::Run() 3090 { 3091 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : Run IN")); 3092 3093 CoreMessage* pCoreMessage; 3094 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*) iOmxComponent.pComponentPrivate; 3095 3096 //Execute the commands from the message handler queue 3097 if ((GetQueueNumElem(ipCoreDescriptor->pMessageQueue) > 0)) 3098 { 3099 pCoreMessage = (CoreMessage*) DeQueue(ipCoreDescriptor->pMessageQueue); 3100 3101 if (OMX_CommandStateSet == pCoreMessage->MessageParam1) 3102 { 3103 if (OMX_StateExecuting == pCoreMessage->MessageParam2) 3104 { 3105 iBufferExecuteFlag = OMX_TRUE; 3106 } 3107 else 3108 { 3109 iBufferExecuteFlag = OMX_FALSE; 3110 } 3111 } 3112 3113 MessageHandler(pCoreMessage); 3114 3115 /* If some allocations/deallocations are required before the state transition 3116 * then queue the command again to be executed later on 3117 */ 3118 if (OMX_TRUE == iStateTransitionFlag) 3119 { 3120 if (OMX_ErrorNone != Queue(ipCoreDescriptor->pMessageQueue, pCoreMessage)) 3121 { 3122 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : Error, Queue command failed, Run OUT")); 3123 return; 3124 } 3125 3126 // Don't reschedule. Wait for arriving buffers to do it 3127 //RunIfNotReady(); 3128 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : Run OUT")); 3129 return; 3130 } 3131 3132 else 3133 { 3134 oscl_free(pCoreMessage); 3135 pCoreMessage = NULL; 3136 } 3137 } 3138 3139 /* If the component is in executing state, call the Buffer management function. 3140 * Stop calling this function as soon as state transition request is received. 3141 */ 3142 if ((OMX_TRUE == iBufferExecuteFlag) && (OMX_TRUE != iResizePending)) 3143 { 3144 pOpenmaxAOType->BufferMgmtFunction(); 3145 } 3146 3147 //Check for any more commands in the message handler queue & schedule them for later 3148 if ((GetQueueNumElem(ipCoreDescriptor->pMessageQueue) > 0)) 3149 { 3150 RunIfNotReady(); 3151 } 3152 3153 3154 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : Run OUT")); 3155 3156 return; 3157 } 3158 3159 3160 /************************** 3161 AUDIO BASE CLASS ROUTINES 3162 **************************/ 3163 OSCL_EXPORT_REF OmxComponentAudio::OmxComponentAudio() 3164 { 3165 iIsAudioComponent = OMX_TRUE; 3166 3167 } 3168 3169 3170 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentAudio::GetParameter( 3171 OMX_IN OMX_HANDLETYPE hComponent, 3172 OMX_IN OMX_INDEXTYPE nParamIndex, 3173 OMX_INOUT OMX_PTR ComponentParameterStructure) 3174 { 3175 OSCL_UNUSED_ARG(hComponent); 3176 3177 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter IN")); 3178 3179 OMX_PRIORITYMGMTTYPE* pPrioMgmt; 3180 OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply; 3181 OMX_PARAM_PORTDEFINITIONTYPE* pPortDef; 3182 OMX_PORT_PARAM_TYPE* pPortDomains; 3183 OMX_U32 PortIndex; 3184 OMX_PARAM_COMPONENTROLETYPE* pCompRole; 3185 3186 OMX_AUDIO_PARAM_PORTFORMATTYPE* pAudioPortFormat; 3187 OMX_AUDIO_PARAM_PCMMODETYPE* pAudioPcmMode; 3188 OMX_AUDIO_PARAM_WMATYPE* pAudioWma; 3189 OMX_AUDIO_PARAM_MP3TYPE* pAudioMp3; 3190 OMX_AUDIO_CONFIG_EQUALIZERTYPE* pAudioEqualizer; 3191 OMX_AUDIO_PARAM_AACPROFILETYPE* pAudioAac; 3192 OMX_AUDIO_PARAM_AMRTYPE* pAudioAmr; 3193 3194 ComponentPortType* pComponentPort; 3195 3196 if (NULL == ComponentParameterStructure) 3197 { 3198 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad parameter")); 3199 return OMX_ErrorBadParameter; 3200 } 3201 3202 switch (nParamIndex) 3203 { 3204 case OMX_IndexParamPriorityMgmt: 3205 { 3206 pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure; 3207 SetHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE)); 3208 pPrioMgmt->nGroupPriority = iGroupPriority; 3209 pPrioMgmt->nGroupID = iGroupID; 3210 } 3211 break; 3212 3213 case OMX_IndexParamAudioInit: 3214 { 3215 SetHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE)); 3216 oscl_memcpy(ComponentParameterStructure, &iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE)); 3217 } 3218 break; 3219 3220 3221 //Following 3 cases have a single common piece of code to be executed 3222 case OMX_IndexParamVideoInit: 3223 case OMX_IndexParamImageInit: 3224 case OMX_IndexParamOtherInit: 3225 { 3226 pPortDomains = (OMX_PORT_PARAM_TYPE*) ComponentParameterStructure; 3227 SetHeader(pPortDomains, sizeof(OMX_PORT_PARAM_TYPE)); 3228 pPortDomains->nPorts = 0; 3229 pPortDomains->nStartPortNumber = 0; 3230 } 3231 break; 3232 3233 case OMX_IndexParamAudioPortFormat: 3234 { 3235 pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure; 3236 //Added to pass parameter test 3237 if (pAudioPortFormat->nIndex > ipPorts[pAudioPortFormat->nPortIndex]->AudioParam.nIndex) 3238 { 3239 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error index out of range")); 3240 return OMX_ErrorNoMore; 3241 } 3242 SetHeader(pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); 3243 if (pAudioPortFormat->nPortIndex <= 1) 3244 { 3245 pComponentPort = (ComponentPortType*) ipPorts[pAudioPortFormat->nPortIndex]; 3246 oscl_memcpy(pAudioPortFormat, &pComponentPort->AudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); 3247 } 3248 else 3249 { 3250 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index")); 3251 return OMX_ErrorBadPortIndex; 3252 } 3253 } 3254 break; 3255 3256 case OMX_IndexParamAudioPcm: 3257 { 3258 pAudioPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*) ComponentParameterStructure; 3259 if (pAudioPcmMode->nPortIndex > 1) 3260 { 3261 return OMX_ErrorBadPortIndex; 3262 } 3263 PortIndex = pAudioPcmMode->nPortIndex; 3264 oscl_memcpy(pAudioPcmMode, &ipPorts[PortIndex]->AudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)); 3265 SetHeader(pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)); 3266 } 3267 break; 3268 3269 case OMX_IndexParamAudioMp3: 3270 { 3271 pAudioMp3 = (OMX_AUDIO_PARAM_MP3TYPE*) ComponentParameterStructure; 3272 if (pAudioMp3->nPortIndex != iCompressedFormatPortNum) 3273 { 3274 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index")); 3275 return OMX_ErrorBadPortIndex; 3276 } 3277 PortIndex = pAudioMp3->nPortIndex; 3278 oscl_memcpy(pAudioMp3, &ipPorts[PortIndex]->AudioMp3Param, sizeof(OMX_AUDIO_PARAM_MP3TYPE)); 3279 SetHeader(pAudioMp3, sizeof(OMX_AUDIO_PARAM_MP3TYPE)); 3280 } 3281 break; 3282 3283 case OMX_IndexParamAudioWma: 3284 { 3285 pAudioWma = (OMX_AUDIO_PARAM_WMATYPE*) ComponentParameterStructure; 3286 if (pAudioWma->nPortIndex != iCompressedFormatPortNum) 3287 { 3288 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index")); 3289 return OMX_ErrorBadPortIndex; 3290 } 3291 PortIndex = pAudioWma->nPortIndex; 3292 oscl_memcpy(pAudioWma, &ipPorts[PortIndex]->AudioWmaParam, sizeof(OMX_AUDIO_PARAM_WMATYPE)); 3293 SetHeader(pAudioWma, sizeof(OMX_AUDIO_PARAM_WMATYPE)); 3294 } 3295 break; 3296 3297 case OMX_IndexConfigAudioEqualizer: 3298 { 3299 pAudioEqualizer = (OMX_AUDIO_CONFIG_EQUALIZERTYPE*) ComponentParameterStructure; 3300 if (pAudioEqualizer->nPortIndex != iCompressedFormatPortNum) 3301 { 3302 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index")); 3303 return OMX_ErrorBadPortIndex; 3304 } 3305 PortIndex = pAudioEqualizer->nPortIndex; 3306 oscl_memcpy(pAudioEqualizer, &ipPorts[PortIndex]->AudioEqualizerType, sizeof(OMX_AUDIO_CONFIG_EQUALIZERTYPE)); 3307 SetHeader(pAudioEqualizer, sizeof(OMX_AUDIO_CONFIG_EQUALIZERTYPE)); 3308 } 3309 break; 3310 3311 case OMX_IndexParamAudioAac: 3312 { 3313 pAudioAac = (OMX_AUDIO_PARAM_AACPROFILETYPE*) ComponentParameterStructure; 3314 if (pAudioAac->nPortIndex != iCompressedFormatPortNum) 3315 { 3316 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index")); 3317 return OMX_ErrorBadPortIndex; 3318 } 3319 PortIndex = pAudioAac->nPortIndex; 3320 oscl_memcpy(pAudioAac, &ipPorts[PortIndex]->AudioAacParam, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE)); 3321 SetHeader(pAudioAac, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE)); 3322 } 3323 break; 3324 3325 case OMX_IndexParamAudioAmr: 3326 { 3327 pAudioAmr = (OMX_AUDIO_PARAM_AMRTYPE*) ComponentParameterStructure; 3328 if (pAudioAmr->nPortIndex != iCompressedFormatPortNum) 3329 { 3330 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index")); 3331 return OMX_ErrorBadPortIndex; 3332 } 3333 PortIndex = pAudioAmr->nPortIndex; 3334 oscl_memcpy(pAudioAmr, &ipPorts[PortIndex]->AudioAmrParam, sizeof(OMX_AUDIO_PARAM_AMRTYPE)); 3335 SetHeader(pAudioAmr, sizeof(OMX_AUDIO_PARAM_AMRTYPE)); 3336 } 3337 break; 3338 3339 case OMX_IndexParamPortDefinition: 3340 { 3341 pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure; 3342 PortIndex = pPortDef->nPortIndex; 3343 if (PortIndex >= iNumPorts) 3344 { 3345 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index")); 3346 return OMX_ErrorBadPortIndex; 3347 } 3348 oscl_memcpy(pPortDef, &ipPorts[PortIndex]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); 3349 } 3350 break; 3351 3352 case OMX_IndexParamCompBufferSupplier: 3353 { 3354 pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure; 3355 PortIndex = pBufSupply->nPortIndex; 3356 if (PortIndex >= iNumPorts) 3357 { 3358 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index")); 3359 return OMX_ErrorBadPortIndex; 3360 } 3361 SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); 3362 3363 if (OMX_DirInput == ipPorts[PortIndex]->PortParam.eDir) 3364 { 3365 pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified; 3366 } 3367 else 3368 { 3369 SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); 3370 pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified; 3371 } 3372 } 3373 break; 3374 3375 case(OMX_INDEXTYPE) PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX: 3376 { 3377 PV_OMXComponentCapabilityFlagsType *pCap_flags = (PV_OMXComponentCapabilityFlagsType *) ComponentParameterStructure; 3378 if (NULL == pCap_flags) 3379 { 3380 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error pCap_flags NULL")); 3381 return OMX_ErrorBadParameter; 3382 } 3383 oscl_memcpy(pCap_flags, &iPVCapabilityFlags, sizeof(iPVCapabilityFlags)); 3384 3385 } 3386 break; 3387 case OMX_IndexParamStandardComponentRole: 3388 { 3389 pCompRole = (OMX_PARAM_COMPONENTROLETYPE*) ComponentParameterStructure; 3390 SetHeader(pCompRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); 3391 oscl_strncpy((OMX_STRING)pCompRole->cRole, (OMX_STRING)iComponentRole, OMX_MAX_STRINGNAME_SIZE); 3392 } 3393 break; 3394 3395 default: 3396 { 3397 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error Unsupported Index")); 3398 return OMX_ErrorUnsupportedIndex; 3399 } 3400 } 3401 3402 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter OUT")); 3403 3404 return OMX_ErrorNone; 3405 3406 } 3407 3408 3409 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentAudio::SetParameter( 3410 OMX_IN OMX_HANDLETYPE hComponent, 3411 OMX_IN OMX_INDEXTYPE nParamIndex, 3412 OMX_IN OMX_PTR ComponentParameterStructure) 3413 { 3414 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter IN")); 3415 3416 OMX_PRIORITYMGMTTYPE* pPrioMgmt; 3417 OMX_AUDIO_PARAM_PORTFORMATTYPE* pAudioPortFormat; 3418 OMX_AUDIO_PARAM_PCMMODETYPE* pAudioPcmMode; 3419 OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply; 3420 OMX_PARAM_PORTDEFINITIONTYPE* pPortDef ; 3421 OMX_PARAM_COMPONENTROLETYPE* pCompRole; 3422 ComponentPortType* pComponentPort; 3423 3424 OMX_AUDIO_PARAM_WMATYPE* pAudioWma; 3425 OMX_AUDIO_PARAM_MP3TYPE* pAudioMp3; 3426 OMX_AUDIO_CONFIG_EQUALIZERTYPE* pAudioEqualizer; 3427 OMX_AUDIO_PARAM_AACPROFILETYPE* pAudioAac; 3428 OMX_AUDIO_PARAM_AMRTYPE* pAudioAmr; 3429 3430 OMX_U32 PortIndex; 3431 OMX_ERRORTYPE ErrorType = OMX_ErrorNone; 3432 OmxComponentAudio* pOpenmaxAOType = (OmxComponentAudio*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 3433 3434 3435 if (NULL == ComponentParameterStructure) 3436 { 3437 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error bad parameter")); 3438 return OMX_ErrorBadParameter; 3439 } 3440 3441 switch (nParamIndex) 3442 { 3443 case OMX_IndexParamAudioInit: 3444 { 3445 /*Check Structure Header*/ 3446 CheckHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE)); 3447 if (ErrorType != OMX_ErrorNone) 3448 { 3449 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error audio init failed")); 3450 return ErrorType; 3451 } 3452 oscl_memcpy(&iPortTypesParam, ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE)); 3453 } 3454 break; 3455 3456 case OMX_IndexParamAudioPortFormat: 3457 { 3458 pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure; 3459 PortIndex = pAudioPortFormat->nPortIndex; 3460 /*Check Structure Header and verify component state*/ 3461 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); 3462 if (ErrorType != OMX_ErrorNone) 3463 { 3464 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error")); 3465 return ErrorType; 3466 } 3467 if (PortIndex <= 1) 3468 { 3469 pComponentPort = (ComponentPortType*) ipPorts[PortIndex]; 3470 oscl_memcpy(&pComponentPort->AudioParam, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); 3471 } 3472 else 3473 { 3474 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error bad port index")); 3475 return OMX_ErrorBadPortIndex; 3476 } 3477 } 3478 break; 3479 3480 case OMX_IndexParamAudioPcm: 3481 { 3482 pAudioPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*) ComponentParameterStructure; 3483 PortIndex = pAudioPcmMode->nPortIndex; 3484 /*Check Structure Header and verify component State*/ 3485 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)); 3486 oscl_memcpy(&ipPorts[PortIndex]->AudioPcmMode, pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE)); 3487 } 3488 break; 3489 3490 case OMX_IndexParamAudioMp3: 3491 { 3492 pAudioMp3 = (OMX_AUDIO_PARAM_MP3TYPE*) ComponentParameterStructure; 3493 PortIndex = pAudioMp3->nPortIndex; 3494 /*Check Structure Header and verify component state*/ 3495 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pAudioMp3, sizeof(OMX_AUDIO_PARAM_MP3TYPE)); 3496 if (ErrorType != OMX_ErrorNone) 3497 { 3498 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error")); 3499 return ErrorType; 3500 } 3501 oscl_memcpy(&ipPorts[PortIndex]->AudioMp3Param, pAudioMp3, sizeof(OMX_AUDIO_PARAM_MP3TYPE)); 3502 } 3503 break; 3504 3505 case OMX_IndexParamAudioWma: 3506 { 3507 3508 3509 pAudioWma = (OMX_AUDIO_PARAM_WMATYPE*) ComponentParameterStructure; 3510 PortIndex = pAudioWma->nPortIndex; 3511 /*Check Structure Header and verify component state*/ 3512 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pAudioWma, sizeof(OMX_AUDIO_PARAM_WMATYPE)); 3513 if (ErrorType != OMX_ErrorNone) 3514 { 3515 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error")); 3516 return ErrorType; 3517 } 3518 oscl_memcpy(&ipPorts[PortIndex]->AudioWmaParam, pAudioWma, sizeof(OMX_AUDIO_PARAM_WMATYPE)); 3519 } 3520 break; 3521 3522 case OMX_IndexConfigAudioEqualizer: 3523 { 3524 pAudioEqualizer = (OMX_AUDIO_CONFIG_EQUALIZERTYPE*) ComponentParameterStructure; 3525 PortIndex = pAudioEqualizer->nPortIndex; 3526 /*Check Structure Header and verify component state*/ 3527 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pAudioEqualizer, sizeof(OMX_AUDIO_CONFIG_EQUALIZERTYPE)); 3528 if (ErrorType != OMX_ErrorNone) 3529 { 3530 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error")); 3531 return ErrorType; 3532 } 3533 oscl_memcpy(&ipPorts[PortIndex]->AudioEqualizerType, pAudioEqualizer, sizeof(OMX_AUDIO_CONFIG_EQUALIZERTYPE)); 3534 } 3535 break; 3536 3537 case OMX_IndexParamAudioAac: 3538 { 3539 OMX_BOOL AacPlusFlag = OMX_TRUE; 3540 3541 pAudioAac = (OMX_AUDIO_PARAM_AACPROFILETYPE*) ComponentParameterStructure; 3542 PortIndex = pAudioAac->nPortIndex; 3543 /*Check Structure Header and verify component state*/ 3544 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pAudioAac, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE)); 3545 if (ErrorType != OMX_ErrorNone) 3546 { 3547 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error")); 3548 return ErrorType; 3549 } 3550 oscl_memcpy(&ipPorts[PortIndex]->AudioAacParam, pAudioAac, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE)); 3551 3552 if ((ipPorts[PortIndex]->AudioAacParam.eAACProfile == OMX_AUDIO_AACObjectHE) 3553 || (ipPorts[PortIndex]->AudioAacParam.eAACProfile == OMX_AUDIO_AACObjectHE_PS)) 3554 { 3555 AacPlusFlag = OMX_TRUE; 3556 } 3557 else 3558 { 3559 AacPlusFlag = OMX_FALSE; 3560 } 3561 3562 pOpenmaxAOType->UpdateAACPlusFlag(AacPlusFlag); 3563 } 3564 break; 3565 3566 case OMX_IndexParamAudioAmr: 3567 { 3568 pAudioAmr = (OMX_AUDIO_PARAM_AMRTYPE*) ComponentParameterStructure; 3569 PortIndex = pAudioAmr->nPortIndex; 3570 /*Check Structure Header and verify component state*/ 3571 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pAudioAmr, sizeof(OMX_AUDIO_PARAM_AMRTYPE)); 3572 if (ErrorType != OMX_ErrorNone) 3573 { 3574 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error")); 3575 return ErrorType; 3576 } 3577 oscl_memcpy(&ipPorts[PortIndex]->AudioAmrParam, pAudioAmr, sizeof(OMX_AUDIO_PARAM_AMRTYPE)); 3578 3579 //If the band mode turns out to be WB, set the sampling freq to 16KHz 3580 if ((pAudioAmr->eAMRBandMode >= OMX_AUDIO_AMRBandModeWB0) && 3581 (pAudioAmr->eAMRBandMode <= OMX_AUDIO_AMRBandModeWB8)) 3582 { 3583 ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioPcmMode.nSamplingRate = 16000; 3584 } 3585 } 3586 break; 3587 3588 case OMX_IndexParamPriorityMgmt: 3589 { 3590 if (iState != OMX_StateLoaded && iState != OMX_StateWaitForResources) 3591 { 3592 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error incorrect state error")); 3593 return OMX_ErrorIncorrectStateOperation; 3594 } 3595 pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure; 3596 if ((ErrorType = CheckHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE))) != OMX_ErrorNone) 3597 { 3598 break; 3599 } 3600 iGroupPriority = pPrioMgmt->nGroupPriority; 3601 iGroupID = pPrioMgmt->nGroupID; 3602 } 3603 break; 3604 3605 case OMX_IndexParamPortDefinition: 3606 { 3607 pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure; 3608 PortIndex = pPortDef->nPortIndex; 3609 3610 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); 3611 if (ErrorType != OMX_ErrorNone) 3612 { 3613 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error")); 3614 return ErrorType; 3615 } 3616 3617 ipPorts[PortIndex]->PortParam.nBufferCountActual = pPortDef->nBufferCountActual; 3618 ipPorts[PortIndex]->PortParam.nBufferSize = pPortDef->nBufferSize; 3619 3620 oscl_memcpy(&ipPorts[PortIndex]->PortParam.format.audio, &pPortDef->format.audio, sizeof(OMX_AUDIO_PORTDEFINITIONTYPE)); 3621 } 3622 break; 3623 3624 case OMX_IndexParamCompBufferSupplier: 3625 { 3626 pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure; 3627 PortIndex = pBufSupply->nPortIndex; 3628 3629 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); 3630 if (OMX_ErrorIncorrectStateOperation == ErrorType) 3631 { 3632 if (PORT_IS_ENABLED(ipPorts[pBufSupply->nPortIndex])) 3633 { 3634 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error incorrect state error")); 3635 return OMX_ErrorIncorrectStateOperation; 3636 } 3637 } 3638 else if (ErrorType != OMX_ErrorNone) 3639 { 3640 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error")); 3641 return ErrorType; 3642 } 3643 3644 if (pBufSupply->eBufferSupplier == OMX_BufferSupplyUnspecified) 3645 { 3646 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter OUT")); 3647 return OMX_ErrorNone; 3648 } 3649 3650 ErrorType = OMX_ErrorNone; 3651 } 3652 break; 3653 3654 case OMX_IndexParamStandardComponentRole: 3655 { 3656 pCompRole = (OMX_PARAM_COMPONENTROLETYPE*) ComponentParameterStructure; 3657 if ((ErrorType = CheckHeader(pCompRole, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone) 3658 { 3659 break; 3660 } 3661 oscl_strncpy((OMX_STRING)iComponentRole, (OMX_STRING)pCompRole->cRole, OMX_MAX_STRINGNAME_SIZE); 3662 iComponentRoleFlag = OMX_TRUE; 3663 } 3664 break; 3665 3666 3667 default: 3668 { 3669 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error Unsupported index")); 3670 return OMX_ErrorUnsupportedIndex; 3671 } 3672 } 3673 3674 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter OUT")); 3675 return ErrorType; 3676 3677 } 3678 3679 3680 /************************* 3681 VIDEO BASE CLASS ROUTINES 3682 *************************/ 3683 OSCL_EXPORT_REF OmxComponentVideo::OmxComponentVideo() 3684 { 3685 iIsAudioComponent = OMX_FALSE; 3686 3687 } 3688 3689 3690 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentVideo::GetParameter( 3691 OMX_IN OMX_HANDLETYPE hComponent, 3692 OMX_IN OMX_INDEXTYPE nParamIndex, 3693 OMX_INOUT OMX_PTR ComponentParameterStructure) 3694 { 3695 OSCL_UNUSED_ARG(hComponent); 3696 3697 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter IN")); 3698 3699 OMX_PRIORITYMGMTTYPE* pPrioMgmt; 3700 OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply; 3701 OMX_PARAM_PORTDEFINITIONTYPE* pPortDef; 3702 OMX_PORT_PARAM_TYPE* pPortDomains; 3703 OMX_U32 PortIndex; 3704 OMX_PARAM_COMPONENTROLETYPE* pCompRole; 3705 3706 3707 OMX_VIDEO_PARAM_PORTFORMATTYPE* pVideoPortFormat; 3708 OMX_VIDEO_PARAM_PROFILELEVELTYPE* pProfileLevel; 3709 3710 OMX_VIDEO_PARAM_MPEG4TYPE* pVideoMpeg4; 3711 OMX_VIDEO_PARAM_H263TYPE* pVideoH263; 3712 OMX_VIDEO_PARAM_AVCTYPE* pVideoAvc; 3713 OMX_VIDEO_PARAM_WMVTYPE* pVideoWmv; 3714 3715 //Video encoder configuration parameters 3716 OMX_CONFIG_ROTATIONTYPE* pVideoRotation; 3717 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE* pVideoErrCorr; 3718 OMX_VIDEO_PARAM_BITRATETYPE* pVideoRateControl; 3719 OMX_VIDEO_PARAM_QUANTIZATIONTYPE* pVideoQuant; 3720 OMX_VIDEO_PARAM_VBSMCTYPE* pVideoBlock; 3721 OMX_VIDEO_PARAM_MOTIONVECTORTYPE* pVideoMotionVector; 3722 OMX_VIDEO_PARAM_INTRAREFRESHTYPE* pVideoIntraRefresh; 3723 3724 if (NULL == ComponentParameterStructure) 3725 { 3726 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad parameter")); 3727 return OMX_ErrorBadParameter; 3728 } 3729 3730 switch (nParamIndex) 3731 { 3732 case OMX_IndexParamPriorityMgmt: 3733 { 3734 pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure; 3735 SetHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE)); 3736 pPrioMgmt->nGroupPriority = iGroupPriority; 3737 pPrioMgmt->nGroupID = iGroupID; 3738 } 3739 break; 3740 3741 case OMX_IndexParamVideoInit: 3742 { 3743 SetHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE)); 3744 oscl_memcpy(ComponentParameterStructure, &iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE)); 3745 } 3746 break; 3747 3748 3749 //Following 3 cases have a single common piece of code to be executed 3750 case OMX_IndexParamAudioInit: 3751 case OMX_IndexParamImageInit: 3752 case OMX_IndexParamOtherInit: 3753 { 3754 pPortDomains = (OMX_PORT_PARAM_TYPE*) ComponentParameterStructure; 3755 SetHeader(pPortDomains, sizeof(OMX_PORT_PARAM_TYPE)); 3756 pPortDomains->nPorts = 0; 3757 pPortDomains->nStartPortNumber = 0; 3758 } 3759 break; 3760 3761 case OMX_IndexParamVideoPortFormat: 3762 { 3763 pVideoPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure; 3764 3765 //Check for valid port index 3766 PortIndex = pVideoPortFormat->nPortIndex; 3767 if (PortIndex >= iNumPorts) 3768 { 3769 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index")); 3770 return OMX_ErrorBadPortIndex; 3771 } 3772 3773 OMX_U32 QueriedIndex = pVideoPortFormat->nIndex; 3774 if (QueriedIndex >= ipPorts[PortIndex]->ActualNumPortFormatsSupported) 3775 { 3776 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error index out of range")); 3777 return OMX_ErrorNoMore; 3778 } 3779 else 3780 { 3781 SetHeader(pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); 3782 oscl_memcpy(pVideoPortFormat, &ipPorts[PortIndex]->VideoParam[QueriedIndex], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); 3783 } 3784 } 3785 3786 break; 3787 3788 case OMX_IndexParamVideoMpeg4: 3789 { 3790 pVideoMpeg4 = (OMX_VIDEO_PARAM_MPEG4TYPE*) ComponentParameterStructure; 3791 if (pVideoMpeg4->nPortIndex != iCompressedFormatPortNum) 3792 { 3793 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index")); 3794 return OMX_ErrorBadPortIndex; 3795 } 3796 PortIndex = pVideoMpeg4->nPortIndex; 3797 oscl_memcpy(pVideoMpeg4, &ipPorts[PortIndex]->VideoMpeg4, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); 3798 SetHeader(pVideoMpeg4, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); 3799 } 3800 break; 3801 3802 case OMX_IndexParamVideoH263: 3803 { 3804 pVideoH263 = (OMX_VIDEO_PARAM_H263TYPE*) ComponentParameterStructure; 3805 if (pVideoH263->nPortIndex != iCompressedFormatPortNum) 3806 { 3807 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index")); 3808 return OMX_ErrorBadPortIndex; 3809 } 3810 PortIndex = pVideoH263->nPortIndex; 3811 oscl_memcpy(pVideoH263, &ipPorts[PortIndex]->VideoH263, sizeof(OMX_VIDEO_PARAM_H263TYPE)); 3812 SetHeader(pVideoH263, sizeof(OMX_VIDEO_PARAM_H263TYPE)); 3813 } 3814 break; 3815 3816 case OMX_IndexParamVideoAvc: 3817 { 3818 pVideoAvc = (OMX_VIDEO_PARAM_AVCTYPE*) ComponentParameterStructure; 3819 if (pVideoAvc->nPortIndex != iCompressedFormatPortNum) 3820 { 3821 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index")); 3822 return OMX_ErrorBadPortIndex; 3823 } 3824 PortIndex = pVideoAvc->nPortIndex; 3825 oscl_memcpy(pVideoAvc, &ipPorts[PortIndex]->VideoAvc, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); 3826 SetHeader(pVideoAvc, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); 3827 } 3828 break; 3829 3830 case OMX_IndexParamVideoWmv: 3831 { 3832 pVideoWmv = (OMX_VIDEO_PARAM_WMVTYPE*)ComponentParameterStructure; 3833 if (pVideoWmv->nPortIndex != iCompressedFormatPortNum) 3834 { 3835 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index")); 3836 return OMX_ErrorBadPortIndex; 3837 } 3838 PortIndex = pVideoWmv->nPortIndex; 3839 oscl_memcpy(pVideoWmv, &ipPorts[PortIndex]->VideoWmv, sizeof(OMX_VIDEO_PARAM_WMVTYPE)); 3840 SetHeader(pVideoWmv, sizeof(OMX_VIDEO_PARAM_WMVTYPE)); 3841 } 3842 break; 3843 3844 case OMX_IndexParamVideoProfileLevelQuerySupported: 3845 { 3846 pProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*) ComponentParameterStructure; 3847 3848 PortIndex = pProfileLevel->nPortIndex; 3849 if (pProfileLevel->nProfileIndex > ipPorts[PortIndex]->ProfileLevel.nProfileIndex) 3850 { 3851 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error profile not supported")); 3852 return OMX_ErrorNoMore; 3853 } 3854 3855 oscl_memcpy(pProfileLevel, &ipPorts[PortIndex]->ProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); 3856 SetHeader(pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); 3857 } 3858 break; 3859 3860 case OMX_IndexParamVideoProfileLevelCurrent: 3861 { 3862 pProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*) ComponentParameterStructure; 3863 3864 PortIndex = pProfileLevel->nPortIndex; 3865 3866 oscl_memcpy(pProfileLevel, &ipPorts[PortIndex]->ProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); 3867 SetHeader(pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); 3868 } 3869 break; 3870 3871 case OMX_IndexParamPortDefinition: 3872 { 3873 pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure; 3874 PortIndex = pPortDef->nPortIndex; 3875 if (PortIndex >= iNumPorts) 3876 { 3877 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index")); 3878 return OMX_ErrorBadPortIndex; 3879 } 3880 oscl_memcpy(pPortDef, &ipPorts[PortIndex]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); 3881 } 3882 break; 3883 3884 case OMX_IndexParamCompBufferSupplier: 3885 { 3886 pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure; 3887 PortIndex = pBufSupply->nPortIndex; 3888 if (PortIndex >= iNumPorts) 3889 { 3890 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index")); 3891 return OMX_ErrorBadPortIndex; 3892 } 3893 SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); 3894 3895 if (OMX_DirInput == ipPorts[PortIndex]->PortParam.eDir) 3896 { 3897 pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified; 3898 } 3899 else 3900 { 3901 SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); 3902 pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified; 3903 } 3904 } 3905 break; 3906 3907 case(OMX_INDEXTYPE) PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX: 3908 { 3909 PV_OMXComponentCapabilityFlagsType *pCap_flags = (PV_OMXComponentCapabilityFlagsType *) ComponentParameterStructure; 3910 if (NULL == pCap_flags) 3911 { 3912 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error pCap_flags NULL")); 3913 return OMX_ErrorBadParameter; 3914 } 3915 oscl_memcpy(pCap_flags, &iPVCapabilityFlags, sizeof(iPVCapabilityFlags)); 3916 3917 } 3918 break; 3919 3920 case OMX_IndexConfigCommonRotate: 3921 { 3922 pVideoRotation = (OMX_CONFIG_ROTATIONTYPE*) ComponentParameterStructure; 3923 if (pVideoRotation->nPortIndex >= iNumPorts) 3924 { 3925 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index")); 3926 return OMX_ErrorBadPortIndex; 3927 } 3928 PortIndex = pVideoRotation->nPortIndex; 3929 oscl_memcpy(pVideoRotation, &ipPorts[PortIndex]->VideoOrientationType, sizeof(OMX_CONFIG_ROTATIONTYPE)); 3930 SetHeader(pVideoRotation, sizeof(OMX_CONFIG_ROTATIONTYPE)); 3931 } 3932 break; 3933 3934 case OMX_IndexParamVideoErrorCorrection: 3935 { 3936 pVideoErrCorr = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE*) ComponentParameterStructure; 3937 if (pVideoErrCorr->nPortIndex != iCompressedFormatPortNum) 3938 { 3939 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index")); 3940 return OMX_ErrorBadPortIndex; 3941 } 3942 PortIndex = pVideoErrCorr->nPortIndex; 3943 oscl_memcpy(pVideoErrCorr, &ipPorts[PortIndex]->VideoErrorCorrection, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); 3944 SetHeader(pVideoErrCorr, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); 3945 } 3946 break; 3947 3948 case OMX_IndexParamVideoBitrate: 3949 { 3950 pVideoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE*) ComponentParameterStructure; 3951 if (pVideoRateControl->nPortIndex != iCompressedFormatPortNum) 3952 { 3953 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index")); 3954 return OMX_ErrorBadPortIndex; 3955 } 3956 PortIndex = pVideoRateControl->nPortIndex; 3957 oscl_memcpy(pVideoRateControl, &ipPorts[PortIndex]->VideoRateType, sizeof(OMX_VIDEO_PARAM_BITRATETYPE)); 3958 SetHeader(pVideoRateControl, sizeof(OMX_VIDEO_PARAM_BITRATETYPE)); 3959 } 3960 break; 3961 3962 case OMX_IndexParamVideoQuantization: 3963 { 3964 pVideoQuant = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE*) ComponentParameterStructure; 3965 if (pVideoQuant->nPortIndex != iCompressedFormatPortNum) 3966 { 3967 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index")); 3968 return OMX_ErrorBadPortIndex; 3969 } 3970 PortIndex = pVideoQuant->nPortIndex; 3971 oscl_memcpy(pVideoQuant, &ipPorts[PortIndex]->VideoQuantType, sizeof(OMX_VIDEO_PARAM_QUANTIZATIONTYPE)); 3972 SetHeader(pVideoQuant, sizeof(OMX_VIDEO_PARAM_QUANTIZATIONTYPE)); 3973 } 3974 break; 3975 3976 case OMX_IndexParamVideoVBSMC: 3977 { 3978 pVideoBlock = (OMX_VIDEO_PARAM_VBSMCTYPE*) ComponentParameterStructure; 3979 if (pVideoBlock->nPortIndex != iCompressedFormatPortNum) 3980 { 3981 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index")); 3982 return OMX_ErrorBadPortIndex; 3983 } 3984 PortIndex = pVideoBlock->nPortIndex; 3985 oscl_memcpy(pVideoBlock, &ipPorts[PortIndex]->VideoBlockMotionSize, sizeof(OMX_VIDEO_PARAM_VBSMCTYPE)); 3986 SetHeader(pVideoBlock, sizeof(OMX_VIDEO_PARAM_VBSMCTYPE)); 3987 } 3988 break; 3989 3990 case OMX_IndexParamVideoMotionVector: 3991 { 3992 pVideoMotionVector = (OMX_VIDEO_PARAM_MOTIONVECTORTYPE*) ComponentParameterStructure; 3993 if (pVideoMotionVector->nPortIndex != iCompressedFormatPortNum) 3994 { 3995 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index")); 3996 return OMX_ErrorBadPortIndex; 3997 } 3998 PortIndex = pVideoMotionVector->nPortIndex; 3999 oscl_memcpy(pVideoMotionVector, &ipPorts[PortIndex]->VideoMotionVector, sizeof(OMX_VIDEO_PARAM_MOTIONVECTORTYPE)); 4000 SetHeader(pVideoMotionVector, sizeof(OMX_VIDEO_PARAM_MOTIONVECTORTYPE)); 4001 } 4002 break; 4003 4004 case OMX_IndexParamVideoIntraRefresh: 4005 { 4006 pVideoIntraRefresh = (OMX_VIDEO_PARAM_INTRAREFRESHTYPE*) ComponentParameterStructure; 4007 if (pVideoIntraRefresh->nPortIndex != iCompressedFormatPortNum) 4008 { 4009 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index")); 4010 return OMX_ErrorBadPortIndex; 4011 } 4012 PortIndex = pVideoIntraRefresh->nPortIndex; 4013 oscl_memcpy(pVideoIntraRefresh, &ipPorts[PortIndex]->VideoIntraRefresh, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE)); 4014 SetHeader(pVideoIntraRefresh, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE)); 4015 } 4016 break; 4017 case OMX_IndexParamStandardComponentRole: 4018 { 4019 pCompRole = (OMX_PARAM_COMPONENTROLETYPE*) ComponentParameterStructure; 4020 SetHeader(pCompRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); 4021 oscl_strncpy((OMX_STRING)pCompRole->cRole, (OMX_STRING)iComponentRole, OMX_MAX_STRINGNAME_SIZE); 4022 } 4023 break; 4024 default: 4025 { 4026 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error Unsupported Index")); 4027 return OMX_ErrorUnsupportedIndex; 4028 } 4029 // break; This break statement was removed to avoid compiler warning for Unreachable Code 4030 } 4031 4032 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter OUT")); 4033 4034 return OMX_ErrorNone; 4035 4036 } 4037 4038 4039 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentVideo::SetParameter( 4040 OMX_IN OMX_HANDLETYPE hComponent, 4041 OMX_IN OMX_INDEXTYPE nParamIndex, 4042 OMX_IN OMX_PTR ComponentParameterStructure) 4043 { 4044 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter IN")); 4045 4046 OMX_ERRORTYPE ErrorType = OMX_ErrorNone; 4047 OMX_PRIORITYMGMTTYPE* pPrioMgmt; 4048 OMX_VIDEO_PARAM_PORTFORMATTYPE* pVideoPortFormat; 4049 OMX_VIDEO_PARAM_PROFILELEVELTYPE* pProfileLevel; 4050 OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply; 4051 OMX_PARAM_PORTDEFINITIONTYPE* pPortDef ; 4052 OMX_U32 PortIndex; 4053 4054 OMX_PARAM_COMPONENTROLETYPE* pCompRole; 4055 OMX_VIDEO_PARAM_MPEG4TYPE* pVideoMpeg4; 4056 OMX_VIDEO_PARAM_H263TYPE* pVideoH263; 4057 OMX_VIDEO_PARAM_WMVTYPE* pVideoWmv; 4058 OMX_VIDEO_PARAM_AVCTYPE* pVideoAvc; 4059 4060 //Video encoder configuration parameters 4061 OMX_CONFIG_ROTATIONTYPE* pVideoRotation; 4062 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE* pVideoErrCorr; 4063 OMX_VIDEO_PARAM_BITRATETYPE* pVideoRateControl; 4064 OMX_VIDEO_PARAM_QUANTIZATIONTYPE* pVideoQuant; 4065 OMX_VIDEO_PARAM_VBSMCTYPE* pVideoBlock; 4066 OMX_VIDEO_PARAM_MOTIONVECTORTYPE* pVideoMotionVector; 4067 OMX_VIDEO_PARAM_INTRAREFRESHTYPE* pVideoIntraRefresh; 4068 4069 4070 ComponentPortType* pComponentPort; 4071 4072 if (NULL == ComponentParameterStructure) 4073 { 4074 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error bad parameter")); 4075 return OMX_ErrorBadParameter; 4076 } 4077 4078 switch (nParamIndex) 4079 { 4080 case OMX_IndexParamVideoInit: 4081 { 4082 /*Check Structure Header*/ 4083 CheckHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE)); 4084 if (ErrorType != OMX_ErrorNone) 4085 { 4086 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error video init check header failed")); 4087 return ErrorType; 4088 } 4089 oscl_memcpy(&iPortTypesParam, ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE)); 4090 } 4091 break; 4092 4093 case OMX_IndexParamVideoPortFormat: 4094 { 4095 pVideoPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure; 4096 PortIndex = pVideoPortFormat->nPortIndex; 4097 /*Check Structure Header and verify component state*/ 4098 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); 4099 if (ErrorType != OMX_ErrorNone) 4100 { 4101 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error parameter sanity check error")); 4102 return ErrorType; 4103 } 4104 if (PortIndex <= 1) 4105 { 4106 pComponentPort = (ComponentPortType*) ipPorts[PortIndex]; 4107 oscl_memcpy(&pComponentPort->VideoParam, pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); 4108 } 4109 else 4110 { 4111 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error bad port index")); 4112 return OMX_ErrorBadPortIndex; 4113 } 4114 } 4115 break; 4116 4117 case OMX_IndexParamVideoMpeg4: 4118 { 4119 pVideoMpeg4 = (OMX_VIDEO_PARAM_MPEG4TYPE*) ComponentParameterStructure; 4120 PortIndex = pVideoMpeg4->nPortIndex; 4121 /*Check Structure Header and verify component state*/ 4122 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoMpeg4, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); 4123 if (ErrorType != OMX_ErrorNone) 4124 { 4125 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed")); 4126 return ErrorType; 4127 } 4128 oscl_memcpy(&ipPorts[PortIndex]->VideoMpeg4, pVideoMpeg4, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); 4129 } 4130 break; 4131 4132 case OMX_IndexParamVideoH263: 4133 { 4134 pVideoH263 = (OMX_VIDEO_PARAM_H263TYPE*) ComponentParameterStructure; 4135 PortIndex = pVideoH263->nPortIndex; 4136 /*Check Structure Header and verify component state*/ 4137 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoH263, sizeof(OMX_VIDEO_PARAM_H263TYPE)); 4138 if (ErrorType != OMX_ErrorNone) 4139 { 4140 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed")); 4141 return ErrorType; 4142 } 4143 oscl_memcpy(&ipPorts[PortIndex]->VideoH263, pVideoH263, sizeof(OMX_VIDEO_PARAM_H263TYPE)); 4144 } 4145 break; 4146 4147 case OMX_IndexParamVideoAvc: 4148 { 4149 pVideoAvc = (OMX_VIDEO_PARAM_AVCTYPE*) ComponentParameterStructure; 4150 PortIndex = pVideoAvc->nPortIndex; 4151 /*Check Structure Header and verify component state*/ 4152 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoAvc, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); 4153 if (ErrorType != OMX_ErrorNone) 4154 { 4155 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error parameter sanity check error")); 4156 return ErrorType; 4157 } 4158 oscl_memcpy(&ipPorts[PortIndex]->VideoAvc, pVideoAvc, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); 4159 } 4160 break; 4161 4162 case OMX_IndexParamVideoWmv: 4163 { 4164 pVideoWmv = (OMX_VIDEO_PARAM_WMVTYPE*)ComponentParameterStructure; 4165 PortIndex = pVideoWmv->nPortIndex; 4166 /*Check Structure Header and verify component state*/ 4167 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoWmv, sizeof(OMX_VIDEO_PARAM_WMVTYPE)); 4168 if (ErrorType != OMX_ErrorNone) 4169 { 4170 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed")); 4171 return ErrorType; 4172 } 4173 oscl_memcpy(&ipPorts[PortIndex]->VideoWmv, pVideoWmv, sizeof(OMX_VIDEO_PARAM_WMVTYPE)); 4174 } 4175 break; 4176 4177 4178 case OMX_IndexParamVideoProfileLevelCurrent: 4179 { 4180 pProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*) ComponentParameterStructure; 4181 PortIndex = pProfileLevel->nPortIndex; 4182 /*Check Structure Header and verify component state*/ 4183 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); 4184 if (OMX_ErrorNone != ErrorType) 4185 { 4186 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error parameter sanity check error")); 4187 return ErrorType; 4188 } 4189 oscl_memcpy(&ipPorts[PortIndex]->ProfileLevel, pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); 4190 } 4191 break; 4192 4193 case OMX_IndexParamPriorityMgmt: 4194 { 4195 if (iState != OMX_StateLoaded && iState != OMX_StateWaitForResources) 4196 { 4197 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error incorrect state error")); 4198 return OMX_ErrorIncorrectStateOperation; 4199 } 4200 pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure; 4201 if ((ErrorType = CheckHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE))) != OMX_ErrorNone) 4202 { 4203 break; 4204 } 4205 iGroupPriority = pPrioMgmt->nGroupPriority; 4206 iGroupID = pPrioMgmt->nGroupID; 4207 } 4208 break; 4209 4210 case OMX_IndexParamPortDefinition: 4211 { 4212 pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure; 4213 PortIndex = pPortDef->nPortIndex; 4214 4215 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); 4216 if (ErrorType != OMX_ErrorNone) 4217 { 4218 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error parameter sanity check error")); 4219 return ErrorType; 4220 } 4221 4222 ipPorts[PortIndex]->PortParam.nBufferCountActual = pPortDef->nBufferCountActual; 4223 ipPorts[PortIndex]->PortParam.nBufferSize = pPortDef->nBufferSize; 4224 4225 oscl_memcpy(&ipPorts[PortIndex]->PortParam.format.video, &pPortDef->format.video, sizeof(OMX_VIDEO_PORTDEFINITIONTYPE)); 4226 4227 // adjust the minimum buffer size of the uncompressed format based on width and height that may have been set 4228 // In case of decoder - output port contains uncompressed data - so outpu buffer size needs to be adjusted 4229 // In case of encoder - input port contains uncompressed data - so input buffer size needs to be adjusted 4230 // In both cases (encoder&decoder) - eCompressionFormat parameter on the appropriate port is set to OMX_VIDEO_CodingUnused 4231 4232 OMX_VIDEO_PORTDEFINITIONTYPE *videoformat = &(ipPorts[PortIndex]->PortParam.format.video); 4233 if (videoformat->eCompressionFormat == OMX_VIDEO_CodingUnused) 4234 { 4235 // check if stride needs to be adjusted - stride should be at least the 16 byte aligned width 4236 // WMV is special case that requires 4 bytes alignment 4237 4238 OMX_U32 min_stride = ((videoformat->nFrameWidth + 15) & (~15)); 4239 OMX_U32 min_sliceheight = ((videoformat->nFrameHeight + 15) & (~15)); 4240 4241 if (oscl_strcmp("video/wmv", videoformat->cMIMEType) == 0) 4242 { 4243 min_stride = ((videoformat->nFrameWidth + 3) & (~3)); 4244 min_sliceheight = ((videoformat->nFrameHeight + 1) & (~1)); 4245 } 4246 4247 4248 videoformat->nStride = min_stride; 4249 videoformat->nSliceHeight = min_sliceheight; 4250 4251 4252 // finally, compute the new minimum buffer size. 4253 4254 // Encoder components can have different formats - (rely on the client to provide the correct size) 4255 if (OMX_PORT_OUTPUTPORT_INDEX == PortIndex) 4256 { 4257 // Decoder components always output YUV420 format 4258 ipPorts[PortIndex]->PortParam.nBufferSize = (videoformat->nSliceHeight * videoformat->nStride * 3) >> 1; 4259 4260 } 4261 4262 if (OMX_PORT_INPUTPORT_INDEX == PortIndex) 4263 { 4264 // Encoder components may have different formats 4265 if (videoformat->eColorFormat == OMX_COLOR_Format24bitRGB888) 4266 { 4267 ipPorts[PortIndex]->PortParam.nBufferSize = videoformat->nSliceHeight * videoformat->nStride * 3; 4268 } 4269 else if (videoformat->eColorFormat == OMX_COLOR_Format12bitRGB444) 4270 { 4271 ipPorts[PortIndex]->PortParam.nBufferSize = videoformat->nSliceHeight * videoformat->nStride * 2; 4272 4273 } 4274 else if (videoformat->eColorFormat == OMX_COLOR_FormatYUV420Planar) 4275 { 4276 ipPorts[PortIndex]->PortParam.nBufferSize = (videoformat->nSliceHeight * videoformat->nStride * 3) >> 1; 4277 4278 } 4279 4280 } 4281 4282 } 4283 4284 } 4285 break; 4286 4287 case OMX_IndexParamCompBufferSupplier: 4288 { 4289 pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure; 4290 PortIndex = pBufSupply->nPortIndex; 4291 4292 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); 4293 if (OMX_ErrorIncorrectStateOperation == ErrorType) 4294 { 4295 if (PORT_IS_ENABLED(ipPorts[pBufSupply->nPortIndex])) 4296 { 4297 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error incorrect state error")); 4298 return OMX_ErrorIncorrectStateOperation; 4299 } 4300 } 4301 else if (ErrorType != OMX_ErrorNone) 4302 { 4303 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error parameter sanity check error")); 4304 return ErrorType; 4305 } 4306 4307 if (pBufSupply->eBufferSupplier == OMX_BufferSupplyUnspecified) 4308 { 4309 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter OUT")); 4310 return OMX_ErrorNone; 4311 } 4312 4313 ErrorType = OMX_ErrorNone; 4314 } 4315 break; 4316 4317 case OMX_IndexParamStandardComponentRole: 4318 { 4319 pCompRole = (OMX_PARAM_COMPONENTROLETYPE*) ComponentParameterStructure; 4320 if ((ErrorType = CheckHeader(pCompRole, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone) 4321 { 4322 break; 4323 } 4324 oscl_strncpy((OMX_STRING)iComponentRole, (OMX_STRING)pCompRole->cRole, OMX_MAX_STRINGNAME_SIZE); 4325 iComponentRoleFlag = OMX_TRUE; 4326 } 4327 break; 4328 4329 4330 case OMX_IndexConfigCommonRotate: 4331 { 4332 pVideoRotation = (OMX_CONFIG_ROTATIONTYPE*) ComponentParameterStructure; 4333 PortIndex = pVideoRotation->nPortIndex; 4334 /*Check Structure Header and verify component state*/ 4335 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoRotation, sizeof(OMX_CONFIG_ROTATIONTYPE)); 4336 if (ErrorType != OMX_ErrorNone) 4337 { 4338 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed")); 4339 return ErrorType; 4340 } 4341 oscl_memcpy(&ipPorts[PortIndex]->VideoOrientationType, pVideoRotation, sizeof(OMX_CONFIG_ROTATIONTYPE)); 4342 } 4343 break; 4344 4345 case OMX_IndexParamVideoErrorCorrection: 4346 { 4347 pVideoErrCorr = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE*) ComponentParameterStructure; 4348 PortIndex = pVideoErrCorr->nPortIndex; 4349 /*Check Structure Header and verify component state*/ 4350 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoErrCorr, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); 4351 if (ErrorType != OMX_ErrorNone) 4352 { 4353 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed")); 4354 return ErrorType; 4355 } 4356 oscl_memcpy(&ipPorts[PortIndex]->VideoErrorCorrection, pVideoErrCorr, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); 4357 } 4358 break; 4359 4360 case OMX_IndexParamVideoBitrate: 4361 { 4362 pVideoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE*) ComponentParameterStructure; 4363 PortIndex = pVideoRateControl->nPortIndex; 4364 /*Check Structure Header and verify component state*/ 4365 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoRateControl, sizeof(OMX_VIDEO_PARAM_BITRATETYPE)); 4366 if (ErrorType != OMX_ErrorNone) 4367 { 4368 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed")); 4369 return ErrorType; 4370 } 4371 oscl_memcpy(&ipPorts[PortIndex]->VideoRateType, pVideoRateControl, sizeof(OMX_VIDEO_PARAM_BITRATETYPE)); 4372 } 4373 break; 4374 4375 case OMX_IndexParamVideoQuantization: 4376 { 4377 pVideoQuant = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE*) ComponentParameterStructure; 4378 PortIndex = pVideoQuant->nPortIndex; 4379 /*Check Structure Header and verify component state*/ 4380 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoQuant, sizeof(OMX_VIDEO_PARAM_QUANTIZATIONTYPE)); 4381 if (ErrorType != OMX_ErrorNone) 4382 { 4383 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed")); 4384 return ErrorType; 4385 } 4386 oscl_memcpy(&ipPorts[PortIndex]->VideoQuantType, pVideoQuant, sizeof(OMX_VIDEO_PARAM_QUANTIZATIONTYPE)); 4387 } 4388 break; 4389 4390 case OMX_IndexParamVideoVBSMC: 4391 { 4392 pVideoBlock = (OMX_VIDEO_PARAM_VBSMCTYPE*) ComponentParameterStructure; 4393 PortIndex = pVideoBlock->nPortIndex; 4394 /*Check Structure Header and verify component state*/ 4395 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoBlock, sizeof(OMX_VIDEO_PARAM_VBSMCTYPE)); 4396 if (ErrorType != OMX_ErrorNone) 4397 { 4398 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed")); 4399 return ErrorType; 4400 } 4401 oscl_memcpy(&ipPorts[PortIndex]->VideoBlockMotionSize, pVideoBlock, sizeof(OMX_VIDEO_PARAM_VBSMCTYPE)); 4402 } 4403 break; 4404 4405 case OMX_IndexParamVideoMotionVector: 4406 { 4407 pVideoMotionVector = (OMX_VIDEO_PARAM_MOTIONVECTORTYPE*) ComponentParameterStructure; 4408 PortIndex = pVideoMotionVector->nPortIndex; 4409 /*Check Structure Header and verify component state*/ 4410 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoMotionVector, sizeof(OMX_VIDEO_PARAM_MOTIONVECTORTYPE)); 4411 if (ErrorType != OMX_ErrorNone) 4412 { 4413 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed")); 4414 return ErrorType; 4415 } 4416 oscl_memcpy(&ipPorts[PortIndex]->VideoMotionVector, pVideoMotionVector, sizeof(OMX_VIDEO_PARAM_MOTIONVECTORTYPE)); 4417 } 4418 break; 4419 4420 case OMX_IndexParamVideoIntraRefresh: 4421 { 4422 pVideoIntraRefresh = (OMX_VIDEO_PARAM_INTRAREFRESHTYPE*) ComponentParameterStructure; 4423 PortIndex = pVideoIntraRefresh->nPortIndex; 4424 /*Check Structure Header and verify component state*/ 4425 ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoIntraRefresh, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE)); 4426 if (ErrorType != OMX_ErrorNone) 4427 { 4428 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed")); 4429 return ErrorType; 4430 } 4431 oscl_memcpy(&ipPorts[PortIndex]->VideoIntraRefresh, pVideoIntraRefresh, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE)); 4432 } 4433 break; 4434 4435 4436 default: 4437 { 4438 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error Unsupported index")); 4439 return OMX_ErrorUnsupportedIndex; 4440 } 4441 // break; This break statement was removed to avoid compiler warning for Unreachable Code 4442 } 4443 4444 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter OUT")); 4445 return ErrorType; 4446 4447 } 4448 #if PROXY_INTERFACE 4449 4450 /** Component entry points declarations with proxy interface*/ 4451 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyGetConfig( 4452 OMX_IN OMX_HANDLETYPE hComponent, 4453 OMX_IN OMX_INDEXTYPE nIndex, 4454 OMX_INOUT OMX_PTR pComponentConfigStructure) 4455 { 4456 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 4457 if (NULL == pOpenmaxAOType) 4458 { 4459 return OMX_ErrorBadParameter; 4460 } 4461 4462 OMX_ERRORTYPE ReturnValue; 4463 4464 ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyGetConfig(hComponent, nIndex, pComponentConfigStructure); 4465 return ReturnValue; 4466 } 4467 4468 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentProxySetConfig( 4469 OMX_IN OMX_HANDLETYPE hComponent, 4470 OMX_IN OMX_INDEXTYPE nIndex, 4471 OMX_IN OMX_PTR pComponentConfigStructure) 4472 { 4473 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 4474 if (NULL == pOpenmaxAOType) 4475 { 4476 return OMX_ErrorBadParameter; 4477 } 4478 4479 OMX_ERRORTYPE ReturnValue; 4480 4481 ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxySetConfig(hComponent, nIndex, pComponentConfigStructure); 4482 return ReturnValue; 4483 } 4484 4485 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyGetExtensionIndex( 4486 OMX_IN OMX_HANDLETYPE hComponent, 4487 OMX_IN OMX_STRING cParameterName, 4488 OMX_OUT OMX_INDEXTYPE* pIndexType) 4489 { 4490 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 4491 if (NULL == pOpenmaxAOType) 4492 { 4493 return OMX_ErrorBadParameter; 4494 } 4495 4496 OMX_ERRORTYPE ReturnValue; 4497 4498 ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyGetExtensionIndex(hComponent, cParameterName, pIndexType); 4499 return ReturnValue; 4500 } 4501 4502 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyGetState( 4503 OMX_IN OMX_HANDLETYPE hComponent, 4504 OMX_OUT OMX_STATETYPE* pState) 4505 { 4506 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 4507 if (NULL == pOpenmaxAOType) 4508 { 4509 return OMX_ErrorBadParameter; 4510 } 4511 4512 OMX_ERRORTYPE ReturnValue; 4513 4514 ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyGetState(hComponent, pState); 4515 return ReturnValue; 4516 } 4517 4518 4519 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyGetParameter( 4520 OMX_IN OMX_HANDLETYPE hComponent, 4521 OMX_IN OMX_INDEXTYPE nParamIndex, 4522 OMX_INOUT OMX_PTR ComponentParameterStructure) 4523 { 4524 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 4525 if (NULL == pOpenmaxAOType) 4526 { 4527 return OMX_ErrorBadParameter; 4528 } 4529 4530 OMX_ERRORTYPE ReturnValue = OMX_ErrorNone; 4531 4532 ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyGetParameter(hComponent, nParamIndex, ComponentParameterStructure); 4533 return ReturnValue; 4534 } 4535 4536 4537 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentProxySetParameter( 4538 OMX_IN OMX_HANDLETYPE hComponent, 4539 OMX_IN OMX_INDEXTYPE nParamIndex, 4540 OMX_IN OMX_PTR ComponentParameterStructure) 4541 { 4542 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 4543 if (NULL == pOpenmaxAOType) 4544 { 4545 return OMX_ErrorBadParameter; 4546 } 4547 4548 OMX_ERRORTYPE ReturnValue; 4549 4550 ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxySetParameter(hComponent, nParamIndex, ComponentParameterStructure); 4551 return ReturnValue; 4552 } 4553 4554 4555 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyUseBuffer( 4556 OMX_IN OMX_HANDLETYPE hComponent, 4557 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, 4558 OMX_IN OMX_U32 nPortIndex, 4559 OMX_IN OMX_PTR pAppPrivate, 4560 OMX_IN OMX_U32 nSizeBytes, 4561 OMX_IN OMX_U8* pBuffer) 4562 { 4563 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 4564 if (NULL == pOpenmaxAOType) 4565 { 4566 return OMX_ErrorBadParameter; 4567 } 4568 4569 OMX_ERRORTYPE ReturnValue; 4570 4571 ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyUseBuffer(hComponent, ppBufferHdr, nPortIndex, pAppPrivate, nSizeBytes, pBuffer); 4572 return ReturnValue; 4573 } 4574 4575 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyAllocateBuffer( 4576 OMX_IN OMX_HANDLETYPE hComponent, 4577 OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer, 4578 OMX_IN OMX_U32 nPortIndex, 4579 OMX_IN OMX_PTR pAppPrivate, 4580 OMX_IN OMX_U32 nSizeBytes) 4581 { 4582 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 4583 if (NULL == pOpenmaxAOType) 4584 { 4585 return OMX_ErrorBadParameter; 4586 } 4587 4588 OMX_ERRORTYPE ReturnValue; 4589 4590 ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyAllocateBuffer(hComponent, pBuffer, nPortIndex, pAppPrivate, nSizeBytes); 4591 return ReturnValue; 4592 } 4593 4594 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyFreeBuffer( 4595 OMX_IN OMX_HANDLETYPE hComponent, 4596 OMX_IN OMX_U32 nPortIndex, 4597 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 4598 { 4599 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 4600 if (NULL == pOpenmaxAOType) 4601 { 4602 return OMX_ErrorBadParameter; 4603 } 4604 4605 OMX_ERRORTYPE ReturnValue; 4606 4607 ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyFreeBuffer(hComponent, nPortIndex, pBuffer); 4608 return ReturnValue; 4609 } 4610 4611 OMX_ERRORTYPE OmxComponentBase::BaseComponentProxySetCallbacks( 4612 OMX_IN OMX_HANDLETYPE hComponent, 4613 OMX_IN OMX_CALLBACKTYPE* pCallbacks, 4614 OMX_IN OMX_PTR pAppData) 4615 { 4616 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 4617 if (NULL == pOpenmaxAOType) 4618 { 4619 return OMX_ErrorBadParameter; 4620 } 4621 4622 OMX_ERRORTYPE ReturnValue; 4623 4624 ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxySetCallbacks(hComponent, pCallbacks, pAppData); 4625 return ReturnValue; 4626 } 4627 4628 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentProxySendCommand( 4629 OMX_IN OMX_HANDLETYPE hComponent, 4630 OMX_IN OMX_COMMANDTYPE Cmd, 4631 OMX_IN OMX_U32 nParam, 4632 OMX_IN OMX_PTR pCmdData) 4633 { 4634 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 4635 if (NULL == pOpenmaxAOType) 4636 { 4637 return OMX_ErrorBadParameter; 4638 } 4639 4640 OMX_ERRORTYPE ReturnValue; 4641 4642 ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxySendCommand(hComponent, Cmd, nParam, pCmdData); 4643 return ReturnValue; 4644 } 4645 4646 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyEmptyThisBuffer( 4647 OMX_IN OMX_HANDLETYPE hComponent, 4648 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 4649 { 4650 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 4651 if (NULL == pOpenmaxAOType) 4652 { 4653 return OMX_ErrorBadParameter; 4654 } 4655 4656 OMX_ERRORTYPE ReturnValue; 4657 4658 ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyEmptyThisBuffer(hComponent, pBuffer); 4659 return ReturnValue; 4660 } 4661 4662 4663 OSCL_EXPORT_REF OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyFillThisBuffer( 4664 OMX_IN OMX_HANDLETYPE hComponent, 4665 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 4666 { 4667 OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate; 4668 if (NULL == pOpenmaxAOType) 4669 { 4670 return OMX_ErrorBadParameter; 4671 } 4672 4673 OMX_ERRORTYPE ReturnValue; 4674 4675 ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyFillThisBuffer(hComponent, pBuffer); 4676 return ReturnValue; 4677 } 4678 4679 #endif // PROXY_INTERFACE 4680