Vixen
02b45cc4
csharp
public sealed class MatroskaAudioStreamDecoder

The audio track of a Matroska segment, behind the interface the mixer already streams.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

A video's audio is not a separate file, and this is what makes that not a problem. The picture and the sound are interleaved in one segment and have to be read by one demuxer — reading the same file twice would mean two file handles, two positions, and a seek in one that the other knows nothing about. So the video decoder owns the demuxer and this shares it, and a seek in either lands both on the same cluster.

It is an IAudioStreamDecoder, so the mixer needs to know nothing about video. AudioEngine.PlayStream takes one of these exactly as it takes an Ogg, the streaming pump fills its ring buffer on the same thread as everything else, and the fact that the bytes came out of a film is invisible from there.

Both halves must be drained. A player that reads video and never reads audio makes the demuxer hold every audio packet of the file — see MatroskaDemuxer. The pump does the draining in practice, which is why VideoPlayer starts the audio stream before it starts decoding pictures.

Fields and properties (5)

  • public MatroskaTrack Track

    What the container said about the track.

  • public AudioFormat Format

    The rate and channel count it produces.

  • public long FrameCount

    How many frames the whole track is, or -1 if the container does not say.

  • public long Position

    Which frame the next Decode starts at.

  • public bool CanSeek

    Whether Seek works.

Methods (5)

  • public MatroskaAudioStreamDecoder(MatroskaDemuxer demuxer, MatroskaTrack track, IAudioPacketDecoder decoder, bool ownsDemuxer = false, bool ownsDecoder = true)

    Reads a track with a decoder for its codec.

  • public int Decode(Span<float> destination, int frameCount)

    Decodes the next frames.

  • public void Seek(long frame)
  • public void Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

  • public static bool TryOpen(MatroskaDemuxer demuxer, out MatroskaAudioStreamDecoder? stream)

    Opens the first audio track of a segment, if anything registered can decode it.

Used by (4)

  • VideoGameVideoPlayback
  • MatroskaAudioTestsVixen.Video.Tests
  • OpusAudioTrackTestsVixen.Video.Codecs.Tests
  • VideoPlaybackVixen.Video