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

MFCreateMFVideoFormatFromMFMediaType

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

シグネチャ

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

HRESULT MFCreateMFVideoFormatFromMFMediaType(
    IMFMediaType* pMFType,
    MFVIDEOFORMAT** ppMFVF,
    DWORD* pcbSize   // optional
);

パラメーター

名前方向説明
pMFTypeIMFMediaType*inビデオメディアタイプの IMFMediaType インターフェイスへのポインター。
ppMFVFMFVIDEOFORMAT**outMFVIDEOFORMAT 構造体へのポインターを受け取ります。呼び出し元は、CoTaskMemFree を呼び出して、この構造体に割り当てられたメモリを解放する必要があります。
pcbSizeDWORD*outoptionalMFVIDEOFORMAT 構造体のサイズを受け取ります。

戻り値の型: HRESULT

公式ドキュメント

ビデオメディアタイプから MFVIDEOFORMAT 構造体を作成します。

戻り値

この関数が成功すると S_OK を返します。それ以外の場合は HRESULT エラーコードを返します。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

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

MFCreateMFVideoFormatFromMFMediaType = ctypes.windll.mfplat.MFCreateMFVideoFormatFromMFMediaType
MFCreateMFVideoFormatFromMFMediaType.restype = ctypes.c_int
MFCreateMFVideoFormatFromMFMediaType.argtypes = [
    ctypes.c_void_p,  # pMFType : IMFMediaType*
    ctypes.c_void_p,  # ppMFVF : MFVIDEOFORMAT** out
    ctypes.POINTER(wintypes.DWORD),  # pcbSize : DWORD* optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mfplat = windows.NewLazySystemDLL("MFPlat.dll")
	procMFCreateMFVideoFormatFromMFMediaType = mfplat.NewProc("MFCreateMFVideoFormatFromMFMediaType")
)

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

