示例#1
0
        protected override bool OnPrepareRecording(RecorderCallbackProxy proxy, ref string errorMessage)
        {
            DeleteAllMediaPortalSchedules();

            string userName = String.Format(CultureInfo.InvariantCulture, "ArgusTV{0}", Thread.CurrentThread.ManagedThreadId);
            _tve3User = new User(userName, true, _recordOnCard.IdCard);
            _tve3User.IdChannel = _channel.IdChannel;
            _tve3User.SubChannel = -1;

            bool argusIsRecordingOnCard;
            return EnsureCardFree(true, ref errorMessage, out argusIsRecordingOnCard);
        }
示例#2
0
        protected override string OnStartRecording(RecorderCallbackProxy proxy, ref string errorMessage)
        {
            string baseFileName = _suggestedBaseFileName;
            if (String.IsNullOrEmpty(baseFileName))
            {
                baseFileName = FileUtility.BuildRecordingBaseFileName(null, this.RecordingProgram);
            }
            else
            {
                this.UsedSuggestedBaseFileName = true;
            }

            string fileName = Path.Combine(_recordOnCard.RecordingFolder, baseFileName);
            string extension = (_recordOnCard.RecordingFormat == 0) ? ".ts" : ".mpg";
            _tve3RecordingFileName = FileUtility.GetFreeFileName(fileName, extension);
            string tve3RecordingDirectory = Path.GetDirectoryName(_tve3RecordingFileName);
            if (!Directory.Exists(tve3RecordingDirectory))
            {
                Directory.CreateDirectory(tve3RecordingDirectory);
            }

            string uncRecordingFolder = Common.ShareExplorer.GetUncPathForLocalPath(tve3RecordingDirectory);
            if (String.IsNullOrEmpty(uncRecordingFolder))
            {
                errorMessage = "Failed to convert '" + Path.GetDirectoryName(_tve3RecordingFileName) + "' to UNC path, please add required share";
                return null;
            }

            bool argusIsRecordingOnCard;
            if (!EnsureCardFree(false, ref errorMessage, out argusIsRecordingOnCard))
            {
                if (!WaitCardFree(argusIsRecordingOnCard, ref errorMessage))
                {
                    return null;
                }
            }

            IChannel tuningChannel = Utility.FindTuningChannelOnCard(_channel, _recordOnCard.IdCard);
            if (tuningChannel == null)
            {
                errorMessage = "Failed to find tuning details for channel " + _channel.DisplayName;
                return null;
            }

            // Make sure only one thread can tune and start a recording at the same time.
            lock (_startRecordingLock)
            {
                if (TvServerPlugin.TvController_Tune(ref _tve3User, tuningChannel, _channel.IdChannel) != TvResult.Succeeded)
                {
                    errorMessage = "Failed to tune to channel " + _channel.DisplayName;
                    return null;
                }

                if (TvServerPlugin.TvController_StartRecording(ref _tve3User, ref _tve3RecordingFileName) != TvResult.Succeeded)
                {
                    errorMessage = "TV Server failed to start recording on channel " + _channel.DisplayName;
                    return null;
                }
            }

            return Path.Combine(uncRecordingFolder, Path.GetFileName(_tve3RecordingFileName));
        }
示例#3
0
 protected override bool OnStopRecording(RecorderCallbackProxy proxy, bool abort)
 {
     if (_tve3User != null)
     {
         if (StopMediaPortalRecording(_tve3User))
         {
             _tve3User = null;
             return true;
         }
     }
     return false;
 }