omxilcomp/omxilgeneric/filesink/src/omxilfilesink.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 "omxilfilesink.h"
       
    23 #include "omxilfilesinkprocessingfunction.h"
       
    24 #include "omxilfilesinkconfigmanager.h"
       
    25 #include "omxilfilesink.hrh"
       
    26 
       
    27 
       
    28 #ifdef OMXIL_AUDIO_FILESINK
       
    29 #include "omxilaudiofilesinkapb0port.h"
       
    30 _LIT8(KNokiaOMXFileSinkComponentName, "OMX.NOKIA.AUDIO.FILESINK");
       
    31 _LIT8(KNokiaOMXFileSinkRole, "audio_writer.binary");
       
    32 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidNokiaOmxILAudioFileSink);
       
    33 
       
    34 #elif defined(OMXIL_VIDEO_FILESINK)
       
    35 #include "omxilvideofilesinkvpb0port.h"
       
    36 _LIT8(KNokiaOMXFileSinkComponentName, "OMX.NOKIA.VIDEO.FILESINK");
       
    37 _LIT8(KNokiaOMXFileSinkRole, "video_writer.binary");
       
    38 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidNokiaOmxILVideoFileSink);
       
    39 
       
    40 #elif defined(OMXIL_IMAGE_FILESINK)
       
    41 #include "omxilimagefilesinkipb0port.h"
       
    42 _LIT8(KNokiaOMXFileSinkComponentName, "OMX.NOKIA.IMAGE.FILESINK");
       
    43 _LIT8(KNokiaOMXFileSinkRole, "image_writer.binary");
       
    44 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidNokiaOmxILImageFileSink);
       
    45 
       
    46 #elif defined(OMXIL_OTHER_FILESINK)
       
    47 #include "omxilotherfilesinkopb0port.h"
       
    48 _LIT8(KNokiaOMXFileSinkComponentName, "OMX.NOKIA.OTHER.FILESINK");
       
    49 _LIT8(KNokiaOMXFileSinkRole, "other_writer.binary");
       
    50 OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidSymbianOmxILOtherFileSink);
       
    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, COmxILFileSink::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 COmxILFileSink::CreateComponentL(OMX_HANDLETYPE aComponent)
       
    78 	{
       
    79 	COmxILFileSink* self = new (ELeave) COmxILFileSink();
       
    80 	CleanupStack::PushL(self);
       
    81 	self->ConstructL(aComponent);
       
    82 	CleanupStack::Pop(self);
       
    83 	}
       
    84 
       
    85 COmxILFileSink::COmxILFileSink()
       
    86 	{
       
    87 	// nothing to do
       
    88 	}
       
    89 
       
    90 COmxILFileSink::~COmxILFileSink()
       
    91 	{
       
    92 	}
       
    93 
       
    94 void COmxILFileSink::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 sink-specific Processing Function...
       
   103     COmxILFileSinkProcessingFunction* pProcessingFunction = COmxILFileSinkProcessingFunction::NewL(*callbackNotificationIf);
       
   104     RegisterProcessingFunction(pProcessingFunction);
       
   105     
       
   106 	// STEP 4: Create Port manager...
       
   107 
       
   108 #ifdef OMXIL_AUDIO_FILESINK
       
   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_FILESINK)
       
   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_FILESINK)
       
   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_FILESINK)
       
   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 Sink 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_DirInput));
       
   168 	CleanupStack::Pop(); //pPort
       
   169 	
       
   170 	// STEP 7: Create the non-port related configuration manager...
       
   171 	RPointerArray<TDesC8> componentRoles;
       
   172 	CleanupClosePushL(componentRoles);
       
   173 
       
   174 	componentRoles.AppendL(&KNokiaOMXFileSinkRole);
       
   175 	COmxILFileSinkConfigManager* pConfigManager = COmxILFileSinkConfigManager::NewL(
       
   176 		KNokiaOMXFileSinkComponentName,
       
   177 		TOmxILVersion(KComponentVersionMajor,
       
   178 					  KComponentVersionMinor,
       
   179 					  KComponentVersionRevision,
       
   180 					  KComponentVersionStep),
       
   181 		componentRoles,
       
   182 		*pProcessingFunction);
       
   183     RegisterConfigurationManager(pConfigManager);
       
   184 	CleanupStack::PopAndDestroy(&componentRoles);
       
   185 
       
   186 	// STEP 9: Finally, let's get everything started
       
   187 	InitComponentL();
       
   188 	}
       
   189 
       
   190 COmxILPort* COmxILFileSink::ConstructPortL() const
       
   191 	{
       
   192 	OMX_U32 thisPortIndex = 0;
       
   193 	//const TUint32 KBufferAlignment = 4;
       
   194 #ifdef OMXIL_AUDIO_FILESINK
       
   195 	RArray<OMX_AUDIO_CODINGTYPE> supportedAudioFormats;
       
   196 	CleanupClosePushL(supportedAudioFormats);
       
   197 	supportedAudioFormats.AppendL(OMX_AUDIO_CodingUnused);
       
   198 	COmxILAudioFileSinkAPB0Port* pPort = COmxILAudioFileSinkAPB0Port::NewL(
       
   199 			TOmxILCommonPortData (
       
   200 			TOmxILSpecVersion(),	// OMX specification version information
       
   201 			thisPortIndex, 			// Port number the structure applies to
       
   202 			OMX_DirInput, 			// Direction of this port
       
   203 			KMinBuffers,			// The minimum number of buffers this port requires
       
   204 			KMinBufferSize,			// Minimum size, in bytes, for buffers to be used for this port
       
   205 			OMX_PortDomainAudio,	// Domain of the port
       
   206 			OMX_FALSE,				// Buffers contiguous requirement (true or false)
       
   207 			0,		                // Buffer aligment requirements
       
   208 			OMX_BufferSupplyOutput,	// supplier preference when tunneling between two ports
       
   209 			COmxILPort::KBufferMarkPropagationPortNotNeeded),
       
   210 			supportedAudioFormats,
       
   211 			static_cast<COmxILFileSinkProcessingFunction&>(*GetProcessingFunction()));
       
   212 	CleanupStack::PopAndDestroy(&supportedAudioFormats);
       
   213 	return pPort;
       
   214 
       
   215 #elif defined(OMXIL_VIDEO_FILESINK)
       
   216     RArray<OMX_VIDEO_CODINGTYPE> supportedVideoFormats;
       
   217     CleanupClosePushL(supportedVideoFormats);
       
   218     RArray<OMX_COLOR_FORMATTYPE> supportedColourFormats;
       
   219     CleanupClosePushL(supportedColourFormats);
       
   220     COmxILVideoFileSinkVPB0Port* pPort = COmxILVideoFileSinkVPB0Port::NewL(
       
   221             TOmxILCommonPortData (
       
   222             TOmxILSpecVersion(),    // OMX specification version information
       
   223             thisPortIndex,          // Port number the structure applies to
       
   224             OMX_DirInput,           // Direction of this port
       
   225             KMinBuffers,            // The minimum number of buffers this port requires
       
   226             KMinBufferSize,         // Minimum size, in bytes, for buffers to be used for this port
       
   227             OMX_PortDomainVideo,    // Domain of the port
       
   228             OMX_FALSE,              // Buffers contiguous requirement (true or false)
       
   229             0,                      // Buffer aligment requirements
       
   230             OMX_BufferSupplyOutput, // supplier preference when tunneling between two ports
       
   231             COmxILPort::KBufferMarkPropagationPortNotNeeded),
       
   232             supportedVideoFormats,
       
   233             supportedColourFormats,
       
   234             static_cast<COmxILFileSinkProcessingFunction&>(*GetProcessingFunction()));
       
   235     CleanupStack::PopAndDestroy(2);
       
   236     return pPort;
       
   237 
       
   238 #elif defined(OMXIL_IMAGE_FILESINK)
       
   239     RArray<OMX_IMAGE_CODINGTYPE> supportedImageFormats;
       
   240     CleanupClosePushL(supportedImageFormats);
       
   241     //supportedImageFormats.AppendL(OMX_IMAGE_CodingUnused);
       
   242     RArray<OMX_COLOR_FORMATTYPE> supportedColourFormats;
       
   243     CleanupClosePushL(supportedColourFormats);
       
   244     COmxILImageFileSinkIPB0Port* pPort = COmxILImageFileSinkIPB0Port::NewL(
       
   245             TOmxILCommonPortData (
       
   246             TOmxILSpecVersion(),    // OMX specification version information
       
   247             thisPortIndex,          // Port number the structure applies to
       
   248             OMX_DirInput,           // Direction of this port
       
   249             KMinBuffers,            // The minimum number of buffers this port requires
       
   250             KMinBufferSize,         // Minimum size, in bytes, for buffers to be used for this port
       
   251             OMX_PortDomainImage,    // Domain of the port
       
   252             OMX_FALSE,              // Buffers contiguous requirement (true or false)
       
   253             0,                      // Buffer aligment requirements
       
   254             OMX_BufferSupplyOutput, // supplier preference when tunneling between two ports
       
   255             COmxILPort::KBufferMarkPropagationPortNotNeeded),
       
   256             supportedImageFormats,
       
   257             supportedColourFormats,
       
   258             static_cast<COmxILFileSinkProcessingFunction&>(*GetProcessingFunction()));
       
   259     CleanupStack::PopAndDestroy(2);
       
   260     return pPort;
       
   261 
       
   262 #elif defined(OMXIL_OTHER_FILESINK)
       
   263 	RArray<OMX_OTHER_FORMATTYPE> supportedOtherFormats;
       
   264 	CleanupClosePushL(supportedOtherFormats);
       
   265 	supportedOtherFormats.AppendL(OMX_OTHER_FormatBinary);
       
   266 	COmxILOtherFileSinkOPB0Port* pPort = COmxILOtherFileSinkOPB0Port::NewL(
       
   267 			TOmxILCommonPortData (
       
   268 			TOmxILSpecVersion(),	// OMX specification version information
       
   269 			thisPortIndex, 			// Port number the structure applies to
       
   270 			OMX_DirInput, 			// Direction of this port
       
   271 			KMinBuffers,			// The minimum number of buffers this port requires
       
   272 			KMinBufferSize,			// Minimum size, in bytes, for buffers to be used for this port
       
   273 			OMX_PortDomainOther,	// Domain of the port
       
   274 			OMX_FALSE,				// Buffers contiguous requirement (true or false)
       
   275 			0,		                // Buffer aligment requirements
       
   276 			OMX_BufferSupplyOutput,	// supplier preference when tunneling between two ports
       
   277 			COmxILPort::KBufferMarkPropagationPortNotNeeded),
       
   278 			supportedOtherFormats,
       
   279 			static_cast<COmxILFileSinkProcessingFunction&>(*GetProcessingFunction()));
       
   280 	CleanupStack::PopAndDestroy(&supportedOtherFormats);
       
   281 	return pPort;
       
   282 
       
   283 #endif
       
   284 	}