omxilcomp/omxilgeneric/filesource/src/omxilfilesource.cpp
changeset 0 58be5850fb6c
equal deleted inserted replaced
-1:000000000000 0:58be5850fb6c
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 #include <openmax/il/common/omxilport.h>
       
    19 #include <openmax/il/common/omxilspecversion.h>
       
    20 #include <openmax/il/loader/omxilsymbiancomponentif.h>
       
    21 
       
    22 #include "omxilfilesource.h"
       
    23 #include "omxilotherfilesourceopb0port.h"
       
    24 #include "omxilfilesourceprocessingfunction.h"
       
    25 #include "omxilfilesourceconfigmanager.h"
       
    26 #include "omxilfilesource.hrh"
       
    27 
       
    28 #ifdef OMXIL_AUDIO_FILESOURCE
       
    29 #include "omxilaudiofilesourceapb0port.h"
       
    30 _LIT8(KNokiaOMXFileSourceComponentName, "OMX.NOKIA.AUDIO.FILESOURCE");
       
    31 _LIT8(KNokiaOMXFileSourceRole, "audio_reader.binary");
       
    32 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidNokiaOmxILAudioFileSource);
       
    33 
       
    34 #elif defined(OMXIL_VIDEO_FILESOURCE)
       
    35 #include "omxilvideofilesourcevpb0port.h"
       
    36 _LIT8(KNokiaOMXFileSourceComponentName, "OMX.NOKIA.VIDEO.FILESOURCE");
       
    37 _LIT8(KNokiaOMXFileSourceRole, "video_reader.binary");
       
    38 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidNokiaOmxILVideoFileSource);
       
    39 
       
    40 #elif defined(OMXIL_IMAGE_FILESOURCE)
       
    41 #include "omxilimagefilesourceipb0port.h"
       
    42 _LIT8(KNokiaOMXFileSourceComponentName, "OMX.NOKIA.IMAGE.FILESOURCE");
       
    43 _LIT8(KNokiaOMXFileSourceRole, "image_reader.binary");
       
    44 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidNokiaOmxILImageFileSource);
       
    45 
       
    46 #elif defined(OMXIL_OTHER_FILESOURCE)
       
    47 #include "omxilotherfilesourceopb0port.h"
       
    48 _LIT8(KNokiaOMXFileSourceComponentName, "OMX.NOKIA.OTHER.FILESOURCE");
       
    49 _LIT8(KNokiaOMXFileSourceRole, "other_reader.binary");
       
    50 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidNokiaOmxILOtherFileSource);
       
    51 
       
    52 #endif
       
    53 
       
    54 const TUint8 KComponentVersionMajor = 1;
       
    55 const TUint8 KComponentVersionMinor = 1;
       
    56 const TUint8 KComponentVersionRevision = 0;
       
    57 const TUint8 KComponentVersionStep = 0;
       
    58 
       
    59 static const TInt KMinBuffers = 1;
       
    60 static const TInt KMinBufferSize = 15360;
       
    61 
       
    62 
       
    63 // Component Entry Point
       
    64 OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE aComponent)
       
    65 	{
       
    66 	TRAPD(err, COmxILFileSource::CreateComponentL(aComponent));
       
    67 	if (err == KErrNone)
       
    68 		{
       
    69 		return OMX_ErrorNone;
       
    70 		}
       
    71 	else
       
    72 		{
       
    73 		return err == KErrNoMemory ? OMX_ErrorInsufficientResources : OMX_ErrorUndefined;
       
    74 		}
       
    75 	}
       
    76 
       
    77 void COmxILFileSource::CreateComponentL(OMX_HANDLETYPE aComponent)
       
    78 	{
       
    79 	COmxILFileSource* self = new (ELeave) COmxILFileSource();
       
    80 	CleanupStack::PushL(self);
       
    81 	self->ConstructL(aComponent);
       
    82 	CleanupStack::Pop(self);
       
    83 	}
       
    84 
       
    85 COmxILFileSource::COmxILFileSource()
       
    86 	{
       
    87 	// nothing to do
       
    88 	}
       
    89 
       
    90 COmxILFileSource::~COmxILFileSource()
       
    91 	{
       
    92 	}
       
    93 
       
    94 void COmxILFileSource::ConstructL(OMX_HANDLETYPE aComponent)
       
    95 	{
       
    96     // STEP 1: Initialize the data received from the IL Core
       
    97     COmxILComponent::ConstructL(aComponent);
       
    98     
       
    99     // STEP 2: Create the call backs manager...
       
   100     MOmxILCallbackNotificationIf* callbackNotificationIf=CreateCallbackManagerL(COmxILComponent::EOutofContext);
       
   101 
       
   102 	// STEP 3: Create the file source-specific Processing Function...
       
   103     COmxILFileSourceProcessingFunction* pProcessingFunction = COmxILFileSourceProcessingFunction::NewL(*callbackNotificationIf);
       
   104     RegisterProcessingFunction(pProcessingFunction);
       
   105     
       
   106 	// STEP 4: Create Port manager...
       
   107 
       
   108 #ifdef OMXIL_AUDIO_FILESOURCE
       
   109     CreatePortManagerL(COmxILComponent::ENonBufferSharingPortManager,
       
   110         TOmxILSpecVersion(),    // OMX Version
       
   111         1,                      // The number of audio ports in this component
       
   112         0,                      // The starting audio port index
       
   113         0,                      // The number of image ports in this component
       
   114         0,                      // The starting image port index
       
   115         0,                      // The number of video ports in this component
       
   116         0,                      // The starting video port index
       
   117         0,                      // The number of other ports in this component
       
   118         0                       // The starting other port index
       
   119         );
       
   120 
       
   121 #elif defined(OMXIL_VIDEO_FILESOURCE)
       
   122     CreatePortManagerL(COmxILComponent::ENonBufferSharingPortManager,
       
   123         TOmxILSpecVersion(),    // OMX Version
       
   124         0,                      // The number of audio ports in this component
       
   125         0,                      // The starting audio port index
       
   126         0,                      // The number of image ports in this component
       
   127         0,                      // The starting image port index
       
   128         1,                      // The number of video ports in this component
       
   129         0,                      // The starting video port index
       
   130         0,                      // The number of other ports in this component
       
   131         0                       // The starting other port index
       
   132         );
       
   133 
       
   134 #elif defined(OMXIL_IMAGE_FILESOURCE)
       
   135     CreatePortManagerL(COmxILComponent::ENonBufferSharingPortManager,
       
   136         TOmxILSpecVersion(),    // OMX Version
       
   137         0,                      // The number of audio ports in this component
       
   138         0,                      // The starting audio port index
       
   139         1,                      // The number of image ports in this component
       
   140         0,                      // The starting image port index
       
   141         0,                      // The number of video ports in this component
       
   142         0,                      // The starting video port index
       
   143         0,                      // The number of other ports in this component
       
   144         0                       // The starting other port index
       
   145         );
       
   146 
       
   147 
       
   148 #elif defined(OMXIL_OTHER_FILESOURCE)
       
   149     CreatePortManagerL(COmxILComponent::ENonBufferSharingPortManager,
       
   150         TOmxILSpecVersion(),    // OMX Version
       
   151         0,                      // The number of audio ports in this component
       
   152         0,                      // The starting audio port index
       
   153         0,                      // The number of image ports in this component
       
   154         0,                      // The starting image port index
       
   155         0,                      // The number of video ports in this component
       
   156         0,                      // The starting video port index
       
   157         1,                      // The number of other ports in this component
       
   158         0                       // The starting other port index
       
   159         );
       
   160 #endif
       
   161 
       
   162 	// STEP 5: Create the File Source component port...
       
   163     COmxILPort* pPort = ConstructPortL();
       
   164     CleanupStack::PushL(pPort);
       
   165     
       
   166 	// STEP 6: Add to the port manager...
       
   167 	User::LeaveIfError(AddPort(pPort, OMX_DirOutput));
       
   168 	CleanupStack::Pop(); //pPort
       
   169 	
       
   170 	// STEP 7: Create the non-port related configuration manager...
       
   171 	RPointerArray<TDesC8> componentRoles;
       
   172 	CleanupClosePushL(componentRoles);
       
   173 	componentRoles.AppendL(&KNokiaOMXFileSourceRole);
       
   174 	COmxILFileSourceConfigManager* pConfigManager = COmxILFileSourceConfigManager::NewL(
       
   175                                     KNokiaOMXFileSourceComponentName,
       
   176                                     TOmxILVersion(KComponentVersionMajor,
       
   177                                                   KComponentVersionMinor,
       
   178                                                   KComponentVersionRevision,
       
   179                                                   KComponentVersionStep),
       
   180                                     componentRoles,
       
   181                                     *pProcessingFunction);
       
   182     RegisterConfigurationManager(pConfigManager);
       
   183 	CleanupStack::PopAndDestroy(&componentRoles);
       
   184 
       
   185 	// STEP 8: Finally, let's get everything started
       
   186 	InitComponentL();
       
   187 	}
       
   188 
       
   189 COmxILPort* COmxILFileSource::ConstructPortL() const
       
   190 	{
       
   191 	OMX_U32 thisPortIndex = 0;
       
   192 #ifdef OMXIL_AUDIO_FILESOURCE
       
   193 	RArray<OMX_AUDIO_CODINGTYPE> supportedAudioFormats;
       
   194 	CleanupClosePushL(supportedAudioFormats);
       
   195 	supportedAudioFormats.AppendL(OMX_AUDIO_CodingUnused);
       
   196 	COmxILAudioFileSourceAPB0Port* opb0Port = COmxILAudioFileSourceAPB0Port::NewL(
       
   197 			TOmxILCommonPortData (
       
   198 			TOmxILSpecVersion(),	// OMX specification version information
       
   199 			thisPortIndex, 			// Port number the structure applies to
       
   200 			OMX_DirOutput, 			// Direction of this port
       
   201 			KMinBuffers,			// The minimum number of buffers this port requires
       
   202 			KMinBufferSize,			// Minimum size, in bytes, for buffers to be used for this port
       
   203 			OMX_PortDomainAudio,	// Domain of the port
       
   204 			OMX_FALSE,				// Buffers contiguous requirement (true or false)
       
   205 			0,		                 // Buffer aligment requirements
       
   206 			OMX_BufferSupplyUnspecified,	// supplier preference when tunneling between two ports
       
   207 			COmxILPort::KBufferMarkPropagationPortNotNeeded),
       
   208 			supportedAudioFormats,
       
   209 			static_cast<COmxILFileSourceProcessingFunction&>(*GetProcessingFunction()));
       
   210 	CleanupStack::PopAndDestroy(&supportedAudioFormats);
       
   211 	return opb0Port;
       
   212 #elif defined(OMXIL_VIDEO_FILESOURCE)
       
   213     RArray<OMX_VIDEO_CODINGTYPE> supportedVideoFormats;
       
   214     CleanupClosePushL(supportedVideoFormats);
       
   215     RArray<OMX_COLOR_FORMATTYPE> supportedColourFormats;
       
   216     CleanupClosePushL(supportedColourFormats);
       
   217     COmxILVideoFileSourceVPB0Port* opb0Port = COmxILVideoFileSourceVPB0Port::NewL(
       
   218             TOmxILCommonPortData (
       
   219             TOmxILSpecVersion(),    // OMX specification version information
       
   220             thisPortIndex,          // Port number the structure applies to
       
   221             OMX_DirOutput,           // Direction of this port
       
   222             KMinBuffers,            // The minimum number of buffers this port requires
       
   223             KMinBufferSize,         // Minimum size, in bytes, for buffers to be used for this port
       
   224             OMX_PortDomainVideo,    // Domain of the port
       
   225             OMX_FALSE,//OMX_TRUE,               // Buffers contiguous requirement (true or false)
       
   226             0,//KBufferAlignment,       // Buffer aligment requirements
       
   227             OMX_BufferSupplyUnspecified, // supplier preference when tunneling between two ports
       
   228             COmxILPort::KBufferMarkPropagationPortNotNeeded),
       
   229             supportedVideoFormats,
       
   230             supportedColourFormats,
       
   231             static_cast<COmxILFileSourceProcessingFunction&>(*GetProcessingFunction()));
       
   232     CleanupStack::PopAndDestroy(2);
       
   233     return opb0Port;
       
   234 #elif defined(OMXIL_IMAGE_FILESOURCE)
       
   235 
       
   236     RArray<OMX_IMAGE_CODINGTYPE> supportedImageFormats;
       
   237      CleanupClosePushL(supportedImageFormats);
       
   238      RArray<OMX_COLOR_FORMATTYPE> supportedColourFormats;
       
   239      CleanupClosePushL(supportedColourFormats);
       
   240      COmxILImageFileSourceIPB0Port* opb0Port = COmxILImageFileSourceIPB0Port::NewL(
       
   241              TOmxILCommonPortData (
       
   242              TOmxILSpecVersion(),    // OMX specification version information
       
   243              thisPortIndex,          // Port number the structure applies to
       
   244              OMX_DirOutput,           // Direction of this port
       
   245              KMinBuffers,            // The minimum number of buffers this port requires
       
   246              KMinBufferSize,         // Minimum size, in bytes, for buffers to be used for this port
       
   247              OMX_PortDomainImage,    // Domain of the port
       
   248              OMX_FALSE,              // Buffers contiguous requirement (true or false)
       
   249              0,                      // Buffer aligment requirements
       
   250              OMX_BufferSupplyUnspecified, // supplier preference when tunneling between two ports
       
   251              COmxILPort::KBufferMarkPropagationPortNotNeeded),
       
   252              supportedImageFormats,
       
   253              supportedColourFormats,
       
   254              static_cast<COmxILFileSourceProcessingFunction&>(*GetProcessingFunction()));
       
   255      CleanupStack::PopAndDestroy(2);
       
   256      return opb0Port;
       
   257 
       
   258 #elif defined(OMXIL_OTHER_FILESOURCE)
       
   259 	RArray<OMX_OTHER_FORMATTYPE> supportedOtherFormats;
       
   260 
       
   261 	CleanupClosePushL(supportedOtherFormats);
       
   262 	supportedOtherFormats.AppendL(OMX_OTHER_FormatBinary);
       
   263 
       
   264 	COmxILOtherFileSourceOPB0Port* opb0Port = COmxILOtherFileSourceOPB0Port::NewL(
       
   265 			TOmxILCommonPortData (
       
   266 			TOmxILSpecVersion(),	// OMX specification version information
       
   267 			thisPortIndex, 			// Port number the structure applies to
       
   268 			OMX_DirOutput, 			// Direction of this port
       
   269 			KMinBuffers,			// The minimum number of buffers this port requires
       
   270 			KMinBufferSize,			// Minimum size, in bytes, for buffers to be used for this port
       
   271 			OMX_PortDomainOther,	// Domain of the port
       
   272 			OMX_FALSE,				// Buffers contiguous requirement (true or false)
       
   273 			0,		                 // Buffer aligment requirements
       
   274 			OMX_BufferSupplyUnspecified,	// supplier preference when tunneling between two ports
       
   275 			COmxILPort::KBufferMarkPropagationPortNotNeeded),
       
   276 			supportedOtherFormats,
       
   277 			static_cast<COmxILFileSourceProcessingFunction&>(*GetProcessingFunction()));
       
   278 
       
   279 	CleanupStack::PopAndDestroy(&supportedOtherFormats);
       
   280 	return opb0Port;
       
   281 #endif
       
   282 	}