Win32 API 日本語リファレンス
ホームMedia.MediaFoundation › MFInitMediaTypeFromWaveFormatEx

MFInitMediaTypeFromWaveFormatEx

関数
WAVEFORMATEXからメディア型を初期化する。
DLLMFPlat.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// MFPlat.dll
#include <windows.h>

HRESULT MFInitMediaTypeFromWaveFormatEx(
    IMFMediaType* pMFType,
    const WAVEFORMATEX* pWaveFormat,
    DWORD cbBufSize
);

パラメーター

名前方向
pMFTypeIMFMediaType*in
pWaveFormatWAVEFORMATEX*in
cbBufSizeDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

// MFPlat.dll
#include <windows.h>

HRESULT MFInitMediaTypeFromWaveFormatEx(
    IMFMediaType* pMFType,
    const WAVEFORMATEX* pWaveFormat,
    DWORD cbBufSize
);
[DllImport("MFPlat.dll", ExactSpelling = true)]
static extern int MFInitMediaTypeFromWaveFormatEx(
    IntPtr pMFType,   // IMFMediaType*
    IntPtr pWaveFormat,   // WAVEFORMATEX*
    uint cbBufSize   // DWORD
);
<DllImport("MFPlat.dll", ExactSpelling:=True)>
Public Shared Function MFInitMediaTypeFromWaveFormatEx(
    pMFType As IntPtr,   ' IMFMediaType*
    pWaveFormat As IntPtr,   ' WAVEFORMATEX*
    cbBufSize As UInteger   ' DWORD
) As Integer
End Function
' pMFType : IMFMediaType*
' pWaveFormat : WAVEFORMATEX*
' cbBufSize : DWORD
Declare PtrSafe Function MFInitMediaTypeFromWaveFormatEx Lib "mfplat" ( _
    ByVal pMFType As LongPtr, _
    ByVal pWaveFormat As LongPtr, _
    ByVal cbBufSize As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MFInitMediaTypeFromWaveFormatEx = ctypes.windll.mfplat.MFInitMediaTypeFromWaveFormatEx
MFInitMediaTypeFromWaveFormatEx.restype = ctypes.c_int
MFInitMediaTypeFromWaveFormatEx.argtypes = [
    ctypes.c_void_p,  # pMFType : IMFMediaType*
    ctypes.c_void_p,  # pWaveFormat : WAVEFORMATEX*
    wintypes.DWORD,  # cbBufSize : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MFPlat.dll')
MFInitMediaTypeFromWaveFormatEx = Fiddle::Function.new(
  lib['MFInitMediaTypeFromWaveFormatEx'],
  [
    Fiddle::TYPE_VOIDP,  # pMFType : IMFMediaType*
    Fiddle::TYPE_VOIDP,  # pWaveFormat : WAVEFORMATEX*
    -Fiddle::TYPE_INT,  # cbBufSize : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "mfplat")]
extern "system" {
    fn MFInitMediaTypeFromWaveFormatEx(
        pMFType: *mut core::ffi::c_void,  // IMFMediaType*
        pWaveFormat: *const WAVEFORMATEX,  // WAVEFORMATEX*
        cbBufSize: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MFPlat.dll")]
public static extern int MFInitMediaTypeFromWaveFormatEx(IntPtr pMFType, IntPtr pWaveFormat, uint cbBufSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MFPlat_MFInitMediaTypeFromWaveFormatEx' -Namespace Win32 -PassThru
# $api::MFInitMediaTypeFromWaveFormatEx(pMFType, pWaveFormat, cbBufSize)
#uselib "MFPlat.dll"
#func global MFInitMediaTypeFromWaveFormatEx "MFInitMediaTypeFromWaveFormatEx" sptr, sptr, sptr
; MFInitMediaTypeFromWaveFormatEx pMFType, varptr(pWaveFormat), cbBufSize   ; 戻り値は stat
; pMFType : IMFMediaType* -> "sptr"
; pWaveFormat : WAVEFORMATEX* -> "sptr"
; cbBufSize : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "MFPlat.dll"
#cfunc global MFInitMediaTypeFromWaveFormatEx "MFInitMediaTypeFromWaveFormatEx" sptr, var, int
; res = MFInitMediaTypeFromWaveFormatEx(pMFType, pWaveFormat, cbBufSize)
; pMFType : IMFMediaType* -> "sptr"
; pWaveFormat : WAVEFORMATEX* -> "var"
; cbBufSize : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT MFInitMediaTypeFromWaveFormatEx(IMFMediaType* pMFType, WAVEFORMATEX* pWaveFormat, DWORD cbBufSize)
#uselib "MFPlat.dll"
#cfunc global MFInitMediaTypeFromWaveFormatEx "MFInitMediaTypeFromWaveFormatEx" intptr, var, int
; res = MFInitMediaTypeFromWaveFormatEx(pMFType, pWaveFormat, cbBufSize)
; pMFType : IMFMediaType* -> "intptr"
; pWaveFormat : WAVEFORMATEX* -> "var"
; cbBufSize : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mfplat = windows.NewLazySystemDLL("MFPlat.dll")
	procMFInitMediaTypeFromWaveFormatEx = mfplat.NewProc("MFInitMediaTypeFromWaveFormatEx")
)

// pMFType (IMFMediaType*), pWaveFormat (WAVEFORMATEX*), cbBufSize (DWORD)
r1, _, err := procMFInitMediaTypeFromWaveFormatEx.Call(
	uintptr(pMFType),
	uintptr(pWaveFormat),
	uintptr(cbBufSize),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function MFInitMediaTypeFromWaveFormatEx(
  pMFType: Pointer;   // IMFMediaType*
  pWaveFormat: Pointer;   // WAVEFORMATEX*
  cbBufSize: DWORD   // DWORD
): Integer; stdcall;
  external 'MFPlat.dll' name 'MFInitMediaTypeFromWaveFormatEx';
result := DllCall("MFPlat\MFInitMediaTypeFromWaveFormatEx"
    , "Ptr", pMFType   ; IMFMediaType*
    , "Ptr", pWaveFormat   ; WAVEFORMATEX*
    , "UInt", cbBufSize   ; DWORD
    , "Int")   ; return: HRESULT
●MFInitMediaTypeFromWaveFormatEx(pMFType, pWaveFormat, cbBufSize) = DLL("MFPlat.dll", "int MFInitMediaTypeFromWaveFormatEx(void*, void*, dword)")
# 呼び出し: MFInitMediaTypeFromWaveFormatEx(pMFType, pWaveFormat, cbBufSize)
# pMFType : IMFMediaType* -> "void*"
# pWaveFormat : WAVEFORMATEX* -> "void*"
# cbBufSize : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。