|
1 /* |
|
2 * Copyright (c) 2008 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 <uri8.h> |
|
25 |
|
26 #include "comxil3gpdemuxerprocessingfunction.h" |
|
27 #include "comxil3gpdemuxerconfigmanager.h" |
|
28 #include "c3gpdemuxer.h" |
|
29 |
|
30 |
|
31 |
|
32 COmxIL3GPDemuxerConfigManager* COmxIL3GPDemuxerConfigManager::NewL( |
|
33 const TDesC8& aComponentName, |
|
34 const OMX_VERSIONTYPE& aComponentVersion, |
|
35 const RPointerArray<TDesC8>& aComponentRoleList, |
|
36 COmxIL3GPDemuxerProcessingFunction& aPf) |
|
37 { |
|
38 COmxIL3GPDemuxerConfigManager* self = new(ELeave) COmxIL3GPDemuxerConfigManager(aPf); |
|
39 CleanupStack::PushL(self); |
|
40 self->ConstructL(aComponentName, aComponentVersion, aComponentRoleList); |
|
41 CleanupStack::Pop(self); |
|
42 return self; |
|
43 } |
|
44 |
|
45 COmxIL3GPDemuxerConfigManager::COmxIL3GPDemuxerConfigManager(COmxIL3GPDemuxerProcessingFunction& aPf): |
|
46 iSeekMode(OMX_TIME_SeekModeFast), |
|
47 iPf(aPf) |
|
48 { |
|
49 // nothing to do |
|
50 } |
|
51 |
|
52 void COmxIL3GPDemuxerConfigManager::ConstructL(const TDesC8& aComponentName, |
|
53 const OMX_VERSIONTYPE& aComponentVersion, |
|
54 const RPointerArray<TDesC8>& aComponentRoleList) |
|
55 { |
|
56 COmxILConfigManager::ConstructL(aComponentName, aComponentVersion, aComponentRoleList); |
|
57 } |
|
58 |
|
59 COmxIL3GPDemuxerConfigManager::~COmxIL3GPDemuxerConfigManager() |
|
60 { |
|
61 delete iUri; |
|
62 delete iFilename; |
|
63 } |
|
64 |
|
65 OMX_ERRORTYPE COmxIL3GPDemuxerConfigManager::GetParameter(OMX_INDEXTYPE aParamIndex, |
|
66 TAny* aComponentParameterStructure) const |
|
67 { |
|
68 // try the base class first |
|
69 OMX_ERRORTYPE error = COmxILConfigManager::GetParameter(aParamIndex, aComponentParameterStructure); |
|
70 if(error != OMX_ErrorUnsupportedIndex) |
|
71 { |
|
72 return error; |
|
73 } |
|
74 |
|
75 if(aParamIndex == OMX_IndexParamContentURI) |
|
76 { |
|
77 if(!iUri) |
|
78 { |
|
79 // content URI has not yet been set |
|
80 return OMX_ErrorUnsupportedSetting; // TODO check return code |
|
81 } |
|
82 OMX_PARAM_CONTENTURITYPE* contentUri = reinterpret_cast<OMX_PARAM_CONTENTURITYPE*>(aComponentParameterStructure); |
|
83 TPtr8 destDes(contentUri->contentURI, contentUri->nSize - _FOFF(OMX_PARAM_CONTENTURITYPE, contentURI)); |
|
84 // using >= as a byte has to be left for the null terminator |
|
85 if(iUri->Length() >= destDes.MaxLength()) |
|
86 { |
|
87 // not enough room in supplied struct to copy URI |
|
88 return OMX_ErrorOverflow; // TODO check return code |
|
89 } |
|
90 else |
|
91 { |
|
92 destDes = *iUri; |
|
93 destDes.Append('\0'); |
|
94 return OMX_ErrorNone; |
|
95 } |
|
96 } |
|
97 else if (aParamIndex == OMX_IndexConfigMetadataItem) |
|
98 { |
|
99 if(!iDemuxer) |
|
100 { |
|
101 return OMX_ErrorNotReady; |
|
102 } |
|
103 |
|
104 OMX_CONFIG_METADATAITEMTYPE* metaData = reinterpret_cast<OMX_CONFIG_METADATAITEMTYPE*>(aComponentParameterStructure); |
|
105 OMX_ERRORTYPE omxError = OMX_ErrorNone; |
|
106 TRAPD(error, omxError = iDemuxer->GetMetadataL(metaData)); |
|
107 if (error != KErrNone) |
|
108 { |
|
109 return OMX_ErrorUndefined; |
|
110 } |
|
111 else |
|
112 { |
|
113 return omxError; |
|
114 } |
|
115 } |
|
116 |
|
117 return OMX_ErrorUnsupportedIndex; |
|
118 } |
|
119 |
|
120 OMX_ERRORTYPE COmxIL3GPDemuxerConfigManager::SetParameter(OMX_INDEXTYPE aParamIndex, |
|
121 const TAny* aComponentParameterStructure, |
|
122 OMX_BOOL aInitTime) |
|
123 { |
|
124 // try the base class first |
|
125 OMX_ERRORTYPE error = COmxILConfigManager::SetParameter(aParamIndex, aComponentParameterStructure, aInitTime); |
|
126 if(error != OMX_ErrorUnsupportedIndex) |
|
127 { |
|
128 return error; |
|
129 } |
|
130 |
|
131 if(aParamIndex == OMX_IndexParamContentURI) |
|
132 { |
|
133 const OMX_PARAM_CONTENTURITYPE* contentUri = reinterpret_cast<const OMX_PARAM_CONTENTURITYPE*>(aComponentParameterStructure); |
|
134 TPtrC8 uriDes(contentUri->contentURI); |
|
135 |
|
136 // validate URI by converting to filename |
|
137 TUriParser8 parser; |
|
138 if(parser.Parse(uriDes) != KErrNone) |
|
139 { |
|
140 return OMX_ErrorBadParameter; |
|
141 } |
|
142 |
|
143 HBufC* newFilename = NULL; |
|
144 TInt error; |
|
145 TRAP(error, newFilename = parser.GetFileNameL()); |
|
146 if(error == KErrNoMemory) |
|
147 { |
|
148 return OMX_ErrorInsufficientResources; |
|
149 } |
|
150 else if(error != KErrNone) |
|
151 { |
|
152 return OMX_ErrorBadParameter; |
|
153 } |
|
154 |
|
155 // retain a copy of the original URI for GetParameter |
|
156 HBufC8* newUri = HBufC8::New(uriDes.Length()); |
|
157 if(!newUri) |
|
158 { |
|
159 delete newFilename; |
|
160 return OMX_ErrorInsufficientResources; |
|
161 } |
|
162 *newUri = uriDes; |
|
163 |
|
164 delete iUri; |
|
165 iUri = newUri; |
|
166 delete iFilename; |
|
167 iFilename = newFilename; |
|
168 |
|
169 return iPf.ParamIndication(aParamIndex, aComponentParameterStructure); |
|
170 } |
|
171 |
|
172 return OMX_ErrorUnsupportedIndex; |
|
173 } |
|
174 |
|
175 OMX_ERRORTYPE COmxIL3GPDemuxerConfigManager::GetConfig(OMX_INDEXTYPE aConfigIndex, |
|
176 TAny* apComponentConfigStructure) const |
|
177 { |
|
178 switch (aConfigIndex) |
|
179 { |
|
180 case OMX_IndexConfigTimePosition: |
|
181 { |
|
182 if(!iDemuxer) |
|
183 { |
|
184 return OMX_ErrorNotReady; |
|
185 } |
|
186 OMX_TIME_CONFIG_TIMESTAMPTYPE* timestampType = reinterpret_cast<OMX_TIME_CONFIG_TIMESTAMPTYPE*>(apComponentConfigStructure); |
|
187 return iDemuxer->GetVideoTimestamp(timestampType->nTimestamp); |
|
188 } |
|
189 |
|
190 case OMX_IndexConfigTimeSeekMode: |
|
191 { |
|
192 OMX_TIME_CONFIG_SEEKMODETYPE* seekModeType = reinterpret_cast<OMX_TIME_CONFIG_SEEKMODETYPE*>(apComponentConfigStructure); |
|
193 seekModeType->eType = iSeekMode; |
|
194 return OMX_ErrorNone; |
|
195 } |
|
196 |
|
197 default: |
|
198 { |
|
199 return COmxILConfigManager::GetConfig(aConfigIndex, apComponentConfigStructure); |
|
200 } |
|
201 } |
|
202 } |
|
203 |
|
204 OMX_ERRORTYPE COmxIL3GPDemuxerConfigManager::SetConfig(OMX_INDEXTYPE aConfigIndex, |
|
205 const TAny* apComponentConfigStructure) |
|
206 { |
|
207 switch (aConfigIndex) |
|
208 { |
|
209 case OMX_IndexConfigTimePosition: |
|
210 { |
|
211 const OMX_TIME_CONFIG_TIMESTAMPTYPE* timestampType = reinterpret_cast<const OMX_TIME_CONFIG_TIMESTAMPTYPE*>(apComponentConfigStructure); |
|
212 if (OMX_TIME_SeekModeAccurate == iSeekMode) |
|
213 { |
|
214 return OMX_ErrorUnsupportedSetting; //Accurate mode is not supported currently. |
|
215 } |
|
216 //Currently only the fast mode is supported so not using iSeekMode as parameter. |
|
217 iDemuxer->Seek(timestampType->nTimestamp, OMX_TIME_SeekModeFast); |
|
218 return iPf.ConfigIndication(aConfigIndex, apComponentConfigStructure); |
|
219 } |
|
220 |
|
221 case OMX_IndexConfigTimeSeekMode: |
|
222 { |
|
223 const OMX_TIME_CONFIG_SEEKMODETYPE* seekModeType = reinterpret_cast<const OMX_TIME_CONFIG_SEEKMODETYPE*>(apComponentConfigStructure); |
|
224 iSeekMode = seekModeType->eType; |
|
225 return iPf.ConfigIndication(aConfigIndex, apComponentConfigStructure); |
|
226 } |
|
227 |
|
228 default: |
|
229 { |
|
230 return COmxILConfigManager::SetConfig(aConfigIndex, apComponentConfigStructure); |
|
231 } |
|
232 } |
|
233 } |
|
234 |
|
235 const HBufC* COmxIL3GPDemuxerConfigManager::Filename() const |
|
236 { |
|
237 return iFilename; |
|
238 } |
|
239 |
|
240 void COmxIL3GPDemuxerConfigManager::SetDemuxer(C3GPDemuxer& aDemuxer) |
|
241 { |
|
242 iDemuxer = &aDemuxer; |
|
243 } |