|
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 |
|
27 #include "glxhdmicontroller.h" |
|
28 |
|
29 // 720p image size |
|
30 const TInt KHdTvWidth = 1280; |
|
31 const TInt KHdTvHeight = 720; |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // NewLC |
|
35 // ----------------------------------------------------------------------------- |
|
36 EXPORT_C CGlxHdmiController* CGlxHdmiController::NewL(const TDesC& aImageFile) |
|
37 { |
|
38 TRACER("CGlxHdmiController* CGlxHdmiController::NewL()"); |
|
39 CGlxHdmiController* self = new (ELeave) CGlxHdmiController(aImageFile); |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop(self); |
|
43 return self; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // destructor |
|
48 // ----------------------------------------------------------------------------- |
|
49 EXPORT_C CGlxHdmiController::~CGlxHdmiController() |
|
50 { |
|
51 TRACER("CGlxHdmiController::~CGlxHdmiController()"); |
|
52 DestroySurfaceUpdater(); |
|
53 DestroyContainer(); |
|
54 delete iStoredImagePath; |
|
55 iStoredImagePath = NULL; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // Setting an Image Path |
|
60 // ----------------------------------------------------------------------------- |
|
61 EXPORT_C void CGlxHdmiController::SetImageL(const TDesC& aImageFile, |
|
62 TSize aImageDimensions, TInt aFrameCount) |
|
63 { |
|
64 TRACER("CGlxHdmiController::SetImageL()"); |
|
65 StoreImageInfoL(aImageFile, aImageDimensions, aFrameCount); |
|
66 if (iGlxTvOut->IsConnected()) |
|
67 { |
|
68 if(aImageDimensions.iHeight<=KHdTvHeight && |
|
69 aImageDimensions.iWidth<= KHdTvWidth && aFrameCount > 0) |
|
70 { |
|
71 DestroySurfaceUpdater(); |
|
72 if (!iHdmiContainer) |
|
73 { |
|
74 CreateHdmiContainerL(); |
|
75 } |
|
76 CreateSurfaceUpdaterL(aImageFile, aImageDimensions, aFrameCount); |
|
77 } |
|
78 else |
|
79 { |
|
80 // do not close the surface , use the same surface instead. |
|
81 // Call a function to pass imagefile, imagedimension, framecount |
|
82 if (!iHdmiContainer) |
|
83 { |
|
84 CreateHdmiContainerL(); |
|
85 } |
|
86 if (!iSurfaceUpdater) |
|
87 { |
|
88 // This case would come when surface updater is not created at the first instance and also |
|
89 // it satisfies the 720p condition |
|
90 CreateSurfaceUpdaterL(aImageFile, aImageDimensions, aFrameCount); |
|
91 } |
|
92 else |
|
93 { |
|
94 iSurfaceUpdater->UpdateNewImageL(aImageFile, aFrameCount); |
|
95 } |
|
96 iHdmiContainer->DrawNow(); |
|
97 } |
|
98 } |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // IsVideo |
|
103 // ----------------------------------------------------------------------------- |
|
104 EXPORT_C void CGlxHdmiController::IsVideo() |
|
105 { |
|
106 TRACER("CGlxHdmiController::IsVideo()"); |
|
107 if (iGlxTvOut->IsConnected()) |
|
108 { |
|
109 DestroySurfaceUpdater(); |
|
110 } |
|
111 } |
|
112 |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // ActivateZoom |
|
116 // ----------------------------------------------------------------------------- |
|
117 EXPORT_C void CGlxHdmiController::ActivateZoom() |
|
118 { |
|
119 TRACER("CGlxHdmiController::ActivateZoom()"); |
|
120 if (iGlxTvOut->IsConnected()) |
|
121 { |
|
122 iSurfaceUpdater->ActivateZoom(); |
|
123 } |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // DeactivateZoom |
|
128 // ----------------------------------------------------------------------------- |
|
129 EXPORT_C void CGlxHdmiController::DeactivateZoom() |
|
130 { |
|
131 TRACER("CGlxHdmiController::DeactivateZoom()"); |
|
132 if (iGlxTvOut->IsConnected()) |
|
133 { |
|
134 iSurfaceUpdater->DeactivateZoom(); |
|
135 } |
|
136 } |
|
137 // ----------------------------------------------------------------------------- |
|
138 // Constructor |
|
139 // ----------------------------------------------------------------------------- |
|
140 CGlxHdmiController::CGlxHdmiController(const TDesC& aImageFile): |
|
141 iImagePath(aImageFile) |
|
142 { |
|
143 TRACER("CGlxHdmiController::CGlxHdmiController()"); |
|
144 // Implement nothing here |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // ConstructL |
|
149 // ----------------------------------------------------------------------------- |
|
150 void CGlxHdmiController::ConstructL() |
|
151 { |
|
152 TRACER("CGlxHdmiController::ConstructL()"); |
|
153 iGlxTvOut = CGlxTv::NewL(*this); |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // DestroyContainer |
|
158 // ----------------------------------------------------------------------------- |
|
159 void CGlxHdmiController::DestroyContainer() |
|
160 { |
|
161 TRACER("CGlxHdmiController::DestroyContainer()"); |
|
162 if (iHdmiContainer) |
|
163 { |
|
164 GLX_LOG_INFO("CGlxHdmiController::DestroyHdmi() - deleting iHdmiContainer 1"); |
|
165 delete iHdmiContainer; |
|
166 iHdmiContainer = NULL; |
|
167 } |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // DestroySurfaceUpdater |
|
172 // ----------------------------------------------------------------------------- |
|
173 void CGlxHdmiController::DestroySurfaceUpdater() |
|
174 { |
|
175 TRACER("CGlxHdmiController::DestroySurfaceUpdater()"); |
|
176 if (iSurfaceUpdater) |
|
177 { |
|
178 delete iSurfaceUpdater; |
|
179 iSurfaceUpdater = NULL; |
|
180 } |
|
181 } |
|
182 |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CreateHdmiContainerL |
|
186 // ----------------------------------------------------------------------------- |
|
187 void CGlxHdmiController::CreateHdmiContainerL() |
|
188 { |
|
189 TRACER("CGlxHdmiController::CreateHdmiContainer()"); |
|
190 TRect rect = AlfUtil::ScreenSize(); |
|
191 iHdmiContainer = CGlxHdmiContainer::NewL(rect); |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CreateSurfaceUpdaterL |
|
196 // ----------------------------------------------------------------------------- |
|
197 void CGlxHdmiController::CreateSurfaceUpdaterL(const TDesC& aImageFile, |
|
198 TSize aImageDimensions, TInt aFrameCount) |
|
199 { |
|
200 TRACER("CGlxHdmiController::CreateSurfaceUpdater()"); |
|
201 RWindow* window = iHdmiContainer->GetWindow(); |
|
202 iSurfaceUpdater = CGlxHdmiSurfaceUpdater::NewL(window, aImageFile, aImageDimensions, |
|
203 aFrameCount, iHdmiContainer); |
|
204 iHdmiContainer->DrawNow(); |
|
205 } |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // StoreImageInfoL |
|
209 // ----------------------------------------------------------------------------- |
|
210 void CGlxHdmiController::StoreImageInfoL(const TDesC& aImageFile, |
|
211 TSize aImageDimensions, TInt aFrameCount) |
|
212 { |
|
213 TRACER("CGlxHdmiController::StoreImageInfoL()"); |
|
214 iStoredImagePath = aImageFile.AllocL(); |
|
215 iImageDimensions = aImageDimensions; |
|
216 iFrameCount = aFrameCount; |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // HandleTvStatusChangedL |
|
221 // ----------------------------------------------------------------------------- |
|
222 void CGlxHdmiController::HandleTvStatusChangedL( TTvChangeType aChangeType ) |
|
223 { |
|
224 TRACER("CGlxHdmiController::HandleTvStatusChangedL()"); |
|
225 if ( aChangeType == ETvConnectionChanged ) |
|
226 { |
|
227 if ( iGlxTvOut->IsConnected() ) |
|
228 { |
|
229 GLX_LOG_INFO("CGlxHdmiController::HandleTvStatusChangedL() - HDMI Connected"); |
|
230 // Calling SetImageL() with appropriate parameters |
|
231 SetImageL(iStoredImagePath->Des(), iImageDimensions, iFrameCount); |
|
232 } |
|
233 else |
|
234 { |
|
235 // if it gets disconnected, destroy the surface |
|
236 GLX_LOG_INFO("CGlxHdmiController::HandleTvStatusChangedL() - HDMI Not Connected"); |
|
237 DestroySurfaceUpdater(); |
|
238 } |
|
239 } |
|
240 } |
|
241 |