Пример #1
0
        /// <summary>
        /// Open the media.
        /// Create the structures.
        /// </summary>
        protected override void OpenMediaAsync()
        {
            try
            {
                // Create a parser
                this.wavParser = new WavParser(this.stream);

                // Parse the header
                this.wavParser.ParseWaveHeader();

                this.wavParser.WaveFormatEx.ValidateWaveFormat();

                this.startPosition = this.currentPosition = this.wavParser.DataPosition;

                // 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] = this.wavParser.WaveFormatEx.ToHexString();
                MediaStreamDescription msd = new MediaStreamDescription(MediaStreamType.Audio, streamAttributes);

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

                sourceAttributes[MediaSourceAttributesKeys.Duration] = this.wavParser.Duration.ToString();
                ReportOpenMediaCompleted(sourceAttributes, availableStreams);
            }
            catch (Exception) {}
        }
Пример #2
0
 /// <summary>
 /// Close the media. Release the resources.
 /// </summary>
 protected override void CloseMedia()
 {
     // Close the stream
     this.startPosition = this.currentPosition = 0;
     this.wavParser     = null;
     this.audioDesc     = null;
 }
        protected override void OpenMediaAsync()
        {
            try
            {
                this.wavParser = new WavParser(this.stream);

                this.wavParser.ParseWaveHeader();

                this.wavParser.WaveFormatEx.ValidateWaveFormat();

                this.startPosition = this.currentPosition = this.wavParser.DataPosition;

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

                streamAttributes[MediaStreamAttributeKeys.CodecPrivateData] = this.wavParser.WaveFormatEx.ToHexString();
                MediaStreamDescription msd = new MediaStreamDescription(MediaStreamType.Audio, streamAttributes);

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

                sourceAttributes[MediaSourceAttributesKeys.Duration] = this.wavParser.Duration.ToString();
                ReportOpenMediaCompleted(sourceAttributes, availableStreams);
            }
            catch(Exception){}
        }
 /// <summary>
 /// Close the media. Release the resources.
 /// </summary>
 protected override void CloseMedia()
 {
     // Close the stream
     this.startPosition = this.currentPosition = 0;
     this.wavParser = null;
     this.audioDesc = null;
 }
Пример #5
0
 /// <summary>
 /// Implementation of the IDisposable pattern
 /// </summary>
 /// <param name="disposing">Are we being destroyed</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.wavParser != null)
         {
             this.wavParser.Dispose();
             this.wavParser = null;
         }
     }
 }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.wavParser != null)
         {
             this.wavParser.Dispose();
             this.wavParser = null;
         }
     }
 }