私は2つのIMFByteStream
インターフェイスを実装しています.1つはMediaByteStreamと呼ばれ、非ストレージメモリストリーミングに使用され、もう1つはStoreByteStreamと呼ばれ、インメモリストレージに使用されます。
IMFByteStream
実装にコードを配置すると、シーク可能なエラーがなくなり、ストリーム配信機能に影響しません。
/// <summary>
/// Retrieves the characteristics of the byte stream.
/// </summary>
/// <param name="pdwCapabilities">Receives a bitwise OR of zero or more flags. The following flags are defined. [out]</param>
/// <returns>The result of the operation.</returns>
HRESULT MediaByteStream::GetCapabilities(
DWORD *pdwCapabilities)
{
HRESULT hr = S_OK;
// Stream can read, can write, can seek.
*pdwCapabilities = MFBYTESTREAM_IS_READABLE | MFBYTESTREAM_IS_WRITABLE | MFBYTESTREAM_IS_SEEKABLE;
// Return the result.
return hr;
}
あなたはIMFByteStream
インターフェイスのSeek
メソッドを実装したいことができるかどうかが、あなたの場合(ネットワーク・ストリーミング)で、あなただけの追求の位置を返すことができます。
/// <summary>
/// Moves the current position in the stream by a specified offset.
/// </summary>
/// <param name="SeekOrigin">Specifies the origin of the seek as a member of the MFBYTESTREAM_SEEK_ORIGIN enumeration. The offset is calculated relative to this position. [in]</param>
/// <param name="qwSeekOffset">Specifies the new position, as a byte offset from the seek origin. [in]</param>
/// <param name="dwSeekFlags">Specifies zero or more flags. The following flags are defined. [in]</param>
/// <param name="pqwCurrentPosition">Receives the new position after the seek. [out]</param>
/// <returns>The result of the operation.</returns>
HRESULT MediaByteStream::Seek(
MFBYTESTREAM_SEEK_ORIGIN SeekOrigin,
LONGLONG qwSeekOffset,
DWORD dwSeekFlags,
QWORD *pqwCurrentPosition)
{
HRESULT hr = S_OK;
_seekRequest = true;
// Select the seek origin.
switch (SeekOrigin)
{
case MFBYTESTREAM_SEEK_ORIGIN::msoCurrent:
// If the buffer is less or same.
if ((qwSeekOffset + _position) < size)
_position += qwSeekOffset;
else
_position = size;
break;
case MFBYTESTREAM_SEEK_ORIGIN::msoBegin:
default:
// If the buffer is less or same.
if (qwSeekOffset < size)
_position = qwSeekOffset;
else
_position = size;
break;
}
// Get the current position in the stream.
*pqwCurrentPosition = _position;
// Return the result.
return hr;
}
シーク不可能なストリームのメディアソースが必要です。いくつかの情報源はシークが必要であり、シークが利用可能になることを確かめるためにキャップをチェックするのは全体的なポイントです。 –
宛先メディアソースのコンテンツタイプがASFです。シーク可能なバイトストリームを必要としないASFメディアソースを作成することは可能ですか? – pawel
私はすべてのシークが "前方"であると仮定しているので、ストリームのための簡単なシークを実装することが可能です(不要なデータを読み込むだけです)。 –