Esempio n. 1
0
 private static void ClearItemsList()
 {
     Countrys.Clear();
     Citys.Clear();
     Bitrate.Clear();
     Genres.Clear();
 }
Esempio n. 2
0
        // https://github.com/xiph/opus/issues/42 w
        public VoiceClient(SampleRate sampleRate     = SampleRate._48k,
                           Bitrate bitRate           = Bitrate._192k,
                           Channels channels         = Channels.Two,
                           FrameDelay frameDelay     = FrameDelay.Delay20,
                           BitDepthEnum bitDepthEnum = BitDepthEnum.Float32)
        {
            this.frameDelay = (int)frameDelay;
            this.sampleRate = (int)sampleRate;
            this.bitRate    = (int)bitRate;
            this.channels   = (int)channels;
            this.bitDepth   = (int)bitDepthEnum;

            this.Encoder = new LibOpusEncoder(this.sampleRate, this.channels, this.bitRate, this.frameDelay);

            Encode = bitDepthEnum switch
            {
                BitDepthEnum.Float32 => Encoder.EncodeFloat,
                BitDepthEnum.UInt16 => Encoder.Encode,
                _ => throw new NotSupportedException(nameof(BitDepth))
            };

            if (bitDepthEnum == BitDepthEnum.Float32)
            {
                Encode = Encoder.EncodeFloat;
            }
            else
            {
                Encode = Encoder.Encode;
            }

            _arrayPool = ArrayPool <byte> .Shared;
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes an instance of <see cref="MuxedStreamInfo"/>.
 /// </summary>
 public MuxedStreamInfo(
     int tag,
     string url,
     Container container,
     FileSize size,
     Bitrate bitrate,
     string audioCodec,
     string videoCodec,
     string videoQualityLabel,
     VideoQuality videoQuality,
     VideoResolution resolution,
     Framerate framerate)
 {
     Tag               = tag;
     Url               = url;
     Container         = container;
     Size              = size;
     Bitrate           = bitrate;
     AudioCodec        = audioCodec;
     VideoCodec        = videoCodec;
     VideoQualityLabel = videoQualityLabel;
     VideoQuality      = videoQuality;
     Resolution        = resolution;
     Framerate         = framerate;
 }
Esempio n. 4
0
        private static void FillAllItemsList()
        {
            ClearItemsList();

            foreach (var s in CounList)
            {
                var item = new ListItem {
                    AdditionalProperties = { [NAME] = s }
                };
                item.SetLabel("Name", "[Country." + s + "]");
                if (SelectedCountrys.Contains(s))
                {
                    item.Selected = true;
                }
                Countrys.Add(item);
            }
            Refresh(Countrys);

            foreach (var s in CityList)
            {
                var item = new ListItem {
                    AdditionalProperties = { [NAME] = s }
                };
                item.SetLabel("Name", s);
                if (SelectedCitys.Contains(s))
                {
                    item.Selected = true;
                }
                Citys.Add(item);
            }
            Refresh(Citys);

            foreach (var s in BitrList)
            {
                var item = new ListItem {
                    AdditionalProperties = { [NAME] = Convert.ToInt32(s) + " kbps" }
                };
                item.SetLabel("Name", Convert.ToInt32(s) + " kbps");
                if (SelectedBitrate.Contains(Convert.ToInt32(s) + " kbps"))
                {
                    item.Selected = true;
                }
                Bitrate.Add(item);
            }
            Refresh(Bitrate);

            foreach (var s in GenrList)
            {
                var item = new ListItem {
                    AdditionalProperties = { [NAME] = s }
                };
                item.SetLabel("Name", s);
                if (SelectedGenres.Contains(s))
                {
                    item.Selected = true;
                }
                Genres.Add(item);
            }
            Refresh(Genres);
        }
Esempio n. 5
0
        public static string ToNormalizedString(this Bitrate bRate)
        {
            string bitrateString = bRate.ToString();
            char   size          = bitrateString[0];

            bitrateString  = bitrateString.Replace('_', '.');
            bitrateString  = bitrateString.Remove(0, 1);
            bitrateString += size;
            return(bitrateString);
        }
Esempio n. 6
0
        public string Convert(string inputFile, AudioEncoder audioEncoder, Bitrate audioBitrate, string outputFile)
        {
            var arguments = "-i " + "\"" + inputFile + "\"" +
                            " -v quiet -stats " +
                            _arguments.GetValue(audioEncoder.ToString()) +
                            _arguments.GetValue(audioBitrate.ToString()) +
                            " -y " + outputFile;

            return(arguments);
        }
        //TODO: finish the method params with the bitrate
        /// <summary>
        /// Gets the required information to play a track for a user by streaming the specified audio asset.
        /// </summary>
        /// <param name="trackId">The unique ID of the track.</param>
        /// <param name="bitrate">The desired bitrate of an audio asset. Values: lowest, highest</param>
        /// <param name="aquire">Determines whether to automatically acquire streaming rights. Values: true, false. Default false. This parameter should only be used when: The user explicitly clicks on a play button. The audio stream request returns a StreamContention error.</param>
        /// <returns></returns>
        public async Task<SingleRootObject<AudioData>> GetAudioStreamingInfo(string trackId, Bitrate bitrate,
            bool aquire = false)
        {
            var methodParams = new List<KeyValuePair<string, string>>()
            {
                new KeyValuePair<string, string>("aquire", Convert.ToInt32(aquire).ToString())
            };

            return await BeatsMusicManager.GetSingleParsedResult<AudioData>(string.Format("tracks/{0}/audio", trackId), methodParams,
                true);
        }
 /// <summary>
 /// Initializes an instance of <see cref="AudioOnlyStreamInfo"/>.
 /// </summary>
 public AudioOnlyStreamInfo(
     string url,
     Container container,
     FileSize size,
     Bitrate bitrate,
     string audioCodec)
 {
     Url        = url;
     Container  = container;
     Size       = size;
     Bitrate    = bitrate;
     AudioCodec = audioCodec;
 }
        public override int GetHashCode()
        {
            unchecked
            {
                int hashCode = -2083580346;
                hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(CodecId);

                hashCode = hashCode * -1521134295 + SampleRate.GetHashCode();
                hashCode = hashCode * -1521134295 + Channels.GetHashCode();
                hashCode = hashCode * -1521134295 + DecoderGain.GetHashCode();
                hashCode = hashCode * -1521134295 + FrameDuration.GetHashCode();
                hashCode = hashCode * -1521134295 + Bitrate.GetHashCode();
                return(hashCode);
            }
        }
Esempio n. 10
0
        public ISession SetPreferredOfflineBitrate(Bitrate bitrate, bool resync)
        {
            AssertHandle();

            lock (Spotify.Mutex)
            {
                Error error = Spotify.sp_session_preferred_offline_bitrate(Handle, bitrate, resync);

                if (error != Error.OK)
                {
                    throw new TorshifyException(error.GetMessage(), error);
                }
            }

            return(this);
        }
Esempio n. 11
0
 /// <summary>
 /// Initializes an instance of <see cref="VideoOnlyStreamInfo"/>.
 /// </summary>
 public VideoOnlyStreamInfo(
     string url,
     Container container,
     FileSize size,
     Bitrate bitrate,
     string videoCodec,
     VideoQuality videoQuality,
     Resolution videoResolution)
 {
     Url             = url;
     Container       = container;
     Size            = size;
     Bitrate         = bitrate;
     VideoCodec      = videoCodec;
     VideoQuality    = videoQuality;
     VideoResolution = videoResolution;
 }
Esempio n. 12
0
 /// <summary>
 /// Initializes an instance of <see cref="MuxedStreamInfo"/>.
 /// </summary>
 public MuxedStreamInfo(
     string url,
     Container container,
     FileSize size,
     Bitrate bitrate,
     string audioCodec,
     string videoCodec,
     VideoQuality videoQuality,
     Resolution resolution)
 {
     Url             = url;
     Container       = container;
     Size            = size;
     Bitrate         = bitrate;
     AudioCodec      = audioCodec;
     VideoCodec      = videoCodec;
     VideoQuality    = videoQuality;
     VideoResolution = resolution;
 }
Esempio n. 13
0
        public string Convert(string inputFile, VideoEncoder videoEncoder, VideoResize videoResize,
                              VideoPreset videoPreset, ConstantRateFactor videoConstantRateFactor,
                              AudioCodec audioCodec, Bitrate audioBitrate, string outputFile)
        {
            //-vf scale=-1:720 -c:v libx264 -preset veryfast -crf 23 -c:a aac -b:a 160k

            var arguments = "-i " + "\"" + inputFile + "\"" +
                            " -v quiet -stats " +
                            _arguments.GetValue(videoResize.ToString()) +
                            _arguments.GetValue(videoEncoder.ToString()) +
                            _arguments.GetValue(videoPreset.ToString()) +
                            _arguments.GetValue(videoConstantRateFactor.ToString()) +
                            _arguments.GetValue(audioCodec.ToString()) +
                            _arguments.GetValue(audioBitrate.ToString()) +
                            " -y " + "\"" + outputFile + "\"";



            return(arguments);
        }
    public static Player RetrievePlayer(string PageContent)
    {
        IList <Player> PlayerQualityTypes = new List <Player>();

        Bitrate[] Bitrates = { Bitrate.Create(5000, Quality.High), Bitrate.Create(0, Quality.MediumHighest), Bitrate.Create(2500, Quality.Medium), Bitrate.Create(1500, Quality.Low), Bitrate.Create(600, Quality.VeryLow) };


        foreach (var Bitrate in Bitrates)
        {
            string Url = ScrapeBit.FirstString(PageContent, "{\"bitrate\":" + Bitrate.amount + ",\"playUrl\":\"", "\","); // FHD High Bitrate

            if (Url == null)
            {
                continue;
            }
            else
            {
                return(new Player(Url, Bitrate.quality));
            }
        }
        return(new Player(null, Quality.NotFound));
    }
Esempio n. 15
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Category != 0)
            {
                hash ^= Category.GetHashCode();
            }
            if (Type != 0)
            {
                hash ^= Type.GetHashCode();
            }
            if (Bitrate != 0)
            {
                hash ^= Bitrate.GetHashCode();
            }
            if (Fps != 0)
            {
                hash ^= Fps.GetHashCode();
            }
            if (Unknown1 != 0)
            {
                hash ^= Unknown1.GetHashCode();
            }
            if (Unknown2 != 0)
            {
                hash ^= Unknown2.GetHashCode();
            }
            if (Unknown3 != 0)
            {
                hash ^= Unknown3.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Esempio n. 16
0
 internal static extern Error sp_session_preferred_offline_bitrate(IntPtr sessionPtr, Bitrate bitrate, bool allowResync);
Esempio n. 17
0
 internal static extern Error sp_session_preferred_bitrate(IntPtr sessionPtr, Bitrate bitrate);
Esempio n. 18
0
 public virtual string GetSourceName()
 {
     return(Source + "_" + Bitrate.ToString() + "_" + (string.IsNullOrEmpty(TrackName) ? "unknown" :TrackName.ToString()));
 }
Esempio n. 19
0
    public void Calculate(List <Packet> packetList, int videoStream, int audioStream, int threshold)
    {
        if (packetList == null)
        {
            throw new ArgumentNullException(nameof(packetList));
        }

        // Calculating duration from timestamp values
        Duration = 0;
        foreach (Packet packet in packetList.Where(packet => ShouldCompute(packet, videoStream, audioStream)))
        {
            // Use DTS if PTS not set
            if (double.IsNaN(packet.PtsTime))
            {
                packet.PtsTime = packet.DtsTime;
            }
            Debug.Assert(!double.IsNaN(packet.PtsTime));

            // Packet duration can't be longer than the 1s sample interval
            Debug.Assert(double.IsNaN(packet.DurationTime) || packet.DurationTime <= 1.0);

            // Size must be valid
            Debug.Assert(packet.Size > 0);

            int packetTime = System.Convert.ToInt32(Math.Floor(packet.PtsTime));
            if (packetTime > Duration)
            {
                Duration = packetTime;
            }
        }

        // Add 1 for index offset
        Duration++;

        // Set the bitrate array size to the duration in seconds
        VideoBitrate    = new Bitrate(Duration);
        AudioBitrate    = new Bitrate(Duration);
        CombinedBitrate = new Bitrate(Duration);

        // Iterate through all the packets
        long videoPackets = 0;
        long audioPackets = 0;

        foreach (Packet packet in packetList)
        {
            if (!ShouldCompute(packet, videoStream, audioStream))
            {
                continue;
            }

            // Round down when calculating index
            int index = System.Convert.ToInt32(Math.Floor(packet.PtsTime));

            // Calculate values
            if (packet.StreamIndex == videoStream)
            {
                videoPackets++;
                VideoBitrate.Rate[index]    += packet.Size;
                CombinedBitrate.Rate[index] += packet.Size;
            }
            if (packet.StreamIndex == audioStream)
            {
                audioPackets++;
                AudioBitrate.Rate[index]    += packet.Size;
                CombinedBitrate.Rate[index] += packet.Size;
            }
        }

        // If there are no packets the stream is empty?
        // MkvMerge and HandBrake do not like empty streams
        if (videoPackets == 0 || audioPackets == 0)
        {
            Log.Logger.Error("Empty stream detected : VideoPackets: {VideoPackets}, AudioPackets: {AudioPackets}", videoPackets, audioPackets);
        }

        // Calculate the bitrates
        VideoBitrate.Calculate(threshold);
        AudioBitrate.Calculate(threshold);
        CombinedBitrate.Calculate(threshold);
    }
Esempio n. 20
0
 public virtual string GetSourceName()
 {
     return(Source + "_" + Bitrate.ToString() + "_" + TrackName.ToString());
 }
Esempio n. 21
0
        private void BWCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Bitrate br = (Bitrate)BWCombo.SelectedItem;

            highRate = br.bitrate;
        }