extern "mfplat" fn MFCreateMFVideoFormatFromMFMediaType(
    pMFType: ?*anyopaque, // IMFMediaType*
    ppMFVF: [*c][*c]MFVIDEOFORMAT, // MFVIDEOFORMAT** out
    pcbSize: [*c]u32 // DWORD* optional, out
) callconv(std.os.windows.WINAPI) i32;
proc MFCreateMFVideoFormatFromMFMediaType(
    pMFType: pointer,  # IMFMediaType*
    ppMFVF: ptr MFVIDEOFORMAT,  # MFVIDEOFORMAT** out
    pcbSize: ptr uint32  # DWORD* optional, out
): int32 {.importc: "MFCreateMFVideoFormatFromMFMediaType", stdcall, dynlib: "MFPlat.dll".}
pragma(lib, "mfplat");
extern(Windows)
int MFCreateMFVideoFormatFromMFMediaType(
    void* pMFType,   // IMFMediaType*
    MFVIDEOFORMAT** ppMFVF,   // MFVIDEOFORMAT** out
    uint* pcbSize   // DWORD* optional, out
);
ccall((:MFCreateMFVideoFormatFromMFMediaType, "MFPlat.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{MFVIDEOFORMAT}, Ptr{UInt32}),
      pMFType, ppMFVF, pcbSize)
# pMFType : IMFMediaType* -> Ptr{Cvoid}
# ppMFVF : MFVIDEOFORMAT** out -> Ptr{MFVIDEOFORMAT}
# pcbSize : DWORD* optional, out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t MFCreateMFVideoFormatFromMFMediaType(
    void* pMFType,
    void* ppMFVF,
    uint32_t* pcbSize);
]]
local mfplat = ffi.load("mfplat")
-- mfplat.MFCreateMFVideoFormatFromMFMediaType(pMFType, ppMFVF, pcbSize)
-- pMFType : IMFMediaType*
-- ppMFVF : MFVIDEOFORMAT** out
-- pcbSize : DWORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('MFPlat.dll');
const MFCreateMFVideoFormatFromMFMediaType = lib.func('__stdcall', 'MFCreateMFVideoFormatFromMFMediaType', 'int32_t', ['void *', 'void *', 'uint32_t *']);
// MFCreateMFVideoFormatFromMFMediaType(pMFType, ppMFVF, pcbSize)
// pMFType : IMFMediaType* -> 'void *'
// ppMFVF : MFVIDEOFORMAT** out -> 'void *'
// pcbSize : DWORD* optional, out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("MFPlat.dll", {
  MFCreateMFVideoFormatFromMFMediaType: { parameters: ["pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.MFCreateMFVideoFormatFromMFMediaType(pMFType, ppMFVF, pcbSize)
// pMFType : IMFMediaType* -> "pointer"
// ppMFVF : MFVIDEOFORMAT** out -> "pointer"
// pcbSize : DWORD* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t MFCreateMFVideoFormatFromMFMediaType(
    void* pMFType,
    void* ppMFVF,
    uint32_t* pcbSize);
C, "MFPlat.dll");
// $ffi->MFCreateMFVideoFormatFromMFMediaType(pMFType, ppMFVF, pcbSize);
// pMFType : IMFMediaType*
// ppMFVF : MFVIDEOFORMAT** out
// pcbSize : DWORD* optional, out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Mfplat extends StdCallLibrary {
    Mfplat INSTANCE = Native.load("mfplat", Mfplat.class);
    int MFCreateMFVideoFormatFromMFMediaType(
        Pointer pMFType,   // IMFMediaType*
        Pointer ppMFVF,   // MFVIDEOFORMAT** out
        IntByReference pcbSize   // DWORD* optional, out
    );
}
@[Link("mfplat")]
lib LibMFPlat
  fun MFCreateMFVideoFormatFromMFMediaType = MFCreateMFVideoFormatFromMFMediaType(
    pMFType : Void*,   # IMFMediaType*
    ppMFVF : MFVIDEOFORMAT**,   # MFVIDEOFORMAT** out
    pcbSize : UInt32*   # DWORD* optional, out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef MFCreateMFVideoFormatFromMFMediaTypeNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
typedef MFCreateMFVideoFormatFromMFMediaTypeDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
final MFCreateMFVideoFormatFromMFMediaType = DynamicLibrary.open('MFPlat.dll')
    .lookupFunction<MFCreateMFVideoFormatFromMFMediaTypeNative, MFCreateMFVideoFormatFromMFMediaTypeDart>('MFCreateMFVideoFormatFromMFMediaType');
// pMFType : IMFMediaType* -> Pointer<Void>
// ppMFVF : MFVIDEOFORMAT** out -> Pointer<Void>
// pcbSize : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MFCreateMFVideoFormatFromMFMediaType(
  pMFType: Pointer;   // IMFMediaType*
  ppMFVF: Pointer;   // MFVIDEOFORMAT** out
  pcbSize: Pointer   // DWORD* optional, out
): Integer; stdcall;
  external 'MFPlat.dll' name 'MFCreateMFVideoFormatFromMFMediaType';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MFCreateMFVideoFormatFromMFMediaType"
  c_MFCreateMFVideoFormatFromMFMediaType :: Ptr () -> Ptr () -> Ptr Word32 -> IO Int32
-- pMFType : IMFMediaType* -> Ptr ()
-- ppMFVF : MFVIDEOFORMAT** out -> Ptr ()
-- pcbSize : DWORD* optional, out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mfcreatemfvideoformatfrommfmediatype =
  foreign "MFCreateMFVideoFormatFromMFMediaType"
    ((ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> returning int32_t)
(* pMFType : IMFMediaType* -> (ptr void) *)
(* ppMFVF : MFVIDEOFORMAT** out -> (ptr void) *)
(* pcbSize : DWORD* optional, out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mfplat (t "MFPlat.dll"))
(cffi:use-foreign-library mfplat)

(cffi:defcfun ("MFCreateMFVideoFormatFromMFMediaType" mfcreate-mfvideo-format-from-mfmedia-type :convention :stdcall) :int32
  (p-mftype :pointer)   ; IMFMediaType*
  (pp-mfvf :pointer)   ; MFVIDEOFORMAT** out
  (pcb-size :pointer))   ; DWORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MFCreateMFVideoFormatFromMFMediaType = Win32::API::More->new('MFPlat',
    'int MFCreateMFVideoFormatFromMFMediaType(LPVOID pMFType, LPVOID ppMFVF, LPVOID pcbSize)');
# my $ret = $MFCreateMFVideoFormatFromMFMediaType->Call($pMFType, $ppMFVF, $pcbSize);
# pMFType : IMFMediaType* -> LPVOID
# ppMFVF : MFVIDEOFORMAT** out -> LPVOID
# pcbSize : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型