[xiph-commits] r8105 - trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Tue Oct 26 08:10:52 PDT 2004


Author: illiminable
Date: 2004-10-26 08:10:52 -0700 (Tue, 26 Oct 2004)
New Revision: 8105

Modified:
   trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.cpp
   trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.h
Log:
* Seeking in native flac works... though there's some crashing due to threading problems.

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.cpp	2004-10-26 14:21:36 UTC (rev 8104)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.cpp	2004-10-26 15:10:52 UTC (rev 8105)
@@ -64,6 +64,7 @@
 	,	mBegun(false)
 	,	mUpto(0)
 	,	mJustStopped(true)
+	,	mTotalNumSamples(0)
 	
 	//,	mDecoder(NULL)
 {
@@ -136,7 +137,12 @@
 											((locBuff[21] & FLAC_BPS_END_MASK) >> 4)) + 1;	
 
 
+	mTotalNumSamples = (((__int64)(locBuff[21] % 16)) << 32) + ((__int64)(iBE_Math::charArrToULong(&locBuff[22])));
 	debugLog<<mNumChannels<<" channels with "<<mSampleRate<<" Hz @ "<<mBitsPerSample<<" bits per sample"<<endl;
+	debugLog<<"Total num samples = "<<mTotalNumSamples<<endl;
+
+
+	//TODO::: NEed to handle the case where the number of samples is zero by making it non-seekable.
 	mInputFile.seekg(0, ios_base::beg);
 
 	debugLog<<"Pre init"<<endl;
@@ -375,4 +381,99 @@
 bool NativeFLACSourceFilter::eof_callback(void) {
 	debugLog<<"EOF Req"<<endl;
 	return mInputFile.eof();
+}
+
+
+
+STDMETHODIMP NativeFLACSourceFilter::GetCapabilities(DWORD* inCapabilities) {
+	*inCapabilities = AM_SEEKING_CanSeekAbsolute |
+						AM_SEEKING_CanSeekForwards |
+						AM_SEEKING_CanSeekBackwards |
+						AM_SEEKING_CanGetCurrentPos |
+						AM_SEEKING_CanGetStopPos |
+						AM_SEEKING_CanGetDuration;
+	return S_OK;
+}
+STDMETHODIMP NativeFLACSourceFilter::CheckCapabilities(DWORD *pCapabilities) {
+	return E_NOTIMPL;
+}
+STDMETHODIMP NativeFLACSourceFilter::IsFormatSupported(const GUID *pFormat) {
+	if (*pFormat == TIME_FORMAT_MEDIA_TIME) {
+		//debugLog<<"IsFormatSupported	: TRUE"<<endl;
+		return S_OK;
+	} else {
+		//debugLog<<"IsFormatSupported	: FALSE !!!"<<endl;
+		return S_FALSE;
+	}
+}
+STDMETHODIMP NativeFLACSourceFilter::QueryPreferredFormat(GUID *pFormat) {
+	*pFormat = TIME_FORMAT_MEDIA_TIME;
+	return S_OK;
+}
+STDMETHODIMP NativeFLACSourceFilter::SetTimeFormat(const GUID *pFormat) {
+	return E_NOTIMPL;
+}
+STDMETHODIMP NativeFLACSourceFilter::GetTimeFormat( GUID *pFormat) {
+	*pFormat = TIME_FORMAT_MEDIA_TIME;
+	return S_OK;
+}
+STDMETHODIMP NativeFLACSourceFilter::GetDuration(LONGLONG *pDuration) {
+	*pDuration = (mTotalNumSamples * UNITS) / mSampleRate;
+	return S_OK;
+}
+STDMETHODIMP NativeFLACSourceFilter::GetStopPosition(LONGLONG *pStop) {
+	*pStop = (mTotalNumSamples * UNITS) / mSampleRate;
+	return S_OK;
+}
+STDMETHODIMP NativeFLACSourceFilter::GetCurrentPosition(LONGLONG *pCurrent){
+	return E_NOTIMPL;
+}
+STDMETHODIMP NativeFLACSourceFilter::ConvertTimeFormat(LONGLONG *pTarget, const GUID *pTargetFormat, LONGLONG Source, const GUID *pSourceFormat){
+	return E_NOTIMPL;
+}
+STDMETHODIMP NativeFLACSourceFilter::SetPositions(LONGLONG *pCurrent,DWORD dwCurrentFlags,LONGLONG *pStop,DWORD dwStopFlags){
+	debugLog<<"Request seek to "<<*pCurrent<<endl;
+	mUpto = 0;
+	unsigned __int64 locSampleToSeek = (*pCurrent) * mSampleRate/ UNITS;
+	debugLog<<"W**** Which is sample no = "<<locSampleToSeek<<endl;
+	mFLACSourcePin->DeliverBeginFlush();
+	mFLACSourcePin->DeliverEndFlush();
+	bool locRes = seek_absolute(locSampleToSeek);
+	if (locRes) {
+		debugLog<<"Seek suceeded"<<endl;
+	} else {
+		debugLog<<"Seek failed"<<endl;
+	}
+	
+	return S_OK;
+}
+STDMETHODIMP NativeFLACSourceFilter::GetPositions(LONGLONG *pCurrent, LONGLONG *pStop){
+	debugLog<<"Calling get positions _ NOTIMPL"<<endl;
+	return E_NOTIMPL;
+}
+STDMETHODIMP NativeFLACSourceFilter::GetAvailable(LONGLONG *pEarliest, LONGLONG *pLatest){
+	*pEarliest = 0;
+	*pLatest = (mTotalNumSamples * UNITS) / mSampleRate;
+	debugLog<<"Get available"<<endl;
+	return S_OK;
+}
+STDMETHODIMP NativeFLACSourceFilter::SetRate(double dRate){
+	return E_NOTIMPL;
+}
+STDMETHODIMP NativeFLACSourceFilter::GetRate(double *dRate){
+	*dRate = 1.0;
+	return S_OK;
+}
+STDMETHODIMP NativeFLACSourceFilter::GetPreroll(LONGLONG *pllPreroll){
+	*pllPreroll = 0;
+	return S_OK;
+}
+STDMETHODIMP NativeFLACSourceFilter::IsUsingTimeFormat(const GUID *pFormat){
+	if (*pFormat == TIME_FORMAT_MEDIA_TIME) {
+		//debugLog<<"IsFormatSupported	: TRUE"<<endl;
+		return S_OK;
+	} else {
+		//debugLog<<"IsFormatSupported	: FALSE !!!"<<endl;
+		return S_FALSE;
+	}
 }
\ No newline at end of file

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.h	2004-10-26 14:21:36 UTC (rev 8104)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.h	2004-10-26 15:10:52 UTC (rev 8105)
@@ -44,6 +44,7 @@
 	:	public CBaseFilter
 	,	public IFileSourceFilter
 	,	public IAMFilterMiscFlags
+	,	public IMediaSeeking
 	,	public CAMThread
 	,	protected FLAC::Decoder::SeekableStream
 {
@@ -94,10 +95,29 @@
 
 
 	bool eof_callback(void);
+	//
+	//IMediaSeeking Interface
+	 virtual STDMETHODIMP GetCapabilities(DWORD *pCapabilities);
+	 virtual STDMETHODIMP CheckCapabilities(DWORD *pCapabilities);
+	 virtual STDMETHODIMP IsFormatSupported(const GUID *pFormat);
+	 virtual STDMETHODIMP QueryPreferredFormat(GUID *pFormat);
+	 virtual STDMETHODIMP SetTimeFormat(const GUID *pFormat);
+	 virtual STDMETHODIMP GetTimeFormat( GUID *pFormat);
+	 virtual STDMETHODIMP GetDuration(LONGLONG *pDuration);
+	 virtual STDMETHODIMP GetStopPosition(LONGLONG *pStop);
+	 virtual STDMETHODIMP GetCurrentPosition(LONGLONG *pCurrent);
+	 virtual STDMETHODIMP ConvertTimeFormat(LONGLONG *pTarget, const GUID *pTargetFormat, LONGLONG Source, const GUID *pSourceFormat);
+	 virtual STDMETHODIMP SetPositions(LONGLONG *pCurrent,DWORD dwCurrentFlags,LONGLONG *pStop,DWORD dwStopFlags);
+	 virtual STDMETHODIMP GetPositions(LONGLONG *pCurrent, LONGLONG *pStop);
+	 virtual STDMETHODIMP GetAvailable(LONGLONG *pEarliest, LONGLONG *pLatest);
+	 virtual STDMETHODIMP SetRate(double dRate);
+	 virtual STDMETHODIMP GetRate(double *dRate);
+	 virtual STDMETHODIMP GetPreroll(LONGLONG *pllPreroll);
+	 virtual STDMETHODIMP IsUsingTimeFormat(const GUID *pFormat);
+	//
 
 
 
-
 protected:
 
 	HRESULT DataProcessLoop();
@@ -120,5 +140,6 @@
 	unsigned long mFrameSize;
 	unsigned long mSampleRate;
 	unsigned long mBitsPerSample;
+	__int64 mTotalNumSamples;
 
 };



More information about the commits mailing list