コード例 #1
0
ファイル: RecordingsPanel.cs プロジェクト: rob-opsi/ARGUS-TV
        private static void SetRecordingNodeIcon(TreeNode recordingNode)
        {
            RecordingSummary recording = recordingNode.Tag as RecordingSummary;

            if (!recording.IsFileOnDisk)
            {
                recordingNode.ImageIndex = TreeImageIndex.RecordingFileMissing;
            }
            else
            {
                if (recording.RecordingStopTime.HasValue)
                {
                    recordingNode.ImageIndex = recording.IsPartialRecording ? TreeImageIndex.RecordingPartial : TreeImageIndex.Recording;
                }
                else
                {
                    recordingNode.ImageIndex = TreeImageIndex.RecordingInProgress;
                }
                if (!recording.LastWatchedTime.HasValue)
                {
                    recordingNode.ImageIndex += 3;
                }
            }
            recordingNode.SelectedImageIndex = recordingNode.ImageIndex;
        }
コード例 #2
0
ファイル: SearchTest.cs プロジェクト: kudrinyaroslav/ON-0110
        protected RecordingSummary GetRecordingSummary(string stepName)
        {
            RecordingSummary response = null;

            RunStep(() => { response = Client.GetRecordingSummary(); }, stepName);
            return(response);
        }
コード例 #3
0
        public override RecordingSummary GetRecordingSummary()
        {
            RecordingSummary result = new RecordingSummary();

            result.NumberRecordings = 3;

            return(result);
        }
コード例 #4
0
ファイル: RecordingsPanel.cs プロジェクト: rob-opsi/ARGUS-TV
        private static TreeNode AddRecordingNode(System.Collections.IList nodes, RecordingSummary recording, bool addChannelName)
        {
            TreeNode recordingNode = new TreeNode(GetRecordingDisplayText(recording, addChannelName));

            nodes.Add(recordingNode);
            recordingNode.Tag = recording;
            SetRecordingNodeIcon(recordingNode);
            return(recordingNode);
        }
コード例 #5
0
        public void FindRecordingWithMinResultsTest()
        {
            int         testKeepAlive = _searchKeepAlive;
            SearchState state         = SearchState.Completed;
            string      searchToken   = string.Empty;

            RunTest(
                () =>
            {
                string keepAlive = string.Format("PT{0}S", testKeepAlive);

                List <RecordingInformation> currentInfos = null;

                Action <int?> checkAction =
                    new Action <int?>(
                        (minResults) =>
                {
                    SearchScope searchScope = new SearchScope();
                    searchToken             = FindRecordings(searchScope, null, keepAlive);

                    List <RecordingInformation> recordings = GetAllRecordingsSearchResults(searchToken, minResults, null, null, out state);

                    ValidateSearchResult(recordings);

                    currentInfos.AddRange(recordings);
                });

                // Get total number of recordings;
                RecordingSummary summary = GetRecordingSummary();
                int N1 = summary.NumberRecordings;

                List <RecordingInformation> recordings1 = new List <RecordingInformation>();
                currentInfos = recordings1;
                checkAction(N1);

                List <RecordingInformation> recordings2 = new List <RecordingInformation>();
                currentInfos = recordings2;
                checkAction(N1 + 1);

                // compare lists of recordings

                Assert(recordings1.Count == recordings2.Count,
                       "Number of recordings is different for different minResults parameter",
                       "Check that number of recordings is the same");

                CompareLists(recordings1, recordings2);
            },
                () =>
            {
                if (state != SearchState.Completed)
                {
                    // 10000 is 10S from request.
                    // if chaged to "Get from UI", change it in both places
                    ReleaseSearch(searchToken, testKeepAlive * 1000);
                }
            });
        }
コード例 #6
0
ファイル: RecordingsPanel.cs プロジェクト: rob-opsi/ARGUS-TV
        private static string GetRecordingDisplayText(RecordingSummary recording, bool addChannelName)
        {
            StringBuilder programTitle = new StringBuilder(recording.CreateProgramTitle());

            programTitle.Append(" - ");
            if (addChannelName)
            {
                programTitle.Append(recording.ChannelDisplayName).Append(" - ");
            }
            programTitle.Append(FormatDateWithTime(recording.ProgramStartTime, true));
            return(programTitle.ToString());
        }
