/****************************************************************************
**
** Copyright 1999 Adaptec, Inc.,  All Rights Reserved.
**
** This software contains the valuable trade secrets of Adaptec.  The
** software is protected under copyright laws as an unpublished work of
** Adaptec.  Notice is for informational purposes only and does not imply
** publication.  The user of this software may make copies of the software
** for use with parts manufactured by Adaptec or under license from Adaptec
** and for no other use.
**
****************************************************************************/

/****************************************************************************
**
**  Module Name:    IMAPI.idl
**
**  Description:    IDL soruce for Image Mastering API (IMAPI).  The file will
**                  be processed by the MIDL tool to produce the type library
**                  (IMAPI.tlb) and marshalling code.
**
**  Programmers:    Daniel Evers (dle)
**                  Tom Halloran (tgh)
**                  Don Lilly (drl)
**                  Daniel Polfer (dap)
**
**  History:        8/18/99 (dap)  Opened history and added header.
**
**  Notes:          This file created using 4 spaces per tab.
**
****************************************************************************/

import "oaidl.idl";
import "ocidl.idl";
import "propidl.idl";

// ---------------------------------------------------------------------------

[
    object,
    uuid(85AC9776-CA88-4cf2-894E-09598C078A41),
    helpstring("IDiscRecorder Interface"),
    pointer_default(unique)
]
interface IDiscRecorder : IUnknown
{
    enum MEDIA_TYPES {
            // Media types
        MEDIA_CDDA_CDROM = 1,
        MEDIA_CD_ROM_XA,
        MEDIA_CD_I,
        MEDIA_CD_EXTRA,
        MEDIA_CD_OTHER,
        MEDIA_SPECIAL };

    enum MEDIA_FLAGS {
            // Media flags
        MEDIA_BLANK = 0x00000001,
        MEDIA_RW    = 0x00000002,
        MEDIA_WRITABLE = 0x00000004,
        MEDIA_FORMAT_UNUSABLE_BY_IMAPI = 0x00000008 };
 
    enum RECORDER_TYPES {
            // Recorder flags
        RECORDER_CDR    = 0x00000001,
        RECORDER_CDRW   = 0x00000002 };

    const ULONG RECORDER_DOING_NOTHING = 0;
    const ULONG RECORDER_OPENED  = 0x00000001;
    const ULONG RECORDER_BURNING = 0x00000002;

    [helpstring("method Init")] HRESULT Init([in,size_is(nulIDSize)] byte * pbyUniqueID, [in] ULONG nulIDSize, [in] ULONG nulDriveNumber);
    [helpstring("method GetRecorderGUID")] HRESULT GetRecorderGUID([in,out,unique,size_is(ulBufferSize)] byte * pbyUniqueID, [in] ULONG ulBufferSize, [out] ULONG *pulReturnSizeRequired );
    [helpstring("method GetRecorderType")] HRESULT GetRecorderType([out] long *fTypeCode);
    [helpstring("method GetDisplayNames")] HRESULT GetDisplayNames( [in,out,unique] BSTR *pbstrVendorID, [in,out,unique] BSTR *pbstrProductID, [in,out,unique] BSTR *pbstrRevision );
    [helpstring("method GetBasePnPID")] HRESULT GetBasePnPID([out] BSTR *pbstrBasePnPID);
    [helpstring("method GetPath")] HRESULT GetPath([out] BSTR *pbstrPath);
    [helpstring("method GetRecorderProperties")] HRESULT GetRecorderProperties([out] IPropertyStorage **ppPropStg);
    [helpstring("method SetRecorderProperties")] HRESULT SetRecorderProperties([in] IPropertyStorage *pPropStg);
    [helpstring("method GetRecorderState")] HRESULT GetRecorderState([out] ULONG *pulDevStateFlags);
    [helpstring("method OpenExclusive")] HRESULT OpenExclusive();
    [helpstring("method QueryMediaType")] HRESULT QueryMediaType([out] long *fMediaType, [out] long *fMediaFlags);
    [helpstring("method QueryMediaInfo")] HRESULT QueryMediaInfo([out] byte *pbSessions, [out] byte *pbLastTrack, [out] ULONG *ulStartAddress, [out] ULONG *ulNextWritable, [out] ULONG *ulFreeBlocks );
    [helpstring("method Eject")] HRESULT Eject();
    [helpstring("method Erase")] HRESULT Erase( [in] boolean bFullErase );
    [helpstring("method Close")] HRESULT Close();
};

