ホーム › Media.MediaFoundation › MFCreateSourceReaderFromURL
MFCreateSourceReaderFromURL
関数URLで指定したメディアファイルからソースリーダーを作成する。
シグネチャ
// MFReadWrite.dll
#include <windows.h>
HRESULT MFCreateSourceReaderFromURL(
LPCWSTR pwszURL,
IMFAttributes* pAttributes, // optional
IMFSourceReader** ppSourceReader
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pwszURL | LPCWSTR | in | 開くメディアファイルの URL。 |
| pAttributes | IMFAttributes* | inoptional | IMFAttributes インターフェイスへのポインター。このパラメーターを使用してソースリーダーを構成できます。詳細については、Source Reader Attributes を参照してください。このパラメーターは NULL にすることができます。 |
| ppSourceReader | IMFSourceReader** | out | IMFSourceReader インターフェイスへのポインターを受け取ります。呼び出し元はこのインターフェイスを解放する必要があります。 |
戻り値の型: HRESULT
公式ドキュメント
URL からソースリーダーを作成します。
戻り値
この関数が成功した場合は S_OK を返します。それ以外の場合は HRESULT エラーコードを返します。
解説(Remarks)
この関数を呼び出す前に、CoInitialize(Ex) および MFStartup を呼び出してください。
内部的には、ソースリーダーは IMFSourceResolver::CreateObjectFromURL メソッドを呼び出して、URL からメディアソースを作成します。
この関数は、Platform Update Supplement for Windows Vista がインストールされている場合に Windows Vista で利用できます。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// MFReadWrite.dll
#include <windows.h>
HRESULT MFCreateSourceReaderFromURL(
LPCWSTR pwszURL,
IMFAttributes* pAttributes, // optional
IMFSourceReader** ppSourceReader
);[DllImport("MFReadWrite.dll", ExactSpelling = true)]
static extern int MFCreateSourceReaderFromURL(
[MarshalAs(UnmanagedType.LPWStr)] string pwszURL, // LPCWSTR
IntPtr pAttributes, // IMFAttributes* optional
IntPtr ppSourceReader // IMFSourceReader** out
);<DllImport("MFReadWrite.dll", ExactSpelling:=True)>
Public Shared Function MFCreateSourceReaderFromURL(
<MarshalAs(UnmanagedType.LPWStr)> pwszURL As String, ' LPCWSTR
pAttributes As IntPtr, ' IMFAttributes* optional
ppSourceReader As IntPtr ' IMFSourceReader** out
) As Integer
End Function' pwszURL : LPCWSTR
' pAttributes : IMFAttributes* optional
' ppSourceReader : IMFSourceReader** out
Declare PtrSafe Function MFCreateSourceReaderFromURL Lib "mfreadwrite" ( _
ByVal pwszURL As LongPtr, _
ByVal pAttributes As LongPtr, _
ByVal ppSourceReader As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MFCreateSourceReaderFromURL = ctypes.windll.mfreadwrite.MFCreateSourceReaderFromURL
MFCreateSourceReaderFromURL.restype = ctypes.c_int
MFCreateSourceReaderFromURL.argtypes = [
wintypes.LPCWSTR, # pwszURL : LPCWSTR
ctypes.c_void_p, # pAttributes : IMFAttributes* optional
ctypes.c_void_p, # ppSourceReader : IMFSourceReader** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MFReadWrite.dll')
MFCreateSourceReaderFromURL = Fiddle::Function.new(
lib['MFCreateSourceReaderFromURL'],
[
Fiddle::TYPE_VOIDP, # pwszURL : LPCWSTR
Fiddle::TYPE_VOIDP, # pAttributes : IMFAttributes* optional
Fiddle::TYPE_VOIDP, # ppSourceReader : IMFSourceReader** out
],
Fiddle::TYPE_INT)#[link(name = "mfreadwrite")]
extern "system" {
fn MFCreateSourceReaderFromURL(
pwszURL: *const u16, // LPCWSTR
pAttributes: *mut core::ffi::c_void, // IMFAttributes* optional
ppSourceReader: *mut *mut core::ffi::c_void // IMFSourceReader** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MFReadWrite.dll")]
public static extern int MFCreateSourceReaderFromURL([MarshalAs(UnmanagedType.LPWStr)] string pwszURL, IntPtr pAttributes, IntPtr ppSourceReader);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MFReadWrite_MFCreateSourceReaderFromURL' -Namespace Win32 -PassThru
# $api::MFCreateSourceReaderFromURL(pwszURL, pAttributes, ppSourceReader)#uselib "MFReadWrite.dll"
#func global MFCreateSourceReaderFromURL "MFCreateSourceReaderFromURL" sptr, sptr, sptr
; MFCreateSourceReaderFromURL pwszURL, pAttributes, ppSourceReader ; 戻り値は stat
; pwszURL : LPCWSTR -> "sptr"
; pAttributes : IMFAttributes* optional -> "sptr"
; ppSourceReader : IMFSourceReader** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "MFReadWrite.dll"
#cfunc global MFCreateSourceReaderFromURL "MFCreateSourceReaderFromURL" wstr, sptr, sptr
; res = MFCreateSourceReaderFromURL(pwszURL, pAttributes, ppSourceReader)
; pwszURL : LPCWSTR -> "wstr"
; pAttributes : IMFAttributes* optional -> "sptr"
; ppSourceReader : IMFSourceReader** out -> "sptr"; HRESULT MFCreateSourceReaderFromURL(LPCWSTR pwszURL, IMFAttributes* pAttributes, IMFSourceReader** ppSourceReader)
#uselib "MFReadWrite.dll"
#cfunc global MFCreateSourceReaderFromURL "MFCreateSourceReaderFromURL" wstr, intptr, intptr
; res = MFCreateSourceReaderFromURL(pwszURL, pAttributes, ppSourceReader)
; pwszURL : LPCWSTR -> "wstr"
; pAttributes : IMFAttributes* optional -> "intptr"
; ppSourceReader : IMFSourceReader** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mfreadwrite = windows.NewLazySystemDLL("MFReadWrite.dll")
procMFCreateSourceReaderFromURL = mfreadwrite.NewProc("MFCreateSourceReaderFromURL")
)
// pwszURL (LPCWSTR), pAttributes (IMFAttributes* optional), ppSourceReader (IMFSourceReader** out)
r1, _, err := procMFCreateSourceReaderFromURL.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszURL))),
uintptr(pAttributes),
uintptr(ppSourceReader),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction MFCreateSourceReaderFromURL(
pwszURL: PWideChar; // LPCWSTR
pAttributes: Pointer; // IMFAttributes* optional
ppSourceReader: Pointer // IMFSourceReader** out
): Integer; stdcall;
external 'MFReadWrite.dll' name 'MFCreateSourceReaderFromURL';result := DllCall("MFReadWrite\MFCreateSourceReaderFromURL"
, "WStr", pwszURL ; LPCWSTR
, "Ptr", pAttributes ; IMFAttributes* optional
, "Ptr", ppSourceReader ; IMFSourceReader** out
, "Int") ; return: HRESULT●MFCreateSourceReaderFromURL(pwszURL, pAttributes, ppSourceReader) = DLL("MFReadWrite.dll", "int MFCreateSourceReaderFromURL(char*, void*, void*)")
# 呼び出し: MFCreateSourceReaderFromURL(pwszURL, pAttributes, ppSourceReader)
# pwszURL : LPCWSTR -> "char*"
# pAttributes : IMFAttributes* optional -> "void*"
# ppSourceReader : IMFSourceReader** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mfreadwrite" fn MFCreateSourceReaderFromURL(
pwszURL: [*c]const u16, // LPCWSTR
pAttributes: ?*anyopaque, // IMFAttributes* optional
ppSourceReader: ?*anyopaque // IMFSourceReader** out
) callconv(std.os.windows.WINAPI) i32;proc MFCreateSourceReaderFromURL(
pwszURL: WideCString, # LPCWSTR
pAttributes: pointer, # IMFAttributes* optional
ppSourceReader: pointer # IMFSourceReader** out
): int32 {.importc: "MFCreateSourceReaderFromURL", stdcall, dynlib: "MFReadWrite.dll".}pragma(lib, "mfreadwrite");
extern(Windows)
int MFCreateSourceReaderFromURL(
const(wchar)* pwszURL, // LPCWSTR
void* pAttributes, // IMFAttributes* optional
void* ppSourceReader // IMFSourceReader** out
);ccall((:MFCreateSourceReaderFromURL, "MFReadWrite.dll"), stdcall, Int32,
(Cwstring, Ptr{Cvoid}, Ptr{Cvoid}),
pwszURL, pAttributes, ppSourceReader)
# pwszURL : LPCWSTR -> Cwstring
# pAttributes : IMFAttributes* optional -> Ptr{Cvoid}
# ppSourceReader : IMFSourceReader** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MFCreateSourceReaderFromURL(
const uint16_t* pwszURL,
void* pAttributes,
void* ppSourceReader);
]]
local mfreadwrite = ffi.load("mfreadwrite")
-- mfreadwrite.MFCreateSourceReaderFromURL(pwszURL, pAttributes, ppSourceReader)
-- pwszURL : LPCWSTR
-- pAttributes : IMFAttributes* optional
-- ppSourceReader : IMFSourceReader** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MFReadWrite.dll');
const MFCreateSourceReaderFromURL = lib.func('__stdcall', 'MFCreateSourceReaderFromURL', 'int32_t', ['str16', 'void *', 'void *']);
// MFCreateSourceReaderFromURL(pwszURL, pAttributes, ppSourceReader)
// pwszURL : LPCWSTR -> 'str16'
// pAttributes : IMFAttributes* optional -> 'void *'
// ppSourceReader : IMFSourceReader** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MFReadWrite.dll", {
MFCreateSourceReaderFromURL: { parameters: ["buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.MFCreateSourceReaderFromURL(pwszURL, pAttributes, ppSourceReader)
// pwszURL : LPCWSTR -> "buffer"
// pAttributes : IMFAttributes* optional -> "pointer"
// ppSourceReader : IMFSourceReader** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MFCreateSourceReaderFromURL(
const uint16_t* pwszURL,
void* pAttributes,
void* ppSourceReader);
C, "MFReadWrite.dll");
// $ffi->MFCreateSourceReaderFromURL(pwszURL, pAttributes, ppSourceReader);
// pwszURL : LPCWSTR
// pAttributes : IMFAttributes* optional
// ppSourceReader : IMFSourceReader** 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 Mfreadwrite extends StdCallLibrary {
Mfreadwrite INSTANCE = Native.load("mfreadwrite", Mfreadwrite.class);
int MFCreateSourceReaderFromURL(
WString pwszURL, // LPCWSTR
Pointer pAttributes, // IMFAttributes* optional
Pointer ppSourceReader // IMFSourceReader** out
);
}@[Link("mfreadwrite")]
lib LibMFReadWrite
fun MFCreateSourceReaderFromURL = MFCreateSourceReaderFromURL(
pwszURL : UInt16*, # LPCWSTR
pAttributes : Void*, # IMFAttributes* optional
ppSourceReader : Void* # IMFSourceReader** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MFCreateSourceReaderFromURLNative = Int32 Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
typedef MFCreateSourceReaderFromURLDart = int Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
final MFCreateSourceReaderFromURL = DynamicLibrary.open('MFReadWrite.dll')
.lookupFunction<MFCreateSourceReaderFromURLNative, MFCreateSourceReaderFromURLDart>('MFCreateSourceReaderFromURL');
// pwszURL : LPCWSTR -> Pointer<Utf16>
// pAttributes : IMFAttributes* optional -> Pointer<Void>
// ppSourceReader : IMFSourceReader** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MFCreateSourceReaderFromURL(
pwszURL: PWideChar; // LPCWSTR
pAttributes: Pointer; // IMFAttributes* optional
ppSourceReader: Pointer // IMFSourceReader** out
): Integer; stdcall;
external 'MFReadWrite.dll' name 'MFCreateSourceReaderFromURL';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MFCreateSourceReaderFromURL"
c_MFCreateSourceReaderFromURL :: CWString -> Ptr () -> Ptr () -> IO Int32
-- pwszURL : LPCWSTR -> CWString
-- pAttributes : IMFAttributes* optional -> Ptr ()
-- ppSourceReader : IMFSourceReader** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mfcreatesourcereaderfromurl =
foreign "MFCreateSourceReaderFromURL"
((ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* pwszURL : LPCWSTR -> (ptr uint16_t) *)
(* pAttributes : IMFAttributes* optional -> (ptr void) *)
(* ppSourceReader : IMFSourceReader** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mfreadwrite (t "MFReadWrite.dll"))
(cffi:use-foreign-library mfreadwrite)
(cffi:defcfun ("MFCreateSourceReaderFromURL" mfcreate-source-reader-from-url :convention :stdcall) :int32
(pwsz-url (:string :encoding :utf-16le)) ; LPCWSTR
(p-attributes :pointer) ; IMFAttributes* optional
(pp-source-reader :pointer)) ; IMFSourceReader** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MFCreateSourceReaderFromURL = Win32::API::More->new('MFReadWrite',
'int MFCreateSourceReaderFromURL(LPCWSTR pwszURL, LPVOID pAttributes, LPVOID ppSourceReader)');
# my $ret = $MFCreateSourceReaderFromURL->Call($pwszURL, $pAttributes, $ppSourceReader);
# pwszURL : LPCWSTR -> LPCWSTR
# pAttributes : IMFAttributes* optional -> LPVOID
# ppSourceReader : IMFSourceReader** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。