コード例 #7
0
        public void GetRecordingSummaryTest()
        {
            RunTest(
                () =>
            {
                RecordingSummary summary = GetRecordingSummary();

                Assert(summary.DataUntil >= summary.DataFrom,
                       string.Format("DataUntil ({0}) less than DataFrom ({1})", summary.DataUntil.StdDateTimeToString(), summary.DataFrom.StdDateTimeToString()),
                       "Validate RecordingSummary structure received");
            });
        }
コード例 #8
0
        public string GetRecordingDisplayText(RecordingSummary recording, bool addChannelName)
        {
            StringBuilder programTitle = new StringBuilder(recording.CreateProgramTitle());

            programTitle.Append(" - ");
            if (addChannelName)
            {
                programTitle.Append(recording.ChannelDisplayName).Append(" - ");
            }
            programTitle.AppendFormat("{0:g}", recording.ProgramStartTime);
            return(programTitle.ToString());
        }
コード例 #9
0
        public void FindRecordingWithMaxMatchesTest()
        {
            int         testKeepAlive = _searchKeepAlive;
            SearchState state         = SearchState.Completed;
            string      searchToken   = string.Empty;

            RunTest(
                () =>
            {
                string keepAlive = string.Format("PT{0}S", testKeepAlive);

                RecordingSummary summary = GetRecordingSummary();
                int N1 = summary.NumberRecordings;

                Action <int> checkAction =
                    new Action <int>(
                        (maxMatches) =>
                {
                    SearchScope searchScope = new SearchScope();

                    searchToken = FindRecordings(searchScope, maxMatches, keepAlive);
                    List <RecordingInformation> recordings =
                        GetAllRecordingsSearchResults(searchToken, null, null, null, out state);

                    ValidateSearchResult(recordings);

                    Assert(maxMatches >= recordings.Count,
                           string.Format("Number of recordings found ({0}) is greater than maxMatches search parameter ({1})", recordings.Count, maxMatches),
                           "Check that number of recordings returned is not greater than maxMatches parameter passsed");
                });

                checkAction(1);
                if (N1 > 1)
                {
                    if (N1 > 2)
                    {
                        checkAction(N1 - 1);
                    }
                    checkAction(N1);
                }
            },
                () =>
            {
                if (state != SearchState.Completed)
                {
                    // 10000 is 10S from request.
                    // if chaged to "Get from UI", change it in both places
                    ReleaseSearch(searchToken, testKeepAlive * 1000);
                }
            });
        }
コード例 #10
0
ファイル: RecordingsPanel.cs プロジェクト: rob-opsi/ARGUS-TV
        private List <RecordingSummary> GetSelectedRecordings()
        {
            List <RecordingSummary> selectedRecordings = new List <RecordingSummary>();

            foreach (TreeNode node in _recordingsTreeView.SelectedNodes)
            {
                RecordingSummary recording = node.Tag as RecordingSummary;
                if (recording != null)
                {
                    selectedRecordings.Add(recording);
                }
            }
            return(selectedRecordings);
        }
コード例 #11
0
        public bool AddRecording(RecordingSummary recording)
        {
            string key = GetRecordingKey(recording.RecordingFileName);

            if (key != null)
            {
                if (!_allRecordings.ContainsKey(key))
                {
                    _allRecordings[key] = recording;
                    return(true);
                }
            }
            return(false);
        }
コード例 #12
0
 private void AddToExportList(List <RecordingSummary> exportRecordings, TreeNodeCollection nodes)
 {
     foreach (TreeNode node in nodes)
     {
         if (node.StateImageIndex == ThreeStateTreeView.ItemState.Checked)
         {
             RecordingSummary recording = node.Tag as RecordingSummary;
             if (recording != null)
             {
                 exportRecordings.Add(recording);
             }
         }
         AddToExportList(exportRecordings, node.Nodes);
     }
 }
コード例 #13
0
        public bool ContainsRecording(string recordingFileName)
        {
            string key = GetRecordingKey(recordingFileName);

            if (key != null)
            {
                if (_allRecordings.ContainsKey(key))
                {
                    RecordingSummary recording         = _allRecordings[key];
                    string           hostName          = GetHostFromUncPath(recordingFileName);
                    string           recordingHostName = GetHostFromUncPath(recording.RecordingFileName);
                    return(HostsAreEqual(hostName, recordingHostName));
                }
            }
            return(false);
        }
