Example #1
0
        void FChannelInfo_OnInit(object sender, EventArgs e)
        {
            string msg;

            this.FEncoder = this.GetEncoder(this.FChannelInfo.BassHandle.Value, out msg);

            if (this.FEncoder != null)
            {
                this.FEncoder.Start(null, IntPtr.Zero, true);
            }

            double dorecord;

            this.FPinInRecord.GetValue(0, out dorecord);
            if (dorecord >= 0.5)
            {
                this.FEncoder.Pause(false);
            }
            else
            {
                this.FEncoder.Pause(true);
            }

            this.FPinOutStatus.SetString(0, msg);
        }
Example #2
0
 public ICEcast(IBaseEncoder encoder, bool useBASS) : base(encoder, useBASS)
 {
     if (encoder.EncoderType != BASSChannelType.BASS_CTYPE_STREAM_OGG && encoder.EncoderType != BASSChannelType.BASS_CTYPE_STREAM_MP3 && encoder.EncoderType != BASSChannelType.BASS_CTYPE_STREAM_AAC && encoder.EncoderType != BASSChannelType.BASS_CTYPE_STREAM_FLAC_OGG && encoder.EncoderType != BASSChannelType.BASS_CTYPE_STREAM_OPUS)
     {
         throw new ArgumentException("Invalid EncoderType (only OGG, MP3, AAC, FLAC_OGG and OPUS is supported)!");
     }
 }
Example #3
0
 public SHOUTcast(IBaseEncoder encoder, bool useBASS) : base(encoder, useBASS)
 {
     if (encoder.EncoderType != BASSChannelType.BASS_CTYPE_STREAM_MP3 && encoder.EncoderType != BASSChannelType.BASS_CTYPE_STREAM_AAC && encoder.EncoderType != BASSChannelType.BASS_CTYPE_STREAM_WAV)
     {
         throw new ArgumentException("Invalid EncoderType (only MP3 and AAC is supported)!");
     }
 }
Example #4
0
        public void Evaluate(int SpreadMax)
        {
            bool resetencoder = false;

            if (this.FPinInFilename.PinIsChanged || this.FPinInHandle.PinIsChanged)
            {
                this.StopEncoder();
                double dhandle;
                this.FPinInFilename.GetString(0, out this.FFilename);

                this.FPinInHandle.GetValue(0, out dhandle);

                int ihandle = Convert.ToInt32(dhandle);
                if (this.FManager.Exists(ihandle))
                {
                    this.FChannelInfo = this.FManager.GetChannel(ihandle);
                    if (this.FChannelInfo.BassHandle.HasValue)
                    {
                        string msg;
                        this.FEncoder = this.GetEncoder(this.FChannelInfo.BassHandle.Value, out msg);

                        if (this.FEncoder != null)
                        {
                            this.FEncoder.Start(null, IntPtr.Zero, true);
                            resetencoder = true;
                            this.FPinOutStatus.SetString(0, msg);
                        }
                    }
                    else
                    {
                        this.FChannelInfo.OnInit += new EventHandler(FChannelInfo_OnInit);
                        this.FPinOutStatus.SetString(0, "Channel not initialized");
                    }
                }
                else
                {
                    this.FChannelInfo = null;
                    this.FEncoder     = null;
                }
            }

            if ((this.FEncoder != null && this.FPinInRecord.PinIsChanged) || (resetencoder))
            {
                double dorecord;
                this.FPinInRecord.GetValue(0, out dorecord);
                if (dorecord >= 0.5)
                {
                    this.FEncoder.Pause(false);
                }
                else
                {
                    this.FEncoder.Pause(true);
                }
            }
        }
Example #5
0
 public StreamingServer(IBaseEncoder encoder, bool useBASS)
 {
     this._encoder = encoder;
     this._useBASS = useBASS;
     if (this._encoder == null)
     {
         throw new ArgumentNullException("encoder", "No encoder specified!");
     }
     if (!this._encoder.EncoderExists)
     {
         throw new ArgumentException("Encoder does NOT exist!");
     }
 }
