次の方法で共有


IWMReaderCallback::OnSample method (wmsdkidl.h)

[The feature associated with this page, Windows Media Format 11 SDK, is a legacy feature. It has been superseded by Source Reader and Sink Writer. Source Reader and Sink Writer have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Source Reader and Sink Writer instead of Windows Media Format 11 SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The OnSample method is called during the reading of a file (due to a Start call) indicating that new data is available.

Syntax

HRESULT OnSample(
  [in] DWORD      dwOutputNum,
  [in] QWORD      cnsSampleTime,
  [in] QWORD      cnsSampleDuration,
  [in] DWORD      dwFlags,
  [in] INSSBuffer *pSample,
  [in] void       *pvContext
);

Parameters

[in] dwOutputNum

DWORD containing the number of the output to which the sample belongs.

[in] cnsSampleTime

QWORD containing the sample time, in 100-nanosecond units.

[in] cnsSampleDuration

QWORD containing the sample duration, in 100-nanosecond units. For video streams, if the SampleDuration data unit extension was set on this sample when the file was created, then this parameter will contain that value. For more information on SampleDuration , see INSSBuffer3::GetProperty.

[in] dwFlags

The flags that can be specified in dwFlags have the following uses.

Flag Description
No flag set None of the conditions for the other flags applies. For example, a delta frame in most cases would not have any flags set for it.
WM_SF_CLEANPOINT This is the same as a key frame. It indicates a good point to go to during a seek, for example.
WM_SF_DISCONTINUITY The data stream has a gap in it, which could be due to a seek, a network loss, or other reason. This can be useful extra information for an application such as a codec or renderer. The flag is set on the first piece of data following the gap.
WM_SF_DATALOSS Some data has been lost between the previous sample and the sample with this flag set.

[in] pSample

Pointer to the INSSBuffer interface of an object containing the sample. The reader calls SAFE_RELEASE on this pointer after your OnSample method returns. You can call AddRef on this pointer if you need to keep a reference count on the buffer. Do not call Release on this pointer unless you have called AddRef.

[in] pvContext

Generic pointer, for use by the application. This pointer is the context pointer given to the IWMReader::Start method.

Return value

To use this method, you must implement it in your application. The method should always return S_OK.

Remarks

This method is for receipt of uncompressed samples by output number only. If you need to receive samples for multiple streams in a single output (as in the case of mutually exclusive streams), you must use IWMReaderCallbackAdvanced::OnStreamSample. In this case, you will receive compressed samples. There is no way to use the reader to receive uncompressed samples by stream number.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only],Windows Media Format 7 SDK, or later versions of the SDK
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header wmsdkidl.h (include Wmsdk.h)

See also

IWMReaderCallback Interface