Exemple #1
0
        /// <summary>
        /// Tunes the specified channel.
        /// </summary>
        /// <param name="subChannelId">The sub channel id</param>
        /// <param name="channel">The channel.</param>
        /// <returns></returns>
        public override ITvSubChannel Tune(int subChannelId, IChannel channel)
        {
            Log.Log.WriteFile("dvbt: Tune:{0}", channel);
            try
            {
                if (!BeforeTune(channel, ref subChannelId))
                {
                    return(null);
                }

                ITvSubChannel ch = base.Tune(subChannelId, channel);

                Log.Log.Info("dvbt: tune: Graph running. Returning {0}", ch.ToString());
                return(ch);
            }
            catch (TvExceptionTuneCancelled)
            {
                throw;
            }
            catch (TvExceptionNoSignal)
            {
                throw;
            }
            catch (TvExceptionNoPMT)
            {
                throw;
            }
            catch (Exception ex)
            {
                Log.Log.Write(ex);
                throw;
            }
        }
Exemple #2
0
        /// <summary>
        /// Tune to channel
        /// </summary>
        /// <param name="subChannelId"></param>
        /// <param name="channel"></param>
        /// <returns></returns>
        private ITvSubChannel DoTune(int subChannelId, IChannel channel, bool ignorePMT)
        {
            Log.Log.WriteFile("dvbip:  Tune:{0}", channel);
            ITvSubChannel ch = null;

            try
            {
                DVBIPChannel dvbipChannel = channel as DVBIPChannel;
                if (dvbipChannel == null)
                {
                    Log.Log.WriteFile("Channel is not a IP TV channel!!! {0}", channel.GetType().ToString());
                    return(null);
                }

                Log.Log.Info("dvbip: tune: Assigning oldChannel");
                DVBIPChannel oldChannel = CurrentChannel as DVBIPChannel;
                if (CurrentChannel != null)
                {
                    //@FIX this fails for back-2-back recordings
                    //if (oldChannel.Equals(channel)) return _mapSubChannels[0];
                    Log.Log.Info("dvbip: tune: Current Channel != null {0}", CurrentChannel.ToString());
                }
                else
                {
                    Log.Log.Info("dvbip: tune: Current channel is null");
                }
                if (_graphState == GraphState.Idle)
                {
                    Log.Log.Info("dvbip: tune: Building graph");
                    BuildGraph();
                    if (_mapSubChannels.ContainsKey(subChannelId) == false)
                    {
                        subChannelId = GetNewSubChannel(channel);
                    }
                }
                else
                {
                    Log.Log.Info("dvbip: tune: Graph is running");
                }

                //_pmtPid = -1;

                Log.Log.Info("dvb:Submiting tunerequest Channel:{0} subChannel:{1} ", channel.Name, subChannelId);
                if (_mapSubChannels.ContainsKey(subChannelId) == false)
                {
                    Log.Log.Info("dvb:Getting new subchannel");
                    subChannelId = GetNewSubChannel(channel);
                }
                else
                {
                }
                Log.Log.Info("dvb:Submit tunerequest size:{0} new:{1}", _mapSubChannels.Count, subChannelId);
                _mapSubChannels[subChannelId].CurrentChannel = channel;

                _mapSubChannels[subChannelId].OnBeforeTune();

                if (_interfaceEpgGrabber != null)
                {
                    _interfaceEpgGrabber.Reset();
                }

                Log.Log.WriteFile("dvb:Submit tunerequest calling put_TuneRequest");
                _lastSignalUpdate = DateTime.MinValue;

                _mapSubChannels[subChannelId].OnAfterTune();
                ch = _mapSubChannels[subChannelId];
                Log.Log.Info("dvbip: tune: Running graph for channel {0}", ch.ToString());
                Log.Log.Info("dvbip: tune: SubChannel {0}", ch.SubChannelId);

                try
                {
                    RunGraph(ch.SubChannelId, dvbipChannel.Url);
                }
                catch (TvExceptionNoPMT)
                {
                    if (!ignorePMT)
                    {
                        throw;
                    }
                }

                Log.Log.Info("dvbip: tune: Graph running. Returning {0}", ch.ToString());
                return(ch);
            }
            catch (Exception ex)
            {
                if (ch != null)
                {
                    FreeSubChannel(ch.SubChannelId);
                }
                Log.Log.Write(ex);
                throw;
            }
            //unreachable return null;
        }