home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / mac / SiteBldr / AMOVIE / SDK / _SETUP / COMMON.Z / axcore.idl < prev    next >
Encoding:
Text File  |  1996-06-20  |  43.1 KB  |  1,129 lines

  1. //==========================================================================;
  2. //
  3. //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. //  PURPOSE.
  7. //
  8. //  Copyright (c) 1992 - 1996  Microsoft Corporation.  All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------;
  11.  
  12. //
  13. // This file contains the core ActiveX interfaces that are common with other
  14. // streaming architecture implementations in Microsoft (eg Clockwork).
  15. // Other, ActiveX-only interfaces are in AXExtend.idl
  16.  
  17. // include unknwn.idl and objidl.idl first
  18.  
  19.  
  20. #define CHARS_IN_GUID 39  // 128 bits, plus { - } punctuation and terminal null
  21.                           // chars NOT BYTES in the standard representation
  22.                           // e.g. {D3588AB0-0781-11ce-B03A-0020AF0BA770} + null
  23. cpp_quote("#define CHARS_IN_GUID     39")
  24.  
  25.  
  26. //=====================================================================
  27. //=====================================================================
  28. // media types & formats
  29. //=====================================================================
  30. //=====================================================================
  31.  
  32. // there is a high-level media type (audio, compressed video,
  33. // mpeg video, midi). Within each type, there is a subtype (cinepak, pcm)
  34. // and a length+untyped data block defining the format in a
  35. // type-specific manner. EG for video/cinepak, the data block would be
  36. // a bitmapinfo.
  37. // the contents of the format block is defined by the formattype GUID
  38. // for example FORMAT_VideoInfo, FORMAT_WaveFormatEx. In the future this
  39. // may be a pointer to an object supporting property style interfaces
  40. // in which case the GUID may be something like FORMAT_IUnknown. When
  41. // you are passed a media type you should check the format type, if
  42. // it isn't a type you recognise then don't touch the format block
  43.  
  44. typedef struct _AMMediaType {
  45.     GUID     majortype;
  46.     GUID     subtype;
  47.     BOOL     bFixedSizeSamples;
  48.     BOOL     bTemporalCompression;
  49.     ULONG    lSampleSize;
  50.     GUID     formattype;
  51.     IUnknown *pUnk;
  52.     ULONG    cbFormat;
  53.     [size_is(cbFormat)] BYTE * pbFormat;
  54. } AM_MEDIA_TYPE;
  55.  
  56. //=====================================================================
  57. //=====================================================================
  58. // pin information
  59. //=====================================================================
  60. //=====================================================================
  61.  
  62. // is this an input or output pin
  63. typedef enum _PinDirection {
  64.     PINDIR_INPUT,
  65.     PINDIR_OUTPUT
  66. } PIN_DIRECTION;
  67.  
  68. // other types that need defining
  69. #define MAX_PIN_NAME     128
  70. cpp_quote("#define MAX_PIN_NAME     128")
  71. cpp_quote("#define MAX_FILTER_NAME  128")
  72. #define MAX_FILTER_NAME  128
  73.  
  74.  
  75. //=====================================================================
  76. //=====================================================================
  77. // time information
  78. //
  79. // This represents a time (either reference or stream) in 100ns units
  80. // The class library contains a CRefTime helper class
  81. // that supports simple comparison and arithmetic operations
  82. //=====================================================================
  83. //=====================================================================
  84.  
  85. typedef LONGLONG REFERENCE_TIME;
  86. typedef double REFTIME;
  87. typedef LONGLONG TIME;
  88.  
  89. // Win32 HANDLEs have to be cast to these as the MIDL compiler doesn't
  90. // like the HANDLE type or in fact anything remotely associated with
  91. // them. If this ever gets ported to a MAC environment then these will
  92. // have to become an alertable synchronisation object that it supports
  93.  
  94. typedef unsigned long HSEMAPHORE;
  95. typedef unsigned long HEVENT;
  96.  
  97. //=====================================================================
  98. //=====================================================================
  99. // Allocator properties
  100. //
  101. // Used to describe the actual properties of an allocator,
  102. // and used to request properties from an allocator or from an upstream
  103. // filter that could create an allocator. See IMemAllocator and
  104. // IMemInputPin.
  105. //=====================================================================
  106. //=====================================================================
  107. typedef struct _AllocatorProperties {
  108.         long cBuffers;    // count of buffers at this allocator
  109.     long cbBuffer;    // size of each buffer, excluding any prefix
  110.  
  111.         // alignment of the buffer - buffer start will be aligned on a multiple of
  112.         // this amount
  113.         long cbAlign;
  114.  
  115.         // prefix amount. Each buffer is immediately preceeded by cbPrefix bytes.
  116.         // note that GetPointer points to the beginning of the buffer proper.
  117.         // the prefix is aligned, i.e. (GetPointer() - cbPrefix) is aligned on cbAlign.
  118.         long cbPrefix;
  119. } ALLOCATOR_PROPERTIES;
  120.  
  121.  
  122.  
  123.  
  124.  
  125. // forward declarations (in alphabetical order - we were getting duplicates)
  126. interface IAMovieSetup;
  127. interface IEnumFilters;
  128. interface IEnumMediaTypes;
  129. interface IEnumPins;
  130. interface IFilter;
  131. interface IFilterGraph;
  132. interface IMediaFilter;
  133. interface IMediaSample;
  134. interface IMediaSelection;
  135. interface IMemAllocator;
  136. interface IMemInputPin;
  137. interface IPin;
  138. interface IReferenceClock;
  139.  
  140.  
  141.  
  142. //=====================================================================
  143. //=====================================================================
  144. // Defines IPin interface
  145. //
  146. // interface representing a single, unidirection connection point on a
  147. // filter. A Pin will connect to exactly one other pin on another filter.
  148. // This interface represents the interface other objects can call on
  149. // this pin. The interface between the filter and the pin is private to
  150. // the implementation of a specific filter.
  151. //
  152. // During the connection process, one pin will be instructed to take
  153. // the lead: the connect interface on this pin will be calling, passing
  154. // the IPin* for the other pin. This connecting pin will call the
  155. // ReceiveConnection member function on the other pin, as well as presumably
  156. // other format-enumeration and queryinterface calls to establish whether
  157. // the connection is possible.
  158. //=====================================================================
  159. //=====================================================================
  160.  
  161. [
  162. object,
  163. uuid(56a86891-0ad4-11ce-b03a-0020af0ba770),
  164. pointer_default(unique)
  165. ]
  166. interface IPin : IUnknown {
  167.  
  168.     // initiate a connection to another pin. calls ReceiveConnection on the
  169.     // other pin. Verifies that the connection is possible and may reject
  170.     // it.
  171.     // The mediatype parameter is optional. If it is not null, the pin must
  172.     // connect using that media type if possible. The subtype and/or format
  173.     // type can be GUID_NULL, meaning that the pin can fill them in as desired.
  174.     // This allows an application to partially specify the media type to be
  175.     // used for the connection, insisting on eg YUV 422 but leaving details
  176.     // (such as the image size) to be negotiated between the pins.
  177.     HRESULT Connect(
  178.         [in] IPin * pReceivePin,        // connect yourself to this pin
  179.         [in] const AM_MEDIA_TYPE * pmt  // (optional) connect using this type
  180.     );
  181.  
  182.     // called by a connecting pin to make a connection
  183.     HRESULT ReceiveConnection(
  184.         [in] IPin * pConnector,
  185.         [in] const AM_MEDIA_TYPE *pmt   // this is the media type we will exchange
  186.     );
  187.  
  188.     // break a connection - no params since there is only one connection
  189.     // possible on this pin
  190.     HRESULT Disconnect(void);
  191.  
  192.     // Find the pin this pin is connected to (if any)
  193.     // The pointer returned is AddRef()d
  194.     // Fails if the pin is not connected
  195.     HRESULT ConnectedTo(
  196.         [out] IPin **pPin
  197.     );
  198.  
  199.     // Return the media type of a connection if the pin is connected
  200.     HRESULT ConnectionMediaType(
  201.         [out] AM_MEDIA_TYPE *pmt
  202.     );
  203.  
  204.     // get information about the pin itself
  205.     typedef struct _PinInfo {
  206.     IFilter *pFilter;    // the filter this pin is on
  207.     PIN_DIRECTION dir;    // am I an input or output pin?
  208.     [string]WCHAR achName[MAX_PIN_NAME];    // the name of this pin within this filter
  209.     } PIN_INFO;
  210.  
  211.     HRESULT QueryPinInfo(
  212.         [out] PIN_INFO * pInfo
  213.     );
  214.  
  215.     // We often want to know the direction.  Rather than use the
  216.     // relatively expensive QueryPinInfo, use this
  217.     HRESULT QueryDirection(
  218.         [out] PIN_DIRECTION *pPinDir
  219.     );
  220.  
  221.     // Get an identifier for the pin (allows connections to be saved).
  222.     // The storage will be allocated by the filter using CoTaskMemAlloc
  223.     // The caller should free it using CoTaskMemFree
  224.     HRESULT QueryId(
  225.         [out] LPWSTR * Id
  226.     );
  227.  
  228.     // will the pin accept the format type, S_OK yes, S_FALSE no
  229.     HRESULT QueryAccept(
  230.         [in] const AM_MEDIA_TYPE *pmt
  231.     );
  232.  
  233.     // return an enumerator for this pin's preferred media types
  234.     HRESULT EnumMediaTypes(
  235.         [out] IEnumMediaTypes **ppEnum
  236.     );
  237.  
  238.     // return an array of IPin* - the pins that this pin internally connects to
  239.     // All pins put in the array must be AddReffed (but no others)
  240.     // Errors: "Can't say" - FAIL; not enough slots - return S_FALSE
  241.     // Default: return E_NOTIMPL
  242.     // The filter graph will interpret E_NOTIMPL as any input pin connects to
  243.     // all visible output pins and vise versa.
  244.     // apPin can be NULL if nPin==0 (not otherwise).
  245.     HRESULT QueryInternalConnections(
  246.         [out] IPin* *apPin,     // array of IPin*
  247.         [in, out] ULONG *nPin   // on input, the number of slots
  248.                                 // on output  the number of pins
  249.     );
  250.  
  251.     // notify the pin that no more data is expected until a new run
  252.     // command is issued. End of stream should be queued and delivered after
  253.     // all queued data is delivered. Pass through if there is no queued data.
  254.     // Flush should flush any queued EOS.
  255.     // returns S_OK unless there is some error.
  256.     // input pins only: output pins will normally return E_UNEXPECTED.
  257.     HRESULT EndOfStream(void);
  258.  
  259.     // Flush
  260.  
  261.     // Enter flush state: do the following steps (in order)
  262.     // -- prevent any more Receives succeeding (set a flushing flag)
  263.     // -- discard any queued data
  264.     // -- free anyone blocked on Receive in your filter
  265.     // -- pass BeginFlush to any downstream pins
  266.     HRESULT BeginFlush(void);
  267.  
  268.     // End flush state: do the following steps in order
  269.     // -- ensure no more data will be pushed by your filter
  270.     //    (sync with thread if you have one, stop it pushing and
  271.     //     discard any queued data)
  272.     // -- re-enable Receive (clear internal flushing flag)
  273.     // -- pass EndFlush to any downstream pins
  274.     HRESULT EndFlush(void);
  275.  
  276.     // informational: all data arriving after this call is part of a segment
  277.     // from StartTime to StopTime, played at rate. This allows filters that
  278.     // process buffers containing more than one sample to clip the rendering
  279.     // to within the start and stop times.
  280.     //
  281.     // A source pin will call a destination pin on this method after completing
  282.     // delivery of any previous data, and before any Receive calls for the
  283.     // new data
  284.     HRESULT NewSegment(
  285.                 [in] REFERENCE_TIME tStart,
  286.                 [in] REFERENCE_TIME tStop,
  287.                 [in] double dRate);
  288. }
  289.  
  290. typedef IPin *PPIN;
  291.  
  292.  
  293. //=====================================================================
  294. //=====================================================================
  295. // Defines IEnumPins interface
  296. //
  297. // interface returned from IFilter::EnumPins(). based on IEnumXXXX
  298. //=====================================================================
  299. //=====================================================================
  300.  
  301. [
  302. object,
  303. uuid(56a86892-0ad4-11ce-b03a-0020af0ba770),
  304. pointer_default(unique)
  305. ]
  306. interface IEnumPins : IUnknown {
  307.  
  308.     HRESULT Next(
  309.         [in] ULONG cPins,                       // place this many pins...
  310.         [out, size_is(cPins)] IPin ** ppPins,   // ...in this array
  311.         [out] ULONG * pcFetched                 // actual count passed
  312.     );
  313.  
  314.     HRESULT Skip(
  315.         [in] ULONG cPins);
  316.  
  317.     HRESULT Reset(void);
  318.  
  319.     HRESULT Clone(
  320.         [out] IEnumPins **ppEnum
  321.     );
  322. }
  323.  
  324. typedef IEnumPins *PENUMPINS;
  325.  
  326.  
  327. //=====================================================================
  328. //=====================================================================
  329. // Defines IEnumMediaTypes interface
  330. //
  331. // Enumerates the preferred formats for a pin
  332. //=====================================================================
  333. //=====================================================================
  334.  
  335. [
  336. object,
  337. uuid(89c31040-846b-11ce-97d3-00aa0055595a),
  338. pointer_default(unique)
  339. ]
  340. interface IEnumMediaTypes : IUnknown {
  341.  
  342.     // to call this member function pass in the address of a pointer to a
  343.     // media type. The interface will allocate the necessary AM_MEDIA_TYPE
  344.     // structures and initialise them with the variable format block
  345.  
  346.     HRESULT Next(
  347.         [in] ULONG cMediaTypes,             // place this many types...
  348.         [out, size_is(cMediaTypes)]
  349.              AM_MEDIA_TYPE ** ppMediaTypes, // ...in this array
  350.         [out] ULONG * pcFetched             // actual count passed
  351.     );
  352.  
  353.     HRESULT Skip(
  354.         [in] ULONG cMediaTypes);
  355.  
  356.     HRESULT Reset(void);
  357.  
  358.     HRESULT Clone(
  359.         [out] IEnumMediaTypes **ppEnum
  360.     );
  361. }
  362.  
  363. typedef IEnumMediaTypes *PENUMMEDIATYPES;
  364.  
  365.  
  366.  
  367. //========================================================================
  368. //========================================================================
  369. // Defines IFilterGraph interface
  370. //
  371. // abstraction representing a graph of filters
  372. // This allows filters to be joined into a graph and operated as a unit.
  373. //========================================================================
  374. //========================================================================
  375.  
  376. [
  377. object,
  378. uuid(56a8689f-0ad4-11ce-b03a-0020af0ba770),
  379. pointer_default(unique)
  380. ]
  381. interface IFilterGraph : IUnknown {
  382.  
  383.     //==========================================================================
  384.     // Low level filter functions
  385.     //==========================================================================
  386.  
  387.         // Add a filter to the graph and name it with *pName.
  388.         // If the name is not unique, The request will fail.
  389.         // The Filter graph will call the JoinFilterGraph
  390.         // member function of the filter to inform it.
  391.         // This must be called before attempting Connect, ConnectDirect or Render
  392.         // for pins of the filter.
  393.  
  394.         HRESULT AddFilter
  395.             ( [in] IFilter * pFilter,
  396.               [in, string] LPCWSTR pName
  397.             );
  398.  
  399.  
  400.         // Remove a filter from the graph. The filter graph implementation
  401.         // will inform the filter that it is being removed.
  402.  
  403.         HRESULT RemoveFilter
  404.             ( [in] IFilter * pFilter
  405.             );
  406.  
  407.  
  408.         // Set *ppEnum to be an enumerator for all filters in the graph.
  409.  
  410.         HRESULT EnumFilters
  411.             ( [out] IEnumFilters **ppEnum
  412.             );
  413.  
  414.  
  415.         // Set *ppFilter to be the filter which was added with the name *pName
  416.         // Will fail and set *ppFilter to NULL if the name is not in this graph.
  417.  
  418.         HRESULT FindFilterByName
  419.             ( [in, string] LPCWSTR pName,
  420.               [out] IFilter ** ppFilter
  421.             );
  422.  
  423.     //==========================================================================
  424.     // Low level connection functions
  425.     //==========================================================================
  426.  
  427.         // Connect these two pins directly (i.e. without intervening filters)
  428.         // the media type is optional, and may be partially specified (that is
  429.         // the subtype and/or format type may be GUID_NULL). See IPin::Connect
  430.         // for details of the media type parameter.
  431.         HRESULT ConnectDirect
  432.             ( [in] IPin * ppinOut,              // the output pin
  433.               [in] IPin * ppinIn,               // the input pin
  434.               [in] const AM_MEDIA_TYPE* pmt     // optional mediatype
  435.             );
  436.  
  437.         // On a separate thread (which will not hold any relevant locks)
  438.         // Break the connection that this pin has and reconnect it to the
  439.         // same other pin.
  440.  
  441.         HRESULT Reconnect
  442.             ( [in] IPin * ppin        // the pin to disconnect and reconnect
  443.             );
  444.  
  445.  
  446.  
  447.         // Disconnect this pin, if connected.  Successful no-op if not connected.
  448.  
  449.         HRESULT Disconnect
  450.             ( [in] IPin * ppin
  451.             );
  452.  
  453.     //==========================================================================
  454.     // intelligent connectivity - now in IGraphBuilder, axextend.idl
  455.     //==========================================================================
  456.  
  457.     //==========================================================================
  458.     // Whole graph functions
  459.     //==========================================================================
  460.  
  461.     // Once a graph is built, it can behave as a (composite) filter.
  462.     // To control this filter, QueryInterface for IMediaFilter.
  463.  
  464.     // The filtergraph will by default ensure that the graph has a sync source
  465.     // when it is made to Run.  SetSyncSource(NULL) will prevent that and allow
  466.     // all the filters to run unsynchronised until further notice.
  467.     // SetDefaultSyncSource will set the default sync source (the same as would
  468.     // have been set by default on the first call to Run).
  469.     HRESULT SetDefaultSyncSource(void);
  470.  
  471. }
  472.  
  473. typedef IFilterGraph *PFILTERGRAPH;
  474.  
  475.  
  476.  
  477. //==========================================================================
  478. //==========================================================================
  479. // Defines IEnumFilters interface
  480. //
  481. // enumerator interface returned from IFilterGraph::EnumFilters().
  482. // based on IEnum pseudo-template
  483. //==========================================================================
  484. //==========================================================================
  485.  
  486. [
  487. object,
  488. uuid(56a86893-0ad4-11ce-b03a-0020af0ba770),
  489. pointer_default(unique)
  490. ]
  491. interface IEnumFilters : IUnknown {
  492.  
  493.     HRESULT Next
  494.         ( [in]  ULONG cFilters,           // place this many filters...
  495.           [out] IFilter ** ppFilter,      // ...in this array of IFilter*
  496.           [out] ULONG * pcFetched         // actual count passed returned here
  497.         );
  498.  
  499.  
  500.     HRESULT Skip
  501.         ( [in] ULONG cFilters
  502.         );
  503.  
  504.  
  505.     HRESULT Reset(void);
  506.  
  507.  
  508.     HRESULT Clone
  509.         ( [out] IEnumFilters **ppEnum
  510.         );
  511. }
  512.  
  513. typedef IEnumFilters *PENUMFILTERS;
  514.  
  515.  
  516. //=====================================================================
  517. //=====================================================================
  518. // Defines IMediaFilter interface
  519. //
  520. // multimedia components that provide time-based data will expose this.
  521. // this interface abstracts an object that processes time-based data streams
  522. // and represents a multimedia device (possibly implemented in software).
  523. // it controls the active/running state of the object and its synchronization
  524. // to other objects in the system.
  525. //
  526. // derived from IPersist so that all filter-type objects in a graph
  527. // can have their class id serialised.
  528. //=====================================================================
  529. //=====================================================================
  530.  
  531. [
  532. object,
  533. uuid(56a86899-0ad4-11ce-b03a-0020af0ba770),
  534. pointer_default(unique)
  535. ]
  536. interface IMediaFilter : IPersist {
  537.  
  538.     // tell the filter to transition to the new state. The state transition
  539.     // may not be instantaneous (external mechanical activity may be involved,
  540.     // for example). The state functions may return before the state
  541.     // transition has completed
  542.  
  543.     // these functions will return S_OK if the transition is complete, S_FALSE if
  544.     // the transition is not complete but no error has occurred, or some error value
  545.     // if the transition failed.
  546.     HRESULT Stop(void);
  547.     HRESULT Pause(void);
  548.  
  549.     // in order to synchronise independent streams, you must pass a time
  550.     // value with the Run command. This is the difference between stream
  551.     // time and reference time. That is, it is the amount to be added to
  552.     // the IMediaSample timestamp to get the time at which that sample
  553.     // should be rendered according to the reference clock.
  554.     // If we are starting at the beginning of the stream, it will thus be
  555.     // simply the time at which the first sample should appear. If we are
  556.     // restarting from Paused mode in midstream, then it will be the total
  557.     // time we have been paused added to the initial start time.
  558.  
  559.     // the filtergraph will provide this information to its filters. If you
  560.     // are an app calling the filtergraph, it's ok to pass a start time of
  561.     // 0, in which case the filter graph will calculate a soon-as-possible
  562.     // time. FilterGraphs will accept 0 meaning ASAP; most filters will not.
  563.  
  564.     // !!! is this a reason why the filter graph should expose something
  565.     // !!!not quite the same as IMediaFilter?
  566.  
  567.     HRESULT Run(REFERENCE_TIME tStart);
  568.  
  569.  
  570.     // possible states that the filter could be in
  571.     typedef enum _FilterState {
  572.         State_Stopped,            // not in use
  573.         State_Paused,             // holding resources, ready to go
  574.         State_Running            // actively processing media stream
  575.     } FILTER_STATE;
  576.  
  577.     // find out what state the filter is in.
  578.     // If timeout is 0, will return immediately - if a state transition is
  579.     // not complete, it will return the state being transitioned into, and
  580.     // the return code will be VFW_S_STATE_INTERMEDIATE.  if no state
  581.     // transition is in progress the state will be returned and the return
  582.     // code will be S_OK.
  583.     //
  584.     // If timeout is non-zero, GetState will not return until the state
  585.     // transition is complete, or the timeout expires.
  586.     // The timeout is in milliseconds.
  587.     // You can also pass in INFINITE as a special value for the timeout, in
  588.     // which case it will block indefinitely waiting for the state transition
  589.     // to complete. If the timeout expires, the state returned is the
  590.     // state we are trying to reach, and the return code will be
  591.     // VFW_S_STATE_INTERMEDIATE. If no state transition is in progress
  592.     // the routine returns immediately with return code S_OK.
  593.  
  594.     //
  595.     // return State is State_Running, State_Paused or State_Stopped.
  596.     // return code is S_OK, or VFW_S_STATE_INTERMEDIATE if state
  597.     // transition is not complete or an error value if the method failed.
  598.     HRESULT GetState(
  599.                 [in] DWORD dwMilliSecsTimeout,
  600.                 [out] FILTER_STATE *State);
  601.  
  602.  
  603.     // tell the filter the reference clock to which it should synchronize
  604.     // activity. This is most important to rendering filters and may not
  605.     // be of any interest to other filters.
  606.     HRESULT SetSyncSource(
  607.         [in] IReferenceClock * pClock);
  608.  
  609.     // get the reference clock currently in use (it may be NULL)
  610.     HRESULT GetSyncSource(
  611.         [out] IReferenceClock ** pClock);
  612. }
  613.  
  614. typedef IMediaFilter *PMEDIAFILTER;
  615.  
  616.  
  617. //=====================================================================
  618. //=====================================================================
  619. // Defines IFilter interface
  620. //
  621. // all multimedia components will expose this interface
  622. // this interface abstracts an object that has typed input and output
  623. // connections and can be dynamically aggregated.
  624. //
  625. // IMediaFilter supports synchronisation and activity state: IFilter
  626. // is derived from that since all filters need to support IMediaFilter,
  627. // whereas a few objects (plug-in control distributors for example) will
  628. // support IMediaFilter but not IFilter.
  629. //
  630. // IMediaFilter is itself derived from IPersist so that every filter
  631. //supports GetClassID()
  632. //=====================================================================
  633. //=====================================================================
  634.  
  635. [
  636. object,
  637. uuid(56a86895-0ad4-11ce-b03a-0020af0ba770),
  638. pointer_default(unique)
  639. ]
  640. interface IFilter : IMediaFilter {
  641.  
  642.     // enumerate all the pins available on this filter
  643.     // allows enumeration of all pins only.
  644.     //
  645.     HRESULT EnumPins(
  646.         [out] IEnumPins ** ppEnum     // enum interface returned here
  647.     );
  648.  
  649.     // Convert the external identifier of a pin to an IPin *
  650.     // This pin id is quite different from the pin Name in CreatePin.
  651.     // In CreatePin the Name is invented by the caller.  In FindPin the Id
  652.     // must have come from a previous call to IPin::QueryId.  Whether or not
  653.     // this operation would cause a pin to be created depends on the filter
  654.     // design, but if called twice with the same id it should certainly
  655.     // return the same pin both times.
  656.     HRESULT FindPin(
  657.         [in, string] LPCWSTR Id,
  658.         [out] IPin ** ppPin
  659.     );
  660.  
  661.     // find out information about this filter
  662.     typedef struct _FilterInfo {
  663.         [string] WCHAR achName[MAX_FILTER_NAME]; // maybe null if not part of graph
  664.         IFilterGraph * pGraph;                      // null if not part of graph
  665.     } FILTER_INFO;
  666.  
  667.     HRESULT QueryFilterInfo(
  668.         [out] FILTER_INFO * pInfo
  669.     );
  670.  
  671.     // notify a filter that it has joined a filter graph. It is permitted to
  672.     // refuse. The filter should addref and store this interface for later use
  673.     // since it may need to notify events to this interface. A null pointer indicates
  674.     // that the filter is no longer part of a graph.
  675.     HRESULT JoinFilterGraph(
  676.         [in] IFilterGraph * pGraph,
  677.         [in, string] LPCWSTR pName
  678.     );
  679.  
  680.     // return a Vendor information string. Optional - may return E_NOTIMPL.
  681.     // memory returned should be freed using CoTaskMemFree
  682.     HRESULT QueryVendorInfo(
  683.         [out, string] LPWSTR* pVendorInfo
  684.     );
  685. }
  686.  
  687. typedef IFilter *PFILTER;
  688.  
  689.  
  690. //=====================================================================
  691. //=====================================================================
  692. // sync and state management
  693. //=====================================================================
  694. //=====================================================================
  695.  
  696.  
  697. //=====================================================================
  698. //=====================================================================
  699. // Defines IReferenceClock interface
  700. //=====================================================================
  701. //=====================================================================
  702.  
  703. [
  704.         object,
  705.         uuid(56a86897-0ad4-11ce-b03a-0020af0ba770),
  706.         pointer_default(unique)
  707. ]
  708. interface IReferenceClock : IUnknown {
  709.  
  710.     // get the time now
  711.     HRESULT GetTime(
  712.         [out] REFERENCE_TIME *pTime
  713.     );
  714.  
  715.     // ask for an async notification that a time has elapsed
  716.     HRESULT AdviseTime(
  717.         [in] REFERENCE_TIME baseTime,        // base reference time
  718.         [in] REFERENCE_TIME streamTime,        // stream offset time
  719.     [in] HEVENT hEvent,                 // advise via this event
  720.         [out] DWORD * pdwAdviseCookie       // where your cookie goes
  721.     );
  722.  
  723.     // ask for an async periodic notification that a time has elapsed
  724.     HRESULT AdvisePeriodic(
  725.         [in] REFERENCE_TIME startTime,        // starting at this time
  726.         [in] REFERENCE_TIME periodTime,      // time between notifications
  727.         [in] HSEMAPHORE hSemaphore,         // advise via a semaphore
  728.     [out] DWORD * pdwAdviseCookie        // where your cookie goes
  729.     );
  730.  
  731.     // cancel a request for notification
  732.     HRESULT Unadvise(
  733.         [in] DWORD dwAdviseCookie);
  734. }
  735.  
  736. typedef IReferenceClock *PREFERENCECLOCK;
  737.  
  738.  
  739. //=====================================================================
  740. //=====================================================================
  741. // Data transport interfaces
  742. //=====================================================================
  743. //=====================================================================
  744.  
  745.  
  746. //=====================================================================
  747. //=====================================================================
  748. // Defines IMediaSample interface
  749. //=====================================================================
  750. //=====================================================================
  751.  
  752. [
  753.         local,
  754.         object,
  755.         uuid(56a8689a-0ad4-11ce-b03a-0020af0ba770),
  756.         pointer_default(unique)
  757. ]
  758. interface IMediaSample : IUnknown {
  759.  
  760.     // get me a read/write pointer to this buffer's memory. I will actually
  761.     // want to use sizeUsed bytes.
  762.     HRESULT GetPointer([out] BYTE ** ppBuffer);
  763.  
  764.     // return the size in bytes of the buffer data area
  765.     long GetSize(void);
  766.  
  767.     // get the stream time at which this sample should start and finish.
  768.     HRESULT GetTime(
  769.         [out] REFERENCE_TIME * pTimeStart,    // put time here
  770.     [out] REFERENCE_TIME * pTimeEnd
  771.     );
  772.  
  773.     // Set the stream time at which this sample should start and finish.
  774.     // pTimeStart==pTimeEnd==NULL will invalidate the time stamps in
  775.     // this sample
  776.     HRESULT SetTime(
  777.         [in] REFERENCE_TIME * pTimeStart,    // put time here
  778.     [in] REFERENCE_TIME * pTimeEnd
  779.     );
  780.  
  781.     // sync-point property. If true, then the beginning of this
  782.     // sample is a sync-point. (note that if AM_MEDIA_TYPE.bTemporalCompression
  783.     // is false then all samples are sync points). A filter can start
  784.     // a stream at any sync point.  S_FALSE if not sync-point, S_OK if true.
  785.  
  786.     HRESULT IsSyncPoint(void);
  787.     HRESULT SetSyncPoint(BOOL bIsSyncPoint);
  788.  
  789.     // preroll property.  If true, this sample is for preroll only and
  790.     // shouldn't be displayed.
  791.     HRESULT IsPreroll(void);
  792.     HRESULT SetPreroll(BOOL bIsPreroll);
  793.  
  794.     long GetActualDataLength(void);
  795.     HRESULT SetActualDataLength(long);
  796.  
  797.     // these allow for limited format changes in band - if no format change
  798.     // has been made when you receive a sample GetMediaType will return S_FALSE
  799.  
  800.     HRESULT GetMediaType(AM_MEDIA_TYPE **ppMediaType);
  801.     HRESULT SetMediaType(AM_MEDIA_TYPE *pMediaType);
  802.  
  803.     // returns S_OK if there is a discontinuity in the data (this frame is
  804.     // not a continuation of the previous stream of data
  805.     // - there has been a seek or some dropped samples).
  806.     HRESULT IsDiscontinuity(void);
  807.     // set the discontinuity property - TRUE if this sample is not a
  808.     // continuation, but a new sample after a seek or a dropped sample.
  809.     HRESULT SetDiscontinuity(BOOL bDiscontinuity);
  810.  
  811.     // get the media times for this sample
  812.     HRESULT GetMediaTime(
  813.         [out] LONGLONG * pTimeStart,
  814.     [out] LONGLONG * pTimeEnd
  815.     );
  816.  
  817.     // Set the media times for this sample
  818.     // pTimeStart==pTimeEnd==NULL will invalidate the media time stamps in
  819.     // this sample
  820.     HRESULT SetMediaTime(
  821.         [in] LONGLONG * pTimeStart,
  822.     [in] LONGLONG * pTimeEnd
  823.     );
  824. }
  825.  
  826. typedef IMediaSample *PMEDIASAMPLE;
  827.  
  828.  
  829. // flags for dwFlags in IMemAllocator::GetBuffer
  830. // AM_GBF_PREVFRAMESKIPPED is only significant when asking for a buffer from the
  831. // video renderer.  It should be TRUE if and only if the previous frame
  832. // was skipped.  It affects quality management.
  833. // AM_GBF_NOTASYNCPOINT indicates to the downstream filter (most likely the
  834. // video renderer) that you are not going to fill this buffer with a sync point
  835. // (keyframe) so now would be a bad time to return a buffer with a dynamic
  836. // format change, because you will be unable to switch to the new format without
  837. // waiting for the next sync point, causing some frames to be dropped.
  838. #define AM_GBF_PREVFRAMESKIPPED    1
  839. #define AM_GBF_NOTASYNCPOINT    2
  840. cpp_quote("#define AM_GBF_PREVFRAMESKIPPED 1")
  841. cpp_quote("#define AM_GBF_NOTASYNCPOINT 2")
  842.  
  843. //=====================================================================
  844. //=====================================================================
  845. // Defines IMemAllocator interface
  846. //
  847. // an allocator of IMediaSample blocks to be used for data transfer between
  848. // pins. Can be provided by input, output or a third party. Release
  849. // the IMediaSample object obtained back to the pool by calling
  850. // IMediaSample::Release.
  851. //=====================================================================
  852. //=====================================================================
  853.  
  854. [
  855.         object,
  856.         uuid(56a8689c-0ad4-11ce-b03a-0020af0ba770),
  857.         pointer_default(unique)
  858. ]
  859. interface IMemAllocator : IUnknown {
  860.  
  861.     // negotiate buffer sizes, buffer count and alignment. pRequest is filled
  862.     // in by the caller with the requested values. pActual will be returned
  863.     // by the allocator with the closest that the allocator can come to this.
  864.     // Cannot be called unless the allocator is decommitted.
  865.     // Calls to GetBuffer need not succeed until Commit is called.
  866.     HRESULT SetProperties(
  867.         [in] ALLOCATOR_PROPERTIES* pRequest,
  868.         [out] ALLOCATOR_PROPERTIES* pActual);
  869.  
  870.     // return the properties actually being used on this allocator
  871.     HRESULT GetProperties(
  872.         [out] ALLOCATOR_PROPERTIES* pProps);
  873.  
  874.  
  875.     // commit the memory for the agreed buffers
  876.     HRESULT Commit(void);
  877.  
  878.     // release the memory for the agreed buffers. Any threads waiting in
  879.     // GetBuffer will return with an error. GetBuffer calls will always fail
  880.     // if called before Commit or after Decommit.
  881.     HRESULT Decommit(void);
  882.  
  883.     // get container for a sample. Blocking, synchronous call to get the
  884.     // next free buffer (as represented by an IMediaSample interface).
  885.     // on return, the time etc properties will be invalid, but the buffer
  886.     // pointer and size will be correct.
  887.     // Will only succeed if memory is committed. If GetBuffer is blocked
  888.     // waiting for a buffer and Decommit is called on another thread,
  889.     // GetBuffer will return with an error.
  890.     HRESULT GetBuffer(
  891.         [out] IMediaSample **ppBuffer,
  892.         [in] REFERENCE_TIME * pStartTime,
  893.         [in] REFERENCE_TIME * pEndTime,
  894.         [in] DWORD dwFlags
  895.     );
  896.  
  897.     // put a buffer back on the allocators free list.
  898.     // this is typically called by the Release() method of the media
  899.     // sample when the reference count goes to 0
  900.     //
  901.     HRESULT ReleaseBuffer(
  902.         [in] IMediaSample *pBuffer
  903.     );
  904. }
  905.  
  906. typedef IMemAllocator *PMEMALLOCATOR;
  907.  
  908.  
  909. //=====================================================================
  910. //=====================================================================
  911. // Defines IMemInputPin interface
  912. //
  913. // basic shared memory transport interface.
  914. //=====================================================================
  915. //=====================================================================
  916.  
  917. [
  918.         object,
  919.         uuid(56a8689d-0ad4-11ce-b03a-0020af0ba770),
  920.         pointer_default(unique)
  921. ]
  922. interface IMemInputPin : IUnknown {
  923.  
  924.     // return the allocator interface that this input pin
  925.     // would like the output pin to use
  926.     HRESULT GetAllocator(
  927.                 [out] IMemAllocator ** ppAllocator);
  928.  
  929.     // tell the input pin which allocator the output pin is actually
  930.     // going to use.
  931.     // If the readonly flag is set, then all samples from this allocator are
  932.     // to be treated as read-only, and should be copied before being modified.
  933.     HRESULT NotifyAllocator(
  934.                 [in] IMemAllocator * pAllocator,
  935.                 [in] BOOL bReadOnly
  936.                 );
  937.  
  938.     // this method is optional (can return E_NOTIMPL). Output pins are not obliged to call
  939.     // this method, nor are they obliged to fulfil the request. Input pins making such a
  940.     // request should check the allocator in NotifyAllocator to see if it meets their needs. If
  941.     // not, the input pin is responsible for any necessary data copy.
  942.     // Zero values will be treated as don't care: so a pin can return an alignment value
  943.     // and leave the other values 0.
  944.     HRESULT GetAllocatorRequirements( [out] ALLOCATOR_PROPERTIES*pProps);
  945.  
  946.     // here's the next block of data from the stream. AddRef it if
  947.     // you need to hold it beyond the end of the Receive call.
  948.     // call pSample->Release when done with it.
  949.     //
  950.     // This is a blocking synchronous call.  Usually no blocking
  951.     // will occur but if a filter cannot process the sample immediately
  952.     // it may use the caller's thread to wait until it can.
  953.     HRESULT Receive(
  954.                 [in] IMediaSample * pSample);
  955.     // Same as Receive but with multiple samples.  Useful for
  956.     // fragmented streams
  957.     HRESULT ReceiveMultiple(
  958.                 [in, size_is(nSamples)] IMediaSample **pSamples,
  959.                 [in] long nSamples,
  960.                 [out] long *nSamplesProcessed);
  961.  
  962.     // See if Receive might block
  963.     // Returns S_OK if it can block, S_FALSE if it can't or some
  964.     // failure code (assume it can in this case)
  965.     HRESULT ReceiveCanBlock();
  966. }
  967.  
  968. typedef IMemInputPin *PMEMINPUTPIN;
  969.  
  970.  
  971. //=====================================================================
  972. //=====================================================================
  973. // Defines IAMovieSetup interface
  974. //
  975. // exported by filter to allow it to be self-registering
  976. //=====================================================================
  977. //=====================================================================
  978.  
  979. [
  980. object,
  981. uuid(a3d8cec0-7e5a-11cf-bbc5-00805f6cef20),
  982. pointer_default(unique)
  983. ]
  984. interface IAMovieSetup : IUnknown {
  985.  
  986.     // methods to register and unregister
  987.     // filter, etc.
  988.  
  989.     HRESULT Register( );
  990.     HRESULT Unregister( );
  991. }
  992.  
  993. typedef IAMovieSetup *PAMOVIESETUP;
  994.  
  995.  
  996. //=====================================================================
  997. //=====================================================================
  998. // Defines IMediaSelection interface
  999. //
  1000. // Controls media time seeking (bytes, frames, fields and samples)
  1001. //=====================================================================
  1002. //=====================================================================
  1003.  
  1004. [
  1005.         object,
  1006.         uuid(56a868ae-0ad4-11ce-b03a-0020af0ba770),
  1007.         pointer_default(unique)
  1008. ]
  1009.  
  1010. interface IMediaSelection : IUnknown {
  1011.  
  1012.  
  1013.     // returns S_OK if mode is supported, S_FALSE otherwise
  1014.     HRESULT IsFormatSupported([in] const GUID Format);
  1015.     HRESULT QueryPreferredFormat([out] GUID *pFormat);
  1016.  
  1017.     // can only change the mode when stopped (I'd like to relax this - v-dslone 960618)
  1018.     // (returns VFE_E_WRONG_STATE otherwise)
  1019.     HRESULT SetTimeFormat([in] const GUID Format);
  1020.     HRESULT GetTimeFormat([out] GUID *pFormat);
  1021.  
  1022.     // return current properties
  1023.     HRESULT GetDuration([out] LONGLONG *pDuration);
  1024.     HRESULT GetStopPosition([out] LONGLONG *pStop);
  1025.     HRESULT GetCurrentPosition([out] LONGLONG *pCurrent);
  1026.  
  1027.     // set start and end positions in one operation, the stream time that the
  1028.     // current media position produces must be returned from here. The filter
  1029.     // graph manager uses this to keep other filters and itself in sync with
  1030.     // the current time position. So if we seek to frame 999 and that is 10s
  1031.     // into the movie then the parameters might be (current time of 999 and
  1032.     // a stop time of 999) and it should return 10secs (as a REFTIME number)
  1033.  
  1034.     HRESULT SetSelection([in] LONGLONG Current,
  1035.                          [in] LONGLONG Stop,
  1036.                          [out] REFTIME *pTime);
  1037. }
  1038.  
  1039. typedef IMediaSelection *PMEDIASELECTION;
  1040.  
  1041.  
  1042.  
  1043. //=====================================================================
  1044. //=====================================================================
  1045. // Defines IMediaSeeking interface
  1046. //
  1047. // Controls seeking (time, bytes, frames, fields and samples)
  1048. //=====================================================================
  1049. //=====================================================================
  1050.  
  1051. typedef enum _SeekingFlags
  1052. {
  1053.     AM_SEEKING_NoPositioning        = 0x00,     // No change
  1054.     AM_SEEKING_AbsolutePositioning    = 0x01,        // Position is supplied and is absolute
  1055.     AM_SEEKING_RelativePositioning    = 0x02,        // Position is supplied and is relative
  1056.     AM_SEEKING_IncrementalPositioning    = 0x03,        // (Stop) position relative to current
  1057.                             // Useful for seeking when paused (use +1)
  1058.     AM_SEEKING_PositioningBitsMask    = 0x03,     // Useful mask
  1059.     AM_SEEKING_SeekToKeyFrame        = 0x04,        // Just seek to key frame (performance gain)
  1060.     AM_SEEKING_ReturnTime        = 0x08,        // Plug the media time equivalents back into the supplied LONGLONGs
  1061.     
  1062. } SEEKING_FLAGS;
  1063.  
  1064. typedef enum _SeekingCapabilities
  1065. {
  1066.     AM_SEEKING_CanSeekAbsolute     = 0x01,
  1067.     AM_SEEKING_CanSeekForwards     = 0x02,
  1068.     AM_SEEKING_CanSeekBackwards    = 0x04,
  1069.     AM_SEEKING_CanGetCurrentPos    = 0x08,
  1070.     AM_SEEKING_CanGetStopPos       = 0x10,
  1071.     AM_SEEKING_CanGetDuration      = 0x20,
  1072.     AM_SEEKING_CanPlayBackwards    = 0x40,
  1073.  
  1074. } SEEKING_CAPABILITIES;
  1075.  
  1076. // IMediaSelection will eventually be removed, IMediaSeeking will
  1077. // absorb its methods, with the exception of SetSelection.
  1078. // However, deriving IMediaSeeking 
  1079. // from IMediaSelection eases the transition.
  1080. [
  1081.         object,
  1082.         uuid(36b73880-c2c8-11cf-8b46-00805f6cef60),
  1083.         pointer_default(unique)
  1084. ]
  1085. interface IMediaSeeking : IMediaSelection {
  1086.  
  1087.     // Returns the capability flags
  1088.     HRESULT GetCapabilities( [out] DWORD * pCapabilities );
  1089.  
  1090.     // And's the capabilities flag with the capabilities requested.
  1091.     // Returns S_OK if all are present, S_FALSE if some are present, E_FAIL if none.
  1092.     // *pCababilities is always updated with the result of the 'and'ing and can be 
  1093.     // checked in the case of an S_FALSE return code.
  1094.     HRESULT CheckCapabilities( [in,out] DWORD * pCapabilities );
  1095.  
  1096.     // Convert time from one format to another.  
  1097.     // We must be able to convert between all of the formats that we say we support.
  1098.     // (However, we can use intermediate formats (e.g. MEDIA_TIME).)
  1099.     // If a pointer to a format is null, it implies the currently selected format.
  1100.     HRESULT ConvertTimeFormat([out] LONGLONG * pTarget, [in] const GUID * pTargetFormat,
  1101.                               [in]  LONGLONG    Source, [in] const GUID * pSourceFormat );
  1102.  
  1103.  
  1104.     // Set current and end positions in one operation
  1105.     // Either pointer may be null, implying no change
  1106.     HRESULT SetPositions( [in,out] LONGLONG * pCurrent, [in] DWORD dwCurrentFlags
  1107.             , [in,out] LONGLONG * pStop, [in] DWORD dwStopFlags );
  1108.  
  1109.     // Get CurrentPosition & StopTime
  1110.     // Either pointer may be null, implying not interested
  1111.     HRESULT GetPositions( [out] LONGLONG * pCurrent,
  1112.                           [out] LONGLONG * pStop );
  1113.  
  1114.     // Get earliest / latest times to which we can currently seek "efficiently".
  1115.     // This method is intended to help with graphs where the source filter has
  1116.     // a very high latency.  Seeking within the returned limits should just 
  1117.     // result in a re-pushing of already cached data.  Seeking beyond these 
  1118.     // limits may result in extended delays while the data is fetched (e.g.
  1119.     // across a slow network).
  1120.     // (NULL pointer is OK, means caller isn't interested.)
  1121.     HRESULT GetAvailable( [out] LONGLONG * pEarliest, [out] LONGLONG * pLatest );
  1122.  
  1123.     // Rate stuff
  1124.     HRESULT SetRate([in]  double dRate);
  1125.     HRESULT GetRate([out] double * pdRate);
  1126. }
  1127.  
  1128. typedef IMediaSeeking *PMEDIASEEKING;
  1129.