|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "devvideobase.h" |
|
17 #include "devvideoconstants.h" |
|
18 |
|
19 //Include the following headers here just to check they can be compiled OK. |
|
20 #include "Mpeg4Visual.h" |
|
21 #include "AVC.h" |
|
22 #include "H263.h" |
|
23 #include "vc1.h" |
|
24 #include "on2vp6.h" |
|
25 #include "sorensonspark.h" |
|
26 |
|
27 EXPORT_C CCompressedVideoFormat* CCompressedVideoFormat::NewL(const TDesC8& aMimeType,const TDesC8& aOptionalData) |
|
28 { |
|
29 CCompressedVideoFormat* s = new(ELeave) CCompressedVideoFormat; |
|
30 CleanupStack::PushL(s); |
|
31 s->ConstructL(aMimeType, aOptionalData); |
|
32 CleanupStack::Pop(s); |
|
33 return s; |
|
34 } |
|
35 |
|
36 EXPORT_C CCompressedVideoFormat* CCompressedVideoFormat::NewL(const CCompressedVideoFormat& aFormat) |
|
37 { |
|
38 CCompressedVideoFormat* s = new(ELeave) CCompressedVideoFormat; |
|
39 CleanupStack::PushL(s); |
|
40 s->ConstructL(aFormat.MimeType(), aFormat.OptionalData()); |
|
41 CleanupStack::Pop(s); |
|
42 return s; |
|
43 } |
|
44 |
|
45 EXPORT_C CCompressedVideoFormat::~CCompressedVideoFormat() |
|
46 { |
|
47 delete iMimeType; |
|
48 delete iOptionalData; |
|
49 } |
|
50 |
|
51 EXPORT_C const TDesC8& CCompressedVideoFormat::MimeType() const |
|
52 { |
|
53 return *iMimeType; |
|
54 } |
|
55 |
|
56 EXPORT_C const TDesC8& CCompressedVideoFormat::OptionalData() const |
|
57 { |
|
58 return *iOptionalData; |
|
59 } |
|
60 |
|
61 CCompressedVideoFormat::CCompressedVideoFormat() |
|
62 { |
|
63 } |
|
64 |
|
65 void CCompressedVideoFormat::ConstructL(const TDesC8& aMimeType, const TDesC8& aOptionalData) |
|
66 { |
|
67 iMimeType = aMimeType.AllocL(); |
|
68 iOptionalData = aOptionalData.AllocL(); |
|
69 } |
|
70 |
|
71 EXPORT_C TBool CCompressedVideoFormat::operator==(const CCompressedVideoFormat& aOther) const |
|
72 { |
|
73 TBool retval = EFalse; |
|
74 // only test optionalData if aOther has an optional data of length > 0. Need a |
|
75 // check like this for performing matches on mimetype only. |
|
76 if (aOther.OptionalData().Length() > 0) |
|
77 retval = ((aOther.MimeType().CompareF(*iMimeType) == 0) && (aOther.OptionalData().CompareF(*iOptionalData) == 0)); |
|
78 else |
|
79 retval = ((aOther.MimeType().CompareF(*iMimeType) == 0)); |
|
80 return retval; |
|
81 } |
|
82 |
|
83 |
|
84 |
|
85 EXPORT_C CSystemClockSource* CSystemClockSource::NewL() |
|
86 { |
|
87 CSystemClockSource* s = new(ELeave) CSystemClockSource; |
|
88 CleanupStack::PushL(s); |
|
89 s->ConstructL(); |
|
90 CleanupStack::Pop(s); |
|
91 return s; |
|
92 } |
|
93 |
|
94 CSystemClockSource::CSystemClockSource() |
|
95 { |
|
96 iStartTime.UniversalTime(); |
|
97 iTimeSuspended = 0; |
|
98 } |
|
99 |
|
100 void CSystemClockSource::ConstructL() |
|
101 { |
|
102 User::LeaveIfError(iCriticalSection.CreateLocal()); |
|
103 } |
|
104 |
|
105 EXPORT_C CSystemClockSource::~CSystemClockSource() |
|
106 { |
|
107 iCriticalSection.Close(); |
|
108 } |
|
109 |
|
110 TAny* CSystemClockSource::CustomInterface(TUid /*aInterface*/) |
|
111 { |
|
112 return NULL; |
|
113 } |
|
114 |
|
115 EXPORT_C void CSystemClockSource::Reset() |
|
116 { |
|
117 iCriticalSection.Wait(); |
|
118 iStartTime.UniversalTime(); |
|
119 iOffset = 0; |
|
120 iTimeSuspended = 0; |
|
121 iCriticalSection.Signal(); |
|
122 } |
|
123 |
|
124 EXPORT_C void CSystemClockSource::Reset(const TTimeIntervalMicroSeconds& aOffset) |
|
125 { |
|
126 iCriticalSection.Wait(); |
|
127 iStartTime.UniversalTime(); |
|
128 iOffset = aOffset; |
|
129 iTimeSuspended = 0; |
|
130 iCriticalSection.Signal(); |
|
131 } |
|
132 |
|
133 TTimeIntervalMicroSeconds CSystemClockSource::Time() |
|
134 { |
|
135 iCriticalSection.Wait(); |
|
136 TTimeIntervalMicroSeconds elapsed(0); |
|
137 if (!iSuspended) |
|
138 { |
|
139 iCurrentTime.UniversalTime(); |
|
140 elapsed = iCurrentTime.MicroSecondsFrom(iStartTime); |
|
141 } |
|
142 else |
|
143 { |
|
144 // If we're currently suspended, current time == time when we were suspended |
|
145 elapsed = iTimeWhenSuspended.MicroSecondsFrom(iStartTime); |
|
146 } |
|
147 |
|
148 // Perceived elapsed time == true elapsed + offset - time spent suspended |
|
149 TInt64 time = elapsed.Int64() + iOffset.Int64() - iTimeSuspended.Int64(); |
|
150 iCriticalSection.Signal(); |
|
151 return time; |
|
152 } |
|
153 |
|
154 EXPORT_C void CSystemClockSource::Suspend() |
|
155 { |
|
156 __ASSERT_DEBUG(!iSuspended, DevVideoPanic(EDevVideoPanicPreConditionViolation)); |
|
157 iCriticalSection.Wait(); |
|
158 iTimeWhenSuspended.UniversalTime(); |
|
159 iSuspended = ETrue; |
|
160 iCriticalSection.Signal(); |
|
161 } |
|
162 |
|
163 EXPORT_C void CSystemClockSource::Resume() |
|
164 { |
|
165 __ASSERT_DEBUG(iSuspended, DevVideoPanic(EDevVideoPanicPreConditionViolation)); |
|
166 iCriticalSection.Wait(); |
|
167 iSuspended = EFalse; |
|
168 iCurrentTime.UniversalTime(); |
|
169 iTimeSuspended = iTimeSuspended.Int64() + iCurrentTime.MicroSecondsFrom(iTimeWhenSuspended).Int64(); |
|
170 iCriticalSection.Signal(); |
|
171 } |
|
172 |
|
173 |
|
174 EXPORT_C CMMFClockSourcePeriodicUtility* CMMFClockSourcePeriodicUtility::NewL(MMMFClockSource& aClockSource, MMMFClockSourcePeriodicUtilityObserver& aObserver) |
|
175 { |
|
176 CMMFClockSourcePeriodicUtility* s = new(ELeave) CMMFClockSourcePeriodicUtility(aClockSource, aObserver); |
|
177 CleanupStack::PushL(s); |
|
178 s->ConstructL(); |
|
179 CleanupStack::Pop(s); |
|
180 return s; |
|
181 } |
|
182 |
|
183 CMMFClockSourcePeriodicUtility::CMMFClockSourcePeriodicUtility(MMMFClockSource& aClockSource, MMMFClockSourcePeriodicUtilityObserver& aObserver) : |
|
184 iClockSource(aClockSource), |
|
185 iObserver(aObserver) |
|
186 { |
|
187 } |
|
188 |
|
189 void CMMFClockSourcePeriodicUtility::ConstructL() |
|
190 { |
|
191 iTimer = CPeriodic::NewL(EPriorityNormal); |
|
192 } |
|
193 |
|
194 EXPORT_C void CMMFClockSourcePeriodicUtility::Start(TTimeIntervalMicroSeconds32 aPeriod) |
|
195 { |
|
196 TCallBack callback(CMMFClockSourcePeriodicUtility::Callback, this); |
|
197 iTimer->Start(aPeriod, aPeriod, callback); |
|
198 } |
|
199 |
|
200 EXPORT_C void CMMFClockSourcePeriodicUtility::Stop() |
|
201 { |
|
202 iTimer->Cancel(); |
|
203 } |
|
204 |
|
205 EXPORT_C CMMFClockSourcePeriodicUtility::~CMMFClockSourcePeriodicUtility() |
|
206 { |
|
207 delete iTimer; |
|
208 } |
|
209 |
|
210 TInt CMMFClockSourcePeriodicUtility::Callback(TAny* aAny) |
|
211 { |
|
212 CMMFClockSourcePeriodicUtility* me = reinterpret_cast<CMMFClockSourcePeriodicUtility*>(aAny); |
|
213 me->DoCallback(); |
|
214 return KErrNone; |
|
215 } |
|
216 |
|
217 void CMMFClockSourcePeriodicUtility::DoCallback() |
|
218 { |
|
219 iObserver.MmcspuoTick(iClockSource.Time()); |
|
220 } |
|
221 |
|
222 |