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

OPMGetVideoOutputForTarget

関数
指定したVidPnターゲットの出力保護用ビデオ出力を取得する。
DLLdxva2.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT OPMGetVideoOutputForTarget(
    LUID* pAdapterLuid,
    DWORD VidPnTarget,
    OPM_VIDEO_OUTPUT_SEMANTICS vos,
    IOPMVideoOutput** ppOPMVideoOutput
);

パラメーター

名前方向説明
pAdapterLuidLUID*inターゲットが配置されているアダプターの LUID。
VidPnTargetDWORDin指定したアダプター上のターゲットのターゲット ID。
vosOPM_VIDEO_OUTPUT_SEMANTICSin

OPM_VIDEO_OUTPUT_SEMANTICS 列挙体のメンバー。

意味
OPM_VOS_OPM_SEMANTICS
返される IOPMVideoOutput ポインターは OPM セマンティクスを使用します。
OPM_VOS_COPP_SEMANTICS
返される IOPMVideoOutput ポインターは Certified Output Protection Protocol (COPP) セマンティクスを使用します。
ppOPMVideoOutputIOPMVideoOutput**outIOPMVideoOutput ポインターを受け取ります。呼び出し元はこのポインターを解放する必要があります。

戻り値の型: HRESULT

公式ドキュメント

指定したアダプター上の VidPN ターゲットに対応するビデオ出力オブジェクトを返します。

戻り値

この関数が成功した場合は S_OK を返します。それ以外の場合は HRESULT エラー コードを返します。

解説(Remarks)

IOPMVideoOutput インターフェイスには、vos パラメーターの値に応じて 2 つの動作モードがあります。vosOPM_VOS_COPP_SEMANTICS の場合、IOPMVideoOutput は COPP セマンティクスを使用します。このモードは COPP との下位互換性を目的としています。vosOPM_VOS_OPM_SEMANTICS の場合、IOPMVideoOutput はより新しい OPM セマンティクスを使用します。動作の違いは各メソッドのリファレンス ページに記載されています。このモードはオブジェクトの有効期間中に変更されることはありません。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