Esempio n. 22
0
        public ISession SetPreferredOfflineBitrate(Bitrate bitrate, bool resync)
        {
            AssertHandle();

            lock (Spotify.Mutex)
            {
                Error error = Spotify.sp_session_preferred_offline_bitrate(Handle, bitrate, resync);

                if (error != Error.OK)
                {
                    throw new TorshifyException(error.GetMessage(), error);
                }
            }

            return this;
        }
Esempio n. 23
0
        public void SaveSettings(Window wnd)
        {
            string error = GetError();

            if (!string.IsNullOrEmpty(error))
            {
                MessageBox.Show(error, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            HashSet <string> changed = new HashSet <string>();

            if (TailNumber != Settings.Default.TailNumber)
            {
                Settings.Default.TailNumber = TailNumber;
                changed.Add("TailNumber");
            }
            if (UgcsAutomatic != Settings.Default.UgcsAutomatic)
            {
                Settings.Default.UgcsAutomatic = UgcsAutomatic;
                changed.Add("UgcsAutomatic");
            }
            if (UcgsAddress != Settings.Default.UcgsAddress || UcgsPort != Settings.Default.UcgsPort)
            {
                Settings.Default.UcgsAddress = UcgsAddress;
                Settings.Default.UcgsPort    = UcgsPort.GetValueOrDefault();
                if (!UgcsAutomatic)
                {
                    changed.Add("UcgsAddress");
                }
            }
            if (VideoServerAutomatic != Settings.Default.VideoServerAutomatic)
            {
                Settings.Default.VideoServerAutomatic = VideoServerAutomatic;
                changed.Add("VideoServerAutomatic");
            }
            if (VideoServerAddress != Settings.Default.VideoServerAddress || VideoServerPort != Settings.Default.VideoServerPort)
            {
                Settings.Default.VideoServerAddress = VideoServerAddress;
                Settings.Default.VideoServerPort    = VideoServerPort.GetValueOrDefault();
                if (!VideoServerAutomatic)
                {
                    changed.Add("VideoServerAddress");
                }
            }
            if (BitrateAutomatic != Settings.Default.BitrateAutomatic)
            {
                Settings.Default.BitrateAutomatic = BitrateAutomatic;
                changed.Add("BitrateAutomatic");
            }
            if (Bitrate != Settings.Default.Bitrate)
            {
                Settings.Default.Bitrate = Bitrate.GetValueOrDefault();
                if (!BitrateAutomatic)
                {
                    changed.Add("Bitrate");
                }
            }
            if (HardwareDecodingEnable != Settings.Default.HardwareDecodingEnable)
            {
                Settings.Default.HardwareDecodingEnable = HardwareDecodingEnable;
                changed.Add("HardwareDecodingEnable");
            }

            Settings.Default.Save();
            onSave?.Invoke(changed);
            wnd.Close();
        }
Esempio n. 24
0
        /// <summary>
        /// Streams a given music file. (Renamed from request name "stream")
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="id">Required: Yes; A string which uniquely identifies the file to stream. 
        /// Obtained by calls to getMusicDirectory.</param>
        /// <param name="maxBitRate">Required: No; If specified, the server will attempt to 
        /// limit the bitrate to this value, in kilobits per second.  </param>
        /// <returns></returns>
        public static Stream StreamSong(ISubsonicConnection connection, string id, Bitrate maxBitRate = Bitrate.NoPreference)
        {
            // Reades the id of the song and sets it as a parameter
            Dictionary<string, string> theParameters = new Dictionary<string, string> {{"id", id}};
            if (!maxBitRate.Equals(Bitrate.NoPreference))
            {
                theParameters.Add("maxBitRate", maxBitRate.ToString());
            }

            // Makes the request
            return connection.GetResponseStream("stream", theParameters);
        }
Esempio n. 25
0
 public void Bitrate_Contains_Valid_Value(Bitrate bitrate, int expectedResult)
 {
     Assert.That((int)bitrate, Is.EqualTo(expectedResult));
 }
Esempio n. 26
0
 internal static extern Error sp_session_preferred_offline_bitrate(IntPtr sessionPtr, Bitrate bitrate, bool allowResync);
Esempio n. 27
0
 internal static extern Error sp_session_preferred_bitrate(IntPtr sessionPtr, Bitrate bitrate);
Esempio n. 28
0
        public string Capture(string inputFile, int durationInSeconds, AudioEncoder audioEncoder, Bitrate audioBitrate, string outputFile)
        {
            var arguments = "-i " + "\"" + inputFile + "\"" +
                            " -c copy" +
                            " -t " + durationInSeconds +
                            _arguments.GetValue(audioEncoder.ToString()) +
                            _arguments.GetValue(audioBitrate.ToString()) +
                            " -y " + "\"" + outputFile + "\"";

            return(arguments);
        }
Esempio n. 29
0
        public ISession SetPreferredBitrate(Bitrate bitrate)
        {
            AssertHandle();

            lock (Spotify.Mutex)
            {
                Spotify.sp_session_preferred_bitrate(Handle, bitrate);
            }

            return this;
        }
Esempio n. 30
0
        public ISession SetPreferredOfflineBitrate(Bitrate bitrate, bool resync)
        {
            AssertHandle();

            lock (Spotify.Mutex)
            {
                Spotify.sp_session_preferred_offline_bitrate(Handle, bitrate, resync);
            }

            return this;
        }
Esempio n. 31
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     return(Bitrate.GetHashCode());
 }
Esempio n. 32
0
 public void Bitrate_Contains_Valid_Value(Bitrate bitrate, int expectedResult)
 {
     Assert.That((int)bitrate, Is.EqualTo(expectedResult));
 }