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 #include "omxilgenericportilif.h" |
|
17 |
|
18 /** |
|
19 class COmxILGenericPortILIF |
|
20 Concrete implementation of the MILComponentPortIf that encapsulates the |
|
21 component's port specific behaviour according to OpenMAX specification. |
|
22 */ |
|
23 COmxILGenericPortILIF::COmxILGenericPortILIF(COmxILGenericILIF& aParent, |
|
24 TPortDirection aPortDirection, |
|
25 TInt aIndex) |
|
26 : |
|
27 iPortDirection (aPortDirection), |
|
28 iPortIndex (aIndex), |
|
29 iPortComponent(aParent) |
|
30 { |
|
31 } |
|
32 |
|
33 COmxILGenericPortILIF* COmxILGenericPortILIF::NewL(COmxILGenericILIF& aParent, |
|
34 TPortDirection aPortDirection, |
|
35 TInt aIndex) |
|
36 { |
|
37 COmxILGenericPortILIF* self = new (ELeave) COmxILGenericPortILIF(aParent, aPortDirection, aIndex); |
|
38 return self; |
|
39 } |
|
40 |
|
41 TInt COmxILGenericPortILIF::FillThisBuffer(CMMFBuffer& aBuffer) |
|
42 { |
|
43 if (iPortDirection == EDirOutput) |
|
44 { |
|
45 return iPortComponent.OmxFillThisBuffer(&aBuffer, &iPortComponent); |
|
46 } |
|
47 else |
|
48 { |
|
49 return KErrCorrupt; |
|
50 } |
|
51 } |
|
52 |
|
53 TInt COmxILGenericPortILIF::EmptyThisBuffer(const CMMFBuffer& aBuffer) |
|
54 { |
|
55 if (iPortDirection == EDirInput) |
|
56 { |
|
57 return iPortComponent.OmxEmptyThisBuffer(&aBuffer, &iPortComponent); |
|
58 } |
|
59 else |
|
60 { |
|
61 return KErrCorrupt; |
|
62 } |
|
63 } |
|
64 |
|
65 TInt COmxILGenericPortILIF::TunnelRequest(MILComponentPortIf* aPort) |
|
66 { |
|
67 TInt error = KErrNotSupported; |
|
68 |
|
69 if (aPort) |
|
70 // This is the connet tunnel request |
|
71 { |
|
72 TPortDirection otherPortDir = aPort->PortDirection(); |
|
73 COmxILGenericILIF* otherPortComponent = static_cast<COmxILGenericILIF*>(aPort->PortComponent()); |
|
74 |
|
75 if (iPortDirection != otherPortDir) |
|
76 { |
|
77 if (iPortDirection == EDirInput) |
|
78 { |
|
79 error = iPortComponent.OmxComponentTunnelRequest(iPortIndex, |
|
80 otherPortComponent->OmxHandle(), |
|
81 aPort->PortIndex()); |
|
82 |
|
83 } |
|
84 else |
|
85 { |
|
86 error = otherPortComponent->OmxComponentTunnelRequest(aPort->PortIndex(), |
|
87 iPortComponent.OmxHandle(), |
|
88 iPortIndex); |
|
89 } |
|
90 |
|
91 if (error == KErrNone) |
|
92 { |
|
93 iTunneledPort = static_cast<COmxILGenericPortILIF*>(aPort); |
|
94 iTunneledPort->SetPortConnectedTo(this); |
|
95 } |
|
96 } |
|
97 } |
|
98 else |
|
99 // This is the disconnet tunnel request |
|
100 { |
|
101 TPortDirection otherPortDir = iTunneledPort->PortDirection(); |
|
102 COmxILGenericILIF* otherPortComponent = static_cast<COmxILGenericILIF*> (iTunneledPort->PortComponent()); |
|
103 |
|
104 if (iPortDirection != otherPortDir) |
|
105 { |
|
106 if (iPortDirection == EDirInput) |
|
107 { |
|
108 error = iPortComponent.OmxComponentDisconnectTunnel(iPortIndex, |
|
109 otherPortComponent->OmxHandle(), |
|
110 iTunneledPort->PortIndex()); |
|
111 } |
|
112 else |
|
113 { |
|
114 error = otherPortComponent->OmxComponentDisconnectTunnel(iTunneledPort->PortIndex(), |
|
115 iPortComponent.OmxHandle(), |
|
116 iPortIndex); |
|
117 } |
|
118 |
|
119 if (error == KErrNone) |
|
120 { |
|
121 iTunneledPort->SetPortConnectedTo(NULL); |
|
122 iTunneledPort = NULL; |
|
123 } |
|
124 } |
|
125 } |
|
126 |
|
127 return error; |
|
128 } |
|
129 |
|
130 TInt COmxILGenericPortILIF::PortIndex() const |
|
131 { |
|
132 return iPortIndex; |
|
133 } |
|
134 |
|
135 TPortDirection COmxILGenericPortILIF::PortDirection() const |
|
136 { |
|
137 return iPortDirection; |
|
138 } |
|
139 |
|
140 CMMFBuffer* COmxILGenericPortILIF::CreateBufferL(TInt aBufferSize) |
|
141 { |
|
142 return iPortComponent.OmxAllocateBufferL(iPortIndex, aBufferSize); |
|
143 } |
|
144 |
|
145 TInt COmxILGenericPortILIF::UseBuffer(CMMFBuffer& aBuffer) |
|
146 { |
|
147 return iPortComponent.OmxUseBuffer(&aBuffer, iPortIndex); |
|
148 } |
|
149 |
|
150 TInt COmxILGenericPortILIF::FreeBuffer(CMMFBuffer* aBuffer) |
|
151 { |
|
152 return iPortComponent.OmxFreeBuffer(aBuffer); |
|
153 } |
|
154 |
|
155 TInt COmxILGenericPortILIF::FlushPort() |
|
156 { |
|
157 return iPortComponent.OmxSendCommand(OMX_CommandFlush, iPortIndex, NULL); |
|
158 } |
|
159 |
|
160 TInt COmxILGenericPortILIF::EnablePort() |
|
161 { |
|
162 return iPortComponent.OmxSendCommand(OMX_CommandPortEnable, iPortIndex, NULL); |
|
163 } |
|
164 |
|
165 TInt COmxILGenericPortILIF::DisablePort() |
|
166 { |
|
167 return iPortComponent.OmxSendCommand(OMX_CommandPortDisable, iPortIndex, NULL); |
|
168 } |
|
169 |
|
170 MILComponentIf* COmxILGenericPortILIF::PortComponent() const |
|
171 { |
|
172 return &iPortComponent; |
|
173 } |
|
174 |
|
175 void COmxILGenericPortILIF::SetPortConnectedTo(COmxILGenericPortILIF* aPort) |
|
176 { |
|
177 iTunneledPort = aPort; |
|
178 } |
|
179 |
|
180 |
|