예제 #1
0
        /// <summary>Returns string version of bitrate type enum
        /// </summary>
        private string GetBitrateTypeString(BitrateType type = BitrateType.bitrate_NONE)
        {
            string bitrateTypeString = string.Empty;

            if (type == BitrateType.bitrate_NONE)
            {
                type = GetBitrateType();
            }
            switch (type)
            {
            case BitrateType.bitrate_NONE: bitrateTypeString = "-"; break;

            case BitrateType.bitrate_FLAC: bitrateTypeString = "FLAC"; break;

            case BitrateType.bitrate_320: bitrateTypeString = "320"; break;

            case BitrateType.bitrate_256: bitrateTypeString = "256"; break;

            case BitrateType.bitrate_192: bitrateTypeString = "192"; break;

            case BitrateType.bitrate_160: bitrateTypeString = "160"; break;

            case BitrateType.bitrate_128: bitrateTypeString = "128"; break;

            case BitrateType.bitrate_LOW: bitrateTypeString = "low"; break;

            case BitrateType.bitrate_VBR: bitrateTypeString = "VBR"; break;

            default: break;
            }

            return(bitrateTypeString);
        }
예제 #2
0
        private CodecType _codecType;      // тип кодека

        #endregion </Fields>

        #region <Ctors>

        public StreamInfo()
        {
            HasAudio           = false;
            HasVideo           = false;
            ContainerType      = ContainerType.Unknown;
            _msNaturalDuration = 0;
            _frameWidth        = 0;
            _frameHeight       = 0;
            Bitrate            = 0;
            _bitrateType       = BitrateType.Unknown;
            _codecType         = CodecType.Unknown;
            Fps = 0;
        }
예제 #3
0
 /// <summary>
 /// Содержит свединия о формате потока
 /// </summary>
 /// <param name="farmeWidth">Горизонтальное разрешение кадра (пикс)</param>
 /// <param name="frameHeight">Вертикальное разрешение кадра (пикс)</param>
 /// <param name="bitrate">бит в сек</param>
 /// <param name="bitrateType">постоянный битрейт/переменный битрейт</param>
 /// <param name="codecType">тип кодека (h264/h263/mjpeg ....)</param>
 /// <param name="containerType">тип контейнера (mkv, avi ....)</param>
 /// <param name="hasVideo">true - поток содержит видео дорожку</param>
 /// <param name="hasAudio">поток содержит звуковую дорожку</param>
 /// <param name="msNaturalDuration">Длительность в милисекундах</param>
 /// <param name="fps"></param>
 public StreamInfo(UInt32 farmeWidth, UInt32 frameHeight, UInt32 bitrate, BitrateType bitrateType, CodecType codecType, ContainerType containerType, bool hasVideo, bool hasAudio, uint msNaturalDuration, int fps)
 {
     _frameWidth        = farmeWidth;
     _frameHeight       = frameHeight;
     HasAudio           = hasAudio;
     HasVideo           = hasVideo;
     Bitrate            = bitrate;
     BitrateType        = bitrateType;
     CodecType          = codecType;
     _msNaturalDuration = msNaturalDuration;
     Fps           = fps;
     ContainerType = containerType;
     HasVideo      = hasVideo;
     HasAudio      = hasAudio;
 }
예제 #4
0
        /// <summary>
        ///    Gets a bitrate type enumeration.
        /// </summary>
        /// <value>
        ///    A <see cref="BitrateType" /> containing filetype or bitrate.
        /// </value>
        /// <remarks>
        ///    Contains some specific replacements I need.
        /// </remarks>
        /// <seealso cref="BitrateType"/>
        /// <completionlist cref="BitrateType"/>
        /// <returns>This function returns a <see cref="BitrateType"/> that contains either the
        /// type of file, or (for MP3) either the bitrate or if it's VBR</returns>
        private BitrateType GetBitrateType()
        {
            BitrateType typeBitrate = BitrateType.bitrate_NONE;

            if (currentFile.MimeType == "taglib/flac")
            {
                typeBitrate = BitrateType.bitrate_FLAC;
            }
            if (currentFile.MimeType == "taglib/mp3")
            {
                if (IsVBR())
                {
                    typeBitrate = BitrateType.bitrate_VBR;
                }
                else
                {
                    switch (currentFile.Properties.AudioBitrate)
                    {
                    case 320: typeBitrate = BitrateType.bitrate_320; break;

                    case 256: typeBitrate = BitrateType.bitrate_256; break;

                    case 192: typeBitrate = BitrateType.bitrate_192; break;

                    case 160: typeBitrate = BitrateType.bitrate_160; break;

                    case 128: typeBitrate = BitrateType.bitrate_128; break;

                    default:
                        if (currentFile.Properties.AudioBitrate < 128)
                        {
                            typeBitrate = BitrateType.bitrate_LOW;
                        }
                        else
                        {
                            typeBitrate = BitrateType.bitrate_NONE;
                        }
                        break;
                    }
                }
            }
            return(typeBitrate);
        }
