Menu

MFTRegister inputinfo array & outputinfo array is pointer

TopPlay
2019-02-20
2019-11-05
  • TopPlay

    TopPlay - 2019-02-20
    HRESULT MFTRegister(
      CLSID                  clsidMFT,
      GUID                   guidCategory,
      LPWSTR                 pszName,
      UINT32                 Flags,
      UINT32                 cInputTypes,
      MFT_REGISTER_TYPE_INFO *pInputTypes,
      UINT32                 cOutputTypes,
      MFT_REGISTER_TYPE_INFO *pOutputTypes,
      IMFAttributes          *pAttributes
    );
    

    MSDN:
    Pointer to an array of MFT_REGISTER_TYPE_INFO structures. Each member of the array specifies an input format that the MFT supports. This parameter can be NULL.

    so function much like:

    function MFTRegister(const clsidMFT: CLSID; const guidCategory: TGuid; const pszName: LPCWSTR; const Flags: UINT32; const cInputTypes: UINT32; const pInputTypes: PMFT_REGISTER_TYPE_INFO; const cOutputTypes: UINT32;
      const pOutputTypes: PMFT_REGISTER_TYPE_INFO; pAttributes: IMFAttributes): HRESULT; stdcall;
    
     
  • TopPlay

    TopPlay - 2019-02-20
    function MFTRegister( clsidMFT: CLSID;  guidCategory: TGuid;  pszName: LPCWSTR;  Flags: UINT32;  cInputTypes: UINT32;  pInputTypes: PMFT_REGISTER_TYPE_INFO;  cOutputTypes: UINT32;
       pOutputTypes: PMFT_REGISTER_TYPE_INFO; pAttributes: IMFAttributes): HRESULT; stdcall;
    

    no const flag is right ,otherwise addr access error!

     
    • FactoryX

      FactoryX - 2019-02-21

      What version of MfApi you are using? In the latest version (2.5.0) this function looks like this:

      function MFTRegister(clsidMFT: CLSID;
                             guidCategory: TGUID;
                             pszName: LPCWSTR;
                             Flags: UINT32;
                             cInputTypes: UINT32;
                             pInputTypes: MFT_REGISTER_TYPE_INFO;
                             cOutputTypes: UINT32;
                             pOutputTypes: MFT_REGISTER_TYPE_INFO;
                             pAttributes: IMFAttributes): HResult; stdcall;
      
        // "Flags" is for future expansion - for now must be 0
      

      It seems this bug has been repaired a while ago.
      There should be no const declaration at all.

       
  • TopPlay

    TopPlay - 2019-02-20

    Fix MFTRegister:

    function MFTRegister(clsidMFT: CLSID; guidCategory: TGuid; pszName: LPCWSTR; Flags: UINT32;const cInputTypes: UINT32; const pInputTypes: PMFT_REGISTER_TYPE_INFO;const cOutputTypes: UINT32;const  pOutputTypes: PMFT_REGISTER_TYPE_INFO;
      pAttributes: IMFAttributes): HRESULT; stdcall;
    

    and uses it:

    function DllRegisterServer(): HRESULT; stdcall;
    var
      ProcessorInfos: array of MFT_REGISTER_TYPE_INFO;
      PCM_info: MFT_REGISTER_TYPE_INFO;
      I: Integer;
    begin
      Result := E_FAIL;
      for I := Low(AvailableMediaType) to High(AvailableMediaType) do
      begin
        PCM_info.guidMajorType := MFMediaType_Audio;
        PCM_info.guidSubtype := AvailableMediaType[I]^;
        Insert([PCM_info], ProcessorInfos, 0);
      end;
      // Register the MFT's CLSID as a COM object.
      if Failed(RegisterObject(g_hModule, CLSID_TopAudioProcessor, g_sFriendlyName, PWideChar('Both'))) then
        Exit;
      Result := MFTRegister(CLSID_TopAudioProcessor, MFT_CATEGORY_AUDIO_EFFECT, g_sFriendlyName, 0, Length(ProcessorInfos), Pointer(ProcessorInfos), Length(ProcessorInfos), Pointer(ProcessorInfos), nil);
    end;
    
     
    • FactoryX

      FactoryX - 2019-11-05

      Thank you, could you translate this to a sample function?

       
  • FactoryX

    FactoryX - 2019-02-21

    By the way; Why not using the the MFTEnumEx function?

     
  • TopPlay

    TopPlay - 2019-02-21

    i need to write a custom Media foudation Transform to Switch audio stream volume;
    so uses this method do Registered a com & MFT component.

     

    Last edit: TopPlay 2019-02-21
    • FactoryX

      FactoryX - 2019-02-21

      I would use the IMFPresentationDescriptor interface for that purpose.
      An example how to determine, get and set an active stream is given in MfPlayer III. It requires a small piece of code and works fine. see:

      // Returns the active(current) stream of a media type
      function TMfPlayer.GetActiveStreamType(stType: TMediaTypes; out iStreamIndex: DWord): HRESULT;
      
      and
      
      // Select and deselect streams.
      function TMfPlayer.SetActiveStreamType(stType: TMediaTypes; iStreamIndex: DWord): HRESULT;
      
      // Set the volumes for the channels (IMFAudioStreamVolume)
      procedure TMfPlayer.SetVolume(Value: TFloatArray);
      
       

Log in to post a comment.