sl@0: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "devvideobase.h" sl@0: #include "devvideoconstants.h" sl@0: sl@0: //Include the following headers here just to check they can be compiled OK. sl@0: #include "Mpeg4Visual.h" sl@0: #include "AVC.h" sl@0: #include "H263.h" sl@0: #include "vc1.h" sl@0: #include "on2vp6.h" sl@0: #include "sorensonspark.h" sl@0: sl@0: EXPORT_C CCompressedVideoFormat* CCompressedVideoFormat::NewL(const TDesC8& aMimeType,const TDesC8& aOptionalData) sl@0: { sl@0: CCompressedVideoFormat* s = new(ELeave) CCompressedVideoFormat; sl@0: CleanupStack::PushL(s); sl@0: s->ConstructL(aMimeType, aOptionalData); sl@0: CleanupStack::Pop(s); sl@0: return s; sl@0: } sl@0: sl@0: EXPORT_C CCompressedVideoFormat* CCompressedVideoFormat::NewL(const CCompressedVideoFormat& aFormat) sl@0: { sl@0: CCompressedVideoFormat* s = new(ELeave) CCompressedVideoFormat; sl@0: CleanupStack::PushL(s); sl@0: s->ConstructL(aFormat.MimeType(), aFormat.OptionalData()); sl@0: CleanupStack::Pop(s); sl@0: return s; sl@0: } sl@0: sl@0: EXPORT_C CCompressedVideoFormat::~CCompressedVideoFormat() sl@0: { sl@0: delete iMimeType; sl@0: delete iOptionalData; sl@0: } sl@0: sl@0: EXPORT_C const TDesC8& CCompressedVideoFormat::MimeType() const sl@0: { sl@0: return *iMimeType; sl@0: } sl@0: sl@0: EXPORT_C const TDesC8& CCompressedVideoFormat::OptionalData() const sl@0: { sl@0: return *iOptionalData; sl@0: } sl@0: sl@0: CCompressedVideoFormat::CCompressedVideoFormat() sl@0: { sl@0: } sl@0: sl@0: void CCompressedVideoFormat::ConstructL(const TDesC8& aMimeType, const TDesC8& aOptionalData) sl@0: { sl@0: iMimeType = aMimeType.AllocL(); sl@0: iOptionalData = aOptionalData.AllocL(); sl@0: } sl@0: sl@0: EXPORT_C TBool CCompressedVideoFormat::operator==(const CCompressedVideoFormat& aOther) const sl@0: { sl@0: TBool retval = EFalse; sl@0: // only test optionalData if aOther has an optional data of length > 0. Need a sl@0: // check like this for performing matches on mimetype only. sl@0: if (aOther.OptionalData().Length() > 0) sl@0: retval = ((aOther.MimeType().CompareF(*iMimeType) == 0) && (aOther.OptionalData().CompareF(*iOptionalData) == 0)); sl@0: else sl@0: retval = ((aOther.MimeType().CompareF(*iMimeType) == 0)); sl@0: return retval; sl@0: } sl@0: sl@0: sl@0: sl@0: EXPORT_C CSystemClockSource* CSystemClockSource::NewL() sl@0: { sl@0: CSystemClockSource* s = new(ELeave) CSystemClockSource; sl@0: CleanupStack::PushL(s); sl@0: s->ConstructL(); sl@0: CleanupStack::Pop(s); sl@0: return s; sl@0: } sl@0: sl@0: CSystemClockSource::CSystemClockSource() sl@0: { sl@0: iStartTime.UniversalTime(); sl@0: iTimeSuspended = 0; sl@0: } sl@0: sl@0: void CSystemClockSource::ConstructL() sl@0: { sl@0: User::LeaveIfError(iCriticalSection.CreateLocal()); sl@0: } sl@0: sl@0: EXPORT_C CSystemClockSource::~CSystemClockSource() sl@0: { sl@0: iCriticalSection.Close(); sl@0: } sl@0: sl@0: TAny* CSystemClockSource::CustomInterface(TUid /*aInterface*/) sl@0: { sl@0: return NULL; sl@0: } sl@0: sl@0: EXPORT_C void CSystemClockSource::Reset() sl@0: { sl@0: iCriticalSection.Wait(); sl@0: iStartTime.UniversalTime(); sl@0: iOffset = 0; sl@0: iTimeSuspended = 0; sl@0: iCriticalSection.Signal(); sl@0: } sl@0: sl@0: EXPORT_C void CSystemClockSource::Reset(const TTimeIntervalMicroSeconds& aOffset) sl@0: { sl@0: iCriticalSection.Wait(); sl@0: iStartTime.UniversalTime(); sl@0: iOffset = aOffset; sl@0: iTimeSuspended = 0; sl@0: iCriticalSection.Signal(); sl@0: } sl@0: sl@0: TTimeIntervalMicroSeconds CSystemClockSource::Time() sl@0: { sl@0: iCriticalSection.Wait(); sl@0: TTimeIntervalMicroSeconds elapsed(0); sl@0: if (!iSuspended) sl@0: { sl@0: iCurrentTime.UniversalTime(); sl@0: elapsed = iCurrentTime.MicroSecondsFrom(iStartTime); sl@0: } sl@0: else sl@0: { sl@0: // If we're currently suspended, current time == time when we were suspended sl@0: elapsed = iTimeWhenSuspended.MicroSecondsFrom(iStartTime); sl@0: } sl@0: sl@0: // Perceived elapsed time == true elapsed + offset - time spent suspended sl@0: TInt64 time = elapsed.Int64() + iOffset.Int64() - iTimeSuspended.Int64(); sl@0: iCriticalSection.Signal(); sl@0: return time; sl@0: } sl@0: sl@0: EXPORT_C void CSystemClockSource::Suspend() sl@0: { sl@0: __ASSERT_DEBUG(!iSuspended, DevVideoPanic(EDevVideoPanicPreConditionViolation)); sl@0: iCriticalSection.Wait(); sl@0: iTimeWhenSuspended.UniversalTime(); sl@0: iSuspended = ETrue; sl@0: iCriticalSection.Signal(); sl@0: } sl@0: sl@0: EXPORT_C void CSystemClockSource::Resume() sl@0: { sl@0: __ASSERT_DEBUG(iSuspended, DevVideoPanic(EDevVideoPanicPreConditionViolation)); sl@0: iCriticalSection.Wait(); sl@0: iSuspended = EFalse; sl@0: iCurrentTime.UniversalTime(); sl@0: iTimeSuspended = iTimeSuspended.Int64() + iCurrentTime.MicroSecondsFrom(iTimeWhenSuspended).Int64(); sl@0: iCriticalSection.Signal(); sl@0: } sl@0: sl@0: sl@0: EXPORT_C CMMFClockSourcePeriodicUtility* CMMFClockSourcePeriodicUtility::NewL(MMMFClockSource& aClockSource, MMMFClockSourcePeriodicUtilityObserver& aObserver) sl@0: { sl@0: CMMFClockSourcePeriodicUtility* s = new(ELeave) CMMFClockSourcePeriodicUtility(aClockSource, aObserver); sl@0: CleanupStack::PushL(s); sl@0: s->ConstructL(); sl@0: CleanupStack::Pop(s); sl@0: return s; sl@0: } sl@0: sl@0: CMMFClockSourcePeriodicUtility::CMMFClockSourcePeriodicUtility(MMMFClockSource& aClockSource, MMMFClockSourcePeriodicUtilityObserver& aObserver) : sl@0: iClockSource(aClockSource), sl@0: iObserver(aObserver) sl@0: { sl@0: } sl@0: sl@0: void CMMFClockSourcePeriodicUtility::ConstructL() sl@0: { sl@0: iTimer = CPeriodic::NewL(EPriorityNormal); sl@0: } sl@0: sl@0: EXPORT_C void CMMFClockSourcePeriodicUtility::Start(TTimeIntervalMicroSeconds32 aPeriod) sl@0: { sl@0: TCallBack callback(CMMFClockSourcePeriodicUtility::Callback, this); sl@0: iTimer->Start(aPeriod, aPeriod, callback); sl@0: } sl@0: sl@0: EXPORT_C void CMMFClockSourcePeriodicUtility::Stop() sl@0: { sl@0: iTimer->Cancel(); sl@0: } sl@0: sl@0: EXPORT_C CMMFClockSourcePeriodicUtility::~CMMFClockSourcePeriodicUtility() sl@0: { sl@0: delete iTimer; sl@0: } sl@0: sl@0: TInt CMMFClockSourcePeriodicUtility::Callback(TAny* aAny) sl@0: { sl@0: CMMFClockSourcePeriodicUtility* me = reinterpret_cast(aAny); sl@0: me->DoCallback(); sl@0: return KErrNone; sl@0: } sl@0: sl@0: void CMMFClockSourcePeriodicUtility::DoCallback() sl@0: { sl@0: iObserver.MmcspuoTick(iClockSource.Time()); sl@0: } sl@0: sl@0: