Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // this whole page probably qualifies for The Daily WTF, but I'm not a ASP.NET coder and I don't have enough time to learn it. Suggestions and patches welcome.
            if (!Authentication.authenticate(HttpContext.Current))
                return;

            Configuration config = new Configuration();
            MediaStream remoteControl = new MediaStream();
            SetupStreamTable(remoteControl, config);
            SetupRecordingTable(remoteControl, config);

            LogPath.Text = Log.LogPath;
            Config.Text = config.ConfigPath;
            TranscoderLogPath.Text = System.IO.Path.Combine(config.BasePath, "transcoderlogs");
        }
Пример #2
0
        private string GetRecordingPlayList(MediaStream remoteControl, Configuration config, int transcoderId, int recordingId)
        {
            StringBuilder builder = new StringBuilder();
            foreach (Recording rec in remoteControl.GetRecordings()) {
                if (recordingId != 0 && rec.Id != recordingId)
                    continue;

                foreach (Transcoder transcoder in remoteControl.GetTranscoders()) {
                    // show all transcoders, except when transcoderId is given
                    if (transcoderId != 0 && transcoder.Id != transcoderId)
                        continue;
                    string name = rec.Title + " (" + rec.StartTime.ToShortDateString() + " " + rec.StartTime.ToShortTimeString() +
                        (transcoderId == 0 ? ", " + transcoder.Name + ")" : ")");
                    string streamurl = remoteControl.GetTranscodedRecordingStreamUrl(rec.Id, config.Username, config.Password, transcoder.Id);
                    WriteEntry(builder, name, streamurl);
                }
            }

            return builder.ToString();
        }
Пример #3
0
        private string GetChannelPlayList(MediaStream remoteControl, Configuration config, int transcoderId, int channelId)
        {
            StringBuilder builder = new StringBuilder();
            foreach (Channel channel in remoteControl.GetChannels()) {
                // show all channels, except when channelId is given
                if (channelId != 0 && channel.IdChannel != channelId)
                    continue;

                foreach (Transcoder transcoder in remoteControl.GetTranscoders()) {
                    // show all transcoders, except when transcoderId is given
                    if (transcoderId != 0 && transcoder.Id != transcoderId)
                        continue;
                    string name = channel.Name + (transcoderId == 0 ? " (" + transcoder.Name + ")" : "");
                    string streamurl = remoteControl.GetTranscodedTvStreamUrl(channel.IdChannel, config.Username, config.Password, transcoder.Id);
                    WriteEntry(builder, name, streamurl);
                }
            }

            return builder.ToString();
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Authentication.authenticate(HttpContext.Current))
                return;

            Configuration config = new Configuration();
            MediaStream remoteControl = new MediaStream();
            int transcoderId = 0;
            Int32.TryParse(HttpContext.Current.Request.Params["transcoder"], out transcoderId);
            int channelId = 0;
            Int32.TryParse(HttpContext.Current.Request.Params["channel"], out channelId);
            int recordingId = 0;
            Int32.TryParse(HttpContext.Current.Request.Params["recording"], out recordingId);

            Response.ContentType = "audio/x-mpegurl";
            Response.Write("#EXTM3U\r\n");
            if(recordingId == 0) {
                Response.Write(GetChannelPlayList(remoteControl, config, transcoderId, channelId));
            } else {
                Response.Write(GetRecordingPlayList(remoteControl, config, transcoderId, recordingId));
            }
            Response.End();
        }
Пример #5
0
        private void SetupRecordingTable(MediaStream remoteControl, Configuration config)
        {
            // header
            TableHeaderRow hrow = new TableHeaderRow();
            TableHeaderCell dcell = new TableHeaderCell();
            dcell.Text = "Date";
            hrow.Cells.Add(dcell);
            TableHeaderCell tcell = new TableHeaderCell();
            tcell.Text = "Title";
            hrow.Cells.Add(tcell);
            foreach (Transcoder transcoder in remoteControl.GetTranscoders()) {
                TableHeaderCell ccell = new TableHeaderCell();
                ccell.Text = transcoder.Name.Replace(",", ",<br />");
                hrow.Cells.Add(ccell);
            }
            RecordingTable.Rows.Add(hrow);

            foreach (Recording rec in remoteControl.GetRecordings()) {
                // base cells
                TableRow row = new TableRow();
                TableCell date = new TableCell();
                date.Text = rec.StartTime.ToShortDateString() + " " + rec.StartTime.ToShortTimeString();
                row.Cells.Add(date);
                TableCell title = new TableCell();
                title.Text = rec.Title;
                row.Cells.Add(title);

                // all transcoders
                foreach (Transcoder transcoder in remoteControl.GetTranscoders()) {
                    TableCell item = new TableCell();
                    item.Text = createCellContents(remoteControl.GetTranscodedRecordingStreamUrl(rec.Id, config.Username, config.Password, transcoder.Id), "recording", rec.Id.ToString(), transcoder);
                    row.Cells.Add(item);
                }
                RecordingTable.Rows.Add(row);
            }
        }
Пример #6
0
        private void SetupStreamTable(MediaStream remoteControl, Configuration config)
        {
            // header row
            TableHeaderRow hrow = new TableHeaderRow();
            TableHeaderCell cell = new TableHeaderCell();
            cell.Text = "Channel";
            hrow.Cells.Add(cell);
            foreach (Transcoder transcoder in remoteControl.GetTranscoders()) {
                TableHeaderCell tcell = new TableHeaderCell();
                tcell.Text = transcoder.Name.Replace(",", ",<br />");
                hrow.Cells.Add(tcell);
            }
            StreamTable.Rows.Add(hrow);

            // link to the playlist
            TableRow prow = new TableRow();
            prow.Cells.Add(new TableCell());
            foreach (Transcoder transcoder in remoteControl.GetTranscoders()) {
                TableCell pcell = new TableCell();
                HyperLink link = new HyperLink();
                link.NavigateUrl = "Playlist.aspx?transcoder=" + transcoder.Id.ToString();
                link.Text = "Playlist";
                pcell.Controls.Add(link);
                prow.Cells.Add(pcell);
            }
            StreamTable.Rows.Add(prow);

            foreach (Channel channel in remoteControl.GetChannels()) {
                // channel name header cell
                TableRow row = new TableRow();
                TableCell title = new TableCell();
                title.Text = channel.DisplayName;
                row.Cells.Add(title);

                // all transcoders
                foreach (Transcoder transcoder in remoteControl.GetTranscoders()) {
                    TableCell item = new TableCell();
                    item.Text = createCellContents(remoteControl.GetTranscodedTvStreamUrl(channel.IdChannel, config.Username, config.Password, transcoder.Id), "channel", channel.IdChannel.ToString(), transcoder);
                    row.Cells.Add(item);
                }
                StreamTable.Rows.Add(row);
            }
        }