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

MFCreateVideoMediaType

関数
MFVIDEOFORMATからビデオメディア型を生成する。
DLLMFPlat.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT MFCreateVideoMediaType(
    const MFVIDEOFORMAT* pVideoFormat,
    IMFVideoMediaType** ppIVideoMediaType
);

パラメーター

名前方向説明
pVideoFormatMFVIDEOFORMAT*in生成元となるMFVIDEOFORMAT構造体へのポインタ。
ppIVideoMediaTypeIMFVideoMediaType**out生成されたビデオメディアタイプIMFVideoMediaTypeを受け取るポインタのアドレス。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT MFCreateVideoMediaType(
    const MFVIDEOFORMAT* pVideoFormat,
    IMFVideoMediaType** ppIVideoMediaType
);
[DllImport("MFPlat.dll", ExactSpelling = true)]
static extern int MFCreateVideoMediaType(
    IntPtr pVideoFormat,   // MFVIDEOFORMAT*
    IntPtr ppIVideoMediaType   // IMFVideoMediaType** out
);
<DllImport("MFPlat.dll", ExactSpelling:=True)>
Public Shared Function MFCreateVideoMediaType(
    pVideoFormat As IntPtr,   ' MFVIDEOFORMAT*
    ppIVideoMediaType As IntPtr   ' IMFVideoMediaType** out
) As Integer
End Function
' pVideoFormat : MFVIDEOFORMAT*
' ppIVideoMediaType : IMFVideoMediaType** out
Declare PtrSafe Function MFCreateVideoMediaType Lib "mfplat" ( _
    ByVal pVideoFormat As LongPtr, _
    ByVal ppIVideoMediaType As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MFCreateVideoMediaType = ctypes.windll.mfplat.MFCreateVideoMediaType
MFCreateVideoMediaType.restype = ctypes.c_int
MFCreateVideoMediaType.argtypes = [
    ctypes.c_void_p,  # pVideoFormat : MFVIDEOFORMAT*
    ctypes.c_void_p,  # ppIVideoMediaType : IMFVideoMediaType** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mfplat = windows.NewLazySystemDLL("MFPlat.dll")
	procMFCreateVideoMediaType = mfplat.NewProc("MFCreateVideoMediaType")
)

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