37 |
38 |
38 // maximum amount of buffer space we will ever use |
39 // maximum amount of buffer space we will ever use |
39 const TInt KMaxBufferLength=256; |
40 const TInt KMaxBufferLength=256; |
40 |
41 |
41 const TInt KDCFHeaderLength=3; |
42 const TInt KDCFHeaderLength=3; |
|
43 |
|
44 #ifdef DRM_OMA2_ENABLED |
42 const TInt KLengthBoxSize = 4; |
45 const TInt KLengthBoxSize = 4; |
43 const TInt KLengthBoxType = 4; |
46 const TInt KLengthBoxType = 4; |
44 const TInt KLengthBoxSize64 = 8; |
47 const TInt KLengthBoxSize64 = 8; |
45 const TInt KLengthVersion = 1; |
48 const TInt KLengthVersion = 1; |
46 const TInt KLengthFlags = 3; |
49 const TInt KLengthFlags = 3; |
48 _LIT8(KFTypPrefix, "ftyp"); |
51 _LIT8(KFTypPrefix, "ftyp"); |
49 _LIT8(KODFPrefix, "odcf"); |
52 _LIT8(KODFPrefix, "odcf"); |
50 _LIT8(KRoapTriggerElement, "roap-trigger:roapTrigger"); // before OMA spec CR, ROAP Trigger namespace prefix was roap-trigger |
53 _LIT8(KRoapTriggerElement, "roap-trigger:roapTrigger"); // before OMA spec CR, ROAP Trigger namespace prefix was roap-trigger |
51 _LIT8(KRoapTriggerElement2, "roap:roapTrigger"); |
54 _LIT8(KRoapTriggerElement2, "roap:roapTrigger"); |
52 _LIT8(KRoapTriggerType, "application/vnd.oma.drm.roap-trigger+xml"); |
55 _LIT8(KRoapTriggerType, "application/vnd.oma.drm.roap-trigger+xml"); |
|
56 #endif |
53 |
57 |
54 const TImplementationProxy ImplementationTable[] = |
58 const TImplementationProxy ImplementationTable[] = |
55 { |
59 { |
56 IMPLEMENTATION_PROXY_ENTRY(0x101F6DB8, CApaDRMRecognizer::CreateRecognizerL) |
60 IMPLEMENTATION_PROXY_ENTRY(0x101F6DB8, CApaDRMRecognizer::CreateRecognizerL) |
57 }; |
61 }; |
129 return; |
135 return; |
130 } |
136 } |
131 #endif |
137 #endif |
132 |
138 |
133 #ifdef DRM_OMA2_ENABLED |
139 #ifdef DRM_OMA2_ENABLED |
134 // Recognize ROAP Trigger |
140 if( FeatureManager::FeatureSupported( KFeatureIdFfOmadrm2Support ) ) |
135 if ( RecognizeRoapTrigger( aBuffer ) ) |
141 { |
136 { |
142 // Recognize ROAP Trigger |
137 return; |
143 if ( RecognizeRoapTrigger( aBuffer ) ) |
138 } |
144 { |
139 |
145 return; |
140 // Recognize DCFv2 |
146 } |
141 if ( RecognizeODF( aBuffer ) ) |
147 |
142 { |
148 // Recognize DCFv2 |
143 return; |
149 if ( RecognizeODF( aBuffer ) ) |
144 } |
150 { |
145 #endif |
151 return; |
146 // Recognize DCFv1 |
152 } |
147 TUint8 version = aBuffer[0]; |
153 } |
148 TUint8 contentTypeLen = aBuffer[1]; |
154 #endif |
149 TUint8 contentURILen = aBuffer[2]; |
155 // Recognize DCFv1 |
|
156 TUint8 version = aBuffer[0]; |
|
157 TUint8 contentTypeLen = aBuffer[1]; |
|
158 TUint8 contentURILen = aBuffer[2]; |
150 |
159 |
151 if ( contentTypeLen < KMinContentTypeLen || contentURILen == 0 ) |
160 if ( contentTypeLen < KMinContentTypeLen || contentURILen == 0 ) |
152 { |
161 { |
153 return; |
162 return; |
154 } |
163 } |
175 } |
184 } |
176 |
185 |
177 #ifdef DRM_OMA2_ENABLED |
186 #ifdef DRM_OMA2_ENABLED |
178 TBool CApaDRMRecognizer::RecognizeRoapTrigger( const TDesC8& aBuffer ) |
187 TBool CApaDRMRecognizer::RecognizeRoapTrigger( const TDesC8& aBuffer ) |
179 { |
188 { |
|
189 if( ! ( FeatureManager::FeatureSupported( |
|
190 KFeatureIdFfOmadrm2Support ) ) ) |
|
191 { |
|
192 return EFalse; |
|
193 } |
|
194 |
180 if ( aBuffer.FindF( KRoapTriggerElement() ) != KErrNotFound |
195 if ( aBuffer.FindF( KRoapTriggerElement() ) != KErrNotFound |
181 || aBuffer.FindF( KRoapTriggerElement2() ) != KErrNotFound ) |
196 || aBuffer.FindF( KRoapTriggerElement2() ) != KErrNotFound ) |
182 { |
197 { |
183 iConfidence = ECertain; |
198 iConfidence = ECertain; |
184 iDataType=TDataType( KRoapTriggerType() ); |
199 iDataType=TDataType( KRoapTriggerType() ); |
187 return EFalse; |
202 return EFalse; |
188 } |
203 } |
189 |
204 |
190 TBool CApaDRMRecognizer::RecognizeODF( const TDesC8& aBuffer ) |
205 TBool CApaDRMRecognizer::RecognizeODF( const TDesC8& aBuffer ) |
191 { |
206 { |
192 if ( aBuffer.Size() < 24 ) return EFalse; |
207 |
193 TPtrC8 ftypPrefix = aBuffer.Mid( 4, KFTypPrefix().Length() ); |
208 if( ! ( FeatureManager::FeatureSupported( |
194 if ( KFTypPrefix().CompareF( ftypPrefix ) == KErrNone ) |
209 KFeatureIdFfOmadrm2Support ) ) ) |
195 { |
210 { |
196 TPtrC8 odfPrefix = aBuffer.Mid( 8, KODFPrefix().Length() ); |
211 return EFalse; |
197 if ( KODFPrefix().CompareF( odfPrefix ) == KErrNone ) |
212 } |
198 { |
213 |
199 TBuf8<4> buffer; |
214 if ( aBuffer.Size() < 24 ) return EFalse; |
200 TUint32 size; |
215 TPtrC8 ftypPrefix = aBuffer.Mid( 4, KFTypPrefix().Length() ); |
201 TPtr8 ptr(NULL, 0); |
216 if ( KFTypPrefix().CompareF( ftypPrefix ) == KErrNone ) |
202 TUint32 offset(20); |
217 { |
203 |
218 TPtrC8 odfPrefix = aBuffer.Mid( 8, KODFPrefix().Length() ); |
204 // ODRM box header |
219 if ( KODFPrefix().CompareF( odfPrefix ) == KErrNone ) |
205 buffer.Zero(); |
220 { |
206 buffer.Copy( aBuffer.Mid( offset, 4 )); |
221 TBuf8<4> buffer; |
207 size = ReadUint32FromBlock( buffer, 0 ); |
222 TUint32 size; |
208 offset += KLengthBoxSize + KLengthBoxType + KLengthVersion + KLengthFlags; |
223 TPtr8 ptr(NULL, 0); |
209 |
224 TUint32 offset(20); |
210 if (size == 1) |
225 |
211 { |
226 // ODRM box header |
212 offset += KLengthBoxSize64; |
227 buffer.Zero(); |
213 } |
228 buffer.Copy( aBuffer.Mid( offset, 4 )); |
214 if ( aBuffer.Size() < offset+4 ) return EFalse; |
229 size = ReadUint32FromBlock( buffer, 0 ); |
215 |
230 offset += KLengthBoxSize + KLengthBoxType + KLengthVersion + KLengthFlags; |
216 // Discrete headers box header |
231 |
217 buffer.Zero(); |
232 if (size == 1) |
218 buffer.Copy( aBuffer.Mid( offset, 4 )); |
233 { |
219 size = ReadUint32FromBlock( buffer, 0 ); |
234 offset += KLengthBoxSize64; |
220 offset += KLengthBoxSize + KLengthBoxType + KLengthVersion + KLengthFlags; |
235 } |
221 if ( size == 1 ) |
236 if ( aBuffer.Size() < offset+4 ) return EFalse; |
222 { |
237 |
223 offset += KLengthBoxSize64; |
238 // Discrete headers box header |
224 } |
239 buffer.Zero(); |
225 if ( aBuffer.Size() < offset+1 ) return EFalse; |
240 buffer.Copy( aBuffer.Mid( offset, 4 )); |
226 |
241 size = ReadUint32FromBlock( buffer, 0 ); |
227 // Content type |
242 offset += KLengthBoxSize + KLengthBoxType + KLengthVersion + KLengthFlags; |
228 buffer.Zero(); |
243 if ( size == 1 ) |
229 buffer.Copy( aBuffer.Mid( offset, 1 )); |
244 { |
230 if ( aBuffer.Size() < offset + 1 + buffer[0] ) return EFalse; |
245 offset += KLengthBoxSize64; |
231 TPtrC8 mimeType = aBuffer.Mid( offset+1, buffer[0] ); |
246 } |
232 |
247 if ( aBuffer.Size() < offset+1 ) return EFalse; |
233 iConfidence = ECertain; |
248 |
234 iDataType=TDataType( mimeType ); |
249 // Content type |
235 return ETrue; |
250 buffer.Zero(); |
236 } |
251 buffer.Copy( aBuffer.Mid( offset, 1 )); |
237 |
252 if ( aBuffer.Size() < offset + 1 + buffer[0] ) return EFalse; |
238 } |
253 TPtrC8 mimeType = aBuffer.Mid( offset+1, buffer[0] ); |
239 return EFalse; |
254 |
|
255 iConfidence = ECertain; |
|
256 iDataType=TDataType( mimeType ); |
|
257 return ETrue; |
|
258 } |
|
259 |
|
260 } |
|
261 return EFalse; |
240 } |
262 } |
241 #endif |
263 #endif |
242 |
264 |
243 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
265 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
244 { |
266 { |