ホーム › Media.MediaFoundation › MFInitMediaTypeFromWaveFormatEx
MFInitMediaTypeFromWaveFormatEx
関数WAVEFORMATEXからメディア型を初期化する。
シグネチャ
// MFPlat.dll
#include <windows.h>
HRESULT MFInitMediaTypeFromWaveFormatEx(
IMFMediaType* pMFType,
const WAVEFORMATEX* pWaveFormat,
DWORD cbBufSize
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pMFType | IMFMediaType* | in | 初期化するメディアタイプの IMFMediaType インターフェイスへのポインター。未初期化のメディアタイプオブジェクトを作成するには、MFCreateMediaType を呼び出します。 |
| pWaveFormat | WAVEFORMATEX* | in | メディアタイプを記述する WAVEFORMATEX 構造体へのポインター。呼び出し元は、この関数を呼び出す前に構造体のメンバーを設定しておく必要があります。 |
| cbBufSize | DWORD | in | WAVEFORMATEX 構造体のサイズ(バイト単位)。 |
戻り値の型: HRESULT
公式ドキュメント
WAVEFORMATEX 構造体からメディアタイプを初期化します。
戻り値
この関数は HRESULT を返します。取り得る値には、次の表に示すものが含まれますが、これらに限定されません。
| 戻り値 | 説明 |
|---|---|
| 関数は成功しました。 |
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 方式にも切替可。#uselib "MFPlat.dll" #cfunc global MFInitMediaTypeFromWaveFormatEx "MFInitMediaTypeFromWaveFormatEx" sptr, sptr, int ; res = MFInitMediaTypeFromWaveFormatEx(pMFType, varptr(pWaveFormat), cbBufSize) ; pMFType : IMFMediaType* -> "sptr" ; pWaveFormat : WAVEFORMATEX* -> "sptr" ; cbBufSize : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; HRESULT MFInitMediaTypeFromWaveFormatEx(IMFMediaType* pMFType, WAVEFORMATEX* pWaveFormat, DWORD cbBufSize) #uselib "MFPlat.dll" #cfunc global MFInitMediaTypeFromWaveFormatEx "MFInitMediaTypeFromWaveFormatEx" intptr, intptr, int ; res = MFInitMediaTypeFromWaveFormatEx(pMFType, varptr(pWaveFormat), cbBufSize) ; pMFType : IMFMediaType* -> "intptr" ; pWaveFormat : WAVEFORMATEX* -> "intptr" ; cbBufSize : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // HRESULTfunction 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)。const std = @import("std");
extern "mfplat" fn MFInitMediaTypeFromWaveFormatEx(
pMFType: ?*anyopaque, // IMFMediaType*
pWaveFormat: [*c]WAVEFORMATEX, // WAVEFORMATEX*
cbBufSize: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc MFInitMediaTypeFromWaveFormatEx(
pMFType: pointer, # IMFMediaType*
pWaveFormat: ptr WAVEFORMATEX, # WAVEFORMATEX*
cbBufSize: uint32 # DWORD
): int32 {.importc: "MFInitMediaTypeFromWaveFormatEx", stdcall, dynlib: "MFPlat.dll".}pragma(lib, "mfplat");
extern(Windows)
int MFInitMediaTypeFromWaveFormatEx(
void* pMFType, // IMFMediaType*
WAVEFORMATEX* pWaveFormat, // WAVEFORMATEX*
uint cbBufSize // DWORD
);ccall((:MFInitMediaTypeFromWaveFormatEx, "MFPlat.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{WAVEFORMATEX}, UInt32),
pMFType, pWaveFormat, cbBufSize)
# pMFType : IMFMediaType* -> Ptr{Cvoid}
# pWaveFormat : WAVEFORMATEX* -> Ptr{WAVEFORMATEX}
# cbBufSize : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MFInitMediaTypeFromWaveFormatEx(
void* pMFType,
void* pWaveFormat,
uint32_t cbBufSize);
]]
local mfplat = ffi.load("mfplat")
-- mfplat.MFInitMediaTypeFromWaveFormatEx(pMFType, pWaveFormat, cbBufSize)
-- pMFType : IMFMediaType*
-- pWaveFormat : WAVEFORMATEX*
-- cbBufSize : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MFPlat.dll');
const MFInitMediaTypeFromWaveFormatEx = lib.func('__stdcall', 'MFInitMediaTypeFromWaveFormatEx', 'int32_t', ['void *', 'void *', 'uint32_t']);
// MFInitMediaTypeFromWaveFormatEx(pMFType, pWaveFormat, cbBufSize)
// pMFType : IMFMediaType* -> 'void *'
// pWaveFormat : WAVEFORMATEX* -> 'void *'
// cbBufSize : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MFPlat.dll", {
MFInitMediaTypeFromWaveFormatEx: { parameters: ["pointer", "pointer", "u32"], result: "i32" },
});
// lib.symbols.MFInitMediaTypeFromWaveFormatEx(pMFType, pWaveFormat, cbBufSize)
// pMFType : IMFMediaType* -> "pointer"
// pWaveFormat : WAVEFORMATEX* -> "pointer"
// cbBufSize : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MFInitMediaTypeFromWaveFormatEx(
void* pMFType,
void* pWaveFormat,
uint32_t cbBufSize);
C, "MFPlat.dll");
// $ffi->MFInitMediaTypeFromWaveFormatEx(pMFType, pWaveFormat, cbBufSize);
// pMFType : IMFMediaType*
// pWaveFormat : WAVEFORMATEX*
// 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 MFInitMediaTypeFromWaveFormatEx(
Pointer pMFType, // IMFMediaType*
Pointer pWaveFormat, // WAVEFORMATEX*
int cbBufSize // DWORD
);
}@[Link("mfplat")]
lib LibMFPlat
fun MFInitMediaTypeFromWaveFormatEx = MFInitMediaTypeFromWaveFormatEx(
pMFType : Void*, # IMFMediaType*
pWaveFormat : WAVEFORMATEX*, # WAVEFORMATEX*
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 MFInitMediaTypeFromWaveFormatExNative = Int32 Function(Pointer<Void>, Pointer<Void>, Uint32);
typedef MFInitMediaTypeFromWaveFormatExDart = int Function(Pointer<Void>, Pointer<Void>, int);
final MFInitMediaTypeFromWaveFormatEx = DynamicLibrary.open('MFPlat.dll')
.lookupFunction<MFInitMediaTypeFromWaveFormatExNative, MFInitMediaTypeFromWaveFormatExDart>('MFInitMediaTypeFromWaveFormatEx');
// pMFType : IMFMediaType* -> Pointer<Void>
// pWaveFormat : WAVEFORMATEX* -> Pointer<Void>
// cbBufSize : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MFInitMediaTypeFromWaveFormatEx(
pMFType: Pointer; // IMFMediaType*
pWaveFormat: Pointer; // WAVEFORMATEX*
cbBufSize: DWORD // DWORD
): Integer; stdcall;
external 'MFPlat.dll' name 'MFInitMediaTypeFromWaveFormatEx';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MFInitMediaTypeFromWaveFormatEx"
c_MFInitMediaTypeFromWaveFormatEx :: Ptr () -> Ptr () -> Word32 -> IO Int32
-- pMFType : IMFMediaType* -> Ptr ()
-- pWaveFormat : WAVEFORMATEX* -> Ptr ()
-- cbBufSize : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mfinitmediatypefromwaveformatex =
foreign "MFInitMediaTypeFromWaveFormatEx"
((ptr void) @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* pMFType : IMFMediaType* -> (ptr void) *)
(* pWaveFormat : WAVEFORMATEX* -> (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 ("MFInitMediaTypeFromWaveFormatEx" mfinit-media-type-from-wave-format-ex :convention :stdcall) :int32
(p-mftype :pointer) ; IMFMediaType*
(p-wave-format :pointer) ; WAVEFORMATEX*
(cb-buf-size :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MFInitMediaTypeFromWaveFormatEx = Win32::API::More->new('MFPlat',
'int MFInitMediaTypeFromWaveFormatEx(LPVOID pMFType, LPVOID pWaveFormat, DWORD cbBufSize)');
# my $ret = $MFInitMediaTypeFromWaveFormatEx->Call($pMFType, $pWaveFormat, $cbBufSize);
# pMFType : IMFMediaType* -> LPVOID
# pWaveFormat : WAVEFORMATEX* -> LPVOID
# cbBufSize : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。