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

MFInitMediaTypeFromMFVideoFormat

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

シグネチャ

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

HRESULT MFInitMediaTypeFromMFVideoFormat(
    IMFMediaType* pMFType,
    const MFVIDEOFORMAT* pMFVF,
    DWORD cbBufSize
);

パラメーター

名前方向説明
pMFTypeIMFMediaType*in初期化するメディアタイプの IMFMediaType インターフェイスへのポインター。初期化されていないメディアタイプオブジェクトを作成するには、MFCreateMediaType を呼び出します。
pMFVFMFVIDEOFORMAT*inメディアタイプを記述する MFVIDEOFORMAT 構造体へのポインター。呼び出し元は、この関数を呼び出す前に構造体のメンバーを設定する必要があります。
cbBufSizeDWORDinMFVIDEOFORMAT 構造体のサイズ(バイト単位)。

戻り値の型: 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 MFInitMediaTypeFromMFVideoFormat(
    IMFMediaType* pMFType,
    const MFVIDEOFORMAT* pMFVF,
    DWORD cbBufSize
);
[DllImport("MFPlat.dll", ExactSpelling = true)]
static extern int MFInitMediaTypeFromMFVideoFormat(
    IntPtr pMFType,   // IMFMediaType*
    IntPtr pMFVF,   // MFVIDEOFORMAT*
    uint cbBufSize   // DWORD
);
<DllImport("MFPlat.dll", ExactSpelling:=True)>
Public Shared Function MFInitMediaTypeFromMFVideoFormat(
    pMFType As IntPtr,   ' IMFMediaType*
    pMFVF As IntPtr,   ' MFVIDEOFORMAT*
    cbBufSize As UInteger   ' DWORD
) As Integer
End Function
' pMFType : IMFMediaType*
' pMFVF : MFVIDEOFORMAT*
' cbBufSize : DWORD
Declare PtrSafe Function MFInitMediaTypeFromMFVideoFormat Lib "mfplat" ( _
    ByVal pMFType As LongPtr, _
    ByVal pMFVF 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

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

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

var (
	mfplat = windows.NewLazySystemDLL("MFPlat.dll")
	procMFInitMediaTypeFromMFVideoFormat = mfplat.NewProc("MFInitMediaTypeFromMFVideoFormat")
)

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

extern "mfplat" fn MFInitMediaTypeFromMFVideoFormat(
    pMFType: ?*anyopaque, // IMFMediaType*
    pMFVF: [*c]MFVIDEOFORMAT, // MFVIDEOFORMAT*
    cbBufSize: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc MFInitMediaTypeFromMFVideoFormat(
    pMFType: pointer,  # IMFMediaType*
    pMFVF: ptr MFVIDEOFORMAT,  # MFVIDEOFORMAT*
    cbBufSize: uint32  # DWORD
): int32 {.importc: "MFInitMediaTypeFromMFVideoFormat", stdcall, dynlib: "MFPlat.dll".}
pragma(lib, "mfplat");
extern(Windows)
int MFInitMediaTypeFromMFVideoFormat(
    void* pMFType,   // IMFMediaType*
    MFVIDEOFORMAT* pMFVF,   // MFVIDEOFORMAT*
    uint cbBufSize   // DWORD
);
ccall((:MFInitMediaTypeFromMFVideoFormat, "MFPlat.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{MFVIDEOFORMAT}, UInt32),
      pMFType, pMFVF, cbBufSize)
# pMFType : IMFMediaType* -> Ptr{Cvoid}
# pMFVF : MFVIDEOFORMAT* -> Ptr{MFVIDEOFORMAT}
# cbBufSize : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t MFInitMediaTypeFromMFVideoFormat(
    void* pMFType,
    void* pMFVF,
    uint32_t cbBufSize);
]]
local mfplat = ffi.load("mfplat")
-- mfplat.MFInitMediaTypeFromMFVideoFormat(pMFType, pMFVF, cbBufSize)
-- pMFType : IMFMediaType*
-- pMFVF : MFVIDEOFORMAT*
-- cbBufSize : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('MFPlat.dll');
const MFInitMediaTypeFromMFVideoFormat = lib.func('__stdcall', 'MFInitMediaTypeFromMFVideoFormat', 'int32_t', ['void *', 'void *', 'uint32_t']);
// MFInitMediaTypeFromMFVideoFormat(pMFType, pMFVF, cbBufSize)
// pMFType : IMFMediaType* -> 'void *'
// pMFVF : MFVIDEOFORMAT* -> 'void *'
// cbBufSize : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("MFPlat.dll", {
  MFInitMediaTypeFromMFVideoFormat: { parameters: ["pointer", "pointer", "u32"], result: "i32" },
});
// lib.symbols.MFInitMediaTypeFromMFVideoFormat(pMFType, pMFVF, cbBufSize)
// pMFType : IMFMediaType* -> "pointer"
// pMFVF : MFVIDEOFORMAT* -> "pointer"
// cbBufSize : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t MFInitMediaTypeFromMFVideoFormat(
    void* pMFType,
    void* pMFVF,
    uint32_t cbBufSize);
C, "MFPlat.dll");
// $ffi->MFInitMediaTypeFromMFVideoFormat(pMFType, pMFVF, cbBufSize);
// pMFType : IMFMediaType*
// pMFVF : MFVIDEOFORMAT*
// cbBufSize : DWORD
// 構造体/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 MFInitMediaTypeFromMFVideoFormat(
        Pointer pMFType,   // IMFMediaType*
        Pointer pMFVF,   // MFVIDEOFORMAT*
        int cbBufSize   // DWORD
    );
}
@[Link("mfplat")]
lib LibMFPlat
  fun MFInitMediaTypeFromMFVideoFormat = MFInitMediaTypeFromMFVideoFormat(
    pMFType : Void*,   # IMFMediaType*
    pMFVF : MFVIDEOFORMAT*,   # MFVIDEOFORMAT*
    cbBufSize : UInt32   # DWORD
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

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

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

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

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

関連項目

使用する型