public static TvController_Tune ( IUser &user, IChannel channel, int idChannel ) : TvResult | ||
user | IUser | |
channel | IChannel | |
idChannel | int | |
return | TvResult |
private LiveStreamResult StartTimeShifting(Channel channel, TvDatabase.Card card, TvDatabase.Channel mpChannel, ref IUser tve3User, ref LiveStream liveStream) { IChannel tuningChannel = Utility.FindTuningChannelOnCard(mpChannel, card.IdCard); if (tuningChannel != null) { if (TvServerPlugin.TvController_Tune(ref tve3User, tuningChannel, mpChannel.IdChannel) == TvResult.Succeeded) { string timeshiftFileName = Path.Combine(card.TimeShiftFolder, String.Format(CultureInfo.InvariantCulture, @"live{0}-{1}", tve3User.CardId, tve3User.SubChannel)); switch (TvServerPlugin.TvController_StartTimeShifting(ref tve3User, ref timeshiftFileName)) { case TvResult.Succeeded: if (liveStream == null) { string rtspUrl = TvServerPlugin.TvController_GetStreamingUrl(tve3User); string tsBufferFile = GetTsBufferFile(tve3User); liveStream = new LiveStream(channel, rtspUrl); liveStream.TimeshiftFile = tsBufferFile; #if USE_ARGUS_RTSP string rtspUrlSuffix = String.Format(_rtspUrlSuffixFormat, tve3User.CardId, tve3User.SubChannel); liveStream.RtspUrl = StartRtspStream(tsBufferFile, rtspUrlSuffix); #endif } liveStream.Channel = channel; liveStream.CardId = tve3User.CardId.ToString(CultureInfo.InvariantCulture); liveStream.StreamLastAliveTimeUtc = DateTime.UtcNow; lock (_liveStreamsLock) { _liveStreams[liveStream.RtspUrl] = liveStream; _liveStreamUsers[liveStream.RtspUrl] = tve3User; } return(LiveStreamResult.Succeeded); case TvResult.AllCardsBusy: return(LiveStreamResult.NoFreeCardFound); case TvResult.ChannelIsScrambled: return(LiveStreamResult.IsScrambled); case TvResult.ChannelNotMappedToAnyCard: case TvResult.NoSignalDetected: case TvResult.NoTuningDetails: case TvResult.NoVideoAudioDetected: case TvResult.UnknownChannel: return(LiveStreamResult.ChannelTuneFailed); default: return(LiveStreamResult.UnknownError); } } else { Log(TraceEventType.Error, "StartTimeShifting(): failed to tune to {0}", tuningChannel.Name); return(LiveStreamResult.ChannelTuneFailed); } } else { Log(TraceEventType.Error, "StartTimeShifting(): no tuning channel found for {0}", mpChannel.DisplayName); return(LiveStreamResult.ChannelTuneFailed); } }
protected override string OnStartRecording(RecorderCallbackServiceAgent callbackAgent, ref string errorMessage) { string baseFileName = _suggestedBaseFileName; if (String.IsNullOrEmpty(baseFileName)) { baseFileName = Common.Utility.BuildRecordingBaseFileName(null, this.RecordingProgram); } else { this.UsedSuggestedBaseFileName = true; } string fileName = Path.Combine(_recordOnCard.RecordingFolder, baseFileName); string extension = (_recordOnCard.RecordingFormat == 0) ? ".ts" : ".mpg"; _tve3RecordingFileName = Common.Utility.GetFreeFileName(fileName, extension, 0); 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))); }