예제 #5
0
        public static int Value(this BitrateType data)
        {
            switch (data)
            {
            case BitrateType.undefined:
                return(0);

            case BitrateType.kpbs10:
                return(10);

            case BitrateType.kpbs20:
                return(20);

            case BitrateType.kpbs50:
                return(50);

            case BitrateType.kpbs83:
                return(83);

            case BitrateType.kpbs100:
                return(100);

            case BitrateType.kpbs125:
                return(125);

            case BitrateType.kpbs250:
                return(250);

            case BitrateType.kpbs500:
                return(500);

            case BitrateType.kpbs800:
                return(800);

            case BitrateType.kpbs1000:
                return(1000);
            }
            return(0);
        }
예제 #6
0
        //MP3GAIN_MINMAX
        //MP3GAIN_UNDO
        //REPLAYGAIN_TRACK_GAIN
        //REPLAYGAIN_TRACK_PEAK

        /// <summary>
        /// Function that goes through a directory with music files to determine a rating, checking for types,
        /// bitrates and if files are corrupt.
        /// </summary>
        /// <returns>A string containing the quality rating</returns>
        /// <remarks>This function checks all files in a directory and returns a 'quality rating'
        /// This means the lossless type, bitrate for lossy, corrupt if there are 0-byte music files
        /// Or various if it contains files with various bitrates or for example both VBR and CBR files
        /// </remarks>
        private string DetermineMusicQualityRating()
        {
            string verdict = string.Empty;        //The resulting string
            //Possible reasons/results
            bool        bCorruptFiles    = false; //Are the corrupt files
            bool        bVariousBitrates = false;
            bool        bMP3             = false;
            bool        bFlac            = false;
            bool        bVBR             = false;
            bool        bCBR             = false;
            BitrateType typeBitrate      = BitrateType.bitrate_NONE;
            int         lastBitrate      = 0;

            foreach (string file in Directory.EnumerateFiles(System.IO.Path.GetDirectoryName(currentFile.Name), "*.*", SearchOption.TopDirectoryOnly)
                     .Where(s => extensions.Any(ext => ext == Path.GetExtension(s))))
            {
                try
                {
                    currentFile = TagLib.File.Create(file);
                    typeBitrate = GetBitrateType();
                    if (typeBitrate == BitrateType.bitrate_FLAC)
                    {
                        bFlac = true;
                    }
                    //Flac is currently the last none-mp3 type listed
                    else if (typeBitrate > BitrateType.bitrate_MP3)
                    {
                        bMP3 = true;
                        if (typeBitrate == BitrateType.bitrate_VBR)
                        {
                            bVBR = true;
                        }
                        else
                        {
                            bCBR = true;
                        }
                        if (lastBitrate > 0)
                        {
                            if (lastBitrate != currentFile.Properties.AudioBitrate)
                            {
                                bVariousBitrates = true;
                            }
                        }
                        if (lastBitrate == 0)
                        {
                            lastBitrate = currentFile.Properties.AudioBitrate;
                        }
                    }
                }
                catch (TagLib.CorruptFileException)
                {
                    bCorruptFiles = true;
                }
            }
            if (bCorruptFiles)
            {
                if (verdict.Length > 0)
                {
                    verdict += "+";
                }
                verdict += "CORRUPT";
            }
            if (bVariousBitrates)
            {
                if (verdict.Length > 0)
                {
                    verdict += "+";
                }
                verdict += "VARIOUS BITRATES";
            }
            if (bFlac && !bMP3 && !bCBR && !bVBR)
            {
                verdict += " - FLAC";
            }
            if (bFlac && (bMP3 || bCBR || bVBR))
            {
                verdict += " - Lossless & Lossy";
            }
            if (!bFlac && bMP3 && !bVBR && !bVariousBitrates)
            {
                verdict += " - " + GetBitrateTypeString(typeBitrate);
            }                                                                                                           //Just use the last one
            if (!bFlac && !bMP3 && bVBR && !bVariousBitrates)
            {
                verdict += " - VBR";
            }
            if (!bFlac && bMP3 && bVBR)
            {
                verdict += " - VBR+CBR";
            }
            return(verdict);
        }