bool TextureDX9Imp::acquireResource() { if( NULL != textureDX9_ ) return true; LPDIRECT3DTEXTURE9 newTexDX9; if( isFromFile() ) { const HRESULT hr = D3DXCreateTextureFromFileEx( getD3D9Device(), filename_.c_str(), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, & newTexDX9 ); RETURN_FALSE_IF_FAILED( hr, L"TextureDX9Imp::acquireResource" ); } else { const HRESULT hr = D3DXCreateTexture( getD3D9Device(), requiredWidth_, requiredHeight_, requiredMipLevels_, requiredUsage_, requiredFormat_, requiredPool_, & newTexDX9 ); RETURN_FALSE_IF_FAILED( hr, L"TextureDX9Imp::acquireResource" ); } textureDX9_ = IDirect3DTexture9Ptr( newTexDX9, ComReleaser< IDirect3DTexture9 >() ); MY_FOR_EACH( Surfaces, iter, surfaces_ ) acquireSurface( iter->level ); return true; }
// // OnConnect // // Called when the property page connects to a filter // HRESULT CProgramProperties::OnConnect(IUnknown *pUnknown) { ASSERT(m_pProgram == NULL); CheckPointer(pUnknown,E_POINTER); HRESULT hr = pUnknown->QueryInterface(IID_IMpeg2PsiParser, (void **) &m_pProgram); if(FAILED(hr)) { return E_NOINTERFACE; } ASSERT(m_pProgram); IBaseFilter * pParserFilter ; hr = m_pProgram->QueryInterface(IID_IBaseFilter, (void **) &pParserFilter); RETURN_FALSE_IF_FAILED(TEXT("CProgramProperties::OnUpdate() QueryInterface() failed."), hr); FILTER_INFO Info; IFilterGraph * pGraph; hr = pParserFilter->QueryFilterInfo(&Info); RETURN_FALSE_IF_FAILED(TEXT("CProgramProperties::OnUpdate() QueryFilterInfo() failed."), hr); pGraph = Info.pGraph; pParserFilter->Release(); hr = pGraph->QueryInterface(IID_IGraphBuilder, (void **) & m_pGraphBuilder); RETURN_FALSE_IF_FAILED(TEXT("CProgramProperties::OnUpdate() QueryInterface() failed."), hr); // get demux filter hr = GetDemuxFilter(pGraph, &m_pDemux); RETURN_FALSE_IF_FAILED(TEXT("CProgramProperties::OnUpdate() GetDemuxFilter() failed."), hr); pGraph->Release(); // if there is no streaming, the following variables will not be initialized. if(m_pDemux != NULL && m_pGraphBuilder != NULL){ hr = m_pGraphBuilder->QueryInterface(IID_IMediaControl, (void **) & m_pMediaControl); RETURN_FALSE_IF_FAILED( TEXT(" CProgramProperties::OnUpdate():Failed to QI IMediaControl."), hr); // Get the initial Program value m_pProgram->GetTransportStreamId( &m_stream_id); m_pProgram->GetPatVersionNumber( &m_pat_version); m_pProgram->GetCountOfPrograms( &m_number_of_programs ); } if(!OnUpdate()) return FALSE; return NOERROR; }
BOOL CProgramProperties::UnmapAvPIDs() { HRESULT hr; ULONG ulAudioPID[1] = {(ULONG) m_mappedAudPid}; hr = m_pIAudioPIDMap->UnmapPID(1, ulAudioPID); RETURN_FALSE_IF_FAILED(TEXT(" CPATProcessor::SetupMPEGDeMux():: Unmapping the PID of the Audio Output Pin on the Demux Filter Failed %X"), hr); ULONG ulVideoPID[1] = {(ULONG) m_mappedVidPid}; hr = m_pIVideoPIDMap->UnmapPID(1, ulVideoPID); RETURN_FALSE_IF_FAILED(TEXT(" CPATProcessor::SetupMPEGDeMux():: Unmapping the PID of the Video Output Pin on the Demux Filter Failed %X"), hr); return TRUE; } //MapRenderAvOutPins
// //CreatAvOutPins // BOOL CProgramProperties::CreateAndRenderAvOutPins() { HRESULT hr = S_OK; RETURN_FALSE_IF_BADPTR( TEXT("CProgramProperties::SetupMPEGDeMux : pDemuxDev is null "), m_pDemux); // Query the interface to create pins on the demux IMpeg2Demultiplexer * pIMpeg2Demux ; hr = m_pDemux->QueryInterface(IID_IMpeg2Demultiplexer, (void **) &pIMpeg2Demux) ; RETURN_FALSE_IF_FAILED(TEXT("CProgramProperties::SetupMPEGDeMux : create pIMpeg2Demux failed %X"), hr); RETURN_FALSE_IF_BADPTR(TEXT("CProgramProperties::SetupMPEGDeMux :pIMpeg2Demux is NULL"), pIMpeg2Demux); //video: // Setting the media type for the pins to be created AM_MEDIA_TYPE amTypeVideo; amTypeVideo.majortype = MEDIATYPE_Video; amTypeVideo.subtype = MEDIASUBTYPE_MPEG2_VIDEO; amTypeVideo.bFixedSizeSamples = TRUE; amTypeVideo.bTemporalCompression = 0; amTypeVideo.formattype = FORMAT_MPEG2Video; amTypeVideo.pUnk = NULL; amTypeVideo.cbFormat = sizeof(g_Mpeg2ProgramVideo); amTypeVideo.pbFormat = g_Mpeg2ProgramVideo; // Create the pins hr = pIMpeg2Demux->CreateOutputPin(&amTypeVideo, L"MpegVideo", &m_pVideoOutPin); RETURN_FALSE_IF_FAILED(TEXT(" CProgramProperties::SetupMPEGDeMux():: Creating the Video Output Pin failed %X"), hr); RETURN_FALSE_IF_BADPTR(TEXT("CProgramProperties::SetupMPEGDeMux()::pVideoOutpin is null "), m_pVideoOutPin) ; // for audio: could be Mpeg1, Mpeg2, AC3: AM_MEDIA_TYPE amTypeAudio; amTypeAudio.majortype = MEDIATYPE_Audio; amTypeAudio.bFixedSizeSamples = TRUE; amTypeAudio.bTemporalCompression = 0; amTypeAudio.formattype = FORMAT_WaveFormatEx; amTypeAudio.pUnk = NULL; amTypeAudio.cbFormat = sizeof g_MPEG1AudioFormat; amTypeAudio.pbFormat = g_MPEG1AudioFormat; // put the graph to stop state, in order to render the pins hr = m_pMediaControl->Stop(); hr = m_pGraphBuilder->Render(m_pVideoOutPin); if(FAILED(hr)) { hr = pIMpeg2Demux->DeleteOutputPin(L"MpegAudio"); RETURN_FALSE_IF_FAILED(TEXT(" CProgramProperties::SetupMPEGDeMux():: render the video Output Pin failed %X"), hr); } //create audio output pin ( must use L"MpegAudio", will be used in pid finder filter to find this pin BOOL bTryAgain = TRUE; const GUID* guidStr[] = { & MEDIASUBTYPE_MPEG1Payload, &MEDIASUBTYPE_MPEG2_AUDIO, &MEDIASUBTYPE_DOLBY_AC3 }; int i; for (i = 0; i<3; i++ ) { amTypeAudio.subtype = *(guidStr[i]);//can be Mpeg1, MPeg2 or AC3 hr = pIMpeg2Demux->CreateOutputPin(&amTypeAudio, L"MpegAudio", &m_pAudioOutPin); RETURN_FALSE_IF_FAILED(TEXT(" CProgramProperties::SetupMPEGDeMux():: Creating the Audio Output Pin failed %X"), hr); RETURN_FALSE_IF_BADPTR(TEXT("CProgramProperties::SetupMPEGDeMux()::pAudioOutpin is null "), m_pAudioOutPin) ; hr = m_pGraphBuilder->Render(m_pAudioOutPin); if(SUCCEEDED(hr)) break; else { hr = pIMpeg2Demux->DeleteOutputPin(L"MpegAudio"); RETURN_FALSE_IF_FAILED(TEXT(" CProgramProperties::SetupMPEGDeMux():: Delete Audio Output Pin on the Demux Filter Failed %X"), hr); } } // after rendering the pins, switch to run state: hr = m_pMediaControl->Run(); hr = m_pVideoOutPin->QueryInterface(__uuidof(IMPEG2PIDMap), (void **) &m_pIVideoPIDMap); RETURN_FALSE_IF_FAILED(TEXT(" CPATProcessor::SetupMPEGDeMux():: QI the IMPEG2PIDMap inf on video out pin failed %X"), hr); RETURN_FALSE_IF_BADPTR(TEXT("CPATProcessor::SetupMPEGDeMux()::pIVideoPIDMap is null "), m_pIVideoPIDMap) ; hr = m_pAudioOutPin->QueryInterface(__uuidof(IMPEG2PIDMap), (void **) &m_pIAudioPIDMap); RETURN_FALSE_IF_FAILED(TEXT(" CPATProcessor::SetupMPEGDeMux():: QI the IMPEG2PIDMap inf on audio put pin failed %X"), hr); RETURN_FALSE_IF_BADPTR(TEXT("CPATProcessor::SetupMPEGDeMux()::pIAudioPIDMap is null "), m_pIAudioPIDMap) ; pIMpeg2Demux->Release(); return TRUE; } //CreatAvOutPins
bool EffectShaderAnnotationDX9Imp::getBool() { BOOL buff; const HRESULT hr = effect_->GetBool( getHandleDX9(), & buff ); RETURN_FALSE_IF_FAILED( hr, L"EffectShaderAnnotationDX9Imp::getBool" ); return TRUE == buff; }
float EffectShaderAnnotationDX9Imp::getFloat() { float buff; const HRESULT hr = effect_->GetFloat( getHandleDX9(), & buff ); RETURN_FALSE_IF_FAILED( hr, L"EffectShaderAnnotationDX9Imp::getFloat" ); return buff; }
wstring EffectShaderAnnotationDX9Imp::getString() { const char * buff; const HRESULT hr = effect_->GetString( getHandleDX9(), & buff ); RETURN_FALSE_IF_FAILED( hr, L"EffectShaderAnnotationDX9Imp::getString" ); return convertString( buff ); }