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

AM_MPEGSYSTEMTYPE

構造体
サイズx64: 112 バイト / x86: 92 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
dwBitRateDWORD4+0+0MPEGシステムストリーム全体のビットレート。単位はbps。
cStreamsDWORD4+4+4含まれるエレメンタリストリームの数。
StreamsAM_MPEGSTREAMTYPE104/84+8+8ストリーム情報配列(AM_MPEGSTREAMTYPE)。可変長の先頭要素。

各言語での定義

#include <windows.h>

// AM_MEDIA_TYPE  (x64 88 / x86 72 バイト)
typedef struct AM_MEDIA_TYPE {
    GUID majortype;
    GUID subtype;
    BOOL bFixedSizeSamples;
    BOOL bTemporalCompression;
    DWORD lSampleSize;
    GUID formattype;
    IUnknown* pUnk;
    DWORD cbFormat;
    BYTE* pbFormat;
} AM_MEDIA_TYPE;

// AM_MPEGSTREAMTYPE  (x64 104 / x86 84 バイト)
typedef struct AM_MPEGSTREAMTYPE {
    DWORD dwStreamId;
    DWORD dwReserved;
    AM_MEDIA_TYPE mt;
    BYTE bFormat[1];
} AM_MPEGSTREAMTYPE;

// AM_MPEGSYSTEMTYPE  (x64 112 / x86 92 バイト)
typedef struct AM_MPEGSYSTEMTYPE {
    DWORD dwBitRate;
    DWORD cStreams;
    AM_MPEGSTREAMTYPE Streams[1];
} AM_MPEGSYSTEMTYPE;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct AM_MEDIA_TYPE
{
    public Guid majortype;
    public Guid subtype;
    [MarshalAs(UnmanagedType.Bool)] public bool bFixedSizeSamples;
    [MarshalAs(UnmanagedType.Bool)] public bool bTemporalCompression;
    public uint lSampleSize;
    public Guid formattype;
    public IntPtr pUnk;
    public uint cbFormat;
    public IntPtr pbFormat;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct AM_MPEGSTREAMTYPE
{
    public uint dwStreamId;
    public uint dwReserved;
    public AM_MEDIA_TYPE mt;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] bFormat;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct AM_MPEGSYSTEMTYPE
{
    public uint dwBitRate;
    public uint cStreams;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public AM_MPEGSTREAMTYPE[] Streams;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure AM_MEDIA_TYPE
    Public majortype As Guid
    Public subtype As Guid
    <MarshalAs(UnmanagedType.Bool)> Public bFixedSizeSamples As Boolean
    <MarshalAs(UnmanagedType.Bool)> Public bTemporalCompression As Boolean
    Public lSampleSize As UInteger
    Public formattype As Guid
    Public pUnk As IntPtr
    Public cbFormat As UInteger
    Public pbFormat As IntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure AM_MPEGSTREAMTYPE
    Public dwStreamId As UInteger
    Public dwReserved As UInteger
    Public mt As AM_MEDIA_TYPE
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public bFormat() As Byte
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure AM_MPEGSYSTEMTYPE
    Public dwBitRate As UInteger
    Public cStreams As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Streams() As AM_MPEGSTREAMTYPE
End Structure
import ctypes
from ctypes import wintypes

class AM_MEDIA_TYPE(ctypes.Structure):
    _fields_ = [
        ("majortype", GUID),
        ("subtype", GUID),
        ("bFixedSizeSamples", wintypes.BOOL),
        ("bTemporalCompression", wintypes.BOOL),
        ("lSampleSize", wintypes.DWORD),
        ("formattype", GUID),
        ("pUnk", ctypes.c_void_p),
        ("cbFormat", wintypes.DWORD),
        ("pbFormat", ctypes.c_void_p),
    ]

class AM_MPEGSTREAMTYPE(ctypes.Structure):
    _fields_ = [
        ("dwStreamId", wintypes.DWORD),
        ("dwReserved", wintypes.DWORD),
        ("mt", AM_MEDIA_TYPE),
        ("bFormat", ctypes.c_ubyte * 1),
    ]

class AM_MPEGSYSTEMTYPE(ctypes.Structure):
    _fields_ = [
        ("dwBitRate", wintypes.DWORD),
        ("cStreams", wintypes.DWORD),
        ("Streams", AM_MPEGSTREAMTYPE * 1),
    ]
#[repr(C)]
pub struct AM_MEDIA_TYPE {
    pub majortype: GUID,
    pub subtype: GUID,
    pub bFixedSizeSamples: i32,
    pub bTemporalCompression: i32,
    pub lSampleSize: u32,
    pub formattype: GUID,
    pub pUnk: *mut core::ffi::c_void,
    pub cbFormat: u32,
    pub pbFormat: *mut core::ffi::c_void,
}

#[repr(C)]
pub struct AM_MPEGSTREAMTYPE {
    pub dwStreamId: u32,
    pub dwReserved: u32,
    pub mt: AM_MEDIA_TYPE,
    pub bFormat: [u8; 1],
}

#[repr(C)]
pub struct AM_MPEGSYSTEMTYPE {
    pub dwBitRate: u32,
    pub cStreams: u32,
    pub Streams: [AM_MPEGSTREAMTYPE; 1],
}
import "golang.org/x/sys/windows"

type AM_MEDIA_TYPE struct {
	majortype windows.GUID
	subtype windows.GUID
	bFixedSizeSamples int32
	bTemporalCompression int32
	lSampleSize uint32
	formattype windows.GUID
	pUnk uintptr
	cbFormat uint32
	pbFormat uintptr
}

type AM_MPEGSTREAMTYPE struct {
	dwStreamId uint32
	dwReserved uint32
	mt AM_MEDIA_TYPE
	bFormat [1]byte
}

type AM_MPEGSYSTEMTYPE struct {
	dwBitRate uint32
	cStreams uint32
	Streams [1]AM_MPEGSTREAMTYPE
}
type
  AM_MEDIA_TYPE = record
    majortype: TGUID;
    subtype: TGUID;
    bFixedSizeSamples: BOOL;
    bTemporalCompression: BOOL;
    lSampleSize: DWORD;
    formattype: TGUID;
    pUnk: Pointer;
    cbFormat: DWORD;
    pbFormat: Pointer;
  end;

  AM_MPEGSTREAMTYPE = record
    dwStreamId: DWORD;
    dwReserved: DWORD;
    mt: AM_MEDIA_TYPE;
    bFormat: array[0..0] of Byte;
  end;

  AM_MPEGSYSTEMTYPE = record
    dwBitRate: DWORD;
    cStreams: DWORD;
    Streams: array[0..0] of AM_MPEGSTREAMTYPE;
  end;
const AM_MEDIA_TYPE = extern struct {
    majortype: GUID,
    subtype: GUID,
    bFixedSizeSamples: i32,
    bTemporalCompression: i32,
    lSampleSize: u32,
    formattype: GUID,
    pUnk: ?*anyopaque,
    cbFormat: u32,
    pbFormat: ?*anyopaque,
};

const AM_MPEGSTREAMTYPE = extern struct {
    dwStreamId: u32,
    dwReserved: u32,
    mt: AM_MEDIA_TYPE,
    bFormat: [1]u8,
};

const AM_MPEGSYSTEMTYPE = extern struct {
    dwBitRate: u32,
    cStreams: u32,
    Streams: [1]AM_MPEGSTREAMTYPE,
};
type
  AM_MEDIA_TYPE {.bycopy.} = object
    majortype: GUID
    subtype: GUID
    bFixedSizeSamples: int32
    bTemporalCompression: int32
    lSampleSize: uint32
    formattype: GUID
    pUnk: pointer
    cbFormat: uint32
    pbFormat: pointer

  AM_MPEGSTREAMTYPE {.bycopy.} = object
    dwStreamId: uint32
    dwReserved: uint32
    mt: AM_MEDIA_TYPE
    bFormat: array[1, uint8]

  AM_MPEGSYSTEMTYPE {.bycopy.} = object
    dwBitRate: uint32
    cStreams: uint32
    Streams: array[1, AM_MPEGSTREAMTYPE]
struct AM_MEDIA_TYPE
{
    GUID majortype;
    GUID subtype;
    int bFixedSizeSamples;
    int bTemporalCompression;
    uint lSampleSize;
    GUID formattype;
    void* pUnk;
    uint cbFormat;
    void* pbFormat;
}

struct AM_MPEGSTREAMTYPE
{
    uint dwStreamId;
    uint dwReserved;
    AM_MEDIA_TYPE mt;
    ubyte[1] bFormat;
}

struct AM_MPEGSYSTEMTYPE
{
    uint dwBitRate;
    uint cStreams;
    AM_MPEGSTREAMTYPE[1] Streams;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; AM_MPEGSYSTEMTYPE サイズ: 92 バイト(x86)
dim st, 23    ; 4byte整数×23(構造体サイズ 92 / 4 切り上げ)
; dwBitRate : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; cStreams : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; Streams : AM_MPEGSTREAMTYPE (+8, 84byte)  varptr(st)+8 を基点に操作(84byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; AM_MPEGSYSTEMTYPE サイズ: 112 バイト(x64)
dim st, 28    ; 4byte整数×28(構造体サイズ 112 / 4 切り上げ)
; dwBitRate : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; cStreams : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; Streams : AM_MPEGSTREAMTYPE (+8, 104byte)  varptr(st)+8 を基点に操作(104byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global GUID, pack=1
    #field int Data1
    #field short Data2
    #field short Data3
    #field byte Data4 8
#endstruct

#defstruct global AM_MEDIA_TYPE
    #field GUID majortype
    #field GUID subtype
    #field bool bFixedSizeSamples
    #field bool bTemporalCompression
    #field int lSampleSize
    #field GUID formattype
    #field intptr pUnk
    #field int cbFormat
    #field intptr pbFormat
#endstruct

#defstruct global AM_MPEGSTREAMTYPE
    #field int dwStreamId
    #field int dwReserved
    #field AM_MEDIA_TYPE mt
    #field byte bFormat 1
#endstruct

#defstruct global AM_MPEGSYSTEMTYPE
    #field int dwBitRate
    #field int cStreams
    #field AM_MPEGSTREAMTYPE Streams 1
#endstruct

stdim st, AM_MPEGSYSTEMTYPE        ; NSTRUCT 変数を確保
st->dwBitRate = 100
mes "dwBitRate=" + st->dwBitRate