ホーム › Media.MediaFoundation › MFCreateAggregateSource
MFCreateAggregateSource
関数複数のメディアソースを統合する集約ソースを生成する。
シグネチャ
// MF.dll
#include <windows.h>
HRESULT MFCreateAggregateSource(
IMFCollection* pSourceCollection,
IMFMediaSource** ppAggSource
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pSourceCollection | IMFCollection* | in | メディアソースのリストを保持するコレクションオブジェクトの IMFCollection インターフェイスへのポインター。 |
| ppAggSource | IMFMediaSource** | out | 集約されたメディアソースの IMFMediaSource インターフェイスへのポインターを受け取ります。呼び出し側はこのインターフェイスを解放する必要があります。 |
戻り値の型: HRESULT
公式ドキュメント
複数のメディアソースのコレクションを集約するメディアソースを作成します。
戻り値
この関数は HRESULT を返します。指定できる値には、次の表に示すものが含まれますが、これらに限定されません。
| 戻り値 | 説明 |
|---|---|
| メソッドは成功しました。 | |
| pSourceCollection コレクションに要素が 1 つも含まれていません。 |
解説(Remarks)
集約されたメディアソースは、複数の別個のメディアソースからのストリームを組み合わせる場合に役立ちます。たとえば、ビデオキャプチャソースとオーディオキャプチャソースを組み合わせるために使用できます。
例
HRESULT CreateAggregatedSource(
IMFMediaSource *pSource1,
IMFMediaSource *pSource2,
IMFMediaSource **ppAggSource
)
{
*ppAggSource = NULL;
IMFCollection *pCollection = NULL;
HRESULT hr = MFCreateCollection(&pCollection);
if (SUCCEEDED(hr))
{
hr = pCollection->AddElement(pSource1);
}
if (SUCCEEDED(hr))
{
hr = pCollection->AddElement(pSource2);
}
if (SUCCEEDED(hr))
{
hr = MFCreateAggregateSource(pCollection, ppAggSource);
}
SafeRelease(&pCollection);
return hr;
}
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// MF.dll
#include <windows.h>
HRESULT MFCreateAggregateSource(
IMFCollection* pSourceCollection,
IMFMediaSource** ppAggSource
);[DllImport("MF.dll", ExactSpelling = true)]
static extern int MFCreateAggregateSource(
IntPtr pSourceCollection, // IMFCollection*
IntPtr ppAggSource // IMFMediaSource** out
);<DllImport("MF.dll", ExactSpelling:=True)>
Public Shared Function MFCreateAggregateSource(
pSourceCollection As IntPtr, ' IMFCollection*
ppAggSource As IntPtr ' IMFMediaSource** out
) As Integer
End Function' pSourceCollection : IMFCollection*
' ppAggSource : IMFMediaSource** out
Declare PtrSafe Function MFCreateAggregateSource Lib "mf" ( _
ByVal pSourceCollection As LongPtr, _
ByVal ppAggSource As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MFCreateAggregateSource = ctypes.windll.mf.MFCreateAggregateSource
MFCreateAggregateSource.restype = ctypes.c_int
MFCreateAggregateSource.argtypes = [
ctypes.c_void_p, # pSourceCollection : IMFCollection*
ctypes.c_void_p, # ppAggSource : IMFMediaSource** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MF.dll')
MFCreateAggregateSource = Fiddle::Function.new(
lib['MFCreateAggregateSource'],
[
Fiddle::TYPE_VOIDP, # pSourceCollection : IMFCollection*
Fiddle::TYPE_VOIDP, # ppAggSource : IMFMediaSource** out
],
Fiddle::TYPE_INT)#[link(name = "mf")]
extern "system" {
fn MFCreateAggregateSource(
pSourceCollection: *mut core::ffi::c_void, // IMFCollection*
ppAggSource: *mut *mut core::ffi::c_void // IMFMediaSource** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MF.dll")]
public static extern int MFCreateAggregateSource(IntPtr pSourceCollection, IntPtr ppAggSource);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MF_MFCreateAggregateSource' -Namespace Win32 -PassThru
# $api::MFCreateAggregateSource(pSourceCollection, ppAggSource)#uselib "MF.dll"
#func global MFCreateAggregateSource "MFCreateAggregateSource" sptr, sptr
; MFCreateAggregateSource pSourceCollection, ppAggSource ; 戻り値は stat
; pSourceCollection : IMFCollection* -> "sptr"
; ppAggSource : IMFMediaSource** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "MF.dll"
#cfunc global MFCreateAggregateSource "MFCreateAggregateSource" sptr, sptr
; res = MFCreateAggregateSource(pSourceCollection, ppAggSource)
; pSourceCollection : IMFCollection* -> "sptr"
; ppAggSource : IMFMediaSource** out -> "sptr"; HRESULT MFCreateAggregateSource(IMFCollection* pSourceCollection, IMFMediaSource** ppAggSource)
#uselib "MF.dll"
#cfunc global MFCreateAggregateSource "MFCreateAggregateSource" intptr, intptr
; res = MFCreateAggregateSource(pSourceCollection, ppAggSource)
; pSourceCollection : IMFCollection* -> "intptr"
; ppAggSource : IMFMediaSource** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mf = windows.NewLazySystemDLL("MF.dll")
procMFCreateAggregateSource = mf.NewProc("MFCreateAggregateSource")
)
// pSourceCollection (IMFCollection*), ppAggSource (IMFMediaSource** out)
r1, _, err := procMFCreateAggregateSource.Call(
uintptr(pSourceCollection),
uintptr(ppAggSource),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction MFCreateAggregateSource(
pSourceCollection: Pointer; // IMFCollection*
ppAggSource: Pointer // IMFMediaSource** out
): Integer; stdcall;
external 'MF.dll' name 'MFCreateAggregateSource';result := DllCall("MF\MFCreateAggregateSource"
, "Ptr", pSourceCollection ; IMFCollection*
, "Ptr", ppAggSource ; IMFMediaSource** out
, "Int") ; return: HRESULT●MFCreateAggregateSource(pSourceCollection, ppAggSource) = DLL("MF.dll", "int MFCreateAggregateSource(void*, void*)")
# 呼び出し: MFCreateAggregateSource(pSourceCollection, ppAggSource)
# pSourceCollection : IMFCollection* -> "void*"
# ppAggSource : IMFMediaSource** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mf" fn MFCreateAggregateSource(
pSourceCollection: ?*anyopaque, // IMFCollection*
ppAggSource: ?*anyopaque // IMFMediaSource** out
) callconv(std.os.windows.WINAPI) i32;proc MFCreateAggregateSource(
pSourceCollection: pointer, # IMFCollection*
ppAggSource: pointer # IMFMediaSource** out
): int32 {.importc: "MFCreateAggregateSource", stdcall, dynlib: "MF.dll".}pragma(lib, "mf");
extern(Windows)
int MFCreateAggregateSource(
void* pSourceCollection, // IMFCollection*
void* ppAggSource // IMFMediaSource** out
);ccall((:MFCreateAggregateSource, "MF.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}),
pSourceCollection, ppAggSource)
# pSourceCollection : IMFCollection* -> Ptr{Cvoid}
# ppAggSource : IMFMediaSource** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MFCreateAggregateSource(
void* pSourceCollection,
void* ppAggSource);
]]
local mf = ffi.load("mf")
-- mf.MFCreateAggregateSource(pSourceCollection, ppAggSource)
-- pSourceCollection : IMFCollection*
-- ppAggSource : IMFMediaSource** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MF.dll');
const MFCreateAggregateSource = lib.func('__stdcall', 'MFCreateAggregateSource', 'int32_t', ['void *', 'void *']);
// MFCreateAggregateSource(pSourceCollection, ppAggSource)
// pSourceCollection : IMFCollection* -> 'void *'
// ppAggSource : IMFMediaSource** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MF.dll", {
MFCreateAggregateSource: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.MFCreateAggregateSource(pSourceCollection, ppAggSource)
// pSourceCollection : IMFCollection* -> "pointer"
// ppAggSource : IMFMediaSource** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MFCreateAggregateSource(
void* pSourceCollection,
void* ppAggSource);
C, "MF.dll");
// $ffi->MFCreateAggregateSource(pSourceCollection, ppAggSource);
// pSourceCollection : IMFCollection*
// ppAggSource : IMFMediaSource** 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 Mf extends StdCallLibrary {
Mf INSTANCE = Native.load("mf", Mf.class);
int MFCreateAggregateSource(
Pointer pSourceCollection, // IMFCollection*
Pointer ppAggSource // IMFMediaSource** out
);
}@[Link("mf")]
lib LibMF
fun MFCreateAggregateSource = MFCreateAggregateSource(
pSourceCollection : Void*, # IMFCollection*
ppAggSource : Void* # IMFMediaSource** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MFCreateAggregateSourceNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef MFCreateAggregateSourceDart = int Function(Pointer<Void>, Pointer<Void>);
final MFCreateAggregateSource = DynamicLibrary.open('MF.dll')
.lookupFunction<MFCreateAggregateSourceNative, MFCreateAggregateSourceDart>('MFCreateAggregateSource');
// pSourceCollection : IMFCollection* -> Pointer<Void>
// ppAggSource : IMFMediaSource** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MFCreateAggregateSource(
pSourceCollection: Pointer; // IMFCollection*
ppAggSource: Pointer // IMFMediaSource** out
): Integer; stdcall;
external 'MF.dll' name 'MFCreateAggregateSource';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MFCreateAggregateSource"
c_MFCreateAggregateSource :: Ptr () -> Ptr () -> IO Int32
-- pSourceCollection : IMFCollection* -> Ptr ()
-- ppAggSource : IMFMediaSource** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mfcreateaggregatesource =
foreign "MFCreateAggregateSource"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* pSourceCollection : IMFCollection* -> (ptr void) *)
(* ppAggSource : IMFMediaSource** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mf (t "MF.dll"))
(cffi:use-foreign-library mf)
(cffi:defcfun ("MFCreateAggregateSource" mfcreate-aggregate-source :convention :stdcall) :int32
(p-source-collection :pointer) ; IMFCollection*
(pp-agg-source :pointer)) ; IMFMediaSource** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MFCreateAggregateSource = Win32::API::More->new('MF',
'int MFCreateAggregateSource(LPVOID pSourceCollection, LPVOID ppAggSource)');
# my $ret = $MFCreateAggregateSource->Call($pSourceCollection, $ppAggSource);
# pSourceCollection : IMFCollection* -> LPVOID
# ppAggSource : IMFMediaSource** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。