// ---------------------------------------------------------------------------

[
    object,
    uuid(9B1921E1-54AC-11d3-9144-00104BA11C5E),
    helpstring("IEnumDiscRecorders Interface"),
    pointer_default(unique)
]
interface IEnumDiscRecorders : IUnknown
{
   HRESULT Next( [in] ULONG cRecorders, [out,size_is(cRecorders),length_is(*pcFetched)] IDiscRecorder **ppRecorder, [out] ULONG *pcFetched );
   HRESULT Skip([in] ULONG cRecorders);
   HRESULT Reset();
   HRESULT Clone([out] IEnumDiscRecorders **ppEnum);
}

// ---------------------------------------------------------------------------

[
    object,
    uuid(DDF445E1-54BA-11d3-9144-00104BA11C5E),
    helpstring("IEnumDiscMasterFormats Interface"),
    pointer_default(unique)
]
interface IEnumDiscMasterFormats : IUnknown
{
   HRESULT Next( [in] ULONG cFormats, [out,size_is(cFormats),length_is(*pcFetched)] LPIID lpiidFormatID, [out] ULONG *pcFetched );
   HRESULT Skip([in] ULONG cFormats);
   HRESULT Reset();
   HRESULT Clone([out] IEnumDiscMasterFormats **ppEnum);
}

// ---------------------------------------------------------------------------

[
    object,
    uuid(E3BC42CD-4E5C-11D3-9144-00104BA11C5E),
    helpstring("IRedbookDiscMaster Interface"),
    pointer_default(unique)
]
interface IRedbookDiscMaster : IUnknown
{
    [helpstring("method GetTotalAudioTracks")] HRESULT GetTotalAudioTracks([out,retval] long *pnTracks);
    [helpstring("method GetTotalAudioBlocks")] HRESULT GetTotalAudioBlocks([out,retval] long *pnBlocks);
    [helpstring("method GetUsedAudioBlocks")] HRESULT GetUsedAudioBlocks([out,retval] long *pnBlocks);
    [helpstring("method GetAvailableAudioTrackBlocks")] HRESULT GetAvailableAudioTrackBlocks([out,retval] long *pnBlocks);
    [helpstring("method GetAudioBlockSize")] HRESULT GetAudioBlockSize([out,retval] long *pnBlockBytes);
    [helpstring("method CreateAudioTrack")] HRESULT CreateAudioTrack([in] long nBlocks);
    [helpstring("method AddAudioTrackBlocks")] HRESULT AddAudioTrackBlocks([in,size_is(cb)] byte *pby, [in] long cb);
    [helpstring("method CloseAudioTrack")] HRESULT CloseAudioTrack();
}

// ---------------------------------------------------------------------------

[
    object,
    uuid(E3BC42CE-4E5C-11D3-9144-00104BA11C5E),
    helpstring("IJolietDiscMaster Interface"),
    pointer_default(unique)
]
interface IJolietDiscMaster : IUnknown
{
    [helpstring("method GetTotalDataBlocks")] HRESULT GetTotalDataBlocks([out,retval] long *pnBlocks);
    [helpstring("method GetUsedDataBlocks")] HRESULT GetUsedDataBlocks([out,retval] long *pnBlocks);
    [helpstring("method GetDataBlockSize")] HRESULT GetDataBlockSize([out,retval] long *pnBlockBytes);
    [helpstring("method AddData")] HRESULT AddData([in] IStorage * pStorage, long lFileOverwrite);
    [helpstring("method GetJolietProperties")] HRESULT GetJolietProperties([out] IPropertyStorage **ppPropStg);
    [helpstring("method SetJolietProperties")] HRESULT SetJolietProperties([in] IPropertyStorage *pPropStg);
}

// ---------------------------------------------------------------------------

