Beispiel #1
0
    /// <summary>
    /// Open the media.
    /// Create the structures.
    /// </summary>
    protected override void OpenMediaAsync() {
      header = WaveFormatExtensible.ReadHeader(stream);
      header.ValidateWaveFormat();

      sampleSize = (long)header.Channels * header.BitsPerSample / 8 * numSamples;
      startPosition = currentPosition = stream.Position;
      pcmDataLen = stream.Length - startPosition;
      duration = header.AudioDurationFromDataLen(pcmDataLen);

      // Init
      Dictionary<MediaStreamAttributeKeys, string> streamAttributes = new Dictionary<MediaStreamAttributeKeys, string>();
      Dictionary<MediaSourceAttributesKeys, string> sourceAttributes = new Dictionary<MediaSourceAttributesKeys, string>();
      List<MediaStreamDescription> availableStreams = new List<MediaStreamDescription>();

      // Stream Description
      streamAttributes[MediaStreamAttributeKeys.CodecPrivateData] = header.ToHexString();
      MediaStreamDescription msd = new MediaStreamDescription(MediaStreamType.Audio, streamAttributes);

      this.audioDesc = msd;
      availableStreams.Add(this.audioDesc);

      sourceAttributes[MediaSourceAttributesKeys.Duration] = duration.ToString();
      ReportOpenMediaCompleted(sourceAttributes, availableStreams);
    }