⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chxclientsink.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			UINT32 bufferSize = spTrackURLBuffer->GetSize();			m_pTrackURL = new char[ bufferSize ];			if ( m_pTrackURL )			{				memcpy( m_pTrackURL, spTrackURLBuffer->GetBuffer(), bufferSize );			}		}		ULONG32 persistentComponentID = 0;		if ( SUCCEEDED( pTrackProperties->GetPropertyULONG32( kPersistentComponentIDPropertyName, persistentComponentID ) ) )		{			SPIHXPersistentComponentManager spPersistentComponentManager = m_pIHXCorePlayer;			if ( spPersistentComponentManager.IsValid() )			{				SPIHXPersistentComponent spPersistentComponent;				spPersistentComponentManager->GetPersistentComponent( persistentComponentID, *spPersistentComponent.AsInOutParam() );				if ( spPersistentComponent.IsValid() )				{					SPIHXValues spPersistentComponentProperties;					spPersistentComponent->GetPersistentProperties( *spPersistentComponentProperties.AsInOutParam() );					if ( spPersistentComponentProperties.IsValid() )					{						SPIHXBuffer spMetafileURLBuffer;						spPersistentComponentProperties->GetPropertyCString( kURLPropertyName, *spMetafileURLBuffer.AsInOutParam() );						if ( !spMetafileURLBuffer.IsValid() )						{							spPersistentComponentProperties->GetPropertyCString( kSourcePropertyName, *spMetafileURLBuffer.AsInOutParam() );						}						if ( spMetafileURLBuffer.IsValid() )						{							UINT32 bufferSize = spMetafileURLBuffer->GetSize();							m_pMetafileURL = new char[ bufferSize ];							if ( m_pMetafileURL )							{								memcpy( m_pMetafileURL, spMetafileURLBuffer->GetBuffer(), bufferSize );							}						}					}				}			}		}	}}static UINT32CopyURLArgument( char* pDest, const char* pSource, UINT32 length ){	if ( length == 0 ) return length;		UINT32 copyLength = length;	const char* pSourceToCopy = pSource;	if ( pSourceToCopy[ 0 ] == '\"' )	{		pSourceToCopy++;		copyLength--;	}	if ( copyLength == 0 ) return copyLength;		if ( pSourceToCopy[ copyLength - 1 ] == '\"' )	{		copyLength--;	}	if ( copyLength == 0 ) return copyLength;	memcpy( pDest, pSourceToCopy, copyLength );	return copyLength;}voidCHXClientSink::UpdateContextURL( void ){	static const char* const kContextURLName    = "rpcontexturl=";	static const char* const kContextWidthName  = "rpcontextwidth=";	static const char* const kContextHeightName = "rpcontextheight=";	static const char* const kContextParamsName = "rpcontextparams=";		char* pNewContextURL = NULL;		const char* pContextURL = NULL;	const char* pURLToParse = ( m_pTrackURL    && ( NULL != ( pContextURL = strstr( m_pTrackURL,    kContextURLName ) ) ) ) ? m_pTrackURL    :							  ( m_pMetafileURL && ( NULL != ( pContextURL = strstr( m_pMetafileURL, kContextURLName ) ) ) ) ? m_pMetafileURL : NULL;	if ( pURLToParse )	{		const char* pArgumentDelim;		UINT32 urlToParseLength = strlen( pURLToParse );		const char* pEndOfURLToParse = pURLToParse + urlToParseLength;				pContextURL += strlen( kContextURLName );				// If the context URL has its own arguments, denoted by a '?', then we assume the context URL runs the remainder of the URL,		// since we have no way of knowing when it actually stops.		bool doesContextURLHaveArguments = ( NULL != strchr( pContextURL, '?' ) );		pArgumentDelim = doesContextURLHaveArguments ? NULL : strchr( pContextURL, '&' );		UINT32 contextURLLength = pArgumentDelim ? ( pArgumentDelim - pContextURL ) : ( pEndOfURLToParse - pContextURL );				UINT32 contextParamsLength = 0;		const char* pContextParams = strstr( pURLToParse, kContextParamsName );		if ( pContextParams )		{			pContextParams += strlen( kContextParamsName );			pArgumentDelim = strchr( pContextParams, '&' );			contextParamsLength = pArgumentDelim ? ( pArgumentDelim - pContextParams ) : ( pEndOfURLToParse - pContextParams );		}		UINT32 contextWidthLength = 0;		const char* pContextWidth = strstr( pURLToParse, kContextWidthName );		if ( pContextWidth )		{			pContextWidth += strlen( kContextWidthName );			pArgumentDelim = strchr( pContextWidth, '&' );			contextWidthLength = pArgumentDelim ? ( pArgumentDelim - pContextWidth ) : ( pEndOfURLToParse - pContextWidth );		}		UINT32 contextHeightLength = 0;		const char* pContextHeight = strstr( pURLToParse, kContextHeightName );		if ( pContextHeight )		{			pContextHeight += strlen( kContextHeightName );			pArgumentDelim = strchr( pContextHeight, '&' );			contextHeightLength = pArgumentDelim ? ( pArgumentDelim - pContextHeight ) : ( pEndOfURLToParse - pContextHeight );		}				// <pContextURL>?<pContextParams>&rptarget=_rpcontextwin&rpcontextwidth=<pContextWidth>&rpcontextheight=<pContextHeight>		const UINT32 kContextURLWithArgsLength = contextURLLength + 1 + 												 ( pContextParams ? ( contextParamsLength + 1 ) : 0 ) +												 ( 8 + 1 + 13 ) +												 ( pContextWidth  ? ( 1 + strlen( kContextWidthName  ) + 1 + contextWidthLength  ) : 0 ) +												 ( pContextHeight ? ( 1 + strlen( kContextHeightName ) + 1 + contextHeightLength ) : 0 );				pNewContextURL = new char[ kContextURLWithArgsLength + 1 ];		if ( pNewContextURL )		{			contextURLLength = CopyURLArgument( pNewContextURL, pContextURL, contextURLLength );			UINT32 copyIndex = contextURLLength;			pNewContextURL[ copyIndex++ ] = doesContextURLHaveArguments ? '&' : '?';						if ( pContextParams )			{				contextParamsLength = CopyURLArgument( &pNewContextURL[ copyIndex ], pContextParams, contextParamsLength );				pNewContextURL[ copyIndex + contextParamsLength ] = '\0';				UnescapeURL( &pNewContextURL[ copyIndex ] ); // Unescape the params here. Since they follow the '?', they'll be ignored in the final Unescape.				copyIndex += strlen( &pNewContextURL[ copyIndex ] );				pNewContextURL[ copyIndex++ ] = '&';			}			sprintf( &pNewContextURL[ copyIndex ], "%s", "rptarget=_rpcontextwin" );			copyIndex += strlen( &pNewContextURL[ copyIndex ] );						if ( pContextWidth )			{				sprintf( &pNewContextURL[ copyIndex ], "%c%s", '&', kContextWidthName );				copyIndex += strlen( &pNewContextURL[ copyIndex ] );				contextWidthLength = CopyURLArgument( &pNewContextURL[ copyIndex ], pContextWidth, contextWidthLength );				copyIndex += contextWidthLength;			}			if ( pContextHeight )			{				sprintf( &pNewContextURL[ copyIndex ], "%c%s", '&', kContextHeightName );				copyIndex += strlen( &pNewContextURL[ copyIndex ] );				contextHeightLength = CopyURLArgument( &pNewContextURL[ copyIndex ], pContextHeight, contextHeightLength );				copyIndex += contextHeightLength;			}			pNewContextURL[ copyIndex ] = '\0';						UnescapeURL( pNewContextURL );		}	}	delete [] m_pContextURL;	m_pContextURL = pNewContextURL;}voidCHXClientSink::UpdateRPURLAndTarget( void ){	static const char* const kRPURLName		  = "rpurl=";	static const char* const kRPURLTargetName = "rpurltarget=";		char* pNewRPURL = NULL;	char* pNewRPURLTarget = NULL;		const char* pRPURL = NULL;	const char* pURLToParse = ( m_pTrackURL    && ( NULL != ( pRPURL = strstr( m_pTrackURL,    kRPURLName ) ) ) ) ? m_pTrackURL    :							  ( m_pMetafileURL && ( NULL != ( pRPURL = strstr( m_pMetafileURL, kRPURLName ) ) ) ) ? m_pMetafileURL : NULL;	if ( pURLToParse )	{		const char* pArgumentDelim;		UINT32 urlToParseLength = strlen( pURLToParse );		const char* pEndOfURLToParse = pURLToParse + urlToParseLength;				pRPURL += strlen( kRPURLName );				// If the RPURL has its own arguments, denoted by a '?', then we assume the RPURL runs the remainder of the URL,		// since we have no way of knowing when it actually stops.		bool doesRPURLHaveArguments = ( NULL != strchr( pRPURL, '?' ) );		pArgumentDelim = doesRPURLHaveArguments ? NULL : strchr( pRPURL, '&' );		UINT32 rpURLLength = pArgumentDelim ? ( pArgumentDelim - pRPURL ) : ( pEndOfURLToParse - pRPURL );				pNewRPURL = new char[ rpURLLength + 1 ];		if ( pNewRPURL )		{			rpURLLength = CopyURLArgument( pNewRPURL, pRPURL, rpURLLength );			pNewRPURL[ rpURLLength ] = '\0';			UnescapeURL( pNewRPURL );					UINT32 rpURLTargetLength = 0;			const char* pRPURLTarget = strstr( pURLToParse, kRPURLTargetName );			if ( pRPURLTarget )			{				pRPURLTarget += strlen( kRPURLTargetName );				pArgumentDelim = strchr( pRPURLTarget, '&' );				rpURLTargetLength = pArgumentDelim ? ( pArgumentDelim - pRPURLTarget ) : ( pEndOfURLToParse - pRPURLTarget );				pNewRPURLTarget = new char[ rpURLTargetLength + 1 ];				if ( pNewRPURLTarget )				{					rpURLTargetLength = CopyURLArgument( pNewRPURLTarget, pRPURLTarget, rpURLTargetLength );					pNewRPURLTarget[ rpURLTargetLength ] = '\0';				}			}		}	}	delete [] m_pRPURL;	m_pRPURL = pNewRPURL;	delete [] m_pRPURLTarget;	m_pRPURLTarget = pNewRPURLTarget;}STDMETHODIMPCHXClientSink::TrackStarted( UINT16 uGroupIndex, UINT16 uTrackIndex, IHXValues* pTrack ){	GetURLsFromTrackProperties( pTrack );	UpdateContextURL();	UpdateRPURLAndTarget();	if ( m_pClientCallbacks->OnGroupStarted )	{		m_pClientCallbacks->OnGroupStarted( m_UserInfo, uGroupIndex );	}	if ( m_pContextURL && m_pClientCallbacks->GoToURL )	{		( void ) m_pClientCallbacks->GoToURL( m_UserInfo, m_pContextURL, NULL, false );	}	if ( m_pRPURL && m_pClientCallbacks->GoToURL )	{		( void ) m_pClientCallbacks->GoToURL( m_UserInfo, m_pRPURL, m_pRPURLTarget, false );	}	return HXR_OK;}STDMETHODIMPCHXClientSink::TrackStopped( UINT16 uGroupIndex, UINT16 uTrackIndex, IHXValues* pTrack ){	return HXR_OK;}STDMETHODIMPCHXClientSink::GroupAdded( UINT16 uGroupIndex, IHXGroup* pGroup ){	m_IsGroupsListDirty = true;	return HXR_OK;}STDMETHODIMPCHXClientSink::GroupRemoved( UINT16 uGroupIndex, IHXGroup* pGroup ){	m_IsGroupsListDirty = true;	return HXR_OK;}STDMETHODIMPCHXClientSink::AllGroupsRemoved( void ){	m_IsGroupsListDirty = true;	return HXR_OK;}STDMETHODIMPCHXClientSink::TrackAdded( UINT16 uGroupIndex, UINT16 uTrackIndex, IHXValues* pTrack ){	return HXR_OK;}STDMETHODIMPCHXClientSink::TrackRemoved( UINT16 uGroupIndex, UINT16 uTrackIndex, IHXValues* pTrack ){	return HXR_OK;}STDMETHODIMPCHXClientSink::CurrentGroupSet( UINT16 uGroupIndex, IHXGroup* pGroup ){	// with a new group open, we may now have access to the clip name	// for the group (though it won't be available yet from the core, that	// slacker; we'll wait until OnBegin happens to update our info)	m_IsGroupsListDirty = true;	return HXR_OK;}#pragma mark -STDMETHODIMPCHXClientSink::OnVolumeChange( const UINT16 uVolume ){	if ( m_pClientCallbacks->OnVolumeChanged )	{		m_pClientCallbacks->OnVolumeChanged( m_UserInfo, uVolume );	}	return HXR_OK;}STDMETHODIMPCHXClientSink::OnMuteChange( const HXBOOL bMute ){	if ( m_pClientCallbacks->OnMuteChanged )	{		bool isMuted = ( ( 0 != bMute ) ? true : false );		m_pClientCallbacks->OnMuteChanged( m_UserInfo, isMuted );	}	return HXR_OK;}#pragma mark -voidCHXClientSink::SetUpPropWatcher( void ){#ifdef HELIX_FEATURE_REGISTRY	if (  m_spPropWatch.IsValid() ) return;		// Get the name of our registry.	SPIHXRegistry spRegistry = m_pIHXCorePlayer;	SPIHXRegistryID spRegistryID = m_pIHXCorePlayer;	if ( !spRegistry.IsValid() || !spRegistryID.IsValid() ) return;		UINT32 playerId;	SPIHXBuffer spPlayerNameBuffer;	spRegistryID->GetID( playerId );	spRegistry->GetPropName( playerId, *spPlayerNameBuffer.AsInOutParam() );	if ( spPlayerNameBuffer.IsValid() && ( spPlayerNameBuffer->GetSize() > 0 ) )	{		HX_RESULT result = spRegistry->CreatePropWatch( *m_spPropWatch.AsInOutParam() );		if ( SUCCEEDED( result ) )		{			result = m_spPropWatch->Init( this );			if ( SUCCEEDED( result ) )			{				char propName[ 256 ] = "";				sprintf( propName, "%s.%s", ( const char* ) spPlayerNameBuffer->GetBuffer(), "Title" );				m_TitlePropID = spRegistry->GetId( propName );				if ( m_TitlePropID > 0 )				{					m_spPropWatch->SetWatchById( m_TitlePropID );				}				sprintf( propName, "%s.%s", ( const char* ) spPlayerNameBuffer->GetBuffer(), "ClipBandwidth" );				m_ClipBandwidthPropID = spRegistry->GetId( propName );				if ( m_ClipBandwidthPropID > 0 )				{					m_spPropWatch->SetWatchById( m_ClipBandwidthPropID );				}			}			else			{				m_spPropWatch.Clear();			}		}	}#endif}#ifdef HELIX_FEATURE_REGISTRYSTDMETHODIMPCHXClientSink::AddedProp( const UINT32 ulId, const HXPropType propType, const UINT32 ulParentID ){	return HXR_OK; // Called when a child property to a watched property is added.}STDMETHODIMPCHXClientSink::ModifiedProp( const UINT32 ulId, const HXPropType propType, const UINT32 ulParentID ){	SPIHXRegistry spRegistry = m_pIHXCorePlayer;	CHXASSERT( spRegistry.IsValid() ); // Wouldn't be getting this callback if the Player didn't support IHXRegistry.	if ( ulId == m_TitlePropID )	{		SPIHXBuffer spPropStringBuffer;		spRegistry->GetStrById( ulId, *spPropStringBuffer.AsInOutParam() );		if ( spPropStringBuffer.IsValid() )		{			UINT32 bufferSize = spPropStringBuffer->GetSize();			if ( ( m_TitleSize != bufferSize ) ||				 ( 0 != memcmp( m_pTitle, spPropStringBuffer->GetBuffer(), m_TitleSize ) ) )			{				delete [] m_pTitle;				m_pTitle = new char[ bufferSize ];				if ( m_pTitle )				{					memcpy( m_pTitle, spPropStringBuffer->GetBuffer(), bufferSize );					m_TitleSize = bufferSize;				}				if ( m_pClientCallbacks->OnTitleChanged )				{					m_pClientCallbacks->OnTitleChanged( m_UserInfo, m_pTitle );				}			}		}		return HXR_OK;	}	if ( ulId == m_ClipBandwidthPropID )	{		INT32 oldClipBandwidth = m_ClipBandwidth;		if ( SUCCEEDED( spRegistry->GetIntById( ulId, m_ClipBandwidth ) ) )		{			if ( m_pClientCallbacks->OnClipBandwidthChanged && ( oldClipBandwidth != m_ClipBandwidth ) )			{				m_pClientCallbacks->OnClipBandwidthChanged( m_UserInfo, m_ClipBandwidth );			}		}		return HXR_OK;	}	return HXR_FAIL;}STDMETHODIMPCHXClientSink::DeletedProp( const UINT32 ulId, const UINT32 ulParentID ){	if ( ulId == m_TitlePropID )	{		m_TitlePropID = 0;		delete [] m_pTitle;		m_pTitle = NULL;		return m_spPropWatch->ClearWatchById( ulId );	}	if ( ulId == m_ClipBandwidthPropID )	{		m_ClipBandwidthPropID = 0;		m_ClipBandwidth = 0;		return m_spPropWatch->ClearWatchById( ulId );	}	return HXR_FAIL;}#endifvoidCHXClientSink::DestroyPropWatcher( void ){#ifdef HELIX_FEATURE_REGISTRY	if ( !m_spPropWatch.IsValid() ) return;	if ( m_ClipBandwidthPropID > 0 )	{		m_spPropWatch->ClearWatchById( m_ClipBandwidthPropID );		m_ClipBandwidthPropID = 0;	}	m_ClipBandwidth = 0;	if ( m_TitlePropID > 0 )	{		m_spPropWatch->ClearWatchById( m_TitlePropID );		m_TitlePropID = 0;	}	delete [] m_pTitle;	m_pTitle = NULL;	m_spPropWatch.Clear();#endif}#pragma mark -STDMETHODIMPCHXClientSink::ErrorOccurred( const UINT8	unSeverity,  							  const ULONG32	ulHXCode,							  const ULONG32	ulUserCode,							  const char*	pUserString,							  const char*	pMoreInfoURL ){	// don't report warnings & logging info	if ( unSeverity <= HXLOG_ERR )	{		DoGroupsListUpdate();		if ( m_pClientCallbacks->OnErrorOccurred )		{			IHXBuffer* pIErrorString = NULL;			SPIHXErrorMessages spErrorMessages = m_pIHXCorePlayer;			if ( spErrorMessages.IsValid() )			{				pIErrorString = spErrorMessages->GetErrorText( ulHXCode );			}			m_pClientCallbacks->OnErrorOccurred( m_UserInfo, ulHXCode, ulUserCode, ( pIErrorString ? ( const char* ) pIErrorString->GetBuffer() : NULL ), pUserString, pMoreInfoURL );			HX_RELEASE( pIErrorString );		}	}	return HXR_OK;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -