本文整理匯總了C++中DeleteMediaType函數的典型用法代碼示例。如果您正苦於以下問題:C++ DeleteMediaType函數的具體用法?C++ DeleteMediaType怎麽用?C++ DeleteMediaType使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DeleteMediaType函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: while
BOOL CSampleCGB::HasMediaType(IPin *pPin, REFGUID majorType )
{
if(!pPin)
{
return FALSE;
}
SmartPtr<IEnumMediaTypes> pMediaTypes;
HRESULT hr = pPin->EnumMediaTypes(&pMediaTypes);
if(FAILED(hr))return FALSE;
hr = pMediaTypes->Reset();
if(FAILED(hr))return FALSE;
ULONG cFetched;
AM_MEDIA_TYPE* pTempMediaType;
while(S_OK == pMediaTypes->Next(1,&pTempMediaType,&cFetched))
{
if(::IsEqualGUID(pTempMediaType->majortype,majorType))
{
DeleteMediaType(pTempMediaType);
return TRUE;
}
DeleteMediaType(pTempMediaType);
}
return FALSE;
}
示例2: while
//-----------------------------------------------------------------------------
// GetPin
// Find the pin of the specified format type on the given filter
// This method leaves an outstanding reference on the pin if successful
HRESULT CDSUtils::GetPin(IBaseFilter* pFilter, const GUID* pFormat, PIN_DIRECTION PinDir, IPin** ppPin)
{
HRESULT hr = S_OK;
if (pFilter && pFormat && ppPin)
{
CComPtr<IEnumPins> pIEnumPins = NULL;
hr = pFilter->EnumPins(&pIEnumPins);
if (SUCCEEDED(hr))
{
// find the pin with the specified format
IPin* pIPin = NULL;
while (S_OK == pIEnumPins->Next(1, &pIPin, NULL))
{
// match the pin direction
PIN_DIRECTION pinDir;
pIPin->QueryDirection(&pinDir);
if (pinDir == PinDir)
{
// match pin direction check the first media type returned from the upstream pin
CComPtr<IEnumMediaTypes> pIEnumMT = NULL;
hr = pIPin->EnumMediaTypes(&pIEnumMT);
if (SUCCEEDED(hr))
{
AM_MEDIA_TYPE* pmt = NULL;
hr = pIEnumMT->Next(1, &pmt, NULL);
if (S_OK == hr)
{
if (pmt->majortype == *pFormat)
{
// found the pin with the specified format
*ppPin = pIPin;
DeleteMediaType(pmt);
break;
}
else
{
DeleteMediaType(pmt);
}
}
}
}
SAFE_RELEASE(pIPin);
}
if (NULL == *ppPin)
{
// failed to find the named pin
hr = E_FAIL;
}
}
}
else
{
hr = E_INVALIDARG;
}
return hr;
}
示例3: while
STDMETHODIMP CStreamSwitcherFilter::Enable(long lIndex, DWORD dwFlags)
{
if (dwFlags != AMSTREAMSELECTENABLE_ENABLE) {
return E_NOTIMPL;
}
PauseGraph;
bool bFound = false;
int i = 0;
CStreamSwitcherInputPin* pNewInputPin = nullptr;
POSITION pos = m_pInputs.GetHeadPosition();
while (pos && !bFound) {
pNewInputPin = m_pInputs.GetNext(pos);
if (pNewInputPin->IsConnected()) {
if (CComPtr<IAMStreamSelect> pSSF = pNewInputPin->GetStreamSelectionFilter()) {
DWORD cStreams = 0;
HRESULT hr = pSSF->Count(&cStreams);
if (SUCCEEDED(hr)) {
for (i = 0; i < (int)cStreams; i++) {
AM_MEDIA_TYPE* pmt = nullptr;
hr = pSSF->Info(i, &pmt, nullptr, nullptr, NULL, nullptr, nullptr, nullptr);
if (SUCCEEDED(hr) && pmt && pmt->majortype == MEDIATYPE_Audio) {
if (lIndex == 0) {
bFound = true;
DeleteMediaType(pmt);
break;
} else {
lIndex--;
}
}
DeleteMediaType(pmt);
}
}
} else if (lIndex == 0) {
bFound = true;
} else {
lIndex--;
}
}
}
if (!bFound) {
return E_INVALIDARG;
}
SelectInput(pNewInputPin);
if (CComPtr<IAMStreamSelect> pSSF = pNewInputPin->GetStreamSelectionFilter()) {
pSSF->Enable(i, dwFlags);
}
ResumeGraph;
return S_OK;
}
示例4: FindDecoderSubpictureOutputPin
IPin* FindDecoderSubpictureOutputPin(IBaseFilter* pFilter)
{
IEnumPins* pEnum = NULL;
HRESULT hr = pFilter->EnumPins(&pEnum);
if (hr != NOERROR)
return NULL;
ULONG ulFound;
IPin *pPin = NULL;
hr = E_FAIL;
while(S_OK == pEnum->Next(1, &pPin, &ulFound))
{
PIN_INFO PinInfo;
//
// grab this, so we can examine its name field
//
hr = pPin->QueryPinInfo(&PinInfo);
if(SUCCEEDED(hr))
{
PinInfo.pFilter->Release();
//
// check direction
//
if (PinInfo.dir == PINDIR_OUTPUT)
{
// Make sure its not connected yet and its a video type.
IPin* dummyPin = NULL;
hr = pPin->ConnectedTo(&dummyPin);
SAFE_RELEASE(dummyPin);
if (hr == VFW_E_NOT_CONNECTED)
{
IEnumMediaTypes *mtEnum = NULL;
pPin->EnumMediaTypes(&mtEnum);
AM_MEDIA_TYPE *pMT = NULL;
while (S_OK == mtEnum->Next(1, &pMT, NULL))
{
if (pMT->majortype == MEDIATYPE_Video)
{
DeleteMediaType(pMT);
SAFE_RELEASE(mtEnum);
SAFE_RELEASE(pEnum);
return pPin;
}
DeleteMediaType(pMT);
}
SAFE_RELEASE(mtEnum);
}
}
}
pPin->Release();
}
SAFE_RELEASE(pEnum);
return NULL;
}
示例5: while
/* 設置捕獲圖像幀的格式,遍曆所有格式是否有預定格式,若沒有則以默認格式捕獲 */
HRESULT CVMR_Capture::InitVideoWindow(HWND hWnd,int width, int height)
{
HRESULT hr;
RECT rcDest;
IAMStreamConfig *pConfig;
IEnumMediaTypes *pMedia;
AM_MEDIA_TYPE *pmt = NULL, *pfnt = NULL;
hr = m_pCamOutPin->EnumMediaTypes( &pMedia );
if(SUCCEEDED(hr))
{
//把所有視頻的所有格式遍曆一遍,看是否有預定的格式
while(pMedia->Next(1, &pmt, 0) == S_OK)
{
if( pmt->formattype == FORMAT_VideoInfo )
{
VIDEOINFOHEADER *vih = (VIDEOINFOHEADER *)pmt->pbFormat;
// 當前的格式是否與預定格式相同,即寬和高相同
if( vih->bmiHeader.biWidth == width && vih->bmiHeader.biHeight == height )
{
pfnt = pmt;
break;
}
DeleteMediaType( pmt );
}
}
pMedia->Release();
}
hr = m_pCamOutPin->QueryInterface( IID_IAMStreamConfig, (void **) &pConfig );
if(SUCCEEDED(hr))
{
// 有預定的格式
if( pfnt != NULL )
{
hr=pConfig->SetFormat( pfnt );
DeleteMediaType( pfnt );
}
// 沒有預定的格式,讀取缺省媒體格式
hr = pConfig->GetFormat( &pfnt );
if(SUCCEEDED(hr))
{
m_nWidth = ((VIDEOINFOHEADER *)pfnt->pbFormat)->bmiHeader.biWidth; //讀取高
m_nHeight = ((VIDEOINFOHEADER *)pfnt->pbFormat)->bmiHeader.biHeight; //讀取寬
DeleteMediaType( pfnt );
}
}
// 獲取傳入窗口的區域,以設置顯示窗口
::GetClientRect (hWnd,&rcDest);
hr = m_pWC->SetVideoPosition(NULL, &rcDest);
return hr;
}
示例6: lock
//
// Receive
//
// Do something with this media sample
//
STDMETHODIMP CWasapiInputPin::Receive(IMediaSample *pSample)
{
// DebugPrintf(L"Receive\n");
CAutoLock lock(m_pReceiveLock);
CheckPointer(pSample,E_POINTER);
bool mediaTypeFailed=false;
HRESULT hr = CBaseInputPin::Receive(pSample);
if(hr!=S_OK)
{
DebugPrintf(L"CWasapiInputPin::Receive CBaseInputPin returned error. %d \n",hr);
goto exit;
}
CMediaType* mediaType=NULL;
hr=pSample->GetMediaType((AM_MEDIA_TYPE**)&mediaType);
if(hr==S_OK)
{
hr = CBasePin::SetMediaType(mediaType);
DeleteMediaType(mediaType);
}
hr= m_pManager->SampleReceived(pSample);
if(hr==S_FALSE) //Media type rejected by Wasapi engine
{
DebugPrintf(L"CWasapiInputPin::Receive returning EC_ERRORABORT. \n");
CBasePin::EndOfStream();
m_pFilter->NotifyEvent(EC_ERRORABORT,NULL,NULL);
goto exit;
}
exit:
return hr;
}
示例7: mcpy
void DeviceSource::SetAudioInfo(AM_MEDIA_TYPE *audioMediaType, GUID &expectedAudioType)
{
expectedAudioType = audioMediaType->subtype;
if(audioMediaType->formattype == FORMAT_WaveFormatEx)
{
WAVEFORMATEX *pFormat = reinterpret_cast<WAVEFORMATEX*>(audioMediaType->pbFormat);
mcpy(&audioFormat, pFormat, sizeof(audioFormat));
Log(TEXT(" device audio info - bits per sample: %u, channels: %u, samples per sec: %u, block size: %u"),
audioFormat.wBitsPerSample, audioFormat.nChannels, audioFormat.nSamplesPerSec, audioFormat.nBlockAlign);
//avoid local resampling if possible
/*if(pFormat->nSamplesPerSec != 44100)
{
pFormat->nSamplesPerSec = 44100;
if(SUCCEEDED(audioConfig->SetFormat(audioMediaType)))
{
Log(TEXT(" also successfully set samples per sec to 44.1k"));
audioFormat.nSamplesPerSec = 44100;
}
}*/
}
else
{
AppWarning(TEXT("DShowAudioPlugin: Audio format was not a normal wave format"));
soundOutputType = 0;
}
DeleteMediaType(audioMediaType);
}
示例8: DeleteMediaType
STDMETHODIMP
CMediaSample::SetMediaType(AM_MEDIA_TYPE *pMediaType)
{
/* Delete the current media type */
if (m_pMediaType) {
DeleteMediaType(m_pMediaType);
m_pMediaType = NULL;
}
/* Mechanism for resetting the format type */
if (pMediaType == NULL) {
m_dwFlags &= ~Sample_TypeChanged;
return NOERROR;
}
ASSERT(pMediaType);
ValidateReadPtr(pMediaType,sizeof(AM_MEDIA_TYPE));
/* Take a copy of the media type */
m_pMediaType = CreateMediaType(pMediaType);
if (m_pMediaType == NULL) {
m_dwFlags &= ~Sample_TypeChanged;
return E_OUTOFMEMORY;
}
m_dwFlags |= Sample_TypeChanged;
return NOERROR;
}
示例9: _mm_empty
HRESULT CBaseVideoFilter::Receive(IMediaSample* pIn)
{
#ifndef _WIN64
// TODOX64 : fixme!
_mm_empty(); // just for safety
#endif
CAutoLock cAutoLock(&m_csReceive);
HRESULT hr;
AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
if (pProps->dwStreamId != AM_STREAM_MEDIA) {
return m_pOutput->Deliver(pIn);
}
AM_MEDIA_TYPE* pmt;
if (SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
m_pInput->SetMediaType(&mt);
DeleteMediaType(pmt);
}
if (FAILED(hr = Transform(pIn))) {
return hr;
}
return S_OK;
}
示例10: CheckPointer
HRESULT CBaseVideoFilter::GetDeliveryBuffer(int w, int h, IMediaSample** ppOut)
{
CheckPointer(ppOut, E_POINTER);
HRESULT hr;
if (FAILED(hr = ReconnectOutput(w, h))) {
return hr;
}
if (FAILED(hr = m_pOutput->GetDeliveryBuffer(ppOut, NULL, NULL, 0))) {
return hr;
}
AM_MEDIA_TYPE* pmt;
if (SUCCEEDED((*ppOut)->GetMediaType(&pmt)) && pmt) {
CMediaType mt = *pmt;
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
}
(*ppOut)->SetDiscontinuity(FALSE);
(*ppOut)->SetSyncPoint(TRUE);
// FIXME: hell knows why but without this the overlay mixer starts very skippy
// (don't enable this for other renderers, the old for example will go crazy if you do)
if (GetCLSID(m_pOutput->GetConnected()) == CLSID_OverlayMixer) {
(*ppOut)->SetDiscontinuity(TRUE);
}
return S_OK;
}
示例11: cAutoLock
STDMETHODIMP CStreamSwitcherFilter::Count(DWORD* pcStreams)
{
if (!pcStreams) {
return E_POINTER;
}
CAutoLock cAutoLock(&m_csPins);
*pcStreams = 0;
POSITION pos = m_pInputs.GetHeadPosition();
while (pos) {
CStreamSwitcherInputPin* pInputPin = m_pInputs.GetNext(pos);
if (pInputPin->IsConnected()) {
if (CComPtr<IAMStreamSelect> pSSF = pInputPin->GetStreamSelectionFilter()) {
DWORD cStreams = 0;
HRESULT hr = pSSF->Count(&cStreams);
if (SUCCEEDED(hr)) {
for (int i = 0; i < (int)cStreams; i++) {
AM_MEDIA_TYPE* pmt = nullptr;
hr = pSSF->Info(i, &pmt, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
if (SUCCEEDED(hr) && pmt && pmt->majortype == MEDIATYPE_Audio) {
(*pcStreams)++;
}
DeleteMediaType(pmt);
}
}
} else {
(*pcStreams)++;
}
}
}
return S_OK;
}
示例12: setPropsTime
STDMETHODIMP TffdshowEncDshow::getDstBuffer(IMediaSample* *pOut, const TffPict &pict)
{
*pOut = NULL;
BYTE *data;
HRESULT hr;
if (FAILED(hr = getDeliveryBuffer(pOut, &data))) {
return hr;
}
if (pict.rtStart == REFTIME_INVALID || pict.rtStop == REFTIME_INVALID) {
REFERENCE_TIME tStart = (params.framenum) * inpin->avgTimePerFrame;
REFERENCE_TIME tStop = (params.framenum + 1) * inpin->avgTimePerFrame;
setPropsTime(*pOut, tStart, tStop, m_pInput->SampleProps(), &m_bSampleSkipped);
//DPRINTF("tStart:%i, tStop:%i, AVIfps:%i",int(tStart),int(tStop),timePerFrame);
} else {
(*pOut)->SetTime((REFERENCE_TIME*)&pict.rtStart, (REFERENCE_TIME*)&pict.rtStop);
}
AM_MEDIA_TYPE *mtOut;
(*pOut)->GetMediaType(&mtOut);
if (mtOut != NULL) {
HRESULT result = S_OK;
DeleteMediaType(mtOut);
if (result != S_OK) {
return result;
}
}
return S_OK;
}
示例13: CopyMediaType
HRESULT CStreamSwitcherOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
if (!pIn || !pIn->IsConnected()) {
return E_UNEXPECTED;
}
CComPtr<IEnumMediaTypes> pEM;
if (FAILED(pIn->GetConnected()->EnumMediaTypes(&pEM))) {
return VFW_S_NO_MORE_ITEMS;
}
if (iPosition > 0 && FAILED(pEM->Skip(iPosition))) {
return VFW_S_NO_MORE_ITEMS;
}
AM_MEDIA_TYPE* tmp = nullptr;
if (S_OK != pEM->Next(1, &tmp, nullptr) || !tmp) {
return VFW_S_NO_MORE_ITEMS;
}
CopyMediaType(pmt, tmp);
DeleteMediaType(tmp);
/*
if (iPosition < 0) return E_INVALIDARG;
if (iPosition > 0) return VFW_S_NO_MORE_ITEMS;
CopyMediaType(pmt, &pIn->CurrentMediaType());
*/
return S_OK;
}
示例14: BindFilter
void VideoCapture::EnumResolutions()
{
int iCount, iSize, iChosen=-1;
IBaseFilter *pSource;
CComPtr <ICaptureGraphBuilder2> pCaptB;
VIDEO_STREAM_CONFIG_CAPS caps;
HRESULT hr;
bool response;
IAMStreamConfig *pConfig;
devices_resolutions = new DeviceResolutions[nDevices];
pCaptB.CoCreateInstance(CLSID_CaptureGraphBuilder2);
for (unsigned int iDevice=0; iDevice<nDevices; iDevice++)
{
response = BindFilter(iDevice, &pSource);
hr = pCaptB->FindInterface(
&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video,
pSource,
IID_IAMStreamConfig,
(void**)&pConfig);
if (!SUCCEEDED(hr))
{
pSource->Release();
devices_resolutions[iDevice].nResolutions = 0;
continue;
}
pConfig->GetNumberOfCapabilities(&iCount, &iSize);
devices_resolutions[iDevice].SetNResolutions(iCount);
for(int i=0; i < iCount; i++) {
AM_MEDIA_TYPE *pmt;
if( pConfig->GetStreamCaps(i, &pmt, reinterpret_cast<BYTE*>(&caps)) == S_OK ) {
VIDEOINFOHEADER *pVih =
reinterpret_cast<VIDEOINFOHEADER*>(pmt->pbFormat);
devices_resolutions[iDevice].x[i] = caps.InputSize.cx;
devices_resolutions[iDevice].y[i] = caps.InputSize.cy;
devices_resolutions[iDevice].color_space[i] = pmt->subtype;
devices_resolutions[iDevice].compression[i] = pVih->bmiHeader.biCompression;
DeleteMediaType(pmt);
}
}
pSource->Release();
pConfig->Release();
pSource = 0;
}
}
示例15: DeleteMediaType
HRESULT CDeCSSFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
{
AM_MEDIA_TYPE* pmt;
if (SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
CMediaType mt = *pmt;
m_pInput->SetMediaType(&mt);
mt.majortype = m_pOutput->CurrentMediaType().majortype;
m_pOutput->SetMediaType(&mt);
pOut->SetMediaType(&mt);
DeleteMediaType(pmt);
}
BYTE* pDataIn = NULL;
BYTE* pDataOut = NULL;
pIn->GetPointer(&pDataIn);
pOut->GetPointer(&pDataOut);
long len = pIn->GetActualDataLength();
long size = pOut->GetSize();
if (len == 0 || pDataIn == NULL) { // format changes do not carry any data
pOut->SetActualDataLength(0);
return S_OK;
}
if (m_pOutput->CurrentMediaType().majortype == MEDIATYPE_MPEG2_PES) {
if (*(DWORD*)pDataIn == 0xBA010000) {
len -= 14;
pDataIn += 14;
if (int stuffing = (pDataIn[-1] & 7)) {
len -= stuffing;
pDataIn += stuffing;
}
}
if (len <= 0) {
return S_FALSE;
}
if (*(DWORD*)pDataIn == 0xBB010000) {
len -= 4;
pDataIn += 4;
int hdrlen = ((pDataIn[0] << 8) | pDataIn[1]) + 2;
len -= hdrlen;
pDataIn += hdrlen;
}
if (len <= 0) {
return S_FALSE;
}
}
if (!pDataIn || !pDataOut || len > size || len < 0) {
return S_FALSE;
}
memcpy(pDataOut, pDataIn, min(len, size));
pOut->SetActualDataLength(min(len, size));
return S_OK;
}