0
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
@internalComponent
|
|
21 |
*/
|
|
22 |
|
|
23 |
#include <openmax/il/common/omxilconfigmanager.h>
|
|
24 |
#include <openmax/il/common/omxilspecversion.h>
|
|
25 |
|
|
26 |
#include "omxilgraphicsink.h"
|
|
27 |
#include "omxilgraphicsinkvpb0port.h"
|
|
28 |
#include "omxilgraphicsinkprocessingfunction.h"
|
|
29 |
#include "omxilgraphicsink.hrh"
|
|
30 |
#include <openmax/il/loader/omxilsymbiancomponentif.h>
|
|
31 |
#include "log.h"
|
|
32 |
|
|
33 |
_LIT8(KSymbianOMXGraphicSinkComponentName, KCompNameSymbianOMXGraphicSink);
|
|
34 |
_LIT8(KSymbianOMXGraphicSinkRole, KRoleSymbianOMXGraphicSink);
|
|
35 |
|
|
36 |
const TUint8 COmxILGraphicSink::iComponentVersionMajor;
|
|
37 |
const TUint8 COmxILGraphicSink::iComponentVersionMinor;
|
|
38 |
const TUint8 COmxILGraphicSink::iComponentVersionRevision;
|
|
39 |
const TUint8 COmxILGraphicSink::iComponentVersionStep;
|
|
40 |
|
|
41 |
OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidSymbianOmxILGraphicSink);
|
|
42 |
|
|
43 |
/**
|
|
44 |
Component Entry Point
|
|
45 |
@param aComponent The handle of the component to be initialised.
|
|
46 |
@return KErrNone if successful;
|
|
47 |
KErrNoMemory if the driver failed to allocate memory for the new component;
|
|
48 |
otherwise one of the other system-wide error codes.
|
|
49 |
*/
|
|
50 |
OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE aComponent)
|
|
51 |
{
|
|
52 |
TInt err = COmxILGraphicSink::CreateComponent(aComponent);
|
|
53 |
if (err == KErrNone)
|
|
54 |
{
|
|
55 |
return OMX_ErrorNone;
|
|
56 |
}
|
|
57 |
else
|
|
58 |
{
|
|
59 |
// return some problem
|
|
60 |
return err == KErrNoMemory ? OMX_ErrorInsufficientResources : OMX_ErrorUndefined;
|
|
61 |
|
|
62 |
}
|
|
63 |
}
|
|
64 |
|
|
65 |
/**
|
|
66 |
This function creates a new Graphic sink component.
|
|
67 |
@param aComponent The handle of the component to be created.
|
|
68 |
@return KErrNone if successful;
|
|
69 |
KErrNoMemory if the driver failed to allocate memory for the new component;
|
|
70 |
otherwise one of the other system-wide error codes.
|
|
71 |
*/
|
|
72 |
TInt COmxILGraphicSink::CreateComponent(OMX_HANDLETYPE aComponent)
|
|
73 |
{
|
|
74 |
DEBUG_PRINTF(_L8("COmxILGraphicSink::CreateComponent"));
|
|
75 |
|
|
76 |
COmxILGraphicSink* self = new COmxILGraphicSink();
|
|
77 |
|
|
78 |
if (!self)
|
|
79 |
{
|
|
80 |
return KErrNoMemory;
|
|
81 |
}
|
|
82 |
|
|
83 |
TRAPD(err, self->ConstructL(aComponent));
|
|
84 |
|
|
85 |
if(err != KErrNone)
|
|
86 |
{
|
|
87 |
delete self;
|
|
88 |
}
|
|
89 |
|
|
90 |
return err;
|
|
91 |
|
|
92 |
}
|
|
93 |
|
|
94 |
/**
|
|
95 |
Constructor of the class.
|
|
96 |
*/
|
|
97 |
COmxILGraphicSink::COmxILGraphicSink()
|
|
98 |
{
|
|
99 |
DEBUG_PRINTF(_L8("COmxILGraphicSink::COmxILGraphicSink +"));
|
|
100 |
}
|
|
101 |
|
|
102 |
/**
|
|
103 |
Destructor of the class.
|
|
104 |
*/
|
|
105 |
COmxILGraphicSink::~COmxILGraphicSink()
|
|
106 |
{
|
|
107 |
DEBUG_PRINTF(_L8("COmxILGraphicSink::~COmxILGraphicSink +"));
|
|
108 |
}
|
|
109 |
|
|
110 |
/**
|
|
111 |
Second phase construction for the component.
|
|
112 |
@param aHandle The handle of the component to be created.
|
|
113 |
*/
|
|
114 |
void COmxILGraphicSink::ConstructL(OMX_HANDLETYPE aHandle)
|
|
115 |
{
|
|
116 |
DEBUG_PRINTF(_L8("COmxILGraphicSink::ConstructL"));
|
|
117 |
// Initialize the data received from IL Core
|
|
118 |
COmxILComponent::ConstructL(aHandle);
|
|
119 |
|
|
120 |
// STEP 2: Create the call backs manager...
|
|
121 |
MOmxILCallbackNotificationIf* callbackNotificationIf=CreateCallbackManagerL(COmxILComponent::EOutofContext);
|
|
122 |
|
|
123 |
// STEP 3: Create the Graphic Sink Processing Function...
|
|
124 |
COmxILGraphicSinkProcessingFunction* pGraphicSinkProcessingFunction = COmxILGraphicSinkProcessingFunction::NewL(*callbackNotificationIf);
|
|
125 |
RegisterProcessingFunction(pGraphicSinkProcessingFunction);
|
|
126 |
|
|
127 |
// STEP 4: Create Port manager...
|
|
128 |
CreatePortManagerL(COmxILComponent::ENonBufferSharingPortManager,
|
|
129 |
TOmxILSpecVersion(), // OMX Version
|
|
130 |
0, // The number of audio ports in this component
|
|
131 |
0, // The starting audio port index
|
|
132 |
0, // The number of image ports in this component
|
|
133 |
0, // The starting image port index
|
|
134 |
1, // The number of video ports in this component
|
|
135 |
0, // The starting video port index
|
|
136 |
0, // The number of other ports in this component
|
|
137 |
0 // The starting other port index
|
|
138 |
);
|
|
139 |
|
|
140 |
COmxILGraphicSinkVPB0Port* pb0Port = ConstructVPB0PortL();
|
|
141 |
CleanupStack::PushL(pb0Port);
|
|
142 |
User::LeaveIfError(AddPort(pb0Port, OMX_DirInput));
|
|
143 |
CleanupStack::Pop(pb0Port);
|
|
144 |
SetPortToPF(pb0Port);
|
|
145 |
|
|
146 |
// STEP 5: Create the non-port related configuration manager...
|
|
147 |
RPointerArray<TDesC8> componentRoles;
|
|
148 |
CleanupClosePushL(componentRoles);
|
|
149 |
componentRoles.AppendL(&KSymbianOMXGraphicSinkRole);
|
|
150 |
COmxILConfigManager* pConfigManager = COmxILConfigManager::NewL(
|
|
151 |
KSymbianOMXGraphicSinkComponentName,
|
|
152 |
TOmxILVersion(iComponentVersionMajor,
|
|
153 |
iComponentVersionMinor,
|
|
154 |
iComponentVersionRevision,
|
|
155 |
iComponentVersionStep),
|
|
156 |
componentRoles);
|
|
157 |
|
|
158 |
CleanupStack::PopAndDestroy(&componentRoles);
|
|
159 |
RegisterConfigurationManager(pConfigManager);
|
|
160 |
|
|
161 |
// And finally, let's get everything started
|
|
162 |
InitComponentL();
|
|
163 |
}
|
|
164 |
|
|
165 |
/**
|
|
166 |
Create the input port VPB0Port for Graphic sink.
|
|
167 |
@return A pointer to the VPB0Port to be created.
|
|
168 |
*/
|
|
169 |
COmxILGraphicSinkVPB0Port* COmxILGraphicSink::ConstructVPB0PortL()
|
|
170 |
{
|
|
171 |
DEBUG_PRINTF(_L8("COmxILGraphicSink::ConstructVPB0PortL +"));
|
|
172 |
|
|
173 |
OMX_U32 thisPortIndex = 0;
|
|
174 |
const TUint32 KBufferCountMin = 2; // OMX_U32
|
|
175 |
const TUint32 KBufferSizeMin = 1024; // OMX_U32
|
|
176 |
#ifndef ILCOMPONENTCONFORMANCE
|
|
177 |
const TUint32 KBufferAlignment = 2; // OMX_U32
|
|
178 |
const OMX_BOOL KBuffersContiguous = OMX_TRUE;
|
|
179 |
#else
|
|
180 |
// conformance suite currently doesn't support allocating contiguous or
|
|
181 |
// beyond byte aligned buffers
|
|
182 |
const TUint32 KBufferAlignment = 0; // OMX_U32
|
|
183 |
const OMX_BOOL KBuffersContiguous = OMX_FALSE;
|
|
184 |
#endif
|
|
185 |
// These arrays must left empty, to be removed from the video port constructor
|
|
186 |
RArray<OMX_VIDEO_CODINGTYPE> supportedVideoFormats;
|
|
187 |
RArray<OMX_COLOR_FORMATTYPE> supportedColorFormats;
|
|
188 |
CleanupClosePushL(supportedVideoFormats);
|
|
189 |
CleanupClosePushL(supportedColorFormats);
|
|
190 |
|
|
191 |
COmxILGraphicSinkVPB0Port* vpb0Port = COmxILGraphicSinkVPB0Port::NewL(
|
|
192 |
TOmxILCommonPortData(
|
|
193 |
TOmxILSpecVersion(),// OMX specification version information
|
|
194 |
thisPortIndex, // Port number the structure applies to
|
|
195 |
OMX_DirInput, // Direction of this port
|
|
196 |
KBufferCountMin, // The minimum number of buffers this port requires
|
|
197 |
KBufferSizeMin, // Minimum size, in bytes, for buffers to be used for this port
|
|
198 |
OMX_PortDomainVideo,// Domain of the port
|
|
199 |
KBuffersContiguous, // Buffers contiguous requirement (true or false)
|
|
200 |
KBufferAlignment, // Buffer aligment requirements
|
|
201 |
OMX_BufferSupplyInput, // supplier preference when tunneling between two ports
|
|
202 |
COmxILPort::KBufferMarkPropagationPortNotNeeded
|
|
203 |
),
|
|
204 |
supportedVideoFormats, // Supported video formats
|
|
205 |
supportedColorFormats, // Supported color formats
|
|
206 |
*((COmxILGraphicSinkProcessingFunction *)(GetProcessingFunction()))
|
|
207 |
);
|
|
208 |
|
|
209 |
CleanupStack::PopAndDestroy(2, &supportedVideoFormats);
|
|
210 |
|
|
211 |
return vpb0Port;
|
|
212 |
}
|
|
213 |
|
|
214 |
/*
|
|
215 |
Set the graphic sink port to the graphic sink processing function,
|
|
216 |
so the processing function can access the port definition later.
|
|
217 |
*/
|
|
218 |
void COmxILGraphicSink::SetPortToPF(COmxILGraphicSinkVPB0Port* aPort)
|
|
219 |
{
|
|
220 |
((COmxILGraphicSinkProcessingFunction *)(GetProcessingFunction()))->iGraphicSinkPort = aPort;
|
|
221 |
}
|