using System;

/*
    Copyright (c) 2011 flixmonk. (http://DVDSwarm.codeplex.com)
    All Rights Reserved.
        
    Redistribution and use in source and binary forms, with or without modification,
    are permitted provided that the following conditions are met:
        
    * Redistributions of source code must retain the above copyright notice, this list
      of conditions and the following disclaimer.
        
    * Redistributions in binary form must reproduce the above copyright notice, this
    list of conditions and the following disclaimer in the documentation and/or other
    materials provided with the distribution. 
        
    * Neither the name of The Flixmonk nor the names of its contributors may be used to
    endorse or promote products derived from this software without specific prior written
    permission.
        
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
    SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
    OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
    TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace DVDSwarm
{
    /// <summary>
    /// Contains information about an audio track.
    /// </summary>
    sealed public class AudioTrackInfo
    {
        #region Fields

        private Int32 _delay = 0;
        private Boolean _downmix = true;
        private Boolean _dynamicRangeCompression = true;
        private string _filename = string.Empty;
        private AudioFormat _format = AudioFormat.Ac3;
        private Boolean _normalize = true;
        private AudioFormat _outputFormat = AudioFormat.Vorbis;

        #endregion

        #region Properties

        /// <summary>
        /// Gets and sets the delay for the track in milliseconds.
        /// </summary>
        public Int32 Delay
        {
            get
            {
                return _delay;
            }
            set
            {
                _delay = value;
            }
        }
        /// <summary>
        /// Gets and sets a value indicating whether muti-channel audio should be downmixed to
        /// 2 channels.
        /// </summary>
        public Boolean Downmix
        {
            get
            {
                return _downmix;
            }
            set
            {
                _downmix = value;
            }
        }
        /// <summary>
        /// Gets and sets a value indicating whether AC3 and DTS audio should have Dynamic Range
        /// Compression (DRC) applied.
        /// </summary>
        public Boolean DynamicRangeCompression
        {
            get
            {
                return _dynamicRangeCompression;
            }
            set
            {
                _dynamicRangeCompression = value;
            }
        }
        /// <summary>
        /// Gets and sets the filename of the track.
        /// </summary>
        public string Filename
        {
            get
            {
                return _filename;
            }
            set
            {
                _filename = value;
                _format = Utility.ConvertAudioFormatFromExtension(value);
            }
        }
        /// <summary>
        /// Gets the audio format for the track.
        /// </summary>
        public AudioFormat Format
        {
            get
            {
                return _format;
            }
        }
        /// <summary>
        /// Gets and sets a value indicating whether the output audio levels should be normalized.
        /// </summary>
        public Boolean Normalize
        {
            get
            {
                return _normalize;
            }
            set
            {
                _normalize = value;
            }
        }
        /// <summary>
        /// Gets and sets the output audio format for the track.
        /// </summary>
        public AudioFormat OutputFormat
        {
            get
            {
                return _outputFormat;
            }
            set
            {
                _outputFormat = value;
            }
        }

        #endregion

        #region Methods

        /// <summary>
        /// Clears internal values.
        /// </summary>
        public void Clear()
        {
            _delay = 0;
            _downmix = true;
            _dynamicRangeCompression = true;
            _filename = string.Empty;
            _format = AudioFormat.Ac3;
            _normalize = true;
            _outputFormat = AudioFormat.Vorbis;
        }

        /// <summary>
        /// Copies data from another instance to this instance.
        /// </summary>
        /// <param name="track">An AudioTrackInfo instance to copy values from.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when track is null.</exception>
        public void Copy(AudioTrackInfo track)
        {
            if (track == null)
            {
                throw new ArgumentNullException("track");
            }

            Clear();

            _delay = track._delay;
            _downmix = track._downmix;
            _dynamicRangeCompression = track._dynamicRangeCompression;
            _filename = track._filename;
            _format = track._format;
            _normalize = track._normalize;
            _outputFormat = track._outputFormat;
        }

        #endregion
    }
}
