• DirectShow3


    \如何修改系统中已经注册的Filter的Merit值
    typedef struct
    {
     DWORD dwVersion; //版本号
     DWORD dwMerit;  //Merit值
     DWORD dwPinCount; //Pin的数量
     DWORD dwReserved; //保留
    }FILTER_HEADER;
    BOOL SetFilterMerit(const char*inClsid,DWORD inMerit)
    {
     const char* cRegistryEntry="CLSID\{083863F1-70DE-11d0-BD40-00A0C911CE86}\Instance\";
     const long cMaxLength=1024*16;
     BYTE filterData[cMaxLength];
     DWORD actualLength=0;
     \生成Filter信息注册部分的注册表入口
     char szEntry[1000];
     strcpy(szEntry,cRegistryEntry);
     strcat(szEntry,inClsid);
     HKEY hKey=NULL;
     LONG result=::RegOpenKeyEx(HKEY_CLASSES_ROOT,szEntry,0,KEY_ALL_ACCESS,&hKey);
     BOOL pass=(result==ERROR_SUCCESS);
     if(pass)
     {
      \读取FilterData的值
      actualLength=actualLength;
      result=::RegQueryValueEx(hKey,"FilterData",NULL,NULL,filterData,&actualLength);
      pass=(result==ERROR_SUCCESS);
     }
     if(pass)
     {
      \修改FiterData中的Merit部分,然后写回到注册表
      FILTER_HEADER *filterHeader=(FILTER_HEADER *)filterData;
      filterHeader->dwMerit=inMerit;
      result=::RegSetValueEx(hKey,"FilterData",NULL,REG_BINARy,filterData,actualLength);
      pass=(result==ERROR_SUCCESS);
     }
     if(hKey)
     {
      ::RegCloseKey(hKey);
     }
     return pass;
    }
     
    STDMETHODIMP CBaseInputPin::Receive(IMediaSample *pSample)
    {
     CheckPointer(pSample,E_POINTER);
     ValidateReadPtr(pSample,sizeof(IMediaSample));
     ASSERT(pSample);
     \检查Filter内部状态,以及数据流传送状态
     HRESULT hr=CheckStreaming();
     if(S_OK!=hr)
     {
      return hr;
     }
     \查询IMediaSample2接口,获取输入Sample上的属性
     IMediaSample2 *pSample2;
     if(SUCCEEDED(pSample->QueryInterface(IID_IMediaSample2,(void **)&pSample2)))
     {
      hr=pSample2->GetProperties(sizeof(m_SampleProps),(PBYTE)&m_SampleProps);
      pSample2->Release();
      if(FAILED(hr))
      {
       return hr;
      }
     }
     else
     {
      \使用ImediaSample接口获取输入Sample上的属性
      m_SampleProps.cbData=sizeof(m_SampleProps);
      m_SampleProps.dwTypeSpecificFlags=0;
      m_SampleProps.dwStreamId=AM_STREAM_MEDIA;
      m_SampleProps.dwSampleFlags=0;
      if(S_OK==pSample->IsDiscontinuity())
      {
       m_SampleProps.dwSampleFlags|=AM_SAMPLE_DATADISCONTINUITY;
      }
      if(S_OK==pSample->IsPreroll())
      {
       m_SampleProps.dwSampleFlags|=AM_SAMPLE_PREROLL;
      }
      if(S_OK==pSample->IsSyncPoint())
      {
       m_SampleProps.dwSampleFlags|=AM_SAMPLE_SPLICEPOINT;
      }
      if(SUCCEEDED(pSample->GetTime(&m_SampleProps.tStart,&m_SampleProps.tStop)))
      {
       m_SampleProps.dwSampleFlags|=AM_SAMPLE_TIMEVALID|AM_SAMPLE_STOPVALID;
      }
      if(S_OK==pSample->GetMediaType(&m_SampleProps.pMediaType))
      {
       m_SampleProps.dwSampleFlags|=AM_SAMPLE_TYPECHANGED;
      }
      pSample->GetPointer(&m_SampleProps.pbBuffer);
      m_SampleProps.lActual=pSample->GetActualDataLength();
      m_SampleProps.cbBuffer=pSample->GetSize();
     }
     \检测Sample上的媒体类型是否改变
     if(!(m_SampleProps.dwSampleFlags&AM_SAMPLE_TYPECHANGED))
     {
      return NOERROR;
     }
     \检查输入Pin上是否支持这种新的媒体类型。此时,输入Pin应该是支持这种媒体类型
     \的,因为上一级Filter在做出这种媒体类型的动态改变之前,一般会先调用输入Pin
     \上的IPin::QueryAccept接口方法进行确认
     hr=CheckMediaType((CMediaType *)m_SampleProps.pMediaType);
     if(hr==NOERROR)
     {
      return NOERROR;
     }
     m_bRunTimeError=TRUE;
     EndOfStream();
     m_pFilter->NotifyEvent(EC_ERRORABORT,VFN_E_TYPE_NOT_ACCEPTED,0);
     return VFW_E_INVALIDMEDIATYPE; 
    }
  • 相关阅读:
    UV有问题?
    利用GPU实现翻页效果(分享自知乎网)
    Directx 9 VS2015环境搭建
    DirectX 读书笔记(14) Cube mapping之SkyBox[转]
    vertex shader must minimally write all four components of POSITION
    unity shader 内置变量
    Real-Time Rendering (2)
    矩阵变换:沿任意轴旋转及其推导
    Python爬虫教程-33-scrapy shell 的使用
    Python爬虫教程-32-Scrapy 爬虫框架项目 Settings.py 介绍
  • 原文地址:https://www.cnblogs.com/xiaomi-daming/p/11510844.html
Copyright © 2020-2023  润新知