Beispiel #1
0
HRESULT CAMROutputPin::DoNewSegment(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, double dRate)
{
	// queue the EOS packet
	this->rtStart	= rtStart;
	this->rtStop	= rtStop;
	this->rate		= dRate;
	eos_delivered	= false;

	discontinuity = true;
	return DeliverNewSegment(rtStart, rtStop, rate);
}
Beispiel #2
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;
}
//******************************************************
/// Called when thread is about to start delivering data to the filter
///
HRESULT CSubtitlePin::OnThreadStartPlay()
{
  //set discontinuity flag indicating to codec that the new data
  //is not belonging to any previous data
  m_bDiscontinuity=TRUE;
  m_bInFillBuffer=false;
  m_bPresentSample=false;

  float fStart=(float)m_rtStart.Millisecs();
  fStart/=1000.0f;

  //  //tell demuxer to start deliver subtitle packets again
  //  CDeMultiplexer& demux=m_pTsReaderFilter->GetDemultiplexer();
  //  demux.SetHoldSubtitle(false);

  LogDebug("subPin:OnThreadStartPlay(%f)", fStart);

  //start playing
  DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
  return CSourceStream::OnThreadStartPlay( );
}
Beispiel #4
0
//******************************************************
/// Called when thread is about to start delivering data to the codec
///
HRESULT CVideoPin::OnThreadStartPlay()
{  
  DWORD thrdID = GetCurrentThreadId();
  LogDebug("vidPin:OnThreadStartPlay(%f), rate:%02.2f, threadID:0x%x, GET_TIME_NOW:0x%x", (float)m_rtStart.Millisecs()/1000.0f, m_dRateSeeking, thrdID, GET_TIME_NOW());

  //set discontinuity flag indicating to codec that the new data
  //is not belonging to any previous data
  m_bDiscontinuity=TRUE;
  m_bPresentSample=false;
  m_delayedDiscont = 0;
  m_FillBuffSleepTime = 1;
  m_LastFillBuffTime = GET_TIME_NOW();
  m_sampleCount = 0;
  m_bInFillBuffer=false;

  m_pTsReaderFilter->m_ShowBufferVideo = INIT_SHOWBUFFERVIDEO;

  m_llLastComp = 0;
  m_llLastMTDts = 0;
  m_nNextMTD = 0;
	m_fMTDMean = 0;
	m_llMTDSumAvg = 0;
  ZeroMemory((void*)&m_pllMTD, sizeof(REFERENCE_TIME) * NB_MTDSIZE);

  //get file-duration and set m_rtDuration
  GetDuration(NULL);

  if( !m_bPinNoNewSegFlush ) //MS DTV video decoder can hang if we flush here...
  {
    //Downstream flush
    DeliverBeginFlush();
    DeliverEndFlush();
  }

  //start playing
  DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
  return CSourceStream::OnThreadStartPlay( );
}
Beispiel #5
0
//******************************************************
/// Called when thread is about to start delivering data to the codec
///
HRESULT CAudioPin::OnThreadStartPlay()
{
  DWORD thrdID = GetCurrentThreadId();
  LogDebug("audPin:OnThreadStartPlay(%f), rate:%02.2f, threadID:0x%x, GET_TIME_NOW:0x%x", (float)m_rtStart.Millisecs()/1000.0f, m_dRateSeeking, thrdID, GET_TIME_NOW());
  
  //set flag to compensate any differences in the stream time & file time
  m_pTsReaderFilter->m_bStreamCompensated = false;

  m_pTsReaderFilter->m_bForcePosnUpdate = true;
  m_pTsReaderFilter->WakeThread();

  m_pTsReaderFilter->m_ShowBufferAudio = INIT_SHOWBUFFERAUDIO;

  //set discontinuity flag indicating to codec that the new data
  //is not belonging to any previous data
  m_bDiscontinuity = TRUE;
  m_bPresentSample = false;
  m_sampleCount = 0;
  m_bInFillBuffer=false;
  m_pTsReaderFilter->m_audioReady = false;

  m_FillBuffSleepTime = 1;
  m_LastFillBuffTime = GET_TIME_NOW();

  ClearAverageFtime();
  
  //get file-duration and set m_rtDuration
  GetDuration(NULL);

  //Downstream flush
  DeliverBeginFlush();
  DeliverEndFlush();
  
  //start playing
  DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
  return CSourceStream::OnThreadStartPlay( );
}
Beispiel #6
0
HRESULT CSubtitleStream::OnThreadStartPlay()
{
	m_bDiscontinuity = TRUE;
	return DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
}
Beispiel #7
0
// vlakno na output
DWORD CAMROutputPin::ThreadProc()
{
	while (true) {
		DWORD cmd = GetRequest();
		switch (cmd) {
			case CMD_EXIT:		Reply(0); return 0; break;
			case CMD_STOP:
				{
					Reply(0); 
				}
				break;
			case CMD_RUN:
				{
					Reply(0);
					if (!IsConnected()) {
						break;
					}

					// deliver packets
					DWORD	cmd2;
					BOOL	is_first = true;
					DataPacketAMR	*packet;
					HRESULT	hr;

					do {
						if (ev_abort.Check()) {
							break;
						}
						hr = NOERROR;
					
						HANDLE	events[] = { ev_can_read, ev_abort};
						DWORD	ret = WaitForMultipleObjects(2, events, FALSE, 10);

						if (ret == WAIT_OBJECT_0) {
							// look for new packet in queue
							{
								CAutoLock	lck(&lock_queue);
								packet = queue.RemoveHead();
								if (queue.IsEmpty()) {
									ev_can_read.Reset();
								}

								// allow buffering
								if (GetBufferTime_MS() < buffer_time_ms) {
									ev_can_write.Set();
								}
							}

							// bud dorucime End Of Stream, alebo packet
							if (packet->type == DataPacketAMR::PACKET_TYPE_EOS) {
								DeliverEndOfStream();
							} else if (packet->type == DataPacketAMR::PACKET_TYPE_NEW_SEGMENT) {
								hr = DeliverNewSegment(packet->rtStart, packet->rtStop, packet->rate);
							} else if (packet->type == DataPacketAMR::PACKET_TYPE_DATA) {
								hr = DeliverDataPacketAMR(*packet);
							}					

							delete packet;

							if (FAILED(hr)) {
								break;
							}
						}
					} while (!CheckRequest(&cmd2));
				}
				break;
			default:
				Reply(E_UNEXPECTED); 
				break;
		}
	}
	return 0;
}
HRESULT	mmSource::OnThreadStartPlay()
{
	_RPT3(_CRT_WARN,"OnThreadStartPlay %d %d %f\n",(int)m_rtStart, (int)m_rtStop, (float)m_dRateSeeking);
	return DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
}
Beispiel #9
0
HRESULT CVideoPin::StartNewSegment()
{
  return DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
}
DWORD CAVIOutputPin::ThreadProc()
{
    CAVIScanner* scanner = m_pSplitter->GetAVIScanner();
    bool bFirst = true;
    REFERENCE_TIME tStart = 0;
    REFERENCE_TIME tStop = 0;
    REFERENCE_TIME duration = 0;
    bool bDeliverEOS = true;
    DWORD req = 0;
    HRESULT hr = S_OK;
    REFERENCE_TIME tSeekStart = 0;
    REFERENCE_TIME tSeekStop = 0;

     double dRate;
    m_pSplitter->GetSeekingParams(&tSeekStart, &tSeekStop, &dRate);
    DeliverNewSegment(tSeekStart, tSeekStop, dRate);
    int startPos = GetIndexStartPosEntry(tSeekStart);
    for (int i = startPos; i < m_pIndex->size(); i++)
    {
        const INDEXENTRY& entry = (*m_pIndex)[i];
        if (!entry.dwChunkLength)
            continue;
        CComPtr<IMediaSample> pSample;
        hr = GetNewSample(&pSample, entry.dwChunkLength);
        
        // Break out without calling EndOfStream if we're asked to
	    // do something different
	    if (CheckRequest(&req)) 
        {
            bDeliverEOS = false;          
            break;
        }


        if (bFirst)
        {
            bFirst = false;
            pSample->SetDiscontinuity(TRUE);
           

        }
        if (entry.dwFlags & AVIIF_INDEX)
            pSample->SetSyncPoint(TRUE);
        tStart = GetCurTime(i) - tSeekStart;
        tStop = GetCurTime(i+1)- tSeekStart;
       
        pSample->SetTime(&tStart,&tStop);
        if (tStart < 0 && tStop <= 0)
            pSample->SetPreroll(TRUE);

        BYTE* pbData = 0;
        pSample->GetPointer(&pbData);
        scanner->ReadData(entry.chunkOffset, entry.dwChunkLength, pbData);   
        hr = Deliver(pSample);
        if (FAILED(hr) || hr == S_FALSE)
        {
            while(true)
            {
                if (CheckRequest(&req)) 
                {
                    bDeliverEOS = false;          
                    break;
                }
                Sleep(100);
            }           
        }
    }
    if (bDeliverEOS)
        DeliverEndOfStream();

    req =GetRequest();
    Reply(S_OK);
    return 0;
}
// CSourceSeeking
HRESULT my12doomImageStream::OnThreadStartPlay()
{
	return DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
}
Beispiel #12
0
//----------------------------------------------------------------------------
//! @brief	  	新たに再生が開始されたことを通知する
//! @return		エラーコード
//----------------------------------------------------------------------------
HRESULT CDemuxSource::NewSegment()
{
	return DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
}