コード例 #14
0
ファイル: RecordingsPanel.cs プロジェクト: rob-opsi/ARGUS-TV
        private void OpenSelectedRecording()
        {
            try
            {
                RecordingSummary recording = GetSelectedRecording();
                if (recording != null)
                {
                    if (Properties.Settings.Default.StreamRecordingsUsingRtsp)
                    {
                        string rtspUrl = null;
                        if (WinFormsUtility.IsVlcInstalled())
                        {
                            rtspUrl = Proxies.ControlService.StartRecordingStream(recording.RecordingFileName).Result;
                        }
                        if (String.IsNullOrEmpty(rtspUrl) ||
                            !WinFormsUtility.RunStreamPlayer(rtspUrl, false))
                        {
                            MessageBox.Show(this, "Failed to start VLC player.", null, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            if (!String.IsNullOrEmpty(rtspUrl))
                            {
                                Proxies.ControlService.StopRecordingStream(rtspUrl).Wait();
                            }
                        }
                    }
                    else if (recording.IsFileOnDisk)
                    {
                        ProcessStartInfo startInfo = new ProcessStartInfo(recording.RecordingFileName);
                        startInfo.WindowStyle     = ProcessWindowStyle.Normal;
                        startInfo.UseShellExecute = true;
                        System.Diagnostics.Process.Start(startInfo);

                        Proxies.ControlService.SetRecordingLastWatched(recording.RecordingFileName).Wait();
                        recording.LastWatchedTime = DateTime.Now;
                        SetRecordingNodeIcon(_recordingsTreeView.SelectedNode);
                    }
                    else
                    {
                        MessageBox.Show(this, "Failed to find recording file.", null, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #15
0
ファイル: RecordingsPanel.cs プロジェクト: rob-opsi/ARGUS-TV
 private void OpenContainingFolder()
 {
     try
     {
         RecordingSummary recording = GetSelectedRecording();
         if (recording != null)
         {
             ProcessStartInfo startInfo = new ProcessStartInfo(Path.GetDirectoryName(recording.RecordingFileName));
             startInfo.WindowStyle     = ProcessWindowStyle.Normal;
             startInfo.UseShellExecute = true;
             System.Diagnostics.Process.Start(startInfo);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #16
0
ファイル: RecordingsPanel.cs プロジェクト: rob-opsi/ARGUS-TV
 private void ResetLastWatched()
 {
     try
     {
         foreach (TreeNode node in _recordingsTreeView.SelectedNodes)
         {
             RecordingSummary recording = node.Tag as RecordingSummary;
             if (recording != null)
             {
                 Proxies.ControlService.SetRecordingLastWatchedPosition(recording.RecordingFileName, null).Wait();
                 recording.LastWatchedTime     = null;
                 recording.LastWatchedPosition = null;
                 SetRecordingNodeIcon(node);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #17
0
ファイル: RecordingsPanel.cs プロジェクト: rob-opsi/ARGUS-TV
        private void ShowRecordingThumbnail()
        {
            try
            {
                if (_recordingsTreeView.SelectedNode != null)
                {
                    RecordingSummary recording = _recordingsTreeView.SelectedNode.Tag as RecordingSummary;
                    if (recording != null)
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        int    width          = MainForm.IsHttpConnection ? 0 : 480;
                        byte[] thumbnailBytes = Proxies.ControlService.GetRecordingThumbnail(recording.RecordingId, width, 0, null, DateTime.MinValue).Result;
                        Cursor.Current = Cursors.Default;

                        if (thumbnailBytes != null &&
                            thumbnailBytes.Length > 0)
                        {
                            using (MemoryStream imageStream = new MemoryStream(thumbnailBytes))
                            {
                                using (ThumbnailPopup popup = new ThumbnailPopup())
                                {
                                    popup.Title          = _recordingsTreeView.SelectedNode.Text;
                                    popup.ThumbnailImage = Image.FromStream(imageStream);
                                    popup.ShowDialog(this);
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show(this, "No thumbnail for this recording.", null, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #18
0
        public static string GetRecordingThumb(RecordingSummary recording, bool createNewThumbIfNotFound, int size, IControlService tvControlAgent)
        {
            string thumb = string.Format("{0}\\{1}{2}", Thumbs.TVRecorded, recording.RecordingId, ".jpg");

            if (Utils.FileExistsInCache(thumb))
            {
                //local thumb
                return(thumb);
            }
            else if (createNewThumbIfNotFound)
            {
                //no local thumb found, ask one from the server and save it
                if (size < 0)
                {
                    size = 0;
                }

                byte[] jpegData = tvControlAgent.GetRecordingThumbnail(recording.RecordingId, size, size, null, recording.RecordingStartTime);
                if (jpegData != null)
                {
                    try
                    {
                        using (System.Drawing.Image img = System.Drawing.Image.FromStream(new MemoryStream(jpegData)))
                        {
                            img.Save(thumb, System.Drawing.Imaging.ImageFormat.Jpeg);
                        }
                    }
                    catch { }
                    jpegData = null;

                    if (Utils.FileExistsInCache(thumb))
                    {
                        return(thumb);
                    }
                }
            }
            return(string.Empty);
        }
コード例 #19
0
        public void FindRecordingWithMaxResultsTest()
        {
            int         testKeepAlive = _searchKeepAlive;
            SearchState state         = SearchState.Completed;
            string      searchToken   = string.Empty;

            RunTest(
                () =>
            {
                string keepAlive = string.Format("PT{0}S", testKeepAlive);

                // total number
                RecordingSummary summary = GetRecordingSummary();
                int N1 = summary.NumberRecordings;

                Action <int?> checkAction =
                    new Action <int?>(
                        (maxResults) =>
                {
                    SearchScope searchScope = new SearchScope();
                    searchToken             = FindRecordings(searchScope, null, keepAlive);
                    List <RecordingInformation> recordings = GetAllRecordingsSearchResults(searchToken, null, maxResults, null, out state);

                    ValidateSearchResult(recordings);
                });

                checkAction(1);
                checkAction(N1);
                checkAction(N1 + 1);
            },
                () =>
            {
                if (state != SearchState.Completed)
                {
                    ReleaseSearch(searchToken, testKeepAlive * 1000);
                }
            });
        }
        internal void PlayRecording(int index)
        {
            RecordingSummary recSummary = (RecordingSummary)latestArgusRecordings[index];
            Recording        rec        = null;

            rec = Proxies.ControlService.GetRecordingById(recSummary.RecordingId).Result;

            int jumpToTime = 0;

            if (rec.LastWatchedPosition.HasValue)
            {
                if (rec.LastWatchedPosition.Value > 10)
                {
                    jumpToTime = rec.LastWatchedPosition.Value;
                }
            }
            if (jumpToTime == 0)
            {
                DateTime startTime = DateTime.Now.AddSeconds(-10);
                if (rec.ProgramStartTime < startTime)
                {
                    startTime = rec.ProgramStartTime;
                }
                TimeSpan preRecordSpan = startTime - rec.RecordingStartTime;
                jumpToTime = (int)preRecordSpan.TotalSeconds;
            }


            //send a message to the Argus plugin, to start playing the recording
            //I use this "GUI_MSG_RECORDER_VIEW_CHANNEL" event because it's a save one to use(no other components in mediaportal listen to this event)
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_RECORDER_VIEW_CHANNEL, 0, 0, 0, 0, 0, null);

            msg.Object = rec;
            msg.Param2 = jumpToTime;
            msg.Param1 = 5577; //just some indentification
            GUIGraphicsContext.SendMessage(msg);
            msg = null;
        }
コード例 #21
0
        internal StepType GetRecordingSummaryTest(out RecordingSummary target, out SoapException ex, out int Timeout)
        {
            StepType res = StepType.None;

            Timeout = 0;
            ex      = null;
            target  = null;
            bool   passed     = true;
            string logMessage = "";

            string tmpCommandName   = "GetRecordingSummary";
            int    tmpCommandNumber = GetRecordingSummary;

            //Get step list for command
            XmlNodeList m_testList = TestCommon.GetStepsForCommand(ServiceName + "." + tmpCommandName);

            if (m_testList.Count != 0)
            {
                //Get current step
                XmlNode test = m_testList[CommandCount[tmpCommandNumber]];

                //Generate response
                object targetObj;
                res    = TestCommon.GenerateResponseStepTypeNotVoid(test, out targetObj, out ex, out Timeout, typeof(RecordingSummary));
                target = (RecordingSummary)targetObj;

                //Log message
                TestCommon.writeToLog(test, logMessage, passed);

                Increment(m_testList.Count, tmpCommandNumber);
            }
            else
            {
                throw new SoapException("NO " + ServiceName + "." + tmpCommandName + " COMMAND IN SCRIPT", SoapException.ServerFaultCode);
            }
            return(res);
        }
コード例 #22
0
ファイル: RecordingsPanel.cs プロジェクト: rob-opsi/ARGUS-TV
 private bool RemoveRecordingNode(TreeNodeCollection nodes, RecordingSummary recording)
 {
     foreach (TreeNode node in nodes)
     {
         if (node.Nodes.Count > 0)
         {
             if (RemoveRecordingNode(node.Nodes, recording))
             {
                 return(true);
             }
         }
         if (node.Tag == recording)
         {
             TreeNode parentNode = node.Parent;
             node.Remove();
             if (parentNode != null)
             {
                 if (parentNode.Nodes.Count == 0)
                 {
                     parentNode.Remove();
                 }
                 else
                 {
                     RecordingGroup group = parentNode.Tag as RecordingGroup;
                     if (group != null)
                     {
                         group.RecordingsCount--;
                         parentNode.Text = GetGroupDisplayText(group);
                     }
                 }
             }
             return(true);
         }
     }
     return(false);
 }
コード例 #23
0
 public bool ContainsRecording(RecordingSummary recording)
 {
     return(ContainsRecording(recording.RecordingFileName));
 }
コード例 #24
0
        private void ExportRecording(RecordingSummary recording)
        {
            Recording metadata = Utility.GetRecordingMetadataFromAds(recording.RecordingFileName);

            string destinationPath = _destinationTextBox.Text;

            if (_createDirectoriesCheckBox.Checked)
            {
                string directoryName = null;

                switch (_directoryNameComboBox.SelectedIndex)
                {
                case DirectoryNameIndex.Title:
                    directoryName = recording.Title;
                    break;

                case DirectoryNameIndex.Schedule:
                    directoryName = recording.ScheduleName;
                    break;

                case DirectoryNameIndex.Channel:
                    directoryName = recording.ChannelDisplayName;
                    break;

                case DirectoryNameIndex.Date:
                    directoryName = String.Format(CultureInfo.CurrentCulture,
                                                  "{0}-{1:00}-{2:00}", recording.ProgramStartTime.Year, recording.ProgramStartTime.Month, recording.ProgramStartTime.Day);
                    break;
                }

                if (!String.IsNullOrEmpty(directoryName))
                {
                    destinationPath = Path.Combine(destinationPath, ArgusTV.Common.Utility.MakeValidFileName(directoryName));
                    if (!Directory.Exists(destinationPath))
                    {
                        Directory.CreateDirectory(destinationPath);
                    }
                }
            }

            SortedList <long, string> filesToCopy = new SortedList <long, string>();

            string sourceDirectory            = Path.GetDirectoryName(recording.RecordingFileName);
            string sourceNameWithoutExtension = Path.GetFileNameWithoutExtension(recording.RecordingFileName);

            DirectoryInfo dirInfo = new DirectoryInfo(sourceDirectory);

            foreach (FileInfo fileInfo in dirInfo.GetFiles(sourceNameWithoutExtension + "*"))
            {
                long size = fileInfo.Length;
                while (filesToCopy.ContainsKey(size))
                {
                    size++;
                }
                filesToCopy.Add(size, fileInfo.FullName);
            }

            foreach (string fileName in filesToCopy.Values)
            {
                string destinationFileName = Path.Combine(destinationPath, Path.GetFileName(fileName));
                Microsoft.VisualBasic.Devices.Computer computer = new Microsoft.VisualBasic.Devices.Computer();
                computer.FileSystem.CopyFile(fileName, destinationFileName,
                                             Microsoft.VisualBasic.FileIO.UIOption.AllDialogs, Microsoft.VisualBasic.FileIO.UICancelOption.ThrowException);
            }

            string destinationRecordingFileName = Path.Combine(destinationPath, Path.GetFileName(recording.RecordingFileName));

            if (_exportMetadataCheckBox.Checked ||
                (metadata != null && !CheckMetadataCopied(destinationRecordingFileName)))
            {
                metadata = Utility.GetRecordingMetadata(recording.RecordingFileName);
                if (metadata == null)
                {
                    metadata = Proxies.ControlService.GetRecordingById(recording.RecordingId).Result;
                }
                if (metadata != null)
                {
                    Utility.WriteRecordingMetadataFile(destinationRecordingFileName, metadata);
                }
            }
        }
コード例 #25
0
 public MissingRecording(RecordingSummary recording, bool deleteRecording)
 {
     _recording       = recording;
     _deleteRecording = deleteRecording;
 }