1 /* |
|
2 * Copyright (c) 2002 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: This class is used for creating animation player. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <logger.h> |
|
21 |
|
22 #include "cmmavideocontrol.h" |
|
23 #include "cmmaanimationratecontrol.h" |
|
24 #include "cmmaanimationstoptimecontrol.h" |
|
25 #include "cmmaanimationframepositioningcontrol.h" |
|
26 #include "cmmaanimationplayer.h" |
|
27 #include "cmmaanimationplayerfactory.h" |
|
28 |
|
29 // Animation type info |
|
30 _LIT(KMMAAnimationMimeTypeGIF, "image/gif"); |
|
31 _LIT(KMMAAnimationSuffixGIF, "gif"); |
|
32 |
|
33 // header data and length |
|
34 _LIT8(KMMAAnimationGIFVersion, "GIF89a"); |
|
35 const TUint8 KMMAGifVersionLength = 6; |
|
36 |
|
37 CMMAAnimationPlayerFactory* CMMAAnimationPlayerFactory::NewLC() |
|
38 { |
|
39 CMMAAnimationPlayerFactory* pFactory = |
|
40 new(ELeave) CMMAAnimationPlayerFactory(); |
|
41 CleanupStack::PushL(pFactory); |
|
42 return pFactory; |
|
43 } |
|
44 |
|
45 CMMAAnimationPlayerFactory::CMMAAnimationPlayerFactory() |
|
46 { |
|
47 } |
|
48 |
|
49 |
|
50 CMMAAnimationPlayerFactory::~CMMAAnimationPlayerFactory() |
|
51 { |
|
52 } |
|
53 |
|
54 // Creates new player according to a content type. |
|
55 CMMAPlayer* CMMAAnimationPlayerFactory::CreatePlayerL( |
|
56 const TDesC& aContentType) |
|
57 { |
|
58 CMMAPlayer* player = NULL; |
|
59 if (aContentType == KMMAAnimationMimeTypeGIF) |
|
60 { |
|
61 player = CreateAnimationPlayerL(); |
|
62 } |
|
63 return player; |
|
64 } |
|
65 |
|
66 // Creates new player according to a locator |
|
67 CMMAPlayer* CMMAAnimationPlayerFactory::CreatePlayerL( |
|
68 const TDesC& aProtocol, |
|
69 const TDesC& aMiddlePart, |
|
70 const TDesC& /*aParameters*/) |
|
71 { |
|
72 CMMAPlayer* player = NULL; |
|
73 if (aProtocol == KMMAFileProtocol) |
|
74 { |
|
75 // filename ends to gif suffix |
|
76 if (aMiddlePart.Right(KMMAAnimationSuffixGIF().Length()) == |
|
77 KMMAAnimationSuffixGIF()) |
|
78 { |
|
79 player = CreateAnimationPlayerL(aMiddlePart); |
|
80 } |
|
81 else |
|
82 { |
|
83 // try to recognize from headerdata |
|
84 RFs fs; |
|
85 CleanupClose< RFs >::PushL(fs); |
|
86 User::LeaveIfError(fs.Connect()); |
|
87 |
|
88 RFile file; |
|
89 CleanupClose< RFile >::PushL(file); |
|
90 |
|
91 User::LeaveIfError(file.Open(fs, aMiddlePart, EFileRead)); |
|
92 |
|
93 TBuf8< KMMAGifVersionLength > header; |
|
94 User::LeaveIfError(file.Read(header)); |
|
95 |
|
96 CleanupStack::PopAndDestroy(2); // fs, file |
|
97 |
|
98 if (header == KMMAAnimationGIFVersion()) |
|
99 { |
|
100 player = CreateAnimationPlayerL(aMiddlePart); |
|
101 } |
|
102 } |
|
103 } |
|
104 |
|
105 return (CMMAPlayer*) player; |
|
106 } |
|
107 |
|
108 // Creates new player according to a header data |
|
109 CMMAPlayer* CMMAAnimationPlayerFactory::CreatePlayerL( |
|
110 const TDesC8& aHeaderData) |
|
111 { |
|
112 CMMAPlayer* player = NULL; |
|
113 TPtrC8 header = aHeaderData.Left(KMMAAnimationGIFVersion().Length()); |
|
114 if (header == KMMAAnimationGIFVersion()) |
|
115 { |
|
116 player = CreateAnimationPlayerL(); |
|
117 } |
|
118 return player; |
|
119 } |
|
120 |
|
121 // Gets player's supported content types. |
|
122 void CMMAAnimationPlayerFactory::GetSupportedContentTypesL( |
|
123 const TDesC& aProtocol, |
|
124 CDesC16Array& aMimeTypeArray) |
|
125 { |
|
126 if (aProtocol == KNullDesC || |
|
127 aProtocol == KMMAHttpProtocol || |
|
128 aProtocol == KMMAHttpsProtocol || |
|
129 aProtocol == KMMAFileProtocol) |
|
130 { |
|
131 aMimeTypeArray.AppendL(KMMAAnimationMimeTypeGIF); |
|
132 } |
|
133 } |
|
134 |
|
135 // Gets player's supported protocols for the content type. |
|
136 void CMMAAnimationPlayerFactory::GetSupportedProtocolsL( |
|
137 const TDesC& aContentType, |
|
138 CDesC16Array& aProtocolArray) |
|
139 { |
|
140 if (aContentType == KNullDesC || |
|
141 aContentType == KMMAAnimationMimeTypeGIF) |
|
142 { |
|
143 aProtocolArray.AppendL(KMMAHttpProtocol); |
|
144 aProtocolArray.AppendL(KMMAHttpsProtocol); |
|
145 aProtocolArray.AppendL(KMMAFileProtocol); |
|
146 } |
|
147 } |
|
148 |
|
149 CMMAAnimationPlayer* CMMAAnimationPlayerFactory::CreateAnimationPlayerL(const TDesC& aFileName) |
|
150 { |
|
151 CMMAAnimationPlayer* player = CMMAAnimationPlayer::NewLC(aFileName); |
|
152 AddControlsL(player); |
|
153 CleanupStack::Pop(); // player |
|
154 return player; |
|
155 } |
|
156 |
|
157 CMMAAnimationPlayer* CMMAAnimationPlayerFactory::CreateAnimationPlayerL() |
|
158 { |
|
159 CMMAAnimationPlayer* player = CMMAAnimationPlayer::NewLC(); |
|
160 AddControlsL(player); |
|
161 CleanupStack::Pop(); // player |
|
162 return player; |
|
163 } |
|
164 |
|
165 void CMMAAnimationPlayerFactory::AddControlsL(CMMAAnimationPlayer* aPlayer) |
|
166 { |
|
167 CMMAVideoControl* videoControl = new(ELeave) CMMAVideoControl(aPlayer); |
|
168 CleanupStack::PushL(videoControl); |
|
169 aPlayer->AddControlL(videoControl); |
|
170 CleanupStack::Pop(videoControl); |
|
171 |
|
172 CMMAAnimationStopTimeControl* stopTimeControl = |
|
173 CMMAAnimationStopTimeControl::NewL(aPlayer); |
|
174 CleanupStack::PushL(stopTimeControl); |
|
175 aPlayer->AddControlL(stopTimeControl); |
|
176 CleanupStack::Pop(stopTimeControl); |
|
177 |
|
178 // Own RateControl |
|
179 CMMAAnimationRateControl* rateControl = |
|
180 CMMAAnimationRateControl::NewL(aPlayer); |
|
181 CleanupStack::PushL(rateControl); |
|
182 aPlayer->AddControlL(rateControl); |
|
183 CleanupStack::Pop(rateControl); |
|
184 |
|
185 // FramePositioningControl is only supported for file locator |
|
186 if (aPlayer->IsFilePlayer()) |
|
187 { |
|
188 CMMAAnimationFramePositioningControl* animationFramePositioningControl = |
|
189 CMMAAnimationFramePositioningControl::NewL(aPlayer); |
|
190 CleanupStack::PushL(animationFramePositioningControl); |
|
191 aPlayer->AddControlL(animationFramePositioningControl); |
|
192 CleanupStack::Pop(animationFramePositioningControl); |
|
193 } |
|
194 |
|
195 } |
|
196 // END OF FILE |
|