// 假设 AMMediaType、PinInfo、PinDirection 等类型已经定义
// 这里简单用 any 代替，实际使用时需要根据具体情况定义
type AMMediaType = any;
type PinInfo = any;
type PinDirection = any;
type IBaseFilter = any;
type IPin = any;
type IEnumPins = any;
type IFilterGraph = any;
type IPropertyBag = any;
type ISampleGrabberCB = any;
type IEnumMoniker = any;

interface IGraphBuilder {
    AddFilter(filter: IBaseFilter, name: string): number;
    RemoveFilter(filter: IBaseFilter): number;
    EnumFilters(): number;
    FindFilterByName(name: string): number;
    ConnectDirect(pinOut: IPin, pinIn: IPin, mediaType: AMMediaType): number;
    Reconnect(pin: IPin): number;
    Disconnect(pin: IPin): number;
    SetDefaultSyncSource(): number;
    Connect(pinOut: IPin, pinIn: IPin): number;
    Render(pinOut: IPin): number;
    RenderFile(file: string, playList: string): number;
    AddSourceFilter(fileName: string, filterName: string): number;
    SetLogFile(hFile: number): number;
    Abort(): number;
    ShouldOperationContinue(): number;
}

interface IBaseFilter {
    GetClassID(): number;
    Stop(): number;
    Pause(): number;
    Run(start: number): number;
    GetState(milliSecsTimeout: number): number;
    SetSyncSource(clock: number): number;
    GetSyncSource(): number;
    EnumPins(): number;
    FindPin(id: string): number;
    QueryFilterInfo(): number;
    JoinFilterGraph(graph: IFilterGraph, name: string): number;
    QueryVendorInfo(): number;
}

interface IPin {
    Connect(receivePin: IPin, mediaType: AMMediaType): number;
    ReceiveConnection(receivePin: IPin, mediaType: AMMediaType): number;
    Disconnect(): number;
    ConnectedTo(): number;
    ConnectionMediaType(): number;
    QueryPinInfo(): number;
    QueryDirection(): number;
    QueryId(): number;
    QueryAccept(mediaType: AMMediaType): number;
    EnumMediaTypes(): number;
    QueryInternalConnections(): number;
    EndOfStream(): number;
    BeginFlush(): number;
    EndFlush(): number;
    NewSegment(start: number, stop: number, rate: number): number;
}

interface IEnumPins {
    Next(cPins: number): number;
    Skip(cPins: number): number;
    Reset(): number;
    Clone(): number;
}

interface IFilterGraph {
    AddFilter(filter: IBaseFilter, name: string): number;
    RemoveFilter(filter: IBaseFilter): number;
    EnumFilters(): number;
    FindFilterByName(name: string): number;
    ConnectDirect(pinOut: IPin, pinIn: IPin, mediaType: AMMediaType): number;
    Reconnect(pin: IPin): number;
    Disconnect(pin: IPin): number;
    SetDefaultSyncSource(): number;
}

interface IPropertyBag {
    Read(propertyName: string, pVar: any): number;
    Write(propertyName: string, pVar: any): number;
}

interface ISampleGrabber {
    SetOneShot(oneShot: boolean): number;
    SetMediaType(mediaType: AMMediaType): number;
    GetConnectedMediaType(): number;
    SetBufferSamples(bufferThem: boolean): number;
    GetCurrentBuffer(bufferSize: number): number;
    GetCurrentSample(): number;
    SetCallback(callback: ISampleGrabberCB, whichMethodToCallback: number): number;
}

interface ISampleGrabberCB {
    SampleCB(sampleTime: number, sample: number): number;
    BufferCB(sampleTime: number, buffer: number, bufferLen: number): number;
}

interface ICreateDevEnum {
    CreateClassEnumerator(type: any): number;
}

interface IVideoWindow {
    put_Caption(caption: string): number;
    get_Caption(): number;
    put_WindowStyle(windowStyle: number): number;
    get_WindowStyle(): number;
    put_WindowStyleEx(windowStyleEx: number): number;
    get_WindowStyleEx(): number;
    put_AutoShow(autoShow: boolean): number;
    get_AutoShow(): number;
    put_WindowState(windowState: number): number;
    get_WindowState(): number;
    put_BackgroundPalette(backgroundPalette: boolean): number;
    get_BackgroundPalette(): number;
    put_Visible(visible: boolean): number;
    get_Visible(): number;
    put_Left(left: number): number;
    get_Left(): number;
    put_Width(width: number): number;
    get_Width(): number;
    put_Top(top: number): number;
    get_Top(): number;
    put_Height(height: number): number;
    get_Height(): number;
    put_Owner(owner: number): number;
    get_Owner(): number;
    put_MessageDrain(drain: number): number;
    get_MessageDrain(): number;
    get_BorderColor(): number;
    put_BorderColor(color: number): number;
    get_FullScreenMode(): number;
    put_FullScreenMode(fullScreenMode: boolean): number;
    SetWindowForeground(focus: number): number;
    NotifyOwnerMessage(hwnd: number, msg: number, wParam: number, lParam: number): number;
    SetWindowPosition(left: number, top: number, width: number, height: number): number;
    GetWindowPosition(): number;
    GetMinIdealImageSize(): number;
    GetMaxIdealImageSize(): number;
    GetRestorePosition(): number;
    HideCursor(hideCursor: boolean): number;
    IsCursorHidden(): number;
}

interface IMediaControl {
    Run(): number;
    Pause(): number;
    Stop(): number;
    GetState(timeout: number): number;
    RenderFile(fileName: string): number;
    AddSourceFilter(fileName: string): number;
    get_FilterCollection(): number;
    get_RegFilterCollection(): number;
    StopWhenReady(): number;
}