componentbase.cpp revision 3ee08716991119e541a439811c8c74988d7be754
1/* 2 * Copyright (C) 2009 Wind River Systems. 3 */ 4 5#include <stdlib.h> 6#include <string.h> 7 8#include <OMX_Core.h> 9#include <OMX_Component.h> 10 11#include <componentbase.h> 12 13#define LOG_TAG "componentbase" 14#include <log.h> 15 16/* 17 * ComponentBase 18 */ 19/* 20 * constructor & destructor 21 */ 22void ComponentBase::__ComponentBase(void) 23{ 24 memset(name, 0, OMX_MAX_STRINGNAME_SIZE); 25 cmodule = NULL; 26 handle = NULL; 27 28 roles = NULL; 29 nr_roles = 0; 30} 31 32ComponentBase::ComponentBase() 33{ 34 __ComponentBase(); 35} 36 37ComponentBase::ComponentBase(const OMX_STRING name) 38{ 39 __ComponentBase(); 40 SetName(name); 41} 42 43ComponentBase::~ComponentBase() 44{ 45 if (roles) { 46 OMX_U32 i; 47 48 for (i = 0; i < nr_roles; i++) 49 free(roles[i]); 50 51 free(roles); 52 } 53} 54 55/* end of constructor & destructor */ 56 57/* 58 * accessor 59 */ 60/* name */ 61void ComponentBase::SetName(const OMX_STRING name) 62{ 63 strncpy(this->name, name, OMX_MAX_STRINGNAME_SIZE); 64 this->name[OMX_MAX_STRINGNAME_SIZE-1] = '\0'; 65} 66 67const OMX_STRING ComponentBase::GetName(void) 68{ 69 return name; 70} 71 72/* component module */ 73void ComponentBase::SetCModule(CModule *cmodule) 74{ 75 this->cmodule = cmodule; 76} 77 78CModule *ComponentBase::GetCModule(void) 79{ 80 return cmodule; 81} 82 83/* end of accessor */ 84 85/* 86 * core methods & helpers 87 */ 88/* roles */ 89OMX_ERRORTYPE ComponentBase::SetRolesOfComponent(OMX_U32 nr_roles, 90 const OMX_U8 **roles) 91{ 92 OMX_U32 i; 93 94 this->roles = (OMX_U8 **)malloc(sizeof(OMX_STRING) * nr_roles); 95 if (!this->roles) 96 return OMX_ErrorInsufficientResources; 97 98 for (i = 0; i < nr_roles; i++) { 99 this->roles[i] = (OMX_U8 *)malloc(OMX_MAX_STRINGNAME_SIZE); 100 if (!this->roles[i]) { 101 int j; 102 103 for (j = (int )i-1; j >= 0; j--) 104 free(this->roles[j]); 105 free(this->roles); 106 107 return OMX_ErrorInsufficientResources; 108 } 109 110 strncpy((OMX_STRING)&this->roles[i][0], 111 (const OMX_STRING)&roles[i][0], 112 OMX_MAX_STRINGNAME_SIZE); 113 } 114 115 this->nr_roles = nr_roles; 116 return OMX_ErrorNone; 117} 118 119OMX_ERRORTYPE ComponentBase::GetRolesOfComponent(OMX_U32 *nr_roles, 120 OMX_U8 **roles) 121{ 122 OMX_U32 i; 123 OMX_U32 this_nr_roles = this->nr_roles; 124 125 if (!roles) { 126 *nr_roles = this_nr_roles; 127 return OMX_ErrorNone; 128 } 129 130 if (!nr_roles || (*nr_roles != this_nr_roles)) 131 return OMX_ErrorBadParameter; 132 133 for (i = 0; i < this_nr_roles; i++) { 134 if (!roles[i]) 135 break; 136 137 if (roles && roles[i]) 138 strncpy((OMX_STRING)&roles[i][0], 139 (const OMX_STRING)&this->roles[i][0], 140 OMX_MAX_STRINGNAME_SIZE); 141 } 142 143 if (i != this_nr_roles) 144 return OMX_ErrorBadParameter; 145 146 *nr_roles = this_nr_roles; 147 return OMX_ErrorNone; 148} 149 150bool ComponentBase::QueryHavingThisRole(const OMX_STRING role) 151{ 152 OMX_U32 i; 153 154 if (!roles || !role) 155 return false; 156 157 for (i = 0; i < nr_roles; i++) { 158 if (!strcmp((OMX_STRING)&roles[i][0], role)) 159 return true; 160 } 161 162 return false; 163} 164 165/* GetHandle & FreeHandle */ 166OMX_ERRORTYPE ComponentBase::GetHandle(OMX_HANDLETYPE *pHandle, 167 OMX_PTR pAppData, 168 OMX_CALLBACKTYPE *pCallBacks) 169{ 170 OMX_ERRORTYPE ret; 171 172 if (handle) 173 return OMX_ErrorUndefined; 174 175 handle = (OMX_COMPONENTTYPE *)calloc(1, sizeof(*handle)); 176 if (!handle) 177 return OMX_ErrorInsufficientResources; 178 179 /* handle initialization */ 180 SetTypeHeader(handle, sizeof(*handle)); 181 handle->pComponentPrivate = static_cast<OMX_PTR>(this); 182 handle->pApplicationPrivate = pAppData; 183 184 /* virtual - see derived class */ 185 ret = InitComponent(); 186 if (ret != OMX_ErrorNone) { 187 LOGE("failed to %s::InitComponent(), ret = 0x%08x\n", 188 name, ret); 189 goto free_handle; 190 } 191 192 /* connect handle's functions */ 193 handle->GetComponentVersion = GetComponentVersion; 194 handle->SendCommand = SendCommand; 195 handle->GetParameter = GetParameter; 196 handle->SetParameter = SetParameter; 197 handle->GetConfig = GetConfig; 198 handle->SetConfig = SetConfig; 199 handle->GetExtensionIndex = GetExtensionIndex; 200 handle->GetState = GetState; 201 handle->ComponentTunnelRequest = ComponentTunnelRequest; 202 handle->UseBuffer = UseBuffer; 203 handle->AllocateBuffer = AllocateBuffer; 204 handle->FreeBuffer = FreeBuffer; 205 handle->EmptyThisBuffer = EmptyThisBuffer; 206 handle->FillThisBuffer = FillThisBuffer; 207 handle->SetCallbacks = SetCallbacks; 208 handle->ComponentDeInit = ComponentDeInit; 209 handle->UseEGLImage = UseEGLImage; 210 handle->ComponentRoleEnum = ComponentRoleEnum; 211 212 appdata = pAppData; 213 callbacks = pCallBacks; 214 *pHandle = (OMX_HANDLETYPE *)handle; 215 216 return OMX_ErrorNone; 217 218free_handle: 219 free(this->handle); 220 this->handle = NULL; 221 222 return ret; 223} 224 225OMX_ERRORTYPE ComponentBase::FreeHandle(OMX_HANDLETYPE hComponent) 226{ 227 OMX_ERRORTYPE ret; 228 229 if (hComponent != handle) 230 return OMX_ErrorBadParameter; 231 232 /* virtual - see derived class */ 233 ret = ExitComponent(); 234 if (ret != OMX_ErrorNone) 235 return ret; 236 237 free(handle); 238 239 appdata = NULL; 240 callbacks = NULL; 241 242 return OMX_ErrorNone; 243} 244 245/* end of core methods & helpers */ 246 247/* 248 * component methods & helpers 249 */ 250OMX_ERRORTYPE ComponentBase::GetComponentVersion( 251 OMX_IN OMX_HANDLETYPE hComponent, 252 OMX_OUT OMX_STRING pComponentName, 253 OMX_OUT OMX_VERSIONTYPE* pComponentVersion, 254 OMX_OUT OMX_VERSIONTYPE* pSpecVersion, 255 OMX_OUT OMX_UUIDTYPE* pComponentUUID) 256{ 257 ComponentBase *cbase; 258 259 if (!hComponent) 260 return OMX_ErrorBadParameter; 261 262 cbase = static_cast<ComponentBase *> 263 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 264 if (!cbase) 265 return OMX_ErrorBadParameter; 266 267 return cbase->CBaseGetComponentVersion(hComponent, 268 pComponentName, 269 pComponentVersion, 270 pSpecVersion, 271 pComponentUUID); 272} 273 274OMX_ERRORTYPE ComponentBase::CBaseGetComponentVersion( 275 OMX_IN OMX_HANDLETYPE hComponent, 276 OMX_OUT OMX_STRING pComponentName, 277 OMX_OUT OMX_VERSIONTYPE* pComponentVersion, 278 OMX_OUT OMX_VERSIONTYPE* pSpecVersion, 279 OMX_OUT OMX_UUIDTYPE* pComponentUUID) 280{ 281 /* 282 * Todo 283 */ 284 285 return OMX_ErrorNotImplemented; 286} 287 288OMX_ERRORTYPE ComponentBase::SendCommand( 289 OMX_IN OMX_HANDLETYPE hComponent, 290 OMX_IN OMX_COMMANDTYPE Cmd, 291 OMX_IN OMX_U32 nParam1, 292 OMX_IN OMX_PTR pCmdData) 293{ 294 ComponentBase *cbase; 295 296 if (!hComponent) 297 return OMX_ErrorBadParameter; 298 299 cbase = static_cast<ComponentBase *> 300 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 301 if (!cbase) 302 return OMX_ErrorBadParameter; 303 304 return cbase->CBaseSendCommand(hComponent, Cmd, nParam1, pCmdData); 305} 306 307OMX_ERRORTYPE ComponentBase::CBaseSendCommand( 308 OMX_IN OMX_HANDLETYPE hComponent, 309 OMX_IN OMX_COMMANDTYPE Cmd, 310 OMX_IN OMX_U32 nParam1, 311 OMX_IN OMX_PTR pCmdData) 312{ 313 /* 314 * Todo 315 */ 316 317 return OMX_ErrorNotImplemented; 318} 319 320OMX_ERRORTYPE ComponentBase::GetParameter( 321 OMX_IN OMX_HANDLETYPE hComponent, 322 OMX_IN OMX_INDEXTYPE nParamIndex, 323 OMX_INOUT OMX_PTR pComponentParameterStructure) 324{ 325 ComponentBase *cbase; 326 327 if (!hComponent) 328 return OMX_ErrorBadParameter; 329 330 cbase = static_cast<ComponentBase *> 331 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 332 if (!cbase) 333 return OMX_ErrorBadParameter; 334 335 return cbase->CBaseGetParameter(hComponent, nParamIndex, 336 pComponentParameterStructure); 337} 338 339OMX_ERRORTYPE ComponentBase::CBaseGetParameter( 340 OMX_IN OMX_HANDLETYPE hComponent, 341 OMX_IN OMX_INDEXTYPE nParamIndex, 342 OMX_INOUT OMX_PTR pComponentParameterStructure) 343{ 344 /* 345 * Todo 346 */ 347 348 return OMX_ErrorNotImplemented; 349} 350 351OMX_ERRORTYPE ComponentBase::SetParameter( 352 OMX_IN OMX_HANDLETYPE hComponent, 353 OMX_IN OMX_INDEXTYPE nIndex, 354 OMX_IN OMX_PTR pComponentParameterStructure) 355{ 356 ComponentBase *cbase; 357 358 if (!hComponent) 359 return OMX_ErrorBadParameter; 360 361 cbase = static_cast<ComponentBase *> 362 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 363 if (!cbase) 364 return OMX_ErrorBadParameter; 365 366 return cbase->CBaseSetParameter(hComponent, nIndex, 367 pComponentParameterStructure); 368} 369 370OMX_ERRORTYPE ComponentBase::CBaseSetParameter( 371 OMX_IN OMX_HANDLETYPE hComponent, 372 OMX_IN OMX_INDEXTYPE nIndex, 373 OMX_IN OMX_PTR pComponentParameterStructure) 374{ 375 /* 376 * Todo 377 */ 378 379 return OMX_ErrorNotImplemented; 380} 381 382OMX_ERRORTYPE ComponentBase::GetConfig( 383 OMX_IN OMX_HANDLETYPE hComponent, 384 OMX_IN OMX_INDEXTYPE nIndex, 385 OMX_INOUT OMX_PTR pComponentConfigStructure) 386{ 387 ComponentBase *cbase; 388 389 if (!hComponent) 390 return OMX_ErrorBadParameter; 391 392 cbase = static_cast<ComponentBase *> 393 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 394 if (!cbase) 395 return OMX_ErrorBadParameter; 396 397 return cbase->CBaseGetConfig(hComponent, nIndex, 398 pComponentConfigStructure); 399} 400 401OMX_ERRORTYPE ComponentBase::CBaseGetConfig( 402 OMX_IN OMX_HANDLETYPE hComponent, 403 OMX_IN OMX_INDEXTYPE nIndex, 404 OMX_INOUT OMX_PTR pComponentConfigStructure) 405{ 406 /* 407 * Todo 408 */ 409 410 return OMX_ErrorNotImplemented; 411} 412 413OMX_ERRORTYPE ComponentBase::SetConfig( 414 OMX_IN OMX_HANDLETYPE hComponent, 415 OMX_IN OMX_INDEXTYPE nIndex, 416 OMX_IN OMX_PTR pComponentConfigStructure) 417{ 418 ComponentBase *cbase; 419 420 if (!hComponent) 421 return OMX_ErrorBadParameter; 422 423 cbase = static_cast<ComponentBase *> 424 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 425 if (!cbase) 426 return OMX_ErrorBadParameter; 427 428 return cbase->CBaseSetConfig(hComponent, nIndex, 429 pComponentConfigStructure); 430} 431 432OMX_ERRORTYPE ComponentBase::CBaseSetConfig( 433 OMX_IN OMX_HANDLETYPE hComponent, 434 OMX_IN OMX_INDEXTYPE nIndex, 435 OMX_IN OMX_PTR pComponentConfigStructure) 436{ 437 /* 438 * Todo 439 */ 440 441 return OMX_ErrorNotImplemented; 442} 443 444OMX_ERRORTYPE ComponentBase::GetExtensionIndex( 445 OMX_IN OMX_HANDLETYPE hComponent, 446 OMX_IN OMX_STRING cParameterName, 447 OMX_OUT OMX_INDEXTYPE* pIndexType) 448{ 449 ComponentBase *cbase; 450 451 if (!hComponent) 452 return OMX_ErrorBadParameter; 453 454 cbase = static_cast<ComponentBase *> 455 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 456 if (!cbase) 457 return OMX_ErrorBadParameter; 458 459 return cbase->CBaseGetExtensionIndex(hComponent, cParameterName, 460 pIndexType); 461} 462 463OMX_ERRORTYPE ComponentBase::CBaseGetExtensionIndex( 464 OMX_IN OMX_HANDLETYPE hComponent, 465 OMX_IN OMX_STRING cParameterName, 466 OMX_OUT OMX_INDEXTYPE* pIndexType) 467{ 468 /* 469 * Todo 470 */ 471 472 return OMX_ErrorNotImplemented; 473} 474 475OMX_ERRORTYPE ComponentBase::GetState( 476 OMX_IN OMX_HANDLETYPE hComponent, 477 OMX_OUT OMX_STATETYPE* pState) 478{ 479 ComponentBase *cbase; 480 481 if (!hComponent) 482 return OMX_ErrorBadParameter; 483 484 cbase = static_cast<ComponentBase *> 485 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 486 if (!cbase) 487 return OMX_ErrorBadParameter; 488 489 return cbase->CBaseGetState(hComponent, pState); 490} 491 492OMX_ERRORTYPE ComponentBase::CBaseGetState( 493 OMX_IN OMX_HANDLETYPE hComponent, 494 OMX_OUT OMX_STATETYPE* pState) 495{ 496 /* 497 * Todo 498 */ 499 500 return OMX_ErrorNotImplemented; 501} 502 503OMX_ERRORTYPE ComponentBase::ComponentTunnelRequest( 504 OMX_IN OMX_HANDLETYPE hComponent, 505 OMX_IN OMX_U32 nPort, 506 OMX_IN OMX_HANDLETYPE hTunneledComponent, 507 OMX_IN OMX_U32 nTunneledPort, 508 OMX_INOUT OMX_TUNNELSETUPTYPE* pTunnelSetup) 509{ 510 ComponentBase *cbase; 511 512 if (!hComponent) 513 return OMX_ErrorBadParameter; 514 515 cbase = static_cast<ComponentBase *> 516 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 517 if (!cbase) 518 return OMX_ErrorBadParameter; 519 520 return cbase->CBaseComponentTunnelRequest(hComponent, nPort, 521 hTunneledComponent, 522 nTunneledPort, pTunnelSetup); 523} 524 525OMX_ERRORTYPE ComponentBase::CBaseComponentTunnelRequest( 526 OMX_IN OMX_HANDLETYPE hComp, 527 OMX_IN OMX_U32 nPort, 528 OMX_IN OMX_HANDLETYPE hTunneledComp, 529 OMX_IN OMX_U32 nTunneledPort, 530 OMX_INOUT OMX_TUNNELSETUPTYPE* pTunnelSetup) 531{ 532 /* 533 * Todo 534 */ 535 536 return OMX_ErrorNotImplemented; 537} 538 539OMX_ERRORTYPE ComponentBase::UseBuffer( 540 OMX_IN OMX_HANDLETYPE hComponent, 541 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, 542 OMX_IN OMX_U32 nPortIndex, 543 OMX_IN OMX_PTR pAppPrivate, 544 OMX_IN OMX_U32 nSizeBytes, 545 OMX_IN OMX_U8* pBuffer) 546{ 547 ComponentBase *cbase; 548 549 if (!hComponent) 550 return OMX_ErrorBadParameter; 551 552 cbase = static_cast<ComponentBase *> 553 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 554 if (!cbase) 555 return OMX_ErrorBadParameter; 556 557 return cbase->CBaseUseBuffer(hComponent, ppBufferHdr, nPortIndex, 558 pAppPrivate, nSizeBytes, pBuffer); 559} 560 561OMX_ERRORTYPE ComponentBase::CBaseUseBuffer( 562 OMX_IN OMX_HANDLETYPE hComponent, 563 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, 564 OMX_IN OMX_U32 nPortIndex, 565 OMX_IN OMX_PTR pAppPrivate, 566 OMX_IN OMX_U32 nSizeBytes, 567 OMX_IN OMX_U8* pBuffer) 568{ 569 /* 570 * Todo 571 */ 572 573 return OMX_ErrorNotImplemented; 574} 575 576OMX_ERRORTYPE ComponentBase::AllocateBuffer( 577 OMX_IN OMX_HANDLETYPE hComponent, 578 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBuffer, 579 OMX_IN OMX_U32 nPortIndex, 580 OMX_IN OMX_PTR pAppPrivate, 581 OMX_IN OMX_U32 nSizeBytes) 582{ 583 ComponentBase *cbase; 584 585 if (!hComponent) 586 return OMX_ErrorBadParameter; 587 588 cbase = static_cast<ComponentBase *> 589 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 590 if (!cbase) 591 return OMX_ErrorBadParameter; 592 593 return cbase->CBaseAllocateBuffer(hComponent, ppBuffer, nPortIndex, 594 pAppPrivate, nSizeBytes); 595} 596 597OMX_ERRORTYPE ComponentBase::CBaseAllocateBuffer( 598 OMX_IN OMX_HANDLETYPE hComponent, 599 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBuffer, 600 OMX_IN OMX_U32 nPortIndex, 601 OMX_IN OMX_PTR pAppPrivate, 602 OMX_IN OMX_U32 nSizeBytes) 603{ 604 /* 605 * Todo 606 */ 607 608 return OMX_ErrorNotImplemented; 609} 610 611OMX_ERRORTYPE ComponentBase::FreeBuffer( 612 OMX_IN OMX_HANDLETYPE hComponent, 613 OMX_IN OMX_U32 nPortIndex, 614 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 615{ 616 ComponentBase *cbase; 617 618 if (!hComponent) 619 return OMX_ErrorBadParameter; 620 621 cbase = static_cast<ComponentBase *> 622 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 623 if (!cbase) 624 return OMX_ErrorBadParameter; 625 626 return cbase->CBaseFreeBuffer(hComponent, nPortIndex, pBuffer); 627} 628 629OMX_ERRORTYPE ComponentBase::CBaseFreeBuffer( 630 OMX_IN OMX_HANDLETYPE hComponent, 631 OMX_IN OMX_U32 nPortIndex, 632 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 633{ 634 /* 635 * Todo 636 */ 637 638 return OMX_ErrorNotImplemented; 639} 640 641OMX_ERRORTYPE ComponentBase::EmptyThisBuffer( 642 OMX_IN OMX_HANDLETYPE hComponent, 643 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 644{ 645 ComponentBase *cbase; 646 647 if (!hComponent) 648 return OMX_ErrorBadParameter; 649 650 cbase = static_cast<ComponentBase *> 651 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 652 if (!cbase) 653 return OMX_ErrorBadParameter; 654 655 return cbase->CBaseEmptyThisBuffer(hComponent, pBuffer); 656} 657 658OMX_ERRORTYPE ComponentBase::CBaseEmptyThisBuffer( 659 OMX_IN OMX_HANDLETYPE hComponent, 660 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 661{ 662 /* 663 * Todo 664 */ 665 666 return OMX_ErrorNotImplemented; 667} 668 669OMX_ERRORTYPE ComponentBase::FillThisBuffer( 670 OMX_IN OMX_HANDLETYPE hComponent, 671 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 672{ 673 ComponentBase *cbase; 674 675 if (!hComponent) 676 return OMX_ErrorBadParameter; 677 678 cbase = static_cast<ComponentBase *> 679 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 680 if (!cbase) 681 return OMX_ErrorBadParameter; 682 683 return cbase->CBaseFillThisBuffer(hComponent, pBuffer); 684} 685 686OMX_ERRORTYPE ComponentBase::CBaseFillThisBuffer( 687 OMX_IN OMX_HANDLETYPE hComponent, 688 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) 689{ 690 /* 691 * Todo 692 */ 693 694 return OMX_ErrorNotImplemented; 695} 696 697OMX_ERRORTYPE ComponentBase::SetCallbacks( 698 OMX_IN OMX_HANDLETYPE hComponent, 699 OMX_IN OMX_CALLBACKTYPE* pCallbacks, 700 OMX_IN OMX_PTR pAppData) 701{ 702 ComponentBase *cbase; 703 704 if (!hComponent) 705 return OMX_ErrorBadParameter; 706 707 cbase = static_cast<ComponentBase *> 708 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 709 if (!cbase) 710 return OMX_ErrorBadParameter; 711 712 return cbase->CBaseSetCallbacks(hComponent, pCallbacks, pAppData); 713} 714 715OMX_ERRORTYPE ComponentBase::CBaseSetCallbacks( 716 OMX_IN OMX_HANDLETYPE hComponent, 717 OMX_IN OMX_CALLBACKTYPE *pCallbacks, 718 OMX_IN OMX_PTR pAppData) 719{ 720 if (hComponent != handle) 721 return OMX_ErrorBadParameter; 722 723 appdata = pAppData; 724 callbacks = pCallbacks; 725 726 return OMX_ErrorNone; 727} 728 729OMX_ERRORTYPE ComponentBase::ComponentDeInit( 730 OMX_IN OMX_HANDLETYPE hComponent) 731{ 732 ComponentBase *cbase; 733 734 if (!hComponent) 735 return OMX_ErrorBadParameter; 736 737 cbase = static_cast<ComponentBase *> 738 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 739 if (!cbase) 740 return OMX_ErrorBadParameter; 741 742 return cbase->CBaseComponentDeInit(hComponent); 743} 744 745OMX_ERRORTYPE ComponentBase::CBaseComponentDeInit( 746 OMX_IN OMX_HANDLETYPE hComponent) 747{ 748 /* 749 * Todo 750 */ 751 752 return OMX_ErrorNotImplemented; 753} 754 755OMX_ERRORTYPE ComponentBase::UseEGLImage( 756 OMX_IN OMX_HANDLETYPE hComponent, 757 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, 758 OMX_IN OMX_U32 nPortIndex, 759 OMX_IN OMX_PTR pAppPrivate, 760 OMX_IN void* eglImage) 761{ 762 ComponentBase *cbase; 763 764 if (!hComponent) 765 return OMX_ErrorBadParameter; 766 767 cbase = static_cast<ComponentBase *> 768 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 769 if (!cbase) 770 return OMX_ErrorBadParameter; 771 772 return cbase->CBaseUseEGLImage(hComponent, ppBufferHdr, nPortIndex, 773 pAppPrivate, eglImage); 774} 775 776OMX_ERRORTYPE ComponentBase::CBaseUseEGLImage( 777 OMX_IN OMX_HANDLETYPE hComponent, 778 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, 779 OMX_IN OMX_U32 nPortIndex, 780 OMX_IN OMX_PTR pAppPrivate, 781 OMX_IN void* eglImage) 782{ 783 /* 784 * Todo 785 */ 786 787 return OMX_ErrorNotImplemented; 788} 789 790OMX_ERRORTYPE ComponentBase::ComponentRoleEnum( 791 OMX_IN OMX_HANDLETYPE hComponent, 792 OMX_OUT OMX_U8 *cRole, 793 OMX_IN OMX_U32 nIndex) 794{ 795 ComponentBase *cbase; 796 797 if (!hComponent) 798 return OMX_ErrorBadParameter; 799 800 cbase = static_cast<ComponentBase *> 801 (((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate); 802 if (!cbase) 803 return OMX_ErrorBadParameter; 804 805 return cbase->CBaseComponentRoleEnum(hComponent, cRole, nIndex); 806} 807 808OMX_ERRORTYPE ComponentBase::CBaseComponentRoleEnum( 809 OMX_IN OMX_HANDLETYPE hComponent, 810 OMX_OUT OMX_U8 *cRole, 811 OMX_IN OMX_U32 nIndex) 812{ 813 if (hComponent != (OMX_HANDLETYPE *)this->handle) 814 return OMX_ErrorBadParameter; 815 816 if (nIndex > nr_roles) 817 return OMX_ErrorBadParameter; 818 819 strncpy((char *)cRole, (const char *)roles[nIndex], 820 OMX_MAX_STRINGNAME_SIZE); 821 return OMX_ErrorNone; 822} 823 824/* end of component methods & helpers */ 825 826/* 827 * omx header manipuation 828 */ 829void ComponentBase::SetTypeHeader(OMX_PTR type, OMX_U32 size) 830{ 831 OMX_U32 *nsize; 832 OMX_VERSIONTYPE *nversion; 833 834 if (!type) 835 return; 836 837 nsize = (OMX_U32 *)type; 838 nversion = (OMX_VERSIONTYPE *)((OMX_U8 *)type + sizeof(OMX_U32)); 839 840 *nsize = sizeof(size); 841 nversion->nVersion = OMX_SPEC_VERSION; 842} 843 844OMX_BOOL ComponentBase::CheckTypeHeader(OMX_PTR type, OMX_U32 size) 845{ 846 OMX_U32 *nsize; 847 OMX_VERSIONTYPE *nversion; 848 OMX_U8 mismatch = 0; 849 850 if (!type) 851 return OMX_FALSE; 852 853 nsize = (OMX_U32 *)type; 854 nversion = (OMX_VERSIONTYPE *)((OMX_U8 *)type + sizeof(OMX_U32)); 855 856 mismatch = (*nsize != sizeof(size)) ? 1 : 0; 857 mismatch |= (nversion->nVersion != OMX_SPEC_VERSION) ? 1 : 0; 858 859 if (mismatch) 860 return OMX_TRUE; 861 else 862 return OMX_FALSE; 863} 864