HRESULT OPMGetVideoOutputForTarget(
    LUID* pAdapterLuid,
    DWORD VidPnTarget,
    OPM_VIDEO_OUTPUT_SEMANTICS vos,
    IOPMVideoOutput** ppOPMVideoOutput
);
[DllImport("dxva2.dll", ExactSpelling = true)]
static extern int OPMGetVideoOutputForTarget(
    IntPtr pAdapterLuid,   // LUID*
    uint VidPnTarget,   // DWORD
    int vos,   // OPM_VIDEO_OUTPUT_SEMANTICS
    IntPtr ppOPMVideoOutput   // IOPMVideoOutput** out
);
<DllImport("dxva2.dll", ExactSpelling:=True)>
Public Shared Function OPMGetVideoOutputForTarget(
    pAdapterLuid As IntPtr,   ' LUID*
    VidPnTarget As UInteger,   ' DWORD
    vos As Integer,   ' OPM_VIDEO_OUTPUT_SEMANTICS
    ppOPMVideoOutput As IntPtr   ' IOPMVideoOutput** out
) As Integer
End Function
' pAdapterLuid : LUID*
' VidPnTarget : DWORD
' vos : OPM_VIDEO_OUTPUT_SEMANTICS
' ppOPMVideoOutput : IOPMVideoOutput** out
Declare PtrSafe Function OPMGetVideoOutputForTarget Lib "dxva2" ( _
    ByVal pAdapterLuid As LongPtr, _
    ByVal VidPnTarget As Long, _
    ByVal vos As Long, _
    ByVal ppOPMVideoOutput As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

OPMGetVideoOutputForTarget = ctypes.windll.dxva2.OPMGetVideoOutputForTarget
OPMGetVideoOutputForTarget.restype = ctypes.c_int
OPMGetVideoOutputForTarget.argtypes = [
    ctypes.c_void_p,  # pAdapterLuid : LUID*
    wintypes.DWORD,  # VidPnTarget : DWORD
    ctypes.c_int,  # vos : OPM_VIDEO_OUTPUT_SEMANTICS
    ctypes.c_void_p,  # ppOPMVideoOutput : IOPMVideoOutput** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	dxva2 = windows.NewLazySystemDLL("dxva2.dll")
	procOPMGetVideoOutputForTarget = dxva2.NewProc("OPMGetVideoOutputForTarget")
)

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

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

typedef OPMGetVideoOutputForTargetNative = Int32 Function(Pointer<Void>, Uint32, Int32, Pointer<Void>);
typedef OPMGetVideoOutputForTargetDart = int Function(Pointer<Void>, int, int, Pointer<Void>);
final OPMGetVideoOutputForTarget = DynamicLibrary.open('dxva2.dll')
    .lookupFunction<OPMGetVideoOutputForTargetNative, OPMGetVideoOutputForTargetDart>('OPMGetVideoOutputForTarget');
// pAdapterLuid : LUID* -> Pointer<Void>
// VidPnTarget : DWORD -> Uint32
// vos : OPM_VIDEO_OUTPUT_SEMANTICS -> Int32
// ppOPMVideoOutput : IOPMVideoOutput** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function OPMGetVideoOutputForTarget(
  pAdapterLuid: Pointer;   // LUID*
  VidPnTarget: DWORD;   // DWORD
  vos: Integer;   // OPM_VIDEO_OUTPUT_SEMANTICS
  ppOPMVideoOutput: Pointer   // IOPMVideoOutput** out
): Integer; stdcall;
  external 'dxva2.dll' name 'OPMGetVideoOutputForTarget';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "OPMGetVideoOutputForTarget"
  c_OPMGetVideoOutputForTarget :: Ptr () -> Word32 -> Int32 -> Ptr () -> IO Int32
-- pAdapterLuid : LUID* -> Ptr ()
-- VidPnTarget : DWORD -> Word32
-- vos : OPM_VIDEO_OUTPUT_SEMANTICS -> Int32
-- ppOPMVideoOutput : IOPMVideoOutput** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let opmgetvideooutputfortarget =
  foreign "OPMGetVideoOutputForTarget"
    ((ptr void) @-> uint32_t @-> int32_t @-> (ptr void) @-> returning int32_t)
(* pAdapterLuid : LUID* -> (ptr void) *)
(* VidPnTarget : DWORD -> uint32_t *)
(* vos : OPM_VIDEO_OUTPUT_SEMANTICS -> int32_t *)
(* ppOPMVideoOutput : IOPMVideoOutput** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library dxva2 (t "dxva2.dll"))
(cffi:use-foreign-library dxva2)

(cffi:defcfun ("OPMGetVideoOutputForTarget" opmget-video-output-for-target :convention :stdcall) :int32
  (p-adapter-luid :pointer)   ; LUID*
  (vid-pn-target :uint32)   ; DWORD
  (vos :int32)   ; OPM_VIDEO_OUTPUT_SEMANTICS
  (pp-opmvideo-output :pointer))   ; IOPMVideoOutput** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $OPMGetVideoOutputForTarget = Win32::API::More->new('dxva2',
    'int OPMGetVideoOutputForTarget(LPVOID pAdapterLuid, DWORD VidPnTarget, int vos, LPVOID ppOPMVideoOutput)');
# my $ret = $OPMGetVideoOutputForTarget->Call($pAdapterLuid, $VidPnTarget, $vos, $ppOPMVideoOutput);
# pAdapterLuid : LUID* -> LPVOID
# VidPnTarget : DWORD -> DWORD
# vos : OPM_VIDEO_OUTPUT_SEMANTICS -> int
# ppOPMVideoOutput : IOPMVideoOutput** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型