26
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-2009 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 |
#include <w32std.h>
|
|
19 |
#include <alf/alfutil.h>
|
|
20 |
#include <glxtracer.h>
|
|
21 |
#include <glxlog.h>
|
|
22 |
#include "glxtv.h" // for CGlxTv
|
|
23 |
#include "glxhdmicontainer.h"
|
|
24 |
#include "glxhdmisurfaceupdater.h"
|
|
25 |
|
|
26 |
#include "glxhdmicontroller.h"
|
|
27 |
|
|
28 |
// -----------------------------------------------------------------------------
|
|
29 |
// NewLC
|
|
30 |
// -----------------------------------------------------------------------------
|
|
31 |
EXPORT_C CGlxHdmiController* CGlxHdmiController::NewL(
|
|
32 |
MGlxHDMIDecoderObserver& aDecoderObserver)
|
|
33 |
{
|
|
34 |
TRACER("CGlxHdmiController* CGlxHdmiController::NewL()");
|
|
35 |
CGlxHdmiController* self = new (ELeave) CGlxHdmiController(
|
|
36 |
aDecoderObserver);
|
|
37 |
CleanupStack::PushL(self);
|
|
38 |
self->ConstructL();
|
|
39 |
CleanupStack::Pop(self);
|
|
40 |
return self;
|
|
41 |
}
|
|
42 |
|
|
43 |
// -----------------------------------------------------------------------------
|
|
44 |
// destructor
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
EXPORT_C CGlxHdmiController::~CGlxHdmiController()
|
|
47 |
{
|
|
48 |
TRACER("CGlxHdmiController::~CGlxHdmiController()");
|
|
49 |
DestroySurfaceUpdater();
|
|
50 |
DestroyContainer();
|
|
51 |
delete iStoredImagePath;
|
|
52 |
delete iStoredNextImagePath;
|
|
53 |
if (iFsBitmap)
|
|
54 |
{
|
|
55 |
delete iFsBitmap;
|
|
56 |
}
|
|
57 |
if (iGlxTvOut)
|
|
58 |
{
|
|
59 |
delete iGlxTvOut;
|
|
60 |
}
|
|
61 |
}
|
|
62 |
|
|
63 |
// -----------------------------------------------------------------------------
|
|
64 |
// Setting an Image Path
|
|
65 |
// -----------------------------------------------------------------------------
|
|
66 |
EXPORT_C void CGlxHdmiController::SetImageL(const TDesC& aImageFile,
|
|
67 |
const TDesC& aNextImageFile, CFbsBitmap* aFsBitmap, TBool aStore)
|
|
68 |
{
|
|
69 |
TRACER("CGlxHdmiController::SetImageL()");
|
|
70 |
if (aFsBitmap == NULL || !aImageFile.Length())
|
|
71 |
{
|
|
72 |
GLX_LOG_INFO("CGlxHdmiController::SetImageL() - NULL Uri");
|
|
73 |
return;
|
|
74 |
}
|
|
75 |
if (aStore)
|
|
76 |
{
|
|
77 |
iIsImageSupported = ETrue;
|
|
78 |
StoreImageInfoL(aImageFile, aNextImageFile, aFsBitmap);
|
|
79 |
}
|
|
80 |
if (iGlxTvOut->IsHDMIConnected())
|
|
81 |
{
|
|
82 |
iIsPhotosInForeground = ETrue; // the image should be in posting mode
|
|
83 |
GLX_LOG_INFO("CGlxHdmiController::SetImageL() - 2");
|
|
84 |
// do not close the surface , use the same surface instead.
|
|
85 |
// Call a function to pass imagefile
|
|
86 |
if (!iHdmiContainer)
|
|
87 |
{
|
|
88 |
CreateHdmiContainerL();
|
|
89 |
}
|
|
90 |
if (!iSurfaceUpdater)
|
|
91 |
{
|
|
92 |
// This case would come when surface updater is not created at the first instance and also
|
|
93 |
// it satisfies the 720p condition
|
|
94 |
CreateSurfaceUpdaterL(aImageFile, aNextImageFile);
|
|
95 |
}
|
|
96 |
else
|
|
97 |
{
|
|
98 |
GLX_LOG_INFO("CGlxHdmiController::SetImageL() - 3");
|
|
99 |
iSurfaceUpdater->UpdateNewImageL(aImageFile, aNextImageFile,
|
|
100 |
aFsBitmap);
|
|
101 |
}
|
|
102 |
iHdmiContainer->DrawNow();
|
|
103 |
}
|
|
104 |
}
|
|
105 |
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
// ItemNotSupported
|
|
108 |
// -----------------------------------------------------------------------------
|
|
109 |
EXPORT_C void CGlxHdmiController::ItemNotSupported()
|
|
110 |
{
|
|
111 |
TRACER("CGlxHdmiController::IsVideo()");
|
|
112 |
iIsImageSupported = EFalse;
|
|
113 |
if (iGlxTvOut->IsHDMIConnected())
|
|
114 |
{
|
|
115 |
DestroySurfaceUpdater();
|
|
116 |
}
|
|
117 |
}
|
|
118 |
|
|
119 |
// -----------------------------------------------------------------------------
|
|
120 |
// ActivateZoom
|
|
121 |
// -----------------------------------------------------------------------------
|
|
122 |
EXPORT_C void CGlxHdmiController::ActivateZoom(TBool aAutoZoomOut)
|
|
123 |
{
|
|
124 |
TRACER("CGlxHdmiController::ActivateZoom()");
|
|
125 |
if (iGlxTvOut->IsHDMIConnected() && iSurfaceUpdater)
|
|
126 |
{
|
|
127 |
iSurfaceUpdater->ActivateZoom(aAutoZoomOut);
|
|
128 |
}
|
|
129 |
}
|
|
130 |
|
|
131 |
// -----------------------------------------------------------------------------
|
|
132 |
// DeactivateZoom
|
|
133 |
// -----------------------------------------------------------------------------
|
|
134 |
EXPORT_C void CGlxHdmiController::DeactivateZoom()
|
|
135 |
{
|
|
136 |
TRACER("CGlxHdmiController::DeactivateZoom()");
|
|
137 |
if (iGlxTvOut->IsHDMIConnected() && iSurfaceUpdater)
|
|
138 |
{
|
|
139 |
iSurfaceUpdater->DeactivateZoom();
|
|
140 |
}
|
|
141 |
}
|
|
142 |
|
|
143 |
// -----------------------------------------------------------------------------
|
|
144 |
// ShiftToCloningMode
|
|
145 |
// -----------------------------------------------------------------------------
|
|
146 |
EXPORT_C void CGlxHdmiController::ShiftToCloningMode()
|
|
147 |
{
|
|
148 |
TRACER("CGlxHdmiController::ShiftToCloningMode()");
|
|
149 |
iIsPhotosInForeground = EFalse;
|
|
150 |
// Shift to cloning only if HDMI is connected and surfaceupdater available.
|
|
151 |
if (iGlxTvOut->IsHDMIConnected() && iSurfaceUpdater)
|
|
152 |
{
|
|
153 |
iSurfaceUpdater->ShiftToCloningMode();
|
|
154 |
}
|
|
155 |
}
|
|
156 |
|
|
157 |
// -----------------------------------------------------------------------------
|
|
158 |
// ShiftToPostingMode
|
|
159 |
// -----------------------------------------------------------------------------
|
|
160 |
EXPORT_C void CGlxHdmiController::ShiftToPostingMode()
|
|
161 |
{
|
|
162 |
TRACER("CGlxHdmiController::ShiftToPostingMode()");
|
|
163 |
iIsPhotosInForeground = ETrue;
|
|
164 |
if (iGlxTvOut->IsHDMIConnected())
|
|
165 |
{
|
|
166 |
if (!iSurfaceUpdater)
|
|
167 |
{
|
|
168 |
GLX_LOG_INFO("CGlxHdmiController::ShiftToPostingMode() - 1");
|
|
169 |
// This case would come when HDMI connected, TvOut /headphones being connected
|
|
170 |
// and then it shows a popup of "microphone connected"
|
|
171 |
// thus Background - Foreground when headphones connected during HDMI connected
|
|
172 |
if (iFsBitmap == NULL || !iStoredImagePath->Length())
|
|
173 |
{
|
|
174 |
GLX_LOG_INFO(
|
|
175 |
"CGlxHdmiController::ShiftToPostingMode() - NULL Uri");
|
|
176 |
return;
|
|
177 |
}
|
|
178 |
SetImageL(iStoredImagePath->Des(), KNullDesC, iFsBitmap, EFalse);
|
|
179 |
}
|
|
180 |
else
|
|
181 |
{
|
|
182 |
GLX_LOG_INFO("CGlxHdmiController::ShiftToPostingMode() - 2");
|
|
183 |
iSurfaceUpdater->ShiftToPostingMode();
|
|
184 |
}
|
|
185 |
}
|
|
186 |
}
|
|
187 |
|
|
188 |
// -----------------------------------------------------------------------------
|
|
189 |
// IsHDMIConnected
|
|
190 |
// -----------------------------------------------------------------------------
|
|
191 |
EXPORT_C TBool CGlxHdmiController::IsHDMIConnected()
|
|
192 |
{
|
|
193 |
TRACER("CGlxHdmiController::IsHDMIConnected()");
|
|
194 |
return iGlxTvOut->IsHDMIConnected();
|
|
195 |
}
|
|
196 |
|
|
197 |
// -----------------------------------------------------------------------------
|
|
198 |
// Constructor
|
|
199 |
// -----------------------------------------------------------------------------
|
|
200 |
CGlxHdmiController::CGlxHdmiController(
|
|
201 |
MGlxHDMIDecoderObserver& aDecoderObserver) :
|
|
202 |
iFsBitmap(NULL), iStoredImagePath(NULL), iStoredNextImagePath(NULL),
|
|
203 |
iIsPhotosInForeground(EFalse), iDecoderObserver(aDecoderObserver)
|
|
204 |
{
|
|
205 |
TRACER("CGlxHdmiController::CGlxHdmiController()");
|
|
206 |
// Implement nothing here
|
|
207 |
}
|
|
208 |
|
|
209 |
// -----------------------------------------------------------------------------
|
|
210 |
// ConstructL
|
|
211 |
// -----------------------------------------------------------------------------
|
|
212 |
void CGlxHdmiController::ConstructL()
|
|
213 |
{
|
|
214 |
TRACER("CGlxHdmiController::ConstructL()");
|
|
215 |
iGlxTvOut = CGlxTv::NewL(*this);
|
|
216 |
}
|
|
217 |
|
|
218 |
// -----------------------------------------------------------------------------
|
|
219 |
// DestroyContainer
|
|
220 |
// -----------------------------------------------------------------------------
|
|
221 |
void CGlxHdmiController::DestroyContainer()
|
|
222 |
{
|
|
223 |
TRACER("CGlxHdmiController::DestroyContainer()");
|
|
224 |
if (iHdmiContainer)
|
|
225 |
{
|
|
226 |
GLX_LOG_INFO(
|
|
227 |
"CGlxHdmiController::DestroyHdmi() - deleting iHdmiContainer 1");
|
|
228 |
delete iHdmiContainer;
|
|
229 |
iHdmiContainer = NULL;
|
|
230 |
}
|
|
231 |
}
|
|
232 |
|
|
233 |
// -----------------------------------------------------------------------------
|
|
234 |
// DestroySurfaceUpdater
|
|
235 |
// -----------------------------------------------------------------------------
|
|
236 |
void CGlxHdmiController::DestroySurfaceUpdater()
|
|
237 |
{
|
|
238 |
TRACER("CGlxHdmiController::DestroySurfaceUpdater()");
|
|
239 |
if (iSurfaceUpdater)
|
|
240 |
{
|
|
241 |
delete iSurfaceUpdater;
|
|
242 |
iSurfaceUpdater = NULL;
|
|
243 |
}
|
|
244 |
}
|
|
245 |
|
|
246 |
// -----------------------------------------------------------------------------
|
|
247 |
// CreateHdmiContainerL
|
|
248 |
// -----------------------------------------------------------------------------
|
|
249 |
void CGlxHdmiController::CreateHdmiContainerL()
|
|
250 |
{
|
|
251 |
TRACER("CGlxHdmiController::CreateHdmiContainer()");
|
|
252 |
TRect rect = AlfUtil::ScreenSize();
|
|
253 |
iHdmiContainer = CGlxHdmiContainer::NewL(rect);
|
|
254 |
}
|
|
255 |
|
|
256 |
// -----------------------------------------------------------------------------
|
|
257 |
// CreateSurfaceUpdaterL
|
|
258 |
// -----------------------------------------------------------------------------
|
|
259 |
void CGlxHdmiController::CreateSurfaceUpdaterL(const TDesC& aImageFile,
|
|
260 |
const TDesC& aNextImageFile)
|
|
261 |
{
|
|
262 |
TRACER("CGlxHdmiController::CreateSurfaceUpdater()");
|
|
263 |
RWindow* window = iHdmiContainer->GetWindow();
|
|
264 |
iSurfaceUpdater = CGlxHdmiSurfaceUpdater::NewL(window, aImageFile,
|
|
265 |
aNextImageFile, iFsBitmap, iHdmiContainer, iDecoderObserver);
|
|
266 |
iHdmiContainer->DrawNow();
|
|
267 |
}
|
|
268 |
|
|
269 |
// -----------------------------------------------------------------------------
|
|
270 |
// StoreImageInfoL
|
|
271 |
// -----------------------------------------------------------------------------
|
|
272 |
void CGlxHdmiController::StoreImageInfoL(const TDesC& aImageFile,
|
|
273 |
const TDesC& aNextImageFile, CFbsBitmap* aFsBitmap)
|
|
274 |
{
|
|
275 |
TRACER("CGlxHdmiController::StoreImageInfoL()");
|
|
276 |
if (iStoredImagePath)
|
|
277 |
{
|
|
278 |
delete iStoredImagePath;
|
|
279 |
iStoredImagePath = NULL;
|
|
280 |
}
|
|
281 |
if (iStoredNextImagePath)
|
|
282 |
{
|
|
283 |
delete iStoredNextImagePath;
|
|
284 |
iStoredNextImagePath = NULL;
|
|
285 |
}
|
|
286 |
if (iFsBitmap)
|
|
287 |
{
|
|
288 |
delete iFsBitmap;
|
|
289 |
iFsBitmap = NULL;
|
|
290 |
}
|
|
291 |
iStoredImagePath = aImageFile.AllocL();
|
|
292 |
iStoredNextImagePath = aNextImageFile.AllocL();
|
|
293 |
iFsBitmap = new (ELeave) CFbsBitmap;
|
|
294 |
iFsBitmap->Duplicate(aFsBitmap->Handle());
|
|
295 |
}
|
|
296 |
|
|
297 |
// -----------------------------------------------------------------------------
|
|
298 |
// HandleTvStatusChangedL
|
|
299 |
// -----------------------------------------------------------------------------
|
|
300 |
void CGlxHdmiController::HandleTvStatusChangedL(TTvChangeType aChangeType)
|
|
301 |
{
|
|
302 |
TRACER("CGlxHdmiController::HandleTvStatusChangedL()");
|
|
303 |
if (aChangeType == ETvConnectionChanged)
|
|
304 |
{
|
|
305 |
if (iGlxTvOut->IsHDMIConnected() && iGlxTvOut->IsConnected()
|
|
306 |
&& iSurfaceUpdater)
|
|
307 |
{
|
|
308 |
GLX_LOG_INFO(
|
|
309 |
"CGlxHdmiController::HandleTvStatusChangedL() - HDMI and TV Connected");
|
|
310 |
// Do nothing , as this means HDMI is already connected and headset/tv cable connected
|
|
311 |
// meaning we shouldnt destroy HDMI and neither have to create surface updater.
|
|
312 |
return;
|
|
313 |
}
|
|
314 |
else if (iGlxTvOut->IsHDMIConnected() && iIsImageSupported
|
|
315 |
&& iIsPhotosInForeground)
|
|
316 |
{
|
|
317 |
GLX_LOG_INFO(
|
|
318 |
"CGlxHdmiController::HandleTvStatusChangedL() - HDMI Connected");
|
|
319 |
// Calling SetImageL() with appropriate parameters
|
|
320 |
if (iStoredNextImagePath)
|
|
321 |
{
|
|
322 |
SetImageL(iStoredImagePath->Des(),
|
|
323 |
iStoredNextImagePath->Des(), iFsBitmap, EFalse);
|
|
324 |
}
|
|
325 |
else
|
|
326 |
{
|
|
327 |
SetImageL(iStoredImagePath->Des(), KNullDesC, iFsBitmap,
|
|
328 |
EFalse);
|
|
329 |
}
|
|
330 |
}
|
|
331 |
else
|
|
332 |
{
|
|
333 |
GLX_LOG_INFO3(
|
|
334 |
"CGlxHdmiController::HandleTvStatusChangedL() iIsImageSupported=%d, iGlxTvOut->IsHDMIConnected()=%d, iIsPostingMode=%d",
|
|
335 |
iIsImageSupported, iGlxTvOut->IsHDMIConnected(),
|
|
336 |
iIsPhotosInForeground);
|
|
337 |
// if it gets disconnected, destroy the surface
|
|
338 |
GLX_LOG_INFO(
|
|
339 |
"CGlxHdmiController::HandleTvStatusChangedL() - HDMI Not Connected");
|
|
340 |
DestroySurfaceUpdater();
|
|
341 |
}
|
|
342 |
}
|
|
343 |
}
|
|
344 |
|