|
1 /* |
|
2 * Copyright (c) 2008 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: Video Source subsystem. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cmultiframedataao.h" |
|
21 #include "mmultiframeprovider.h" |
|
22 #include "cmultiframeprovider.h" |
|
23 #include "VSPanic.h" |
|
24 |
|
25 // MACROS |
|
26 |
|
27 #ifdef _DEBUG |
|
28 # define __IF_DEBUG(t) {RDebug::t;} |
|
29 #else |
|
30 # define __IF_DEBUG(t) |
|
31 #endif |
|
32 // ============================ CMultiframeDataAO =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CMultiframeDataAO::CMultiframeDataAO( CMultiframeProvider* aRequester ) |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CMultiframeDataAO::CMultiframeDataAO( CMultiframeProvider* aRequester ) |
|
39 : CTimer( EPriorityHigh ), iRequester( aRequester ) |
|
40 { |
|
41 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::CMultiframeDataAO() >>"), RThread().Id().operator TUint())); |
|
42 RThread me; |
|
43 iThreadId = me.Id(); |
|
44 CActiveScheduler::Add( this ); |
|
45 TRAP_IGNORE(CTimer::ConstructL()); |
|
46 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::CMultiframeDataAO() <<"), RThread().Id().operator TUint())); |
|
47 } |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CMultiframeDataAO::SetObserver( MMultiframeprovider* aObserever ) |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 void CMultiframeDataAO::SetObserver( MMultiframeprovider* aObserver ) |
|
53 { |
|
54 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::SetObserver() >>"), RThread().Id().operator TUint())); |
|
55 iObserver = aObserver; |
|
56 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::SetObserver() <<"), RThread().Id().operator TUint())); |
|
57 } |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CMultiframeDataAO::~CMultiframeDataAO() |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CMultiframeDataAO::~CMultiframeDataAO() |
|
63 { |
|
64 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::~CMultiframeDataAO() >>"), RThread().Id().operator TUint())); |
|
65 Cancel(); |
|
66 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::~CMultiframeDataAO() <<"), RThread().Id().operator TUint())); |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CMultiframeDataAO::Activate( ) |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CMultiframeDataAO::Activate( TTimeIntervalMicroSeconds aUpdateTime, TBool aInit, TBool aVFUpdate ) |
|
74 { |
|
75 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::Activate() >>"), RThread().Id().operator TUint())); |
|
76 |
|
77 TTimeIntervalMicroSeconds32 time = aUpdateTime.Int64(); |
|
78 iInit = aInit; |
|
79 iVFUpdate = aVFUpdate; |
|
80 if ( !IsActive() ) |
|
81 { |
|
82 CTimer::After( time ); |
|
83 } |
|
84 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::Activate() <<"), RThread().Id().operator TUint())); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CMultiframeDataAO::LocalBuffer( ) |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CMultiframeDataAO::LocalBuffer( CVtImageBitmap* aLocalBuffer ) |
|
92 { |
|
93 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::LocalBuffer() >>"), RThread().Id().operator TUint())); |
|
94 iLocalBuffer.iBitmap = aLocalBuffer; |
|
95 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::LocalBuffer() <<"), RThread().Id().operator TUint())); |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CMultiframeDataAO::RemoteBuffer( ) |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CMultiframeDataAO::RemoteBuffer( CVtImageBitmap* aRemoteBuffer ) |
|
103 { |
|
104 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::RemoteBuffer() >>"), RThread().Id().operator TUint())); |
|
105 iRemoteBuffer.iBitmap = aRemoteBuffer; |
|
106 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::RemoteBuffer() <<"), RThread().Id().operator TUint())); |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CMultiframeDataAO::RunL() |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 void CMultiframeDataAO::RunL() |
|
114 { |
|
115 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::RunL() >>"), RThread().Id().operator TUint())); |
|
116 |
|
117 //stop loop ao |
|
118 if (iRequireStopping) |
|
119 { |
|
120 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::RunL() cancel by flag"), RThread().Id().operator TUint())); |
|
121 iRequireStopping = EFalse; |
|
122 return; |
|
123 } |
|
124 |
|
125 if ( !iVFUpdate ) |
|
126 { |
|
127 iObserver->RefreshYUVData( iRemoteBuffer ); |
|
128 } |
|
129 iObserver->RefreshViewFinder( iLocalBuffer ); |
|
130 iRequester->UseSecondVfBuffer(); |
|
131 if ( iInit ) |
|
132 { |
|
133 iObserver->InitializeReady(); |
|
134 } |
|
135 if ( !iVFUpdate ) |
|
136 { |
|
137 iRequester->AddBitmapToFreeQueue(); |
|
138 } |
|
139 if ( !iInit && !iVFUpdate ) |
|
140 { |
|
141 iRequester->NextFrame(); |
|
142 } |
|
143 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::RunL() <<"), RThread().Id().operator TUint())); |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CMultiframeDataAO::CancelTimeLoop() |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 void CMultiframeDataAO::CancelTimeLoop() |
|
151 { |
|
152 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::CancelTimeLoop >>"), RThread().Id().operator TUint())); |
|
153 if ( IsActive() ) |
|
154 { |
|
155 if ( iStatus == KRequestPending ) |
|
156 { |
|
157 RThread me; |
|
158 if ( me.Id() == iThreadId ) |
|
159 { |
|
160 Cancel(); |
|
161 iRequireStopping = EFalse; |
|
162 } |
|
163 else |
|
164 { |
|
165 iRequireStopping = ETrue; |
|
166 } |
|
167 } |
|
168 else |
|
169 { |
|
170 iRequireStopping = ETrue; |
|
171 } |
|
172 } |
|
173 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeDataAO::CancelTimeLoop <<"), RThread().Id().operator TUint())); |
|
174 } |
|
175 |
|
176 |
|
177 // End of File |