|
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 "paramconversion.h" |
|
25 #include <uri8.h> |
|
26 #include <openmax/il/khronos/v1_x/OMX_Component.h> |
|
27 |
|
28 OMX_PARAM_CONTENTURITYPE* ParamConversion::FilenameAsContentUriStructV1_0L(const TDesC& aFileName) |
|
29 { |
|
30 CUri8* aFileUri = CUri8::CreateFileUriL(aFileName); |
|
31 CleanupStack::PushL(aFileUri); |
|
32 const TDesC8& aUriDes = aFileUri->Uri().UriDes(); |
|
33 if(aUriDes.Length() > 255) |
|
34 { |
|
35 User::Leave(KErrTooBig); |
|
36 } |
|
37 OMX_PARAM_CONTENTURITYPE* aUriStruct = reinterpret_cast<OMX_PARAM_CONTENTURITYPE*>(new(ELeave) TUint8[264]); |
|
38 aUriStruct->nSize = 264; |
|
39 aUriStruct->nVersion.s.nVersionMajor = 1; |
|
40 aUriStruct->nVersion.s.nVersionMinor = 0; |
|
41 aUriStruct->nVersion.s.nRevision = 0; |
|
42 aUriStruct->nVersion.s.nStep = 0; |
|
43 TPtr8 aUriStructDes(aUriStruct->contentURI, aUriDes.Length()+1); |
|
44 aUriStructDes = aUriDes; |
|
45 aUriStructDes.Append('\0'); |
|
46 CleanupStack::PopAndDestroy(aFileUri); |
|
47 return aUriStruct; |
|
48 } |
|
49 |
|
50 OMX_PARAM_CONTENTURITYPE* ParamConversion::FilenameAsContentUriStructV1_1L(const TDesC& aFileName) |
|
51 { |
|
52 CUri8* aFileUri = CUri8::CreateFileUriL(aFileName); |
|
53 CleanupStack::PushL(aFileUri); |
|
54 const TDesC8& aUriDes = aFileUri->Uri().UriDes(); |
|
55 // sizeof(OMX_PARAM_CONTENTURITYPE) includes 1 byte for the URI name. counting this as well leaves room for a null terminator. |
|
56 TInt aStructSize = 9 + aUriDes.Length(); |
|
57 TUint8* aUriBytes = new(ELeave) TUint8[aStructSize]; |
|
58 OMX_PARAM_CONTENTURITYPE* aUriStruct = reinterpret_cast<OMX_PARAM_CONTENTURITYPE*>(aUriBytes); |
|
59 aUriStruct->nSize = aStructSize; |
|
60 aUriStruct->nVersion.s.nVersionMajor = OMX_VERSION_MAJOR; |
|
61 aUriStruct->nVersion.s.nVersionMinor = OMX_VERSION_MINOR; |
|
62 aUriStruct->nVersion.s.nRevision = OMX_VERSION_REVISION; |
|
63 aUriStruct->nVersion.s.nStep = OMX_VERSION_STEP; |
|
64 TPtr8 aUriStructDes(aUriStruct->contentURI, aUriDes.Length()+1); |
|
65 aUriStructDes = aUriDes; |
|
66 aUriStructDes.Append('\0'); |
|
67 CleanupStack::PopAndDestroy(aFileUri); |
|
68 return aUriStruct; |
|
69 } |