1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmhais/videohai/devvideo/src/DevVideo/devvideobase.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,222 @@
1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "devvideobase.h"
1.20 +#include "devvideoconstants.h"
1.21 +
1.22 +//Include the following headers here just to check they can be compiled OK.
1.23 +#include "Mpeg4Visual.h"
1.24 +#include "AVC.h"
1.25 +#include "H263.h"
1.26 +#include "vc1.h"
1.27 +#include "on2vp6.h"
1.28 +#include "sorensonspark.h"
1.29 +
1.30 +EXPORT_C CCompressedVideoFormat* CCompressedVideoFormat::NewL(const TDesC8& aMimeType,const TDesC8& aOptionalData)
1.31 + {
1.32 + CCompressedVideoFormat* s = new(ELeave) CCompressedVideoFormat;
1.33 + CleanupStack::PushL(s);
1.34 + s->ConstructL(aMimeType, aOptionalData);
1.35 + CleanupStack::Pop(s);
1.36 + return s;
1.37 + }
1.38 +
1.39 +EXPORT_C CCompressedVideoFormat* CCompressedVideoFormat::NewL(const CCompressedVideoFormat& aFormat)
1.40 + {
1.41 + CCompressedVideoFormat* s = new(ELeave) CCompressedVideoFormat;
1.42 + CleanupStack::PushL(s);
1.43 + s->ConstructL(aFormat.MimeType(), aFormat.OptionalData());
1.44 + CleanupStack::Pop(s);
1.45 + return s;
1.46 + }
1.47 +
1.48 +EXPORT_C CCompressedVideoFormat::~CCompressedVideoFormat()
1.49 + {
1.50 + delete iMimeType;
1.51 + delete iOptionalData;
1.52 + }
1.53 +
1.54 +EXPORT_C const TDesC8& CCompressedVideoFormat::MimeType() const
1.55 + {
1.56 + return *iMimeType;
1.57 + }
1.58 +
1.59 +EXPORT_C const TDesC8& CCompressedVideoFormat::OptionalData() const
1.60 + {
1.61 + return *iOptionalData;
1.62 + }
1.63 +
1.64 +CCompressedVideoFormat::CCompressedVideoFormat()
1.65 + {
1.66 + }
1.67 +
1.68 +void CCompressedVideoFormat::ConstructL(const TDesC8& aMimeType, const TDesC8& aOptionalData)
1.69 + {
1.70 + iMimeType = aMimeType.AllocL();
1.71 + iOptionalData = aOptionalData.AllocL();
1.72 + }
1.73 +
1.74 +EXPORT_C TBool CCompressedVideoFormat::operator==(const CCompressedVideoFormat& aOther) const
1.75 + {
1.76 + TBool retval = EFalse;
1.77 + // only test optionalData if aOther has an optional data of length > 0. Need a
1.78 + // check like this for performing matches on mimetype only.
1.79 + if (aOther.OptionalData().Length() > 0)
1.80 + retval = ((aOther.MimeType().CompareF(*iMimeType) == 0) && (aOther.OptionalData().CompareF(*iOptionalData) == 0));
1.81 + else
1.82 + retval = ((aOther.MimeType().CompareF(*iMimeType) == 0));
1.83 + return retval;
1.84 + }
1.85 +
1.86 +
1.87 +
1.88 +EXPORT_C CSystemClockSource* CSystemClockSource::NewL()
1.89 + {
1.90 + CSystemClockSource* s = new(ELeave) CSystemClockSource;
1.91 + CleanupStack::PushL(s);
1.92 + s->ConstructL();
1.93 + CleanupStack::Pop(s);
1.94 + return s;
1.95 + }
1.96 +
1.97 +CSystemClockSource::CSystemClockSource()
1.98 + {
1.99 + iStartTime.UniversalTime();
1.100 + iTimeSuspended = 0;
1.101 + }
1.102 +
1.103 +void CSystemClockSource::ConstructL()
1.104 + {
1.105 + User::LeaveIfError(iCriticalSection.CreateLocal());
1.106 + }
1.107 +
1.108 +EXPORT_C CSystemClockSource::~CSystemClockSource()
1.109 + {
1.110 + iCriticalSection.Close();
1.111 + }
1.112 +
1.113 +TAny* CSystemClockSource::CustomInterface(TUid /*aInterface*/)
1.114 + {
1.115 + return NULL;
1.116 + }
1.117 +
1.118 +EXPORT_C void CSystemClockSource::Reset()
1.119 + {
1.120 + iCriticalSection.Wait();
1.121 + iStartTime.UniversalTime();
1.122 + iOffset = 0;
1.123 + iTimeSuspended = 0;
1.124 + iCriticalSection.Signal();
1.125 + }
1.126 +
1.127 +EXPORT_C void CSystemClockSource::Reset(const TTimeIntervalMicroSeconds& aOffset)
1.128 + {
1.129 + iCriticalSection.Wait();
1.130 + iStartTime.UniversalTime();
1.131 + iOffset = aOffset;
1.132 + iTimeSuspended = 0;
1.133 + iCriticalSection.Signal();
1.134 + }
1.135 +
1.136 +TTimeIntervalMicroSeconds CSystemClockSource::Time()
1.137 + {
1.138 + iCriticalSection.Wait();
1.139 + TTimeIntervalMicroSeconds elapsed(0);
1.140 + if (!iSuspended)
1.141 + {
1.142 + iCurrentTime.UniversalTime();
1.143 + elapsed = iCurrentTime.MicroSecondsFrom(iStartTime);
1.144 + }
1.145 + else
1.146 + {
1.147 + // If we're currently suspended, current time == time when we were suspended
1.148 + elapsed = iTimeWhenSuspended.MicroSecondsFrom(iStartTime);
1.149 + }
1.150 +
1.151 + // Perceived elapsed time == true elapsed + offset - time spent suspended
1.152 + TInt64 time = elapsed.Int64() + iOffset.Int64() - iTimeSuspended.Int64();
1.153 + iCriticalSection.Signal();
1.154 + return time;
1.155 + }
1.156 +
1.157 +EXPORT_C void CSystemClockSource::Suspend()
1.158 + {
1.159 + __ASSERT_DEBUG(!iSuspended, DevVideoPanic(EDevVideoPanicPreConditionViolation));
1.160 + iCriticalSection.Wait();
1.161 + iTimeWhenSuspended.UniversalTime();
1.162 + iSuspended = ETrue;
1.163 + iCriticalSection.Signal();
1.164 + }
1.165 +
1.166 +EXPORT_C void CSystemClockSource::Resume()
1.167 + {
1.168 + __ASSERT_DEBUG(iSuspended, DevVideoPanic(EDevVideoPanicPreConditionViolation));
1.169 + iCriticalSection.Wait();
1.170 + iSuspended = EFalse;
1.171 + iCurrentTime.UniversalTime();
1.172 + iTimeSuspended = iTimeSuspended.Int64() + iCurrentTime.MicroSecondsFrom(iTimeWhenSuspended).Int64();
1.173 + iCriticalSection.Signal();
1.174 + }
1.175 +
1.176 +
1.177 +EXPORT_C CMMFClockSourcePeriodicUtility* CMMFClockSourcePeriodicUtility::NewL(MMMFClockSource& aClockSource, MMMFClockSourcePeriodicUtilityObserver& aObserver)
1.178 + {
1.179 + CMMFClockSourcePeriodicUtility* s = new(ELeave) CMMFClockSourcePeriodicUtility(aClockSource, aObserver);
1.180 + CleanupStack::PushL(s);
1.181 + s->ConstructL();
1.182 + CleanupStack::Pop(s);
1.183 + return s;
1.184 + }
1.185 +
1.186 +CMMFClockSourcePeriodicUtility::CMMFClockSourcePeriodicUtility(MMMFClockSource& aClockSource, MMMFClockSourcePeriodicUtilityObserver& aObserver) :
1.187 + iClockSource(aClockSource),
1.188 + iObserver(aObserver)
1.189 + {
1.190 + }
1.191 +
1.192 +void CMMFClockSourcePeriodicUtility::ConstructL()
1.193 + {
1.194 + iTimer = CPeriodic::NewL(EPriorityNormal);
1.195 + }
1.196 +
1.197 +EXPORT_C void CMMFClockSourcePeriodicUtility::Start(TTimeIntervalMicroSeconds32 aPeriod)
1.198 + {
1.199 + TCallBack callback(CMMFClockSourcePeriodicUtility::Callback, this);
1.200 + iTimer->Start(aPeriod, aPeriod, callback);
1.201 + }
1.202 +
1.203 +EXPORT_C void CMMFClockSourcePeriodicUtility::Stop()
1.204 + {
1.205 + iTimer->Cancel();
1.206 + }
1.207 +
1.208 +EXPORT_C CMMFClockSourcePeriodicUtility::~CMMFClockSourcePeriodicUtility()
1.209 + {
1.210 + delete iTimer;
1.211 + }
1.212 +
1.213 +TInt CMMFClockSourcePeriodicUtility::Callback(TAny* aAny)
1.214 + {
1.215 + CMMFClockSourcePeriodicUtility* me = reinterpret_cast<CMMFClockSourcePeriodicUtility*>(aAny);
1.216 + me->DoCallback();
1.217 + return KErrNone;
1.218 + }
1.219 +
1.220 +void CMMFClockSourcePeriodicUtility::DoCallback()
1.221 + {
1.222 + iObserver.MmcspuoTick(iClockSource.Time());
1.223 + }
1.224 +
1.225 +