Exemple #1
0
        /**
        // \fn public bool UpdateTranscoder(WebradioTranscoder transcoder, bool debug, int webradioId)
        //
        // \brief Updates the transcoder.
        //
        // \author Simon Menetrey
        // \date 26.05.2014
        //
        // \param transcoder The transcoder.
        // \param debug      true to debug.
        // \param webradioId Identifier for the webradio.
        //
        // \return true if it succeeds, false if it fails.
        **/
        public bool UpdateTranscoder(WebradioTranscoder transcoder, bool debug, int webradioId)
        {
            try
            {
                bool wasRunning = false;
                if (transcoder.IsRunning())
                {
                    wasRunning = true;
                    transcoder.Process.Kill();
                }

                this.Bdd.UpdateTranscoder(transcoder);
                transcoder.GenerateConfigFile(this.Webradios[webradioId].Playlists);
                if (wasRunning)
                    transcoder.Start(debug);
                this.UpdateObservers(webradioId);
                return true;
            }
            catch
            {
                return false;
            }
        }
Exemple #2
0
        /**
        // \fn public bool DeleteTranscoder(WebradioTranscoder transcoder, int webradioId)
        //
        // \brief Deletes the transcoder.
        //
        // \author Simon Menetrey
        // \date 26.05.2014
        //
        // \param transcoder The transcoder.
        // \param webradioId Identifier for the webradio.
        //
        // \return true if it succeeds, false if it fails.
        **/
        public bool DeleteTranscoder(WebradioTranscoder transcoder, int webradioId)
        {
            if (transcoder.IsRunning())
                transcoder.Stop();

            if (this.Bdd.DeleteTranscoder(transcoder.Id))
            {
                System.IO.File.Delete(transcoder.ConfigFilename);
                if (System.IO.File.Exists(transcoder.LogFilename))
                    System.IO.File.Delete(transcoder.LogFilename);
                this.Webradios[webradioId].Transcoders.Remove(transcoder);
                this.UpdateObservers(webradioId);
                return true;
            }
            else
                return false;
        }
