Esempio n. 1
0
// get the stream time at which this sample should start and finish.
STDMETHODIMP
CMediaSample::GetTime(
					  REFERENCE_TIME * pTimeStart,     // put time here
					  REFERENCE_TIME * pTimeEnd
					  )
{
	ValidateReadWritePtr(pTimeStart,sizeof(REFERENCE_TIME));
	ValidateReadWritePtr(pTimeEnd,sizeof(REFERENCE_TIME));

	if (!(m_dwFlags & Sample_StopValid)) {
		if (!(m_dwFlags & Sample_TimeValid)) {
			return VFW_E_SAMPLE_TIME_NOT_SET;
		} else {
			*pTimeStart = m_Start;

			//  Make sure old stuff works
			*pTimeEnd = m_Start + 1;
			return VFW_S_NO_STOP_TIME;
		}
	}

	*pTimeStart = m_Start;
	*pTimeEnd = m_End;
	return NOERROR;
}
Esempio n. 2
0
//----------------------------------------------------------------------------
//! @brief	  	要求するメモリの詳細を設定する。
//! @param		pRequest : バッファ要求を含む ALLOCATOR_PROPERTIES 構造体のポインタ
//! @param		pActual : 実際のバッファ プロパティを受け取る ALLOCATOR_PROPERTIES 構造体のポインタ
//! @return		エラーコード
//----------------------------------------------------------------------------
STDMETHODIMP TBufferRendererAllocator::SetProperties( ALLOCATOR_PROPERTIES* pRequest, ALLOCATOR_PROPERTIES* pActual )
{
	CheckPointer( pActual, E_POINTER );
	ValidateReadWritePtr( pActual, sizeof(ALLOCATOR_PROPERTIES) );
	CAutoLock	cObjectLock(this);

    ZeroMemory( pActual, sizeof(ALLOCATOR_PROPERTIES) );

	if( m_bCommitted == TRUE)
		return VFW_E_ALREADY_COMMITTED;

	if( m_lFree.GetCount() < m_lAllocated )	// m_lAllocatedが1個以上の時はエラーにした方がよい?
		return VFW_E_BUFFERS_OUTSTANDING;

	if( pRequest->cBuffers == 1 && pRequest->cbBuffer == m_pRenderer->GetBufferSize() &&
		pRequest->cbAlign == 1 && pRequest->cbPrefix == 0 )
	{
		*pActual = *pRequest;
		m_lSize = pRequest->cbBuffer;
		m_lCount = pRequest->cBuffers;
		m_lAlignment = pRequest->cbAlign;
		m_lPrefix = pRequest->cbPrefix;
		m_bChanged = TRUE;
		return S_OK;
	}

	return VFW_E_BADALIGN;
}
Esempio n. 3
0
STDMETHODIMP CTransInPlaceInputPin::GetAllocator(IMemAllocator ** ppAllocator)
{
    CheckPointer(ppAllocator,E_POINTER);
    ValidateReadWritePtr(ppAllocator,sizeof(IMemAllocator *));
    CAutoLock cObjectLock(m_pLock);

    HRESULT hr;

    if ( m_pTIPFilter->m_pOutput->IsConnected() ) {
        //  Store the allocator we got
        hr = m_pTIPFilter->OutputPin()->ConnectedIMemInputPin()
                                        ->GetAllocator( ppAllocator );
        if (SUCCEEDED(hr)) {
            m_pTIPFilter->OutputPin()->SetAllocator( *ppAllocator );
        }
    }
    else {
        //  Help upstream filter (eg TIP filter which is having to do a copy)
        //  by providing a temp allocator here - we'll never use
        //  this allocator because when our output is connected we'll
        //  reconnect this pin
        hr = CTransformInputPin::GetAllocator( ppAllocator );
    }
    return hr;

} // GetAllocator
Esempio n. 4
0
STDMETHODIMP
CTransformOutputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv) {
    CheckPointer(ppv,E_POINTER);
    ValidateReadWritePtr(ppv,sizeof(PVOID));
    *ppv = NULL;

    if(riid == IID_IMediaPosition || riid == IID_IMediaSeeking) {

        // we should have an input pin by now

        ASSERT(m_pTransformFilter->m_pInput != NULL);

        if(m_pPosition == NULL) {

            HRESULT hr = CreatePosPassThru(GetOwner(),
                FALSE,
                (IPin *)m_pTransformFilter->m_pInput,
                &m_pPosition);
            if(FAILED(hr)) {
                return hr;
            }
        }
        return m_pPosition->QueryInterface(riid, ppv);
    }
    else {
        return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);
    }
}
Esempio n. 5
0
STDMETHODIMP CStreamSwitcherOutputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
    CheckPointer(ppv, E_POINTER);
    ValidateReadWritePtr(ppv, sizeof(PVOID));
    *ppv = nullptr;

    if (riid == IID_IMediaPosition || riid == IID_IMediaSeeking) {
        if (m_pStreamSwitcherPassThru == nullptr) {
            HRESULT hr = S_OK;
            m_pStreamSwitcherPassThru = (IUnknown*)(INonDelegatingUnknown*)
                                        DEBUG_NEW CStreamSwitcherPassThru(GetOwner(), &hr, static_cast<CStreamSwitcherFilter*>(m_pFilter));

            if (!m_pStreamSwitcherPassThru) {
                return E_OUTOFMEMORY;
            }
            if (FAILED(hr)) {
                return hr;
            }
        }

        return m_pStreamSwitcherPassThru->QueryInterface(riid, ppv);
    }
    /*
        else if (riid == IID_IStreamBuilder)
        {
            return GetInterface((IStreamBuilder*)this, ppv);
        }
    */
    return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);
}
Esempio n. 6
0
//
// FindPin
//
// If Id is In or Out then return the IPin* for that pin
// creating the pin if need be.  Otherwise return NULL with an error.
STDMETHODIMP CParserFilter::FindPin(LPCWSTR Id, IPin **ppPin) 
{
    CheckPointer(ppPin,E_POINTER);
    ValidateReadWritePtr(ppPin,sizeof(IPin *));

    if(0==lstrcmpW(Id,L"In")) {
        *ppPin = GetPin(0);
    }
    else if(0==lstrcmpW(Id,L"Out")) {
        *ppPin = GetPin(1);
    }
    else {
        *ppPin = NULL;
        return VFW_E_NOT_FOUND;
    }

    HRESULT hr = NOERROR;
    //  AddRef() returned pointer - but GetPin could fail if memory is low.
    if(*ppPin) {
        (*ppPin)->AddRef();
    }
    else {
        hr = E_OUTOFMEMORY;  // probably.  There's no pin anyway.
    }
    return hr;
}
STDMETHODIMP CAnalyzerWriterFilter::GetClassID(CLSID *pClsID)
{
    CheckPointer(pClsID,E_POINTER);
    ValidateReadWritePtr(pClsID,sizeof(CLSID));
    *pClsID = CLSID_FileWriter;
    return NOERROR;
}
Esempio n. 8
0
// get the media times (eg bytes) for this sample
STDMETHODIMP
CMediaSample::GetMediaTime(
						   LONGLONG * pTimeStart,
						   LONGLONG * pTimeEnd
						   )
{
	ValidateReadWritePtr(pTimeStart,sizeof(LONGLONG));
	ValidateReadWritePtr(pTimeEnd,sizeof(LONGLONG));

	if (!(m_dwFlags & Sample_MediaTimeValid)) {
		return VFW_E_MEDIA_TIME_NOT_SET;
	}

	*pTimeStart = m_MediaStart;
	*pTimeEnd = (m_MediaStart + m_MediaEnd);
	return NOERROR;
}
Esempio n. 9
0
/* Return the clock's clsid */
STDMETHODIMP
CSystemClock::GetClassID(__out CLSID *pClsID)
{
    CheckPointer(pClsID,E_POINTER);
    ValidateReadWritePtr(pClsID,sizeof(CLSID));
    *pClsID = CLSID_SystemClock;
    return NOERROR;
}
STDMETHODIMP
CBaseDispatch::GetTypeInfoCount(UINT * pctinfo)
{
    CheckPointer(pctinfo,E_POINTER);
    ValidateReadWritePtr(pctinfo,sizeof(UINT *));
    *pctinfo = 1;
    return S_OK;
}
Esempio n. 11
0
STDMETHODIMP CAMMediaContent::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{
    ValidateReadWritePtr(ppv,sizeof(PVOID));
    if (riid == IID_IAMMediaContent) {
		return GetInterface((IAMMediaContent*)this, ppv);
    } else {
		return CUnknown::NonDelegatingQueryInterface(riid, ppv);
    }
}
STDMETHODIMP
CMediaPosition::NonDelegatingQueryInterface(REFIID riid, void **ppv)
{
    ValidateReadWritePtr(ppv,sizeof(PVOID));
    if (riid == IID_IMediaPosition) {
	return GetInterface( (IMediaPosition *) this, ppv);
    } else {
	return CUnknown::NonDelegatingQueryInterface(riid, ppv);
    }
}
Esempio n. 13
0
STDMETHODIMP
CBasePin::QueryDirection(
						 PIN_DIRECTION * pPinDir
						 )
{
	CheckPointer(pPinDir,E_POINTER);
	ValidateReadWritePtr(pPinDir,sizeof(PIN_DIRECTION));

	*pPinDir = m_dir;
	return NOERROR;
}
STDMETHODIMP CMVEADPCMDecompressor::NonDelegatingQueryInterface(REFIID riid, void **ppv)
{
	// Check and validate the pointer
	CheckPointer(ppv, E_POINTER);
	ValidateReadWritePtr(ppv, sizeof(PVOID));

	// Expose ISpecifyPropertyPages (and the base-class interfaces)
	if (riid == IID_ISpecifyPropertyPages)
		return GetInterface((ISpecifyPropertyPages*)this, ppv);
	else
		return CTransformFilter::NonDelegatingQueryInterface(riid, ppv);
}
Esempio n. 15
0
// get me a read/write pointer to this buffer's memory. I will actually
// want to use sizeUsed bytes.
STDMETHODIMP
CMediaSample::GetPointer(BYTE ** ppBuffer)
{
	ValidateReadWritePtr(ppBuffer,sizeof(BYTE *));

	// creator must have set pointer either during
	// constructor or by SetPointer
	ASSERT(m_pBuffer);

	*ppBuffer = m_pBuffer;
	return NOERROR;
}
Esempio n. 16
0
STDMETHODIMP CSubtitleSource::QueryFilterInfo(FILTER_INFO* pInfo)
{
	CheckPointer(pInfo, E_POINTER);
	ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
	wcscpy_s(pInfo->achName, SubtitleSourceName);
	pInfo->pGraph = m_pGraph;
	if (m_pGraph) {
		m_pGraph->AddRef();
	}

	return S_OK;
}
Esempio n. 17
0
// Return a wide string - allocating memory for it
// Returns:
//    S_OK          - no error
//    E_POINTER     - ppszReturn == NULL
//    E_OUTOFMEMORY - can't allocate memory for returned string
STDAPI AMGetWideString(LPCWSTR psz, LPWSTR *ppszReturn)
{
    CheckPointer(ppszReturn, E_POINTER);
    ValidateReadWritePtr(ppszReturn, sizeof(LPWSTR));
    DWORD nameLen = sizeof(WCHAR) * (lstrlenW(psz)+1);
    *ppszReturn = (LPWSTR)CoTaskMemAlloc(nameLen);
    if (*ppszReturn == NULL) {
       return E_OUTOFMEMORY;
    }
    CopyMemory(*ppszReturn, psz, nameLen); /*ffdshow custom*/
    return NOERROR;
}
Esempio n. 18
0
// overriden to expose IMediaPosition and IMediaSeeking control interfaces
STDMETHODIMP CParserOutputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv) 
{
    CheckPointer(ppv,E_POINTER);
    ValidateReadWritePtr(ppv,sizeof(PVOID));
    *ppv = NULL;

    // See what interface the caller is interested in.
    if (riid == IID_IMediaPosition || riid == IID_IMediaSeeking) 
	{
        return CSourceSeeking::NonDelegatingQueryInterface(riid, ppv);
    } 
	else
        return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);
}
Esempio n. 19
0
STDMETHODIMP CMPEGFilter::QueryVendorInfo(LPWSTR *pVendorInfo)
{
    CheckPointer(pVendorInfo, E_POINTER);
    ValidateReadWritePtr(pVendorInfo, sizeof(LPWSTR));

    *pVendorInfo = (LPWSTR)CoTaskMemAlloc(256);
    if(*pVendorInfo==NULL)
    {
        return E_OUTOFMEMORY;
    }

    wcscpy_s(*pVendorInfo, 256, L"Standard MPEG");
    return NOERROR;
}
Esempio n. 20
0
STDMETHODIMP CDXVA2Sample::QueryInterface(REFIID riid, __deref_out void **ppv)
{
  CheckPointer(ppv,E_POINTER);
  ValidateReadWritePtr(ppv,sizeof(PVOID));

  if (riid == __uuidof(IMFGetService)) {
    return GetInterface((IMFGetService*) this, ppv);
  }
  if (riid == __uuidof(ILAVDXVA2Sample)) {
    return GetInterface((ILAVDXVA2Sample*) this, ppv);
  } else {
    return CMediaSample::QueryInterface(riid, ppv);
  }
}
Esempio n. 21
0
//
// Set Id to point to a CoTaskMemAlloc'd
STDMETHODIMP CSourceStream::QueryId(LPWSTR *Id) {
    CheckPointer(Id,E_POINTER);
    ValidateReadWritePtr(Id,sizeof(LPWSTR));

    // We give the pins id's which are 1,2,...
    // FindPinNumber returns -1 for an invalid pin
    int i = 1+ m_pFilter->FindPinNumber(this);
    if (i<1) return VFW_E_NOT_FOUND;
    *Id = (LPWSTR)CoTaskMemAlloc(8);
    if (*Id==NULL) {
       return E_OUTOFMEMORY;
    }
    IntToWstr(i, *Id);
    return NOERROR;
}
Esempio n. 22
0
//
// FindPin
//
// Set *ppPin to the IPin* that has the id Id.
// or to NULL if the Id cannot be matched.
STDMETHODIMP CSource::FindPin(LPCWSTR Id, IPin **ppPin)
{
    CheckPointer(ppPin,E_POINTER);
    ValidateReadWritePtr(ppPin,sizeof(IPin *));
    // The -1 undoes the +1 in QueryId and ensures that totally invalid
    // strings (for which WstrToInt delivers 0) give a deliver a NULL pin.
    int i = WstrToInt(Id) -1;
    *ppPin = GetPin(i);
    if (*ppPin!=NULL){
        (*ppPin)->AddRef();
        return NOERROR;
    } else {
        return VFW_E_NOT_FOUND;
    }
}
Esempio n. 23
0
STDMETHODIMP CUnknown::NonDelegatingQueryInterface(REFIID riid, void ** ppv)
{
    CheckPointer(ppv,E_POINTER);
    ValidateReadWritePtr(ppv,sizeof(PVOID));

    /* We know only about IUnknown */

    if (riid == IID_IUnknown) {
        GetInterface((LPUNKNOWN) (PNDUNKNOWN) this, ppv);
        return NOERROR;
    } else {
        *ppv = NULL;
        return E_NOINTERFACE;
    }
}
Esempio n. 24
0
STDMETHODIMP CMpaSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
{
	CheckPointer(pInfo, E_POINTER);
	ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));

	if (m_pName && m_pName[0]==L'M' && m_pName[1]==L'P' && m_pName[2]==L'C') {
		(void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
	} else {
		wcscpy(pInfo->achName, MpaSourceName);
	}
	pInfo->pGraph = m_pGraph;
	if (m_pGraph) {
		m_pGraph->AddRef();
	}

	return S_OK;
}
Esempio n. 25
0
/* Return the media type of the connection */
STDMETHODIMP
CBasePin::ConnectionMediaType(
							  AM_MEDIA_TYPE *pmt
							  )
{
	CheckPointer(pmt,E_POINTER);
	ValidateReadWritePtr(pmt,sizeof(AM_MEDIA_TYPE));
	CComAutoLock cObjectLock(m_pLock);

	/*  Copy constructor of m_mt allocates the memory */
	if (IsConnected()) {
		CopyMediaType( pmt, &m_mt );
		return S_OK;
	} else {
		((CMediaType *)pmt)->InitMediaType();
		return VFW_E_NOT_CONNECTED;
	}
}
Esempio n. 26
0
STDMETHODIMP
CBasePin::EnumMediaTypes(
						 IEnumMediaTypes **ppEnum
						 )
{
	CheckPointer(ppEnum,E_POINTER);
	ValidateReadWritePtr(ppEnum,sizeof(IEnumMediaTypes *));

	/* Create a new ref counted enumerator */

	*ppEnum = new CEnumMediaTypes(this,
		NULL);

	if (*ppEnum == NULL) {
		return E_OUTOFMEMORY;
	}

	return NOERROR;
}
Esempio n. 27
0
STDMETHODIMP CDXFilterInPin::EnumMediaTypes( IEnumMediaTypes **ppEnum )
{
    CheckPointer(ppEnum,E_POINTER);
    ValidateReadWritePtr(ppEnum,sizeof(IEnumMediaTypes *));

    // if the output pin isn't connected yet, offer the possibly 
    // partially specified media type that has been set by the user

    if( !((CDXFilter*)m_pTIPFilter)->OutputPin( )->IsConnected() )
    {
        // Create a new reference counted enumerator

        *ppEnum = new CEnumMediaTypes( this, NULL );

        return (*ppEnum) ? NOERROR : E_OUTOFMEMORY;
    }

    // if the output pin is connected, offer it's fully qualified media type

    return ((CDXFilter*)m_pTIPFilter)->OutputPin( )->GetConnected()->EnumMediaTypes( ppEnum );
}
Esempio n. 28
0
STDMETHODIMP
CEnumPins::Clone(IEnumPins **ppEnum)
{
	CheckPointer(ppEnum,E_POINTER);
	ValidateReadWritePtr(ppEnum,sizeof(IEnumPins *));
	HRESULT hr = NOERROR;

	/* Check we are still in sync with the filter */
	if (AreWeOutOfSync() == TRUE) {
		*ppEnum = NULL;
		hr =  VFW_E_ENUM_OUT_OF_SYNC;
	} else {

		*ppEnum = new CEnumPins(m_pFilter,
			this);
		if (*ppEnum == NULL) {
			hr = E_OUTOFMEMORY;
		}
	}
	return hr;
}
//
// get_OutputFormat
//
STDMETHODIMP CAudioSynth::get_OutputFormat(SYNTH_OUTPUT_FORMAT *pOutputFormat)
{
    CheckPointer(pOutputFormat, E_POINTER);

    ValidateReadWritePtr(pOutputFormat, sizeof(SYNTH_OUTPUT_FORMAT));

    switch(m_wFormatTag)
    {
        case WAVE_FORMAT_PCM:
            *pOutputFormat = SYNTH_OF_PCM;
            break;

        case WAVE_FORMAT_ADPCM:
            *pOutputFormat = SYNTH_OF_MS_ADPCM;
            break;

        default:
            return E_UNEXPECTED;
    }

    return S_OK;
}
Esempio n. 30
0
/* Return an AddRef()'d pointer to the connected pin if there is one */
STDMETHODIMP
CBasePin::ConnectedTo(
					  IPin **ppPin
					  )
{
	CheckPointer(ppPin,E_POINTER);
	ValidateReadWritePtr(ppPin,sizeof(IPin *));
	//
	//  It's pointless to lock here.
	//  The caller should ensure integrity.
	//

	IPin *pPin = m_Connected;
	*ppPin = pPin;
	if (pPin != NULL) {
		pPin->AddRef();
		return S_OK;
	} else {
		ASSERT(*ppPin == NULL);
		return VFW_E_NOT_CONNECTED;
	}
}