ホーム › Media.MediaFoundation › MFCreateMediaBufferFromMediaType
MFCreateMediaBufferFromMediaType
関数メディア型に基づいたメディアバッファーを生成する。
シグネチャ
// MFPlat.dll
#include <windows.h>
HRESULT MFCreateMediaBufferFromMediaType(
IMFMediaType* pMediaType,
LONGLONG llDuration,
DWORD dwMinLength,
DWORD dwMinAlignment,
IMFMediaBuffer** ppBuffer
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pMediaType | IMFMediaType* | in |
| llDuration | LONGLONG | in |
| dwMinLength | DWORD | in |
| dwMinAlignment | DWORD | in |
| ppBuffer | IMFMediaBuffer** | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// MFPlat.dll
#include <windows.h>
HRESULT MFCreateMediaBufferFromMediaType(
IMFMediaType* pMediaType,
LONGLONG llDuration,
DWORD dwMinLength,
DWORD dwMinAlignment,
IMFMediaBuffer** ppBuffer
);[DllImport("MFPlat.dll", ExactSpelling = true)]
static extern int MFCreateMediaBufferFromMediaType(
IntPtr pMediaType, // IMFMediaType*
long llDuration, // LONGLONG
uint dwMinLength, // DWORD
uint dwMinAlignment, // DWORD
IntPtr ppBuffer // IMFMediaBuffer** out
);<DllImport("MFPlat.dll", ExactSpelling:=True)>
Public Shared Function MFCreateMediaBufferFromMediaType(
pMediaType As IntPtr, ' IMFMediaType*
llDuration As Long, ' LONGLONG
dwMinLength As UInteger, ' DWORD
dwMinAlignment As UInteger, ' DWORD
ppBuffer As IntPtr ' IMFMediaBuffer** out
) As Integer
End Function' pMediaType : IMFMediaType*
' llDuration : LONGLONG
' dwMinLength : DWORD
' dwMinAlignment : DWORD
' ppBuffer : IMFMediaBuffer** out
Declare PtrSafe Function MFCreateMediaBufferFromMediaType Lib "mfplat" ( _
ByVal pMediaType As LongPtr, _
ByVal llDuration As LongLong, _
ByVal dwMinLength As Long, _
ByVal dwMinAlignment As Long, _
ByVal ppBuffer As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MFCreateMediaBufferFromMediaType = ctypes.windll.mfplat.MFCreateMediaBufferFromMediaType
MFCreateMediaBufferFromMediaType.restype = ctypes.c_int
MFCreateMediaBufferFromMediaType.argtypes = [
ctypes.c_void_p, # pMediaType : IMFMediaType*
ctypes.c_longlong, # llDuration : LONGLONG
wintypes.DWORD, # dwMinLength : DWORD
wintypes.DWORD, # dwMinAlignment : DWORD
ctypes.c_void_p, # ppBuffer : IMFMediaBuffer** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MFPlat.dll')
MFCreateMediaBufferFromMediaType = Fiddle::Function.new(
lib['MFCreateMediaBufferFromMediaType'],
[
Fiddle::TYPE_VOIDP, # pMediaType : IMFMediaType*
Fiddle::TYPE_LONG_LONG, # llDuration : LONGLONG
-Fiddle::TYPE_INT, # dwMinLength : DWORD
-Fiddle::TYPE_INT, # dwMinAlignment : DWORD
Fiddle::TYPE_VOIDP, # ppBuffer : IMFMediaBuffer** out
],
Fiddle::TYPE_INT)#[link(name = "mfplat")]
extern "system" {
fn MFCreateMediaBufferFromMediaType(
pMediaType: *mut core::ffi::c_void, // IMFMediaType*
llDuration: i64, // LONGLONG
dwMinLength: u32, // DWORD
dwMinAlignment: u32, // DWORD
ppBuffer: *mut *mut core::ffi::c_void // IMFMediaBuffer** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MFPlat.dll")]
public static extern int MFCreateMediaBufferFromMediaType(IntPtr pMediaType, long llDuration, uint dwMinLength, uint dwMinAlignment, IntPtr ppBuffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MFPlat_MFCreateMediaBufferFromMediaType' -Namespace Win32 -PassThru
# $api::MFCreateMediaBufferFromMediaType(pMediaType, llDuration, dwMinLength, dwMinAlignment, ppBuffer)#uselib "MFPlat.dll"
#func global MFCreateMediaBufferFromMediaType "MFCreateMediaBufferFromMediaType" sptr, sptr, sptr, sptr, sptr
; MFCreateMediaBufferFromMediaType pMediaType, llDuration, dwMinLength, dwMinAlignment, ppBuffer ; 戻り値は stat
; pMediaType : IMFMediaType* -> "sptr"
; llDuration : LONGLONG -> "sptr"
; dwMinLength : DWORD -> "sptr"
; dwMinAlignment : DWORD -> "sptr"
; ppBuffer : IMFMediaBuffer** out -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "MFPlat.dll"
#cfunc global MFCreateMediaBufferFromMediaType "MFCreateMediaBufferFromMediaType" sptr, int64, int, int, sptr
; res = MFCreateMediaBufferFromMediaType(pMediaType, llDuration, dwMinLength, dwMinAlignment, ppBuffer)
; pMediaType : IMFMediaType* -> "sptr"
; llDuration : LONGLONG -> "int64"
; dwMinLength : DWORD -> "int"
; dwMinAlignment : DWORD -> "int"
; ppBuffer : IMFMediaBuffer** out -> "sptr"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。; HRESULT MFCreateMediaBufferFromMediaType(IMFMediaType* pMediaType, LONGLONG llDuration, DWORD dwMinLength, DWORD dwMinAlignment, IMFMediaBuffer** ppBuffer)
#uselib "MFPlat.dll"
#cfunc global MFCreateMediaBufferFromMediaType "MFCreateMediaBufferFromMediaType" intptr, int64, int, int, intptr
; res = MFCreateMediaBufferFromMediaType(pMediaType, llDuration, dwMinLength, dwMinAlignment, ppBuffer)
; pMediaType : IMFMediaType* -> "intptr"
; llDuration : LONGLONG -> "int64"
; dwMinLength : DWORD -> "int"
; dwMinAlignment : DWORD -> "int"
; ppBuffer : IMFMediaBuffer** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mfplat = windows.NewLazySystemDLL("MFPlat.dll")
procMFCreateMediaBufferFromMediaType = mfplat.NewProc("MFCreateMediaBufferFromMediaType")
)
// pMediaType (IMFMediaType*), llDuration (LONGLONG), dwMinLength (DWORD), dwMinAlignment (DWORD), ppBuffer (IMFMediaBuffer** out)
r1, _, err := procMFCreateMediaBufferFromMediaType.Call(
uintptr(pMediaType),
uintptr(llDuration),
uintptr(dwMinLength),
uintptr(dwMinAlignment),
uintptr(ppBuffer),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction MFCreateMediaBufferFromMediaType(
pMediaType: Pointer; // IMFMediaType*
llDuration: Int64; // LONGLONG
dwMinLength: DWORD; // DWORD
dwMinAlignment: DWORD; // DWORD
ppBuffer: Pointer // IMFMediaBuffer** out
): Integer; stdcall;
external 'MFPlat.dll' name 'MFCreateMediaBufferFromMediaType';result := DllCall("MFPlat\MFCreateMediaBufferFromMediaType"
, "Ptr", pMediaType ; IMFMediaType*
, "Int64", llDuration ; LONGLONG
, "UInt", dwMinLength ; DWORD
, "UInt", dwMinAlignment ; DWORD
, "Ptr", ppBuffer ; IMFMediaBuffer** out
, "Int") ; return: HRESULT●MFCreateMediaBufferFromMediaType(pMediaType, llDuration, dwMinLength, dwMinAlignment, ppBuffer) = DLL("MFPlat.dll", "int MFCreateMediaBufferFromMediaType(void*, int64, dword, dword, void*)")
# 呼び出し: MFCreateMediaBufferFromMediaType(pMediaType, llDuration, dwMinLength, dwMinAlignment, ppBuffer)
# pMediaType : IMFMediaType* -> "void*"
# llDuration : LONGLONG -> "int64"
# dwMinLength : DWORD -> "dword"
# dwMinAlignment : DWORD -> "dword"
# ppBuffer : IMFMediaBuffer** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。