Exemple #3
0
 /**
 // \fn public bool TranscoderCapture(bool active, string device, WebradioTranscoder transcoder, int webradioId)
 //
 // \brief Transcoder capture set.
 //
 // \author Simon Menetrey
 // \date 26.05.2014
 //
 // \param active     true to active.
 // \param device     The device.
 // \param transcoder The transcoder.
 // \param webradioId Identifier for the webradio.
 //
 // \return true if it succeeds, false if it fails.
 **/
 public bool TranscoderCapture(bool active, string device, WebradioTranscoder transcoder, int webradioId)
 {
     try
     {
         transcoder.SetCaptureMode(active, device);
         this.UpdateObservers(webradioId);
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemple #4
0
 /**
 // \fn public bool TranscoderNextTrack(WebradioTranscoder transcoder)
 //
 // \brief Transcoder goes next track.
 //
 // \author Simon Menetrey
 // \date 26.05.2014
 //
 // \param transcoder The transcoder.
 //
 // \return true if it succeeds, false if it fails.
 **/
 public bool TranscoderNextTrack(WebradioTranscoder transcoder)
 {
     try
     {
         transcoder.NextTrack();
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemple #5
0
        /**
        // \fn public bool StartTranscoder(WebradioTranscoder transcoder, bool debug, int webradioId)
        //
        // \brief Starts a transcoder.
        //
        // \author Simon Menetrey
        // \date 26.05.2014
        //
        // \param transcoder The transcoder.
        // \param debug      true to debug.
        // \param webradioId Identifier for the webradio.
        //
        // \return true if it succeeds, false if it fails.
        **/
        public bool StartTranscoder(WebradioTranscoder transcoder, bool debug, int webradioId)
        {
            try
            {
                if (transcoder.Start(debug))
                {
                    this.ActiveTranscoders.Add(transcoder);
                    UpdateObservers(webradioId);
                    return true;
                }
                else
                    return false;

            }
            catch
            {
                return false;
            }
        }
Exemple #6
0
 /**
 // \fn public bool StopTranscoder(WebradioTranscoder transcoder, int webradioId)
 //
 // \brief Stops a transcoder.
 //
 // \author Simon Menetrey
 // \date 26.05.2014
 //
 // \param transcoder The transcoder.
 // \param webradioId Identifier for the webradio.
 //
 // \return true if it succeeds, false if it fails.
 **/
 public bool StopTranscoder(WebradioTranscoder transcoder, int webradioId)
 {
     try
     {
         if (transcoder.Stop())
         {
             this.ActiveTranscoders.Remove(transcoder);
             this.Webradios[webradioId].Calendar.GenerateConfigFile();
             this.UpdateObservers(webradioId);
             return true;
         }
         else
             return false;
     }
     catch
     {
         return false;
     }
 }
 /**
 // \fn public bool TranscoderNextTrack(WebradioTranscoder transcoder)
 //
 // \brief Transcoder next track.
 //
 // \author Simon Menetrey
 // \date 23.05.2014
 //
 // \param transcoder The transcoder.
 //
 // \return true if it succeeds, false if it fails.
 **/
 public bool TranscoderNextTrack(WebradioTranscoder transcoder)
 {
     return this.Model.TranscoderNextTrack(transcoder);
 }
 /**
 // \fn public bool UpdateTranscoder(WebradioTranscoder transcoder, bool debug, int webradioId)
 //
 // \brief Updates the transcoder.
 //
 // \author Simon Menetrey
 // \date 23.05.2014
 //
 // \param transcoder The transcoder.
 // \param debug      Debug or not.
 // \param webradioId Identifier of the webradio.
 //
 // \return true if it succeeds, false if it fails.
 **/
 public bool UpdateTranscoder(WebradioTranscoder transcoder, bool debug, int webradioId)
 {
     return this.Model.UpdateTranscoder(transcoder, debug, webradioId);
 }
 /**
 // \fn public bool StopTranscoder(WebradioTranscoder transcoder, int webradioId)
 //
 // \brief Stops a transcoder.
 //
 // \author Simon Menetrey
 // \date 23.05.2014
 //
 // \param transcoder The transcoder.
 // \param webradioId Identifier of the webradio.
 //
 // \return true if it succeeds, false if it fails.
 **/
 public bool StopTranscoder(WebradioTranscoder transcoder, int webradioId)
 {
     return this.Model.StopTranscoder(transcoder,webradioId);
 }
 /**
 // \fn public bool TranscoderCapture(bool active, string device, WebradioTranscoder transcoder,int webradioId)
 //
 // \brief Transcoder capture mode set.
 //
 // \author Simon Menetrey
 // \date 23.05.2014
 //
 // \param active     true to active.
 // \param device     The device's name.
 // \param transcoder The transcoder.
 // \param webradioId Identifier of the webradio.
 //
 // \return true if it succeeds, false if it fails.
 **/
 public bool TranscoderCapture(bool active, string device, WebradioTranscoder transcoder,int webradioId)
 {
     return this.Model.TranscoderCapture(active, device, transcoder, webradioId);
 }
 /**
 // \fn public bool StartTranscoder(WebradioTranscoder transcoder,bool debug, int webradioId)
 //
 // \brief Starts a transcoder.
 //
 // \author Simon Menetrey
 // \date 23.05.2014
 //
 // \param transcoder The transcoder.
 // \param debug      Debug or not.
 // \param webradioId Identifier of the webradio.
 //
 // \return true if it succeeds, false if it fails.
 **/
 public bool StartTranscoder(WebradioTranscoder transcoder,bool debug, int webradioId)
 {
     return this.Model.StartTranscoder(transcoder, debug, webradioId);
 }
 /**
 // \fn public bool DeleteTranscoder(WebradioTranscoder transcoder, int webradioId)
 //
 // \brief Deletes the transcoder.
 //
 // \author Simon Menetrey
 // \date 23.05.2014
 //
 // \param transcoder The transcoder.
 // \param webradioId Identifier of the webradio.
 //
 // \return true if it succeeds, false if it fails.
 **/
 public bool DeleteTranscoder(WebradioTranscoder transcoder, int webradioId)
 {
     return this.Model.DeleteTranscoder(transcoder, webradioId);
 }
Exemple #13
0
        /**
        // \fn public int AddTranscoder(WebradioTranscoder transcoder, int webradioId)
        //
        // \brief Adds a transcoder to a webradio.
        //
        // \author Simon Menetrey
        // \date 26.05.2014
        //
        // \param transcoder The transcoder.
        // \param webradioId Identifier for the webradio.
        //
        // \return The new transcoder's id.
        **/
        public int AddTranscoder(WebradioTranscoder transcoder, int webradioId)
        {
            if (this.TranscoderExist(transcoder.Name, webradioId))
                return ERROR;
            try
            {
                Dictionary<string, string> data = new Dictionary<string, string>();
                data.Add("webradioid", webradioId.ToString());
                data.Add("streamtypeid", ((int)transcoder.StreamType).ToString());
                data.Add("bitrate", transcoder.Birate.ToString());
                data.Add("samplerate", transcoder.SampleRate.ToString());
                data.Add("name", transcoder.Name);
                data.Add("url", transcoder.Url);
                data.Add("port", transcoder.Port.ToString());
                data.Add("adminport", transcoder.AdminPort.ToString());
                data.Add("ip", transcoder.Ip.ToString());
                data.Add("password", transcoder.Password);
                data.Add("configfilename", transcoder.ConfigFilename);
                data.Add("logfilename", transcoder.LogFilename);
                this.Controls.Insert("ttranscoder", data);

                SQLiteDataReader reader = this.Controls.ExecuteDataReader("SELECT id FROM ttranscoder WHERE webradioid = " + webradioId.ToString() + " AND name = '" + transcoder.Name + "'");
                reader.Read();
                int id = int.Parse(reader["id"].ToString());
                reader.Close();
                data.Clear();
                data.Add("configfilename", transcoder.ConfigFilename + id.ToString() + ".config");
                data.Add("logfilename", transcoder.LogFilename + "/" + id.ToString() + ".log");
                this.Controls.Update("ttranscoder", data, "webradioid = " + webradioId.ToString() + " AND name = '" + transcoder.Name + "'");
                return id;
            }
            catch
            {
                return ERROR;
            }
        }
Exemple #14
0
        /**
        // \fn public bool UpdateTranscoder(WebradioTranscoder transcoder)
        //
        // \brief Updates the transcoder with transcoder param's values.
        //
        // \author Simon Menetrey
        // \date 26.05.2014
        //
        // \param transcoder The transcoder.
        //
        // \return true if it succeeds, false if it fails.
        **/
        public bool UpdateTranscoder(WebradioTranscoder transcoder)
        {
            try
            {
                Dictionary<string, string> data = new Dictionary<string, string>();
                data.Add("streamtypeid", ((int)transcoder.StreamType).ToString());
                data.Add("bitrate", transcoder.Birate.ToString());
                data.Add("samplerate", transcoder.SampleRate.ToString());
                data.Add("name", transcoder.Name);
                data.Add("url", transcoder.Url);
                data.Add("port", transcoder.Port.ToString());
                data.Add("adminport", transcoder.AdminPort.ToString());
                data.Add("ip", transcoder.Ip.ToString());
                data.Add("password", transcoder.Password);

                this.Controls.Update("ttranscoder", data, "id = " + transcoder.Id.ToString());
                return true;
            }
            catch
            {
                return false;
            }
        }
Exemple #15
0
        /**
        // \fn private void ShowTranscoderInfos(WebradioTranscoder transcoder)
        //
        // \brief Shows the transcoder infos.
        //
        // \author Simon Menetrey
        // \date 23.05.2014
        //
        // \param transcoder The transcoder.
        **/
        private void ShowTranscoderInfos(WebradioTranscoder transcoder)
        {
            if (transcoder != null)
            {
                txbStreamNameEdit.Text = transcoder.Name;
                txbStreamUrlEdit.Text = transcoder.Url;
                txbServerIPEdit.Text = transcoder.Ip.ToString();
                txbServerPasswordEdit.Text = transcoder.Password;
                nudPortEdit.Value = transcoder.Port;
                nudAdminPortEdit.Value = transcoder.AdminPort;
                cmbSampleRateEdit.SelectedItem = transcoder.SampleRate.ToString();
                cmbBitrateEdit.SelectedItem = transcoder.Birate;
                cmbEncoderEdit.SelectedItem = (transcoder.StreamType == StreamType.MP3) ? "MP3" : "AAC+";

                bool running = transcoder.IsRunning();
                lblStatusTranscoder.Text = (running) ? "On" : "Off";
                lblStatusTranscoder.ForeColor = (running) ? Color.Green : Color.Red;
                btnStartTranscoder.Enabled = !running;
                btnStopTranscoder.Enabled = running;
                btnNextTrack.Enabled = running;

                btnStartCapture.Enabled = !transcoder.Capture;
                btnStopCapture.Enabled = transcoder.Capture;

            }
        }