0
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-2009 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 |
/**
|
|
20 |
@file
|
|
21 |
@internalComponent
|
|
22 |
*/
|
|
23 |
|
|
24 |
#include <openmax/il/common/omxilspecversion.h>
|
|
25 |
#include <openmax/il/loader/omxilcomponentif.h>
|
|
26 |
#include <openmax/il/loader/omxilsymbiancomponentif.h>
|
|
27 |
|
|
28 |
#include "comxilclockcomponent.h"
|
|
29 |
#include "comxilclockoutputport.h"
|
|
30 |
#include "comxilclockprocessingfunction.h"
|
|
31 |
#include "comxilclockconfigmanager.h"
|
|
32 |
#include "clockpanics.h"
|
|
33 |
#include "omxilclock.hrh"
|
|
34 |
|
|
35 |
_LIT8(KSymbianOmxILClockNameDes, KCompNameSymbianOmxILClock);
|
|
36 |
_LIT8(KSymbianOmxILClockRoleDes, KRoleSymbianOmxILClock);
|
|
37 |
|
|
38 |
OMXIL_COMPONENT_ECOM_ENTRYPOINT(KUidSymbianOmxILClock);
|
|
39 |
|
|
40 |
OMX_ERRORTYPE SymbianErrorToOmx(TInt aError);
|
|
41 |
|
|
42 |
// Component Entry Point
|
|
43 |
OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE aComponent)
|
|
44 |
{
|
|
45 |
TInt err = COmxILClockComponent::CreateComponent(aComponent);
|
|
46 |
return SymbianErrorToOmx(err);
|
|
47 |
}
|
|
48 |
|
|
49 |
TInt COmxILClockComponent::CreateComponent(OMX_HANDLETYPE hComponent)
|
|
50 |
{
|
|
51 |
COmxILClockComponent* self = new COmxILClockComponent();
|
|
52 |
|
|
53 |
if (!self)
|
|
54 |
{
|
|
55 |
return KErrNoMemory;
|
|
56 |
}
|
|
57 |
|
|
58 |
TRAPD(error, self->ConstructL(hComponent));
|
|
59 |
if(error != KErrNone)
|
|
60 |
{
|
|
61 |
delete self;
|
|
62 |
}
|
|
63 |
return error;
|
|
64 |
}
|
|
65 |
|
|
66 |
COmxILClockComponent::COmxILClockComponent()
|
|
67 |
{
|
|
68 |
// nothing to do
|
|
69 |
}
|
|
70 |
|
|
71 |
void COmxILClockComponent::ConstructL(OMX_HANDLETYPE hComponent)
|
|
72 |
{
|
|
73 |
COmxILComponent::ConstructL(hComponent);
|
|
74 |
|
|
75 |
// use synchronous callback manager since BufferDoneNotifications must be serviced at precise times
|
|
76 |
MOmxILCallbackNotificationIf* callbackNotificationIf=CreateCallbackManagerL(COmxILComponent::EOutofContext);
|
|
77 |
|
|
78 |
COmxILClockProcessingFunction* pProcessingFunction = COmxILClockProcessingFunction::NewL(*callbackNotificationIf, *this);
|
|
79 |
RegisterProcessingFunction(pProcessingFunction);
|
|
80 |
|
|
81 |
CreatePortManagerL(COmxILComponent::ENonBufferSharingPortManager,
|
|
82 |
TOmxILSpecVersion(), // OMX Version
|
|
83 |
0, // The number of audio ports in this component
|
|
84 |
0, // The starting audio port index
|
|
85 |
0, // The number of image ports in this component
|
|
86 |
0, // The starting image port index
|
|
87 |
0, // The number of video ports in this component
|
|
88 |
0, // The starting video port index
|
|
89 |
KNumPorts, // The number of other ports in this component
|
|
90 |
0, // The starting other port index
|
|
91 |
OMX_FALSE // Process the time port buffer as usual in port manager
|
|
92 |
);
|
|
93 |
|
|
94 |
|
|
95 |
RPointerArray<TDesC8> roleList;
|
|
96 |
CleanupClosePushL(roleList);
|
|
97 |
roleList.AppendL(&KSymbianOmxILClockRoleDes);
|
|
98 |
COmxILClockConfigManager* configManager = COmxILClockConfigManager::NewL(KSymbianOmxILClockNameDes,
|
|
99 |
TOmxILSpecVersion(), roleList, *(static_cast<COmxILClockProcessingFunction*>(pProcessingFunction)));
|
|
100 |
RegisterConfigurationManager(configManager);
|
|
101 |
CleanupStack::PopAndDestroy(&roleList);
|
|
102 |
|
|
103 |
for(TInt portIndex = 0; portIndex < KNumPorts; portIndex++)
|
|
104 |
{
|
|
105 |
AddPortL();
|
|
106 |
}
|
|
107 |
|
|
108 |
InitComponentL();
|
|
109 |
}
|
|
110 |
|
|
111 |
COmxILClockComponent::~COmxILClockComponent()
|
|
112 |
{
|
|
113 |
iPorts.Reset();
|
|
114 |
}
|
|
115 |
|
|
116 |
void COmxILClockComponent::AddPortL()
|
|
117 |
{
|
|
118 |
TOmxILSpecVersion omxIlVersion;
|
|
119 |
TOmxILCommonPortData portData(
|
|
120 |
omxIlVersion,
|
|
121 |
iPorts.Count(), // port index
|
|
122 |
OMX_DirOutput,
|
|
123 |
4, // minimum number of buffers
|
|
124 |
sizeof(OMX_TIME_MEDIATIMETYPE), // minimum buffer size, in bytes
|
|
125 |
OMX_PortDomainOther,
|
|
126 |
OMX_FALSE, // do not need contigious buffers
|
|
127 |
1, // byte alignment
|
|
128 |
// Clock being buffer supplier allows it to send notifications to clients without
|
|
129 |
// waiting for clients to pass their buffers after a state transition
|
|
130 |
OMX_BufferSupplyOutput,
|
|
131 |
COmxILPort::KBufferMarkPropagationPortNotNeeded
|
|
132 |
);
|
|
133 |
|
|
134 |
RArray<OMX_OTHER_FORMATTYPE> supportedOtherFormats;
|
|
135 |
|
|
136 |
CleanupClosePushL(supportedOtherFormats);
|
|
137 |
supportedOtherFormats.AppendL(OMX_OTHER_FormatTime);
|
|
138 |
|
|
139 |
COmxILClockOutputPort* port = COmxILClockOutputPort::NewL(portData, supportedOtherFormats,
|
|
140 |
*(static_cast<COmxILClockProcessingFunction*>(GetProcessingFunction())));
|
|
141 |
CleanupStack::PopAndDestroy(&supportedOtherFormats);
|
|
142 |
CleanupStack::PushL(port);
|
|
143 |
User::LeaveIfError(AddPort(port, OMX_DirOutput));
|
|
144 |
CleanupStack::Pop(port);
|
|
145 |
iPorts.AppendL(port);
|
|
146 |
}
|
|
147 |
|
|
148 |
/**
|
|
149 |
* Returns true iff the specified port is currently enabled.
|
|
150 |
*/
|
|
151 |
TBool COmxILClockComponent::PortEnabled(TInt aPortIndex) const
|
|
152 |
{
|
|
153 |
return iPorts[aPortIndex]->IsEnabled();
|
|
154 |
}
|
|
155 |
|
|
156 |
/**
|
|
157 |
* Returns the number of buffers as configured in the port definition.
|
|
158 |
*/
|
|
159 |
TInt COmxILClockComponent::PortBufferCount(TInt aPortIndex) const
|
|
160 |
{
|
|
161 |
return iPorts[aPortIndex]->BufferCount();
|
|
162 |
}
|
|
163 |
|
|
164 |
OMX_ERRORTYPE SymbianErrorToOmx(TInt aError)
|
|
165 |
{
|
|
166 |
switch(aError)
|
|
167 |
{
|
|
168 |
case KErrNone:
|
|
169 |
return OMX_ErrorNone;
|
|
170 |
case KErrNoMemory:
|
|
171 |
return OMX_ErrorInsufficientResources;
|
|
172 |
case KErrArgument:
|
|
173 |
return OMX_ErrorUnsupportedSetting;
|
|
174 |
case KErrNotSupported:
|
|
175 |
return OMX_ErrorUnsupportedIndex;
|
|
176 |
case KErrNotReady:
|
|
177 |
return OMX_ErrorIncorrectStateOperation;
|
|
178 |
default:
|
|
179 |
#ifdef _DEBUG
|
|
180 |
// Panic in a debug build. It will make people think about how the error should be handled.
|
|
181 |
Panic(EUndefinedErrorCode);
|
|
182 |
#endif
|
|
183 |
return OMX_ErrorUndefined;
|
|
184 |
}
|
|
185 |
}
|