omxil/omxilcomponentcommon/src/common/omxilclientclockport.cpp
changeset 0 40261b775718
child 16 eedf2dcd43c6
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2008-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 
       
    17 /**
       
    18  @file
       
    19  @internalComponent
       
    20 */
       
    21 
       
    22 #include "omxilclientclockport.h"
       
    23 #include "log.h"
       
    24 
       
    25 
       
    26 EXPORT_C COmxILClientClockPort* COmxILClientClockPort::NewL(const TOmxILCommonPortData& aCommonPortData, 
       
    27 							    							const RArray<OMX_OTHER_FORMATTYPE>& aSupportedOtherFormats)
       
    28 	{
       
    29 	COmxILClientClockPort* self = new(ELeave) COmxILClientClockPort(aCommonPortData);
       
    30 	CleanupStack::PushL(self);
       
    31 	self->COmxILOtherPort::ConstructL(aSupportedOtherFormats);
       
    32 	CleanupStack::Pop();
       
    33 	return self;
       
    34 	}
       
    35 
       
    36 COmxILClientClockPort::COmxILClientClockPort(const TOmxILCommonPortData& aCommonPortData) 
       
    37   : COmxILOtherPort(aCommonPortData),
       
    38     iSpecVersion(TOmxILSpecVersion())
       
    39 	{
       
    40 	DEBUG_PRINTF(_L8("COmxILClientClockPort::COmxILClientClockPort"));
       
    41 	}
       
    42 
       
    43 OMX_ERRORTYPE COmxILClientClockPort::GetLocalOmxParamIndexes(RArray<TUint>& aIndexArray) const
       
    44 	{
       
    45 	DEBUG_PRINTF(_L8("COmxILClientClockPort::GetLocalOmxParamIndexes"));
       
    46 	return COmxILOtherPort::GetLocalOmxParamIndexes(aIndexArray);
       
    47 	}
       
    48 
       
    49 
       
    50 OMX_ERRORTYPE COmxILClientClockPort::GetLocalOmxConfigIndexes(RArray<TUint>& aIndexArray) const
       
    51 	{
       
    52 	DEBUG_PRINTF(_L8("COmxILClientClockPort::GetLocalOmxParamIndexes"));
       
    53 	return COmxILOtherPort::GetLocalOmxConfigIndexes(aIndexArray);
       
    54 	}
       
    55 
       
    56 
       
    57 OMX_ERRORTYPE COmxILClientClockPort::GetParameter(OMX_INDEXTYPE aParamIndex,
       
    58 						     							TAny* apComponentParameterStructure) const
       
    59 	{
       
    60 	DEBUG_PRINTF(_L8("COmxILClientClockPort::GetParameter"));
       
    61 	return COmxILOtherPort::GetParameter(aParamIndex, apComponentParameterStructure);
       
    62 	}
       
    63 
       
    64 
       
    65 OMX_ERRORTYPE COmxILClientClockPort::SetParameter(OMX_INDEXTYPE aParamIndex,
       
    66 						     							const TAny* apComponentParameterStructure,
       
    67 						     							TBool& aUpdateProcessingFunction)
       
    68 	{
       
    69 	DEBUG_PRINTF(_L8("COmxILClientClockPort::SetParameter"));
       
    70 	return COmxILOtherPort::SetParameter(aParamIndex, apComponentParameterStructure, aUpdateProcessingFunction);
       
    71 	}
       
    72 
       
    73 
       
    74 OMX_ERRORTYPE COmxILClientClockPort::SetFormatInPortDefinition(const OMX_PARAM_PORTDEFINITIONTYPE& /*aPortDefinition*/,
       
    75 								  										TBool& /*aUpdateProcessingFunction*/)
       
    76 	{
       
    77 	DEBUG_PRINTF(_L8("COmxILClientClockPort::SetFormatInPortDefinition"));
       
    78 	return OMX_ErrorNone;
       
    79 	}
       
    80 
       
    81 
       
    82 TBool COmxILClientClockPort::IsTunnelledPortCompatible(const OMX_PARAM_PORTDEFINITIONTYPE& aPortDefinition) const
       
    83 	{
       
    84 	DEBUG_PRINTF(_L8("COmxILClientClockPort::IsTunnelledPortCompatible"));
       
    85 	// Domain check
       
    86 	if(aPortDefinition.eDomain != iParamPortDefinition.eDomain)
       
    87 		{
       
    88 		return EFalse;
       
    89 		}
       
    90 	
       
    91 	// Format check
       
    92 	if (aPortDefinition.format.other.eFormat != iParamPortDefinition.format.other.eFormat)
       
    93 		{
       
    94 		return EFalse;
       
    95 		}
       
    96 	
       
    97 	return ETrue;
       
    98 	}
       
    99 
       
   100 
       
   101 EXPORT_C OMX_ERRORTYPE COmxILClientClockPort::GetMediaTime(OMX_TICKS& aMediaTime) const
       
   102 	{
       
   103 	DEBUG_PRINTF(_L8("COmxILClientClockPort::GetMediaTime"));
       
   104 	return GetTime(aMediaTime, OMX_IndexConfigTimeCurrentMediaTime);
       
   105 	}
       
   106 
       
   107 
       
   108 EXPORT_C OMX_ERRORTYPE COmxILClientClockPort::GetWallTime(OMX_TICKS& aWallTime) const
       
   109 	{
       
   110 	DEBUG_PRINTF(_L8("COmxILClientClockPort::GetWallTime"));
       
   111 	return GetTime(aWallTime, OMX_IndexConfigTimeCurrentWallTime);
       
   112 	}
       
   113 
       
   114 
       
   115 EXPORT_C OMX_ERRORTYPE COmxILClientClockPort::GetClockState(OMX_TIME_CONFIG_CLOCKSTATETYPE& aClockState) const
       
   116 	{
       
   117 	DEBUG_PRINTF(_L8("COmxILClientClockPort::GetClockState"));
       
   118 
       
   119 	if (IsClockComponentAvailable())
       
   120 		{
       
   121 		aClockState.nSize = sizeof(OMX_TIME_CONFIG_CLOCKSTATETYPE);
       
   122 		aClockState.nVersion = iSpecVersion;
       
   123 		aClockState.eState = OMX_TIME_ClockStateMax;
       
   124 		aClockState.nStartTime = 0;
       
   125 		aClockState.nOffset = 0;
       
   126 		aClockState.nWaitMask = 0;
       
   127 		return OMX_GetConfig(iTunnelledComponent, OMX_IndexConfigTimeClockState, &aClockState);
       
   128 		}
       
   129 
       
   130 	return OMX_ErrorIncorrectStateOperation;
       
   131 
       
   132 	}
       
   133 
       
   134 EXPORT_C OMX_ERRORTYPE COmxILClientClockPort::MediaTimeRequest(const OMX_PTR apPrivate, 
       
   135 															const OMX_TICKS aMediaTime,
       
   136 															const OMX_TICKS aOffset) const
       
   137 	{
       
   138 	DEBUG_PRINTF(_L8("COmxILClientClockPort::MediaTimeRequest"));
       
   139 	OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE timeInfo;
       
   140 	timeInfo.nSize = sizeof(timeInfo);
       
   141 	timeInfo.nVersion = iSpecVersion;
       
   142 	timeInfo.nPortIndex = iTunnelledPort;
       
   143 	timeInfo.pClientPrivate = apPrivate;
       
   144 	timeInfo.nMediaTimestamp = aMediaTime;
       
   145 	timeInfo.nOffset = aOffset;
       
   146 
       
   147 	if (IsClockComponentAvailable())
       
   148 		{
       
   149 		return OMX_SetConfig(iTunnelledComponent, OMX_IndexConfigTimeMediaTimeRequest, &timeInfo);
       
   150 		}
       
   151 	
       
   152 	return OMX_ErrorIncorrectStateOperation;
       
   153 	}
       
   154 
       
   155 
       
   156 EXPORT_C OMX_ERRORTYPE COmxILClientClockPort::SetStartTime(const OMX_TICKS aStartTime) const
       
   157 	{
       
   158 	DEBUG_PRINTF(_L8("COmxILClientClockPort::SetStartTime"));
       
   159 	return SetTime(aStartTime, OMX_IndexConfigTimeClientStartTime);
       
   160 	}
       
   161 
       
   162 
       
   163 EXPORT_C OMX_ERRORTYPE COmxILClientClockPort::SetVideoReference(const OMX_TICKS aVideoRef) const
       
   164 	{
       
   165 	DEBUG_PRINTF(_L8("COmxILClientClockPort::SetVideoReference"));
       
   166 	return SetTime(aVideoRef, OMX_IndexConfigTimeCurrentVideoReference);
       
   167 	}
       
   168 
       
   169 
       
   170 EXPORT_C OMX_ERRORTYPE COmxILClientClockPort::SetAudioReference(const OMX_TICKS aAudioRef) const
       
   171 	{
       
   172 	DEBUG_PRINTF(_L8("COmxILClientClockPort::SetAudioReference"));
       
   173 	return SetTime(aAudioRef, OMX_IndexConfigTimeCurrentAudioReference);
       
   174 	}
       
   175 
       
   176 EXPORT_C OMX_BOOL COmxILClientClockPort::IsClockComponentAvailable() const
       
   177 {
       
   178 	if (iTunnelledComponent != NULL && iParamPortDefinition.bEnabled)
       
   179 		{
       
   180 		return OMX_TRUE;
       
   181 		}
       
   182 	
       
   183 	return OMX_FALSE;
       
   184 }
       
   185 
       
   186 OMX_ERRORTYPE COmxILClientClockPort::GetTime(OMX_TICKS& aWallTime, const OMX_INDEXTYPE aTimeIndex) const
       
   187 	{
       
   188 	DEBUG_PRINTF(_L8("COmxILClientClockPort::GetTime"));
       
   189 	OMX_TIME_CONFIG_TIMESTAMPTYPE timeInfo;
       
   190 	timeInfo.nSize = sizeof(timeInfo);
       
   191 	timeInfo.nVersion = iSpecVersion;
       
   192 	timeInfo.nPortIndex = iTunnelledPort;
       
   193 
       
   194 	if (!IsClockComponentAvailable())
       
   195 		{
       
   196 		return OMX_ErrorIncorrectStateOperation;
       
   197 		}
       
   198 		
       
   199 	OMX_ERRORTYPE error = OMX_GetConfig(iTunnelledComponent, aTimeIndex, &timeInfo);
       
   200 
       
   201 	if (error == OMX_ErrorNone)
       
   202 		{
       
   203 		aWallTime = timeInfo.nTimestamp;
       
   204 		}
       
   205 	
       
   206 	return error;
       
   207 	}
       
   208 
       
   209 
       
   210 OMX_ERRORTYPE COmxILClientClockPort::SetTime(const OMX_TICKS aStartTime, const OMX_INDEXTYPE aTimeIndex) const
       
   211 	{
       
   212 	DEBUG_PRINTF(_L8("COmxILClientClockPort::SetTime"));
       
   213 	OMX_TIME_CONFIG_TIMESTAMPTYPE timeInfo;
       
   214 	timeInfo.nSize = sizeof(timeInfo);
       
   215 	timeInfo.nVersion = iSpecVersion;
       
   216 	timeInfo.nPortIndex = iTunnelledPort;
       
   217 	timeInfo.nTimestamp = aStartTime;
       
   218 	
       
   219 	if (IsClockComponentAvailable())
       
   220 		{
       
   221 		return OMX_SetConfig(iTunnelledComponent, aTimeIndex, &timeInfo);
       
   222 		}
       
   223 		
       
   224 	return OMX_ErrorIncorrectStateOperation;
       
   225 	}