|
1 /* |
|
2 * Copyright (c) 2002-2007 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 camera players. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32std.h> |
|
21 #include <jdebug.h> |
|
22 |
|
23 #include "cmmacameraplayerfactory.h" |
|
24 #include "cmmacameraplayer.h" |
|
25 #include "cmmavideocontrol.h" |
|
26 #include "cmmavideorecordcontrol.h" |
|
27 #include "cmmastoptimecontrol.h" |
|
28 #include "cmmaplayerproperties.h" |
|
29 #include "cmmammfresolver.h" |
|
30 |
|
31 _LIT(KDefaultVideo, "video"); |
|
32 //is the main camera |
|
33 _LIT(KDevcamZero, "devcam0"); |
|
34 // the secondary camera |
|
35 _LIT(KDevcamOne, "devcam1"); |
|
36 |
|
37 _LIT(KEncodingProperty, "encoding"); |
|
38 |
|
39 _LIT(KVideoMp4MimeType, "video/mp4"); |
|
40 _LIT(KVideoH264MimeType, "video/H264"); |
|
41 |
|
42 CMMACameraPlayerFactory* CMMACameraPlayerFactory::NewLC() |
|
43 { |
|
44 CMMACameraPlayerFactory* pFactory = |
|
45 new(ELeave) CMMACameraPlayerFactory(); |
|
46 CleanupStack::PushL(pFactory); |
|
47 return pFactory; |
|
48 } |
|
49 |
|
50 |
|
51 CMMACameraPlayerFactory::CMMACameraPlayerFactory() |
|
52 { |
|
53 } |
|
54 |
|
55 |
|
56 CMMACameraPlayerFactory::~CMMACameraPlayerFactory() |
|
57 { |
|
58 delete iAudioSettings; |
|
59 } |
|
60 |
|
61 CMMAPlayer* CMMACameraPlayerFactory::CreatePlayerL( |
|
62 CMMAMMFResolver* aResolver) |
|
63 { |
|
64 DEBUG("MMA::CMMACameraPlayerFactory::CreatePlayerL( aResolver )+"); |
|
65 CMMACameraPlayer* player = CMMACameraPlayer::NewLC(iCameraIndex); |
|
66 |
|
67 /* Add VideoControl */ |
|
68 CMMAVideoControl* videoControl = new(ELeave)CMMAVideoControl(player); |
|
69 |
|
70 CleanupStack::PushL(videoControl); |
|
71 player->AddControlL(videoControl); |
|
72 CleanupStack::Pop(videoControl); |
|
73 |
|
74 /* Add RecordControl */ |
|
75 CMMAVideoRecordControl* videoRecordControl = |
|
76 CMMAVideoRecordControl::NewL(player, |
|
77 aResolver, |
|
78 iVideoSettings, |
|
79 iAudioSettings, |
|
80 player->CameraHandle()); |
|
81 CleanupStack::PushL(videoRecordControl); |
|
82 player->AddControlL(videoRecordControl); |
|
83 // ownership transfered to player |
|
84 CleanupStack::Pop(videoRecordControl); |
|
85 |
|
86 // With record control view finder can't be stopped, |
|
87 // because it can not be restarted. |
|
88 player->SetViewFinderMode(EFalse); |
|
89 |
|
90 CleanupStack::Pop(player); |
|
91 return player; |
|
92 } |
|
93 |
|
94 |
|
95 void CMMACameraPlayerFactory::MediaIdsL(RArray<TUid>& aMediaIds) |
|
96 { |
|
97 CleanupClosePushL(aMediaIds); |
|
98 User::LeaveIfError(aMediaIds.Append(KUidMediaTypeVideo)); |
|
99 CleanupStack::Pop(); |
|
100 } |
|
101 |
|
102 void CMMACameraPlayerFactory::PreparePluginSelectionParametersL( |
|
103 CMMAMMFResolver* aResolver, |
|
104 CMMFFormatSelectionParameters* aFormatSelection) |
|
105 { |
|
106 // We are creating record type player |
|
107 aResolver->SetRequiredRecordFormatSupportL(*aFormatSelection); |
|
108 } |
|
109 |
|
110 CMMAPlayer* CMMACameraPlayerFactory::CreatePlayerL(const TDesC&) |
|
111 { |
|
112 // record player cannot be created from conten-type, since this is used only |
|
113 // when we have also data |
|
114 return NULL; |
|
115 } |
|
116 |
|
117 |
|
118 CMMAPlayer* CMMACameraPlayerFactory::CreatePlayerL(const TDesC8&) |
|
119 { |
|
120 // record player cannot be created with header data |
|
121 return NULL; |
|
122 } |
|
123 |
|
124 CMMAPlayer* CMMACameraPlayerFactory::CreatePlayerL( |
|
125 const TDesC& aProtocol, |
|
126 const TDesC& aMiddlePart, |
|
127 const TDesC& aParameters) |
|
128 { |
|
129 DEBUG_STR("MMA::CMMACameraPlayerFactory::CreatePlayerL aParameters = %S", aParameters); |
|
130 // check that locator is capture:://audio |
|
131 if (aProtocol != KMMACaptureProtocol) |
|
132 { |
|
133 return NULL; |
|
134 } |
|
135 |
|
136 iCameraIndex = KErrNotFound; |
|
137 |
|
138 // If the device supports multiple cameras then "capture://devcam0" is the |
|
139 // main camera pointing outwards from the user. "capture://devcam1" is the |
|
140 // secondary camera pointing e.g. towards the user. "capture://video" is |
|
141 // the default camera locator pointing to the same camera as "devcam0" |
|
142 if ((aMiddlePart == KDefaultVideo) || |
|
143 (aMiddlePart == KDevcamZero)) |
|
144 { |
|
145 // First camera |
|
146 iCameraIndex = 0; |
|
147 } |
|
148 else if (aMiddlePart == KDevcamOne) |
|
149 { |
|
150 // Second camera. |
|
151 iCameraIndex = 1; |
|
152 } |
|
153 else |
|
154 { |
|
155 // not supported type |
|
156 return NULL; |
|
157 } |
|
158 |
|
159 CMMAAudioSettings* audioSettings = new(ELeave) CMMAAudioSettings; |
|
160 audioSettings->iDataType = KMMFFourCCCodeNULL; |
|
161 delete iAudioSettings; |
|
162 iAudioSettings = audioSettings; |
|
163 |
|
164 if (aParameters.Length() == 0) |
|
165 { |
|
166 // getting defaults from validator |
|
167 iVideoSettings = TMMAParameterValidator::ValidateVideoPropertiesL(aParameters); |
|
168 } |
|
169 else |
|
170 { |
|
171 // we accept either video or mixed parameters, so properties must contain encoding 2 times for mixed and |
|
172 // 1 time for video. |
|
173 // making tmp des without first "encoding" |
|
174 TInt lengthWithoutEncoding = aParameters.Length() - KEncodingProperty().Length(); |
|
175 if (lengthWithoutEncoding < 0) |
|
176 { |
|
177 User::Leave(KErrArgument); |
|
178 } |
|
179 TPtrC tmp = aParameters.Right(lengthWithoutEncoding); |
|
180 // finding second "encoding" |
|
181 TInt videoPropertiesStartPos = tmp.Find(KEncodingProperty); |
|
182 if (videoPropertiesStartPos == KErrNotFound) |
|
183 { |
|
184 // there is not another encoding, so assuming that there is only video parameters |
|
185 iVideoSettings = TMMAParameterValidator::ValidateVideoPropertiesL(aParameters); |
|
186 } |
|
187 else |
|
188 { |
|
189 // there is mixed parameters |
|
190 videoPropertiesStartPos += KEncodingProperty().Length(); |
|
191 |
|
192 // skipping '&' char |
|
193 TPtrC audioProperties = aParameters.Left(videoPropertiesStartPos - 1); |
|
194 TPtrC videoProperties = aParameters.Mid(videoPropertiesStartPos); |
|
195 iVideoSettings = TMMAParameterValidator::ValidateVideoPropertiesL(videoProperties); |
|
196 |
|
197 CMMAAudioSettings* audioSettings = TMMAParameterValidator::ValidateAudioPropertiesL(audioProperties); |
|
198 delete iAudioSettings; |
|
199 iAudioSettings = audioSettings; |
|
200 } |
|
201 } |
|
202 |
|
203 // if wanted video capture encoding is H264, we must create player with video/mp4 |
|
204 // because mmf doesn't have controller for H264 |
|
205 if (iVideoSettings.iEncoding.Compare(KVideoH264MimeType) == 0) |
|
206 { |
|
207 return CMMAMMFPlayerFactory::CreatePlayerL(KVideoMp4MimeType); |
|
208 } |
|
209 |
|
210 // Find controller with content-type |
|
211 return CMMAMMFPlayerFactory::CreatePlayerL(iVideoSettings.iEncoding); |
|
212 } |
|
213 |
|
214 void CMMACameraPlayerFactory::GetSupportedProtocolsL( |
|
215 const TDesC& aContentType, |
|
216 CDesC16Array& aProtocolArray) |
|
217 { |
|
218 if (IsSupportedContentTypeL(aContentType)) |
|
219 { |
|
220 aProtocolArray.AppendL(KMMACaptureProtocol); |
|
221 } |
|
222 } |
|
223 |
|
224 // END OF FILE |