[
    object,
    uuid(EC9E51C1-4E5D-11D3-9144-00104BA11C5E),
    helpstring("IDiscMasterProgressEvents Interface"),
    pointer_default(unique)
]
interface IDiscMasterProgressEvents : IUnknown
{
    [helpstring("method QueryCancel")] HRESULT QueryCancel([out,retval] boolean *pbCancel);
    [helpstring("method NotifyPnPActivity")] HRESULT NotifyPnPActivity();
    [helpstring("method NotifyAddProgress")] HRESULT NotifyAddProgress([in] long nCompletedSteps, [in] long nTotalSteps);
    [helpstring("method NotifyBlockProgress")] HRESULT NotifyBlockProgress([in] long nCompleted, [in] long nTotal);
    [helpstring("method NotifyTrackProgress")] HRESULT NotifyTrackProgress([in] long nCurrentTrack, [in] long nTotalTracks);
    [helpstring("method NotifyPreparingBurn")] HRESULT NotifyPreparingBurn([in] long nEstimatedSeconds);
    [helpstring("method NotifyClosingDisc")] HRESULT NotifyClosingDisc([in] long nEstimatedSeconds);
    [helpstring("method NotifyBurnComplete")] HRESULT NotifyBurnComplete([in] HRESULT status);
    [helpstring("method NotifyEraseComplete")] HRESULT NotifyEraseComplete([in] HRESULT status);
}

// ---------------------------------------------------------------------------

[
    object,
    uuid(520CCA62-51A5-11D3-9144-00104BA11C5E),

    helpstring("IDiscMaster Interface"),
    pointer_default(unique)
]
interface IDiscMaster : IUnknown
{
    [helpstring("method Open")] HRESULT Open();
    [helpstring("method EnumDiscMasterFormats")] HRESULT EnumDiscMasterFormats([out] IEnumDiscMasterFormats **ppEnum);
    [helpstring("method GetActiveDiscMasterFormat")] HRESULT GetActiveDiscMasterFormat([out] LPIID lpiid );
    [helpstring("method SetActiveDiscMasterFormat")] HRESULT SetActiveDiscMasterFormat([in] REFIID riid, [out,iid_is(riid)] void **ppUnk);
    [helpstring("method EnumDiscRecorders")] HRESULT EnumDiscRecorders([out] IEnumDiscRecorders ** ppEnum);
    [helpstring("method GetActiveDiscRecorder")] HRESULT GetActiveDiscRecorder([out] IDiscRecorder **ppRecorder);
    [helpstring("method SetActiveDiscRecorder")] HRESULT SetActiveDiscRecorder([in] IDiscRecorder *pRecorder);
    [helpstring("method ClearFormatContent")] HRESULT ClearFormatContent();
    [helpstring("method ProgressAdvise")] HRESULT ProgressAdvise([in] IDiscMasterProgressEvents *pEvents, [out,retval] UINT_PTR *pvCookie);
    [helpstring("method ProgressUnadvise")] HRESULT ProgressUnadvise([in] UINT_PTR vCookie);
    [helpstring("method RecordDisc")] HRESULT RecordDisc([in] boolean bSimulate, [in] boolean bEjectAfterBurn);
    [helpstring("method Close")] HRESULT Close();
};

// ---------------------------------------------------------------------------

[
    object,
    uuid(520CCA64-51A5-11D3-9144-00104BA11C5E),
    helpstring("IDiscStash Interface"),
    pointer_default(unique)
]
interface IDiscStash : IUnknown
{
    [helpstring("method OpenExclusive")] HRESULT OpenExclusive([out,retval] UINT_PTR *pvCookie);
    [helpstring("method GetTotalStashBytes")] HRESULT GetTotalStashBytes([in] UINT_PTR vCookie, [out, retval] unsigned __int64 *plibStashBytes);
    [helpstring("method Read")] HRESULT Read([in] UINT_PTR vCookie, [out, size_is(cb), length_is(*pcbRead)] byte *pby, [in] long cb, [out,retval] long *pcbRead);
    [helpstring("method Write")] HRESULT Write([in] UINT_PTR vCookie, [in,size_is(cb)] byte *pby, [in] long cb);
    [helpstring("method Seek")] HRESULT Seek([in] UINT_PTR vCookie, [in] __int64 dlibMove, [in] long dwOrigin, [out] unsigned __int64 *plibNewPosition);
    [helpstring("method Close")] HRESULT Close([in] UINT_PTR vCookie);
    [helpstring("method GetFileHandle")] HRESULT GetFileHandle([out,retval] UINT_PTR *phFileHandle);
};

// ---------------------------------------------------------------------------

