HRESULT AbstractTransformInputPin::BreakConnect() 
{
	CAutoLock locLock(m_pLock);
	//Release the seeking delegate
	ReleaseDelegate();
	return CBaseInputPin::BreakConnect();
}
示例#2
0
STDMETHODIMP OggDemuxFilter::Pause() 
{
	CAutoLock locLock(m_pLock);
    LOG(logDEBUG) << __FUNCTIONW__;

	if (m_State == State_Stopped) 
    {
        LOG(logDEBUG) <<L"Pause -- was stopped";

		if (ThreadExists() == FALSE) 
        {
            LOG(logDEBUG) << L"Pause -- CREATING THREAD";
			Create();
		}

        LOG(logDEBUG) << L"Pause -- RUNNING THREAD";
		CallWorker(THREAD_RUN);
	}

	HRESULT hr = CBaseFilter::Pause();

    LOG(logDEBUG) << __FUNCTIONW__ << L"Base class returned: 0x" << std::hex << hr;
	
	return hr;	
}
STDMETHODIMP AbstractTransformInputPin::NewSegment(REFERENCE_TIME inStartTime, REFERENCE_TIME inStopTime, double inRate) {
	CAutoLock locLock(mStreamLock);

	//This is called on BasePin and not BaseInputPin because the implementation is not overriden in BaseOutputPin.
	CBasePin::NewSegment(inStartTime, inStopTime, inRate);
	return mParentFilter->mOutputPin->DeliverNewSegment(inStartTime, inStopTime, inRate);
}
示例#4
0
//IMEdiaStreaming
STDMETHODIMP OggDemuxFilter::Run(REFERENCE_TIME tStart) 
{
	CAutoLock locLock(m_pLock);
    LOG(logDEBUG) << "Run: " << ReferenceTime(tStart);
	
    return CBaseFilter::Run(tStart);
}
HRESULT AbstractTransformInputPin::CompleteConnect (IPin *inReceivePin) 
{
	CAutoLock locLock(m_pLock);
	
	IMediaSeeking* locSeeker = NULL;
	inReceivePin->QueryInterface(IID_IMediaSeeking, (void**)&locSeeker);
	SetDelegate(locSeeker);
	return CBaseInputPin::CompleteConnect(inReceivePin);
}
示例#6
0
void OggDemuxFilter::DeliverEndFlush() 
{
	CAutoLock locLock(m_pLock);
    LOG(logDEBUG) << __FUNCTIONW__;

	for (unsigned long i = 0; i < m_streamMapper->numPins(); i++) 
    {
		//m_streamMapper->getOggStream(i)->flush();
		m_streamMapper->getPinByIndex(i)->DeliverEndFlush();
	}
}
示例#7
0
void OggDemuxFilter::DeliverBeginFlush() 
{
	CAutoLock locLock(m_pLock);
    LOG(logDEBUG) << __FUNCTIONW__;
	
	for (unsigned long i = 0; i < m_streamMapper->numPins(); i++) 
    {
		m_streamMapper->getPinByIndex(i)->DeliverBeginFlush();
	}

	//Should this be here or endflush or neither ?
	resetStream();
}
示例#8
0
STDMETHODIMP OggDemuxFilter::Stop() 
{
	CAutoLock locLock(m_pLock);
    LOG(logDEBUG) << __FUNCTIONW__;

	CallWorker(THREAD_EXIT);
	Close();
	DeliverBeginFlush();
	//mSetIgnorePackets = true;
	DeliverEndFlush();
	
	return CBaseFilter::Stop();
}
示例#9
0
STDMETHODIMP OggDemuxFilter::SetPositions(LONGLONG *pCurrent,DWORD dwCurrentFlags,LONGLONG *pStop,DWORD dwStopFlags)
{
    CAutoLock locLock(m_pLock);

    LOG(logDEBUG3) << "IMediaSeeking::SetPositions(" << ReferenceTime(*pCurrent) << ", " << dwCurrentFlags
        << ", " << ReferenceTime(*pStop) << ", " << dwStopFlags << ") -> 0x" << std::hex << S_OK;

    if (m_seekTable == NULL || !m_seekTable->enabled())  
    {
        return E_NOTIMPL;
    }
	
	DeliverBeginFlush();
	
	//Find the byte position for this time.
	if (*pCurrent > m_seekTable->fileDuration()) 
    {
		*pCurrent = m_seekTable->fileDuration();
	} 
    else if (*pCurrent < 0) 
    {
		*pCurrent = 0;
	}

	OggGranuleSeekTable::tSeekPair locStartPos = m_seekTable->seekPos(*pCurrent);
		
	//For now, seek to the position directly, later we will discard the preroll
	//Probably don't ever want to do this. We want to record the desired time,
	//	and it will be up to the decoders to drop anything that falls before it.
	
    DeliverEndFlush();
	DeliverNewSegment(*pCurrent, m_seekTable->fileDuration(), 1.0);

	// Second is the file position.
    SetRequestedSeekPos(locStartPos.second.first);
    if (CallWorker(THREAD_SEEK) == E_FAIL)
    {
        // Thread not running, we're changing the current position ourselfs
        SetCurrentReaderPos(GetRequestedSeekPos());
    }

	return S_OK;
}
示例#10
0
HRESULT TheoraEncodeInputPin::deliverData(LONGLONG inStart, LONGLONG inEnd, unsigned char* inBuf, unsigned long inNumBytes) {
	//debugLog <<" deliverData : "<<inStart<<" - "<<inEnd<<"  :: size = "<<inNumBytes<<endl;
	//Get a pointer to a new sample stamped with our time
	IMediaSample* locSample;
	HRESULT locHR = mOutputPin->GetDeliveryBuffer(&locSample, &inStart, &inEnd, NULL);

	if (locHR != S_OK) {
		//We get here when the application goes into stop mode usually.
		return locHR;
	}	
	
	BYTE* locBuffer = NULL;

	
	//Make our pointers set to point to the samples buffer
	locSample->GetPointer(&locBuffer);

	if (locSample->GetSize() >= inNumBytes) {

		memcpy((void*)locBuffer, (const void*)inBuf, inNumBytes);
		
		//Set the sample parameters.
		SetSampleParams(locSample, inNumBytes, &inStart, &inEnd);

		{
			CAutoLock locLock(m_pLock);

			HRESULT locHR = ((TheoraEncodeOutputPin*)mOutputPin)->mDataQueue->Receive(locSample);						//->DownstreamFilter()->Receive(locSample);
			if (locHR != S_OK) {
				return locHR;	
			} else {
			}
		}
		//debugLog<<"deliverData : SUCCESS"<<endl;
		return S_OK;
	} else {
		//debugLog<<"Buffer too small !!!! FATALITY !"<<endl;
		throw 0;
	}

}
STDMETHODIMP AbstractTransformInputPin::Receive(IMediaSample* inSample) 
{
	CAutoLock locLock(mStreamLock);

	HRESULT locHR = CheckStreaming();

	if (locHR == S_OK) {
		BYTE* locBuff = NULL;
		locHR = inSample->GetPointer(&locBuff);

		if (locHR != S_OK) {
			//TODO::: Do a debug dump or something here with specific error info.
			return locHR;
		} 
		else 
		{
			/* Read DirectShow timestamps */
			REFERENCE_TIME pTimeStart, pTimeEnd;
			if (inSample->GetTime(&pTimeStart, &pTimeEnd) == NOERROR) 
			{
				m_dsTimeStart = pTimeStart/10000;
				m_dsTimeEnd = pTimeEnd/10000;
			}

            //http://windowssdk.msdn.microsoft.com/en-us/library/ms787541.aspx
            //Consider using receive to validate conditions ^^^
			HRESULT locResult = TransformData(locBuff, inSample->GetActualDataLength());
			if (locResult == S_OK) {
				return S_OK;
			} else {
				return S_FALSE;
			}
		}
	} else {
		//Not streaming - Bail out.
		return S_FALSE;
	}
}
STDMETHODIMP AbstractTransformInputPin::EndFlush() {
	CAutoLock locLock(m_pLock);

	mParentFilter->mOutputPin->DeliverEndFlush();
	return CBaseInputPin::EndFlush();
}
STDMETHODIMP AbstractTransformInputPin::EndOfStream(void) {
	CAutoLock locLock(mStreamLock);
	
	return mParentFilter->mOutputPin->DeliverEndOfStream();
}