/*
 * Copyright 2017 Alistair Leslie-Hughes
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

import "mfobjects.idl";

typedef struct _MFT_INPUT_STREAM_INFO
{
    LONGLONG hnsMaxLatency;
    DWORD    dwFlags;
    DWORD    cbSize;
    DWORD    cbMaxLookahead;
    DWORD    cbAlignment;
} MFT_INPUT_STREAM_INFO;

typedef struct _MFT_OUTPUT_STREAM_INFO
{
    DWORD dwFlags;
    DWORD cbSize;
    DWORD cbAlignment;
} MFT_OUTPUT_STREAM_INFO;

typedef struct _MFT_OUTPUT_DATA_BUFFER
{
    DWORD         dwStreamID;
    IMFSample     *pSample;
    DWORD         dwStatus;
    IMFCollection *pEvents;
} MFT_OUTPUT_DATA_BUFFER, *PMFT_OUTPUT_DATA_BUFFER;

typedef enum _MFT_MESSAGE_TYPE
{
    MFT_MESSAGE_COMMAND_FLUSH          = 0x00000000,
    MFT_MESSAGE_COMMAND_DRAIN          = 0x00000001,
    MFT_MESSAGE_SET_D3D_MANAGER        = 0x00000002,
    MFT_MESSAGE_DROP_SAMPLES           = 0x00000003,
    MFT_MESSAGE_COMMAND_TICK           = 0x00000004,
    MFT_MESSAGE_NOTIFY_BEGIN_STREAMING = 0x10000000,
    MFT_MESSAGE_NOTIFY_END_STREAMING   = 0x10000001,
    MFT_MESSAGE_NOTIFY_END_OF_STREAM   = 0x10000002,
    MFT_MESSAGE_NOTIFY_START_OF_STREAM = 0x10000003,
    MFT_MESSAGE_COMMAND_MARKER         = 0x20000000
} MFT_MESSAGE_TYPE;

[
    object,
    uuid(bf94c121-5b05-4e6f-8000-ba598961414d)
]
interface IMFTransform : IUnknown
{
    HRESULT GetStreamLimits([out] DWORD *input_minimum, [out] DWORD *input_maximum, [out] DWORD *output_minimum,
                            [out] DWORD *output_maximum);

    HRESULT GetStreamCount([out] DWORD *inputs,  [out] DWORD *outputs);

    HRESULT GetStreamIDs([in] DWORD input_size, [out,size_is(input_size)] DWORD *inputs,
                         [in] DWORD output_size, [out,size_is(output_size)] DWORD *outputs);

    HRESULT GetInputStreamInfo([in] DWORD id, [out] MFT_INPUT_STREAM_INFO *info);

    HRESULT GetOutputStreamInfo([in] DWORD id, [out] MFT_OUTPUT_STREAM_INFO *info);

    HRESULT GetAttributes([out] IMFAttributes **attributes);

    HRESULT GetInputStreamAttributes([in] DWORD id, [out] IMFAttributes **attributes);

    HRESULT GetOutputStreamAttributes([in] DWORD id, [out] IMFAttributes **attributes);

    HRESULT DeleteInputStream([in] DWORD id);

    HRESULT AddInputStreams([in] DWORD streams, [in] DWORD *ids);

    HRESULT GetInputAvailableType([in] DWORD id, [in] DWORD index, [out] IMFMediaType **type);

    HRESULT GetOutputAvailableType([in] DWORD id, [in] DWORD index, [out] IMFMediaType **type);

    HRESULT SetInputType(DWORD id, [in] IMFMediaType *type, [in] DWORD flags);

    HRESULT SetOutputType(DWORD id, [in] IMFMediaType *type, [in] DWORD flags);

    HRESULT GetInputCurrentType([in] DWORD id, [out] IMFMediaType **type);

    HRESULT GetOutputCurrentType([in] DWORD id, [out] IMFMediaType **type);

    HRESULT GetInputStatus([in] DWORD id, [out] DWORD *flags);

    HRESULT GetOutputStatus([out] DWORD *flags);

    HRESULT SetOutputBounds([in] LONGLONG lower, [in] LONGLONG upper);

    HRESULT ProcessEvent([in] DWORD id, [in] IMFMediaEvent *event);

    HRESULT ProcessMessage([in] MFT_MESSAGE_TYPE message, [in] ULONG_PTR param);

    [local] HRESULT ProcessInput([in] DWORD id, [in] IMFSample *sample, [in] DWORD flags);

    [local] HRESULT ProcessOutput([in] DWORD flags, [in] DWORD count, [in,out,size_is(count)] MFT_OUTPUT_DATA_BUFFER *samples,
                                  [out] DWORD *status);
};
