|
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 <logger.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 LOG(EJavaMMAPI, EInfo, "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 User::LeaveIfError(aMediaIds.Append(KUidMediaTypeVideo)); |
|
98 } |
|
99 |
|
100 void CMMACameraPlayerFactory::PreparePluginSelectionParametersL( |
|
101 CMMAMMFResolver* aResolver, |
|
102 CMMFFormatSelectionParameters* aFormatSelection) |
|
103 { |
|
104 // We are creating record type player |
|
105 aResolver->SetRequiredRecordFormatSupportL(*aFormatSelection); |
|
106 } |
|
107 |
|
108 CMMAPlayer* CMMACameraPlayerFactory::CreatePlayerL(const TDesC&) |
|
109 { |
|
110 // record player cannot be created from conten-type, since this is used only |
|
111 // when we have also data |
|
112 return NULL; |
|
113 } |
|
114 |
|
115 |
|
116 CMMAPlayer* CMMACameraPlayerFactory::CreatePlayerL(const TDesC8&) |
|
117 { |
|
118 // record player cannot be created with header data |
|
119 return NULL; |
|
120 } |
|
121 |
|
122 CMMAPlayer* CMMACameraPlayerFactory::CreatePlayerL( |
|
123 const TDesC& aProtocol, |
|
124 const TDesC& aMiddlePart, |
|
125 const TDesC& aParameters) |
|
126 { |
|
127 LOG1(EJavaMMAPI, EInfo, "MMA::CMMACameraPlayerFactory::CreatePlayerL aParameters = %S", aParameters.Ptr()); |
|
128 // check that locator is capture:://audio |
|
129 if (aProtocol != KMMACaptureProtocol) |
|
130 { |
|
131 return NULL; |
|
132 } |
|
133 |
|
134 iCameraIndex = KErrNotFound; |
|
135 |
|
136 // If the device supports multiple cameras then "capture://devcam0" is the |
|
137 // main camera pointing outwards from the user. "capture://devcam1" is the |
|
138 // secondary camera pointing e.g. towards the user. "capture://video" is |
|
139 // the default camera locator pointing to the same camera as "devcam0" |
|
140 if ((aMiddlePart == KDefaultVideo) || |
|
141 (aMiddlePart == KDevcamZero)) |
|
142 { |
|
143 // First camera |
|
144 iCameraIndex = 0; |
|
145 } |
|
146 else if (aMiddlePart == KDevcamOne) |
|
147 { |
|
148 // Second camera. |
|
149 iCameraIndex = 1; |
|
150 } |
|
151 else |
|
152 { |
|
153 // not supported type |
|
154 return NULL; |
|
155 } |
|
156 |
|
157 CMMAAudioSettings* audioSettings = new(ELeave) CMMAAudioSettings; |
|
158 audioSettings->iDataType = KMMFFourCCCodeNULL; |
|
159 delete iAudioSettings; |
|
160 iAudioSettings = audioSettings; |
|
161 |
|
162 if (aParameters.Length() == 0) |
|
163 { |
|
164 // getting defaults from validator |
|
165 iVideoSettings = TMMAParameterValidator::ValidateVideoPropertiesL(aParameters); |
|
166 } |
|
167 else |
|
168 { |
|
169 // we accept either video or mixed parameters, so properties must contain encoding 2 times for mixed and |
|
170 // 1 time for video. |
|
171 // making tmp des without first "encoding" |
|
172 TInt lengthWithoutEncoding = aParameters.Length() - KEncodingProperty().Length(); |
|
173 if (lengthWithoutEncoding < 0) |
|
174 { |
|
175 User::Leave(KErrArgument); |
|
176 } |
|
177 TPtrC tmp = aParameters.Right(lengthWithoutEncoding); |
|
178 // finding second "encoding" |
|
179 TInt videoPropertiesStartPos = tmp.Find(KEncodingProperty); |
|
180 if (videoPropertiesStartPos == KErrNotFound) |
|
181 { |
|
182 // there is not another encoding, so assuming that there is only video parameters |
|
183 iVideoSettings = TMMAParameterValidator::ValidateVideoPropertiesL(aParameters); |
|
184 } |
|
185 else |
|
186 { |
|
187 // there is mixed parameters |
|
188 videoPropertiesStartPos += KEncodingProperty().Length(); |
|
189 |
|
190 // skipping '&' char |
|
191 TPtrC audioProperties = aParameters.Left(videoPropertiesStartPos - 1); |
|
192 TPtrC videoProperties = aParameters.Mid(videoPropertiesStartPos); |
|
193 iVideoSettings = TMMAParameterValidator::ValidateVideoPropertiesL(videoProperties); |
|
194 |
|
195 CMMAAudioSettings* audioSettings = TMMAParameterValidator::ValidateAudioPropertiesL(audioProperties); |
|
196 delete iAudioSettings; |
|
197 iAudioSettings = audioSettings; |
|
198 } |
|
199 } |
|
200 |
|
201 // if wanted video capture encoding is H264, we must create player with video/mp4 |
|
202 // because mmf doesn't have controller for H264 |
|
203 if (iVideoSettings.iEncoding.Compare(KVideoH264MimeType) == 0) |
|
204 { |
|
205 return CMMAMMFPlayerFactory::CreatePlayerL(KVideoMp4MimeType); |
|
206 } |
|
207 |
|
208 // Find controller with content-type |
|
209 return CMMAMMFPlayerFactory::CreatePlayerL(iVideoSettings.iEncoding); |
|
210 } |
|
211 |
|
212 void CMMACameraPlayerFactory::GetSupportedProtocolsL( |
|
213 const TDesC& aContentType, |
|
214 CDesC16Array& aProtocolArray) |
|
215 { |
|
216 if (IsSupportedContentTypeL(aContentType)) |
|
217 { |
|
218 aProtocolArray.AppendL(KMMACaptureProtocol); |
|
219 } |
|
220 } |
|
221 |
|
222 // END OF FILE |