|
1 /* |
|
2 * Copyright (c) 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 |
|
19 #include "baseprofiletimestamping.h" |
|
20 |
|
21 _LIT(KErrDialogTimestampCheckFailed, "A timestamp check failed on Component: %S, Port: %d. Expected time: %u +/- %u, actual: %Lu"); |
|
22 _LIT(KErrDialogTimestampComparisonFailed, "A timestamp compare with clock media time failed on Component: %S, Port: %d. Media time: %Lu, delay allowed: %u, actual: %Lu"); |
|
23 |
|
24 CBaseProfileTimestampHandling::CBaseProfileTimestampHandling(ROmxScriptTest& aTestOwner, RASBreakEventHandler& aParentEventHandler) |
|
25 : CBaseProfileHandler(aTestOwner, aParentEventHandler) |
|
26 { |
|
27 } |
|
28 |
|
29 CBaseProfileTimestampHandling::~CBaseProfileTimestampHandling() |
|
30 { |
|
31 iPendingTimestampChecks.Close(); |
|
32 } |
|
33 |
|
34 void CBaseProfileTimestampHandling::SetClockComponent(OMX_COMPONENTTYPE* aClockComponent) |
|
35 { |
|
36 iClockComponent = aClockComponent; |
|
37 } |
|
38 |
|
39 void CBaseProfileTimestampHandling::QueueTimestampCheckL(TInt aPortIndex, TUint aTime, TUint aTolerance) |
|
40 { |
|
41 TTimestampCheckingInfo timestampCheck; |
|
42 timestampCheck.iPortIndex = aPortIndex; |
|
43 timestampCheck.iExpectedTime = aTime; |
|
44 timestampCheck.iTolerance = aTolerance; |
|
45 timestampCheck.iCompareWithRefClock = EFalse; |
|
46 |
|
47 iPendingTimestampChecks.AppendL(timestampCheck); |
|
48 } |
|
49 |
|
50 void CBaseProfileTimestampHandling::QueueCompareWithRefClockL(TInt aPortIndex, TUint aTolerance) |
|
51 { |
|
52 TTimestampCheckingInfo timestampCheck; |
|
53 timestampCheck.iPortIndex = aPortIndex; |
|
54 timestampCheck.iExpectedTime = 0; |
|
55 timestampCheck.iTolerance = aTolerance; |
|
56 timestampCheck.iCompareWithRefClock = ETrue; |
|
57 |
|
58 iPendingTimestampChecks.AppendL(timestampCheck); |
|
59 } |
|
60 |
|
61 void CBaseProfileTimestampHandling::DoFillBufferDone(OMX_BUFFERHEADERTYPE* aFilledBuffer) |
|
62 { |
|
63 CheckTimestamp(aFilledBuffer); |
|
64 } |
|
65 |
|
66 void CBaseProfileTimestampHandling::DoEmptyBufferDone(OMX_BUFFERHEADERTYPE* aEmptiedBuffer) |
|
67 { |
|
68 CheckTimestamp(aEmptiedBuffer); |
|
69 } |
|
70 |
|
71 void CBaseProfileTimestampHandling::CheckTimestamp(OMX_BUFFERHEADERTYPE* aBuffer) |
|
72 { |
|
73 TInt bufferIndex = iBufferHeaders.Find(*aBuffer, CBaseProfileHandler::BufferHeaderMatchComparison); |
|
74 |
|
75 for (TInt index=0; index < iPendingTimestampChecks.Count(); index++) |
|
76 { |
|
77 if (iBufferHeaders[bufferIndex]->iPortIndex != iPendingTimestampChecks[index].iPortIndex) |
|
78 { |
|
79 continue; |
|
80 } |
|
81 TTimestampCheckingInfo passCriteria = iPendingTimestampChecks[index]; |
|
82 iPendingTimestampChecks.Remove(index); |
|
83 |
|
84 if (passCriteria.iCompareWithRefClock) |
|
85 { |
|
86 OMX_TIME_CONFIG_TIMESTAMPTYPE timeInfo; |
|
87 timeInfo.nSize = sizeof(timeInfo); |
|
88 timeInfo.nVersion = KOmxVersion; |
|
89 timeInfo.nPortIndex = passCriteria.iPortIndex; |
|
90 |
|
91 OMX_ERRORTYPE error = iClockComponent->GetConfig(iClockComponent, OMX_IndexConfigTimeCurrentMediaTime, &timeInfo); |
|
92 |
|
93 if (error != OMX_ErrorNone) |
|
94 { |
|
95 iErrorCallbacks.FailWithOmxError(_L("OMX_GetConfig(OMX_IndexConfigTimeCurrentMediaTime)"), error); |
|
96 } |
|
97 else if ((aBuffer->nTimeStamp > timeInfo.nTimestamp) || (aBuffer->nTimeStamp < (timeInfo.nTimestamp - passCriteria.iTolerance))) |
|
98 { |
|
99 TBuf<200> errorString; |
|
100 errorString.Format(KErrDialogTimestampComparisonFailed, iXmlName, passCriteria.iPortIndex, timeInfo.nTimestamp, passCriteria.iTolerance, aBuffer->nTimeStamp); |
|
101 iErrorCallbacks.FailTest(errorString); |
|
102 } |
|
103 } |
|
104 else |
|
105 { |
|
106 if ((aBuffer->nTimeStamp < (passCriteria.iExpectedTime - passCriteria.iTolerance)) || (aBuffer->nTimeStamp > (passCriteria.iExpectedTime + passCriteria.iTolerance))) |
|
107 { |
|
108 TBuf<200> errorString; |
|
109 errorString.Format(KErrDialogTimestampCheckFailed, iXmlName, passCriteria.iPortIndex, passCriteria.iExpectedTime, passCriteria.iTolerance, aBuffer->nTimeStamp); |
|
110 iErrorCallbacks.FailTest(errorString); |
|
111 } |
|
112 } |
|
113 |
|
114 break; |
|
115 } |
|
116 } |
|
117 |