Example #6
0
 public WMAcast(IBaseEncoder encoder) : base(encoder, true)
 {
     if (encoder.EncoderType != BASSChannelType.BASS_CTYPE_STREAM_WMA)
     {
         throw new ArgumentException("Invalid EncoderType (only WMA is supported)!");
     }
     this._wmaEncoder = (encoder as EncoderWMA);
     if (this._wmaEncoder == null)
     {
         throw new ArgumentNullException("Invalid Encoder used, encoder must be of type EncoderWMA!");
     }
     this._wmaEncoder.WMA_UseNetwork = true;
     this._wmaEncoder.InputFile      = null;
 }
Example #7
0
 /// <summary>
 /// Stop logging
 /// </summary>
 public void Stop()
 {
     // Stop timer
     timer.Stop();
     // Stop encoder
     encoder.Stop();
     encoder = null;
     CurrentStatus = Status.NOTLOGGING;
 }
Example #8
0
 /// <summary>
 /// Start logging
 /// </summary>
 public void Start()
 {
     EncoderLAME lameEncoder = new EncoderLAME(recordingHandle);
     string location;
     // Determine location to save recording to
     if (WeeklyFolders == true) // If option to save into weekly folders is enabled
     {
         CultureInfo cultureInfo = CultureInfo.CurrentCulture; // Get system localisation information
         DayOfWeek firstDay = cultureInfo.DateTimeFormat.FirstDayOfWeek; // Determine first day of the week
         DateTime firstDayInWeek = DateTime.Now.Date; // Set to current date
         // Keep reducing date until the day is the same as the first day of the week
         while (firstDayInWeek.DayOfWeek != firstDay)
         {
             firstDayInWeek = firstDayInWeek.AddDays(-1);
         }
         DayOfWeek lastDay = firstDayInWeek.AddDays(-1).DayOfWeek; // Determine last day of the week
         DateTime lastDayInWeek = DateTime.Now.Date; // Set to current date
         // Keep reducing date until the day is the same as the first day of the week
         while (lastDayInWeek.DayOfWeek != lastDay)
         {
             lastDayInWeek = lastDayInWeek.AddDays(1);
         }
         // Set location
         location = Folder + "\\" + firstDayInWeek.ToString("dd-MM-yy") + " to " + lastDayInWeek.ToString("dd-MM-yy");
     }
     else // If option to save into weekly folders is disabled
     {
         location = Folder;
     }
     // Create location if it does not exist
     if (!Directory.Exists(location))
     {
         Directory.CreateDirectory(location);
     }
     // Set encoder settings
     lameEncoder.InputFile = null; // Set input to Stdout
     lameEncoder.OutputFile = location + "\\Log " + DateTime.Now.ToString("dd-MM-yy HH.mm") + ".mp3"; // Set output file
     lameEncoder.LAME_Bitrate = Bitrate; // Set bitrate
     lameEncoder.LAME_Mode = EncoderLAME.LAMEMode.Default; // Number of channels
     lameEncoder.LAME_TargetSampleRate = (int)EncoderLAME.SAMPLERATE.Hz_44100; // Sample rate
     lameEncoder.LAME_Quality = EncoderLAME.LAMEQuality.Quality; // Encoding quality
     // Set encoder location
     if (IntPtr.Size == 8) // If running in 64 bit
     {
         lameEncoder.EncoderDirectory = "x64";
     }
     else // Else if running in 32 bit
     {
         lameEncoder.EncoderDirectory = "x86";
     }
     if (!lameEncoder.EncoderExists) // If encoder has not been found, throw an exception
     {
         throw new FileNotFoundException("Unable to find encoder");
     }
     // Start encoder
     encoder = lameEncoder;
     encoder.Start(null, IntPtr.Zero, false);
     CurrentStatus = Status.LOGGING;
     // Start timer
     currentHour = DateTime.Now.Hour;
     hourRecordingStarted = currentHour;
     timer.Start();
 }
Example #9
0
 /// <summary>
 /// Stop logging
 /// </summary>
 public void Stop()
 {
     // Stop timer
     timer.Stop();
     // Stop track logging
     if (LogTracks)
     {
         trackTimer.Stop();
     }
     // Stop encoder
     encoder.Stop();
     encoder = null;
     CurrentStatus = Status.NOTLOGGING;
 }