[
    object,
    uuid(520CCA66-51A5-11D3-9144-00104BA11C5E),
    helpstring("IBurnEngine Interface"),
    pointer_default(unique)
]
interface IBurnEngine : IUnknown
{
    typedef enum
    {
        eBurnProgressNoError = 0,
        eBurnProgressNotStarted,
        eBurnProgressBurning,
        eBurnProgressComplete,
        eBurnProgressError,
        eBurnProgressLossOfStreamingError,
        eBurnProgressMediaWriteProtect,
        eBurnProgressUnableToWriteToMedia,
        eBurnProgressBadHandle
    } BURN_PROGRESS_STATUS;

    typedef struct  tag_BURN_PROGRESS
    {
        DWORD                       dwCancelBurn;   // (IN)  if not zero, cancel the burn.
        DWORD                       dwSectionsDone; // (OUT) Number of sections completed.
        DWORD                       dwTotalSections;// (OUT) Total number of sections to burn.
        DWORD                       dwBlocksDone;   // (OUT) Number of blocks completed.
        DWORD                       dwTotalBlocks;  // (OUT) Total number of blocks to burn.
        BURN_PROGRESS_STATUS        eStatus;        // (OUT) Status of the progress operation.
    } BURN_PROGRESS, *PBURN_PROGRESS;

    [helpstring("method ReadOpen")] HRESULT ReadOpen([in] long bOpen);
    [helpstring("method EnumDiscRecorders")] HRESULT EnumDiscRecorders([out] IEnumDiscRecorders ** ppEnum);
    [helpstring("method GetActiveDiscRecorder")] HRESULT GetActiveDiscRecorder([out,retval] IDiscRecorder **ppRecorder);
    [helpstring("method SetActiveDiscRecorder")] HRESULT SetActiveDiscRecorder([in] IDiscRecorder *pRecorder);
    [helpstring("method Read")] HRESULT Read([in,out]byte *pby, [in] long sb, [in] long hmb, [in] long * br );
    [helpstring("method GetSessionInfo")] HRESULT GetSessionInfo([in,out]byte *pbsessions, [in,out] byte *pblasttrack, [in,out] unsigned long *ulstartaddress, [in,out] unsigned long *ulnextwritable, [in,out] unsigned long *ulfreeblocks );
    [helpstring("method Burn")] HRESULT Burn([in,size_is(cb)] byte *pby, [in] long cb, [in] long bSimulate, [in] unsigned long ulsession, [in] unsigned long ulstartoffset, [in] long bEjectAfterBurn );
    [helpstring("method GetBurnProgress")] HRESULT(GetBurnProgress)([in,out]PBURN_PROGRESS pBurnProgress);
};

// ---------------------------------------------------------------------------

[
    uuid(C49F2184-50A7-11D3-9144-00104BA11C5E),
    version(1.0),
    helpstring("Microsoft IMAPI 1.0 Type Library")
]
library IMAPILib
{
//    importlib("stdole32.tlb");
    importlib("stdole2.tlb");

    enum MEDIA_TYPES;
    enum MEDIA_FLAGS;
    enum RECORDER_TYPES;

    [
        uuid(520CCA61-51A5-11D3-9144-00104BA11C5E),
        helpstring("Microsoft IMAPI Disc Recorder")
    ]
    coclass MSDiscRecorderObj
    {
        [default] interface IDiscRecorder;
    };
    [
        uuid(520CCA63-51A5-11D3-9144-00104BA11C5E),
        helpstring("Microsoft IMAPI Disc Master")
    ]
    coclass MSDiscMasterObj
    {
        [default] interface IDiscMaster;
        interface IRedbookDiscMaster;
        interface IJolietDiscMaster;
    };
    [
        uuid(520CCA65-51A5-11D3-9144-00104BA11C5E),
        helpstring("Microsoft IMAPI Disc Stash")
    ]
    coclass MSDiscStashObj
    {
        [default] interface IDiscStash;
    };
    [
        uuid(520CCA67-51A5-11D3-9144-00104BA11C5E),
        helpstring("Microsoft IMAPI Burn Engine")
    ]
    coclass MSBurnEngineObj
    {
        [default] interface IBurnEngine;
    };
    [
        uuid(8A03567A-63CB-4BA8-BAF6-52119816D1EF),
        helpstring("Microsoft IMAPI Disc Recorder Enumerator")
    ]
    coclass MSEnumDiscRecordersObj
    {
        [default] interface IEnumDiscRecorders;
    };
};