public TvResult Tune(ITvCardHandler tvcard, ref IUser user, IChannel channel, int idChannel, ICardTuneReservationTicket ticket) { TvResult tvResult = TvResult.AllCardsBusy; bool ticketFound; bool isTuningPending = CardReservationHelper.GetIsTuningPending(tvcard, ticket, out ticketFound); try { if (isTuningPending && ticketFound) { tvResult = tvcard.Tuner.Tune(ref user, channel, idChannel); bool succes = (tvResult == TvResult.Succeeded); if (succes) { if (!OnStartTune(user)) { tvResult = TvResult.AllCardsBusy; } } CardReservationHelper.SetCardStateBasedOnTVresult(tvcard, tvResult); } else // state is not tuning, some other card tune session is busy. { } } finally { CardReservationHelper.RemoveTuneTicket(tvcard, ticket, ticketFound); tvcard.Tuner.CleanUpPendingTune(ticket.PendingSubchannel); } return(tvResult); }
public TvResult CardTune(ITvCardHandler tvcard, ref IUser user, IChannel channel, Channel dbChannel, ICardTuneReservationTicket ticket) { TvResult tvResult = TvResult.AllCardsBusy; bool ticketFound; bool isTuningPending = CardReservationHelper.GetIsTuningPending(tvcard, ticket, out ticketFound); try { if (isTuningPending && ticketFound) { user.IsFreeToAir = ticket.TuningDetail.FreeToAir; Log.Debug("CardReservationBase.CardTune: tvcard={0}, user={1}, dbChannel={2}, ticket={3}, tunestate={4}, stopstate={5}, ticketFTA={6}", tvcard.DataBaseCard.IdCard, user.Name, dbChannel.IdChannel, ticket.Id, tvcard.Tuner.CardTuneState, tvcard.Tuner.CardStopState, ticket.TuningDetail.FreeToAir); tvResult = tvcard.Tuner.CardTune(ref user, channel, dbChannel); if (tvResult == TvResult.Succeeded) { if (OnStartCardTune != null) { if (!_tvController.IsTimeShifting(ref user)) { CleanTimeShiftFiles(tvcard.DataBaseCard.TimeShiftFolder, String.Format("live{0}-{1}.ts", user.CardId, user.SubChannel)); } string timeshiftFileName = String.Format(@"{0}\live{1}-{2}.ts", tvcard.DataBaseCard.TimeShiftFolder, user.CardId, user.SubChannel); tvResult = OnStartCardTune(ref user, ref timeshiftFileName); } } CardReservationHelper.SetCardStateBasedOnTVresult(tvcard, tvResult); } else // state is not tuning, some other card tune session is busy. { } } finally { CardReservationHelper.RemoveTuneTicket(tvcard, ticket, ticketFound); tvcard.Tuner.CleanUpPendingTune(ticket.PendingSubchannel); } return(tvResult); }