コード例 #1
0
        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>.
        /// </summary>
        /// <param name="obj">The <see cref="T:System.Object"></see> to compare with the current <see cref="T:System.Object"></see>.</param>
        /// <returns>
        /// true if the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>; otherwise, false.
        /// </returns>
        public override bool Equals(object obj)
        {
            DVBAudioStream stream = obj as DVBAudioStream;

            if (stream == null)
            {
                return(false);
            }
            if (_language == stream.Language && _streamType == stream.StreamType && _pid == stream.Pid)
            {
                return(true);
            }
            return(false);
        }
コード例 #2
0
ファイル: TVHome.cs プロジェクト: splatterpop/MediaPortal-1
    private static IAudioStream[] GetStreamsList()
    {
      List<IAudioStream> streamsList = new List<IAudioStream>();
      for (int i = 0; i < g_Player.AudioStreams; i++)
      {
        DVBAudioStream stream = new DVBAudioStream();

        string streamType = g_Player.AudioType(i);

        switch (streamType)
        {
          case "AC3":
            stream.StreamType = AudioStreamType.AC3;
            break;
          case "AC3plus":
            stream.StreamType = AudioStreamType.EAC3;
            break;
          case "Mpeg1":
            stream.StreamType = AudioStreamType.Mpeg1;
            break;
          case "Mpeg2":
            stream.StreamType = AudioStreamType.Mpeg2;
            break;
          case "AAC":
            stream.StreamType = AudioStreamType.AAC;
            break;
          case "LATMAAC":
            stream.StreamType = AudioStreamType.LATMAAC;
            break;
          default:
            stream.StreamType = AudioStreamType.Unknown;
            break;
        }

        stream.Language = g_Player.AudioLanguage(i);
        string[] lang = stream.Language.Split('(');
        if (lang.Length > 1)
        {
          stream.Language = lang[1].Substring(0, lang[1].Length - 1);
        }
        streamsList.Add(stream);
      }
      return streamsList.ToArray();
    }
コード例 #3
0
ファイル: HomeBase.cs プロジェクト: dot-i/ARGUS-TV-Clients
        // also used from tvrecorded class
        public static int GetPreferedAudioStreamIndex()
        {
            int idxFirstAc3 = -1;         // the index of the first avail. ac3 found
            int idxFirstmpeg = -1;        // the index of the first avail. mpg found
            int idxLangAc3 = -1;          // the index of ac3 found based on lang. pref
            int idxLangmpeg = -1;         // the index of mpg found based on lang. pref
            int idx = -1;                 // the chosen audio index we return
            string langSel = "";          // find audio based on this language.
            string ac3BasedOnLang = "";   // for debugging, what lang. in prefs. where used to choose the ac3 audio track ?
            string mpegBasedOnLang = "";  // for debugging, what lang. in prefs. where used to choose the mpeg audio track ?

            IAudioStream[] streams;

            List<IAudioStream> streamsList = new List<IAudioStream>();
            for (int i = 0; i < g_Player.AudioStreams; i++)
            {
                DVBAudioStream stream = new DVBAudioStream();
                string streamType = g_Player.AudioType(i);

                switch (streamType)
                {
                    case "AC3":
                        stream.StreamType = AudioStreamType.AC3;
                        break;
                    case "Mpeg1":
                        stream.StreamType = AudioStreamType.Mpeg1;
                        break;
                    case "Mpeg2":
                        stream.StreamType = AudioStreamType.Mpeg2;
                        break;
                    case "AAC":
                        stream.StreamType = AudioStreamType.AAC;
                        break;
                    case "LATMAAC":
                        stream.StreamType = AudioStreamType.LATMAAC;
                        break;
                    default:
                        stream.StreamType = AudioStreamType.Unknown;
                        break;
                }

                stream.Language = g_Player.AudioLanguage(i);
                streamsList.Add(stream);
            }
            streams = (IAudioStream[])streamsList.ToArray();

            if (_preferredLanguages != null)
            {
                Log.Debug("TVHome.GetPreferedAudioStreamIndex(): preferred LANG(s):{0} preferAC3:{1} preferAudioTypeOverLang:{2}", String.Join(";", _preferredLanguages), _preferAC3, _preferAudioTypeOverLang);
            }
            else
            {
                Log.Debug("TVHome.GetPreferedAudioStreamIndex(): preferred LANG(s):{0} preferAC3:{1} _preferAudioTypeOverLang:{2}", "n/a", _preferAC3, _preferAudioTypeOverLang);
            }
            Log.Debug("Audio streams avail: {0}", streams.Length);

            if (streams.Length == 1)
            {
                Log.Info("Audio stream: switching to preferred AC3/MPEG audio stream 0 (only 1 track avail.)");
                return 0;
            }

            for (int i = 0; i < streams.Length; i++)
            {
                //tag the first found ac3 and mpeg indexes
                if (streams[i].StreamType == AudioStreamType.AC3)
                {
                    if (idxFirstAc3 == -1) idxFirstAc3 = i;
                }
                else
                {
                    if (idxFirstmpeg == -1) idxFirstmpeg = i;
                }

                //now find the ones based on LANG prefs.
                if (_preferredLanguages != null)
                {
                    for (int j = 0; j < _preferredLanguages.Length; j++)
                    {
                        if (_preferredLanguages[j].Length == 0) continue;
                        langSel = _preferredLanguages[j];
                        if (streams[i].Language.Contains(langSel) && langSel.Length > 0)
                        {
                            if ((streams[i].StreamType == AudioStreamType.AC3)) //is the audio track an AC3 track ?
                            {
                                if (idxLangAc3 == -1)
                                {
                                    idxLangAc3 = i;
                                    ac3BasedOnLang = langSel;
                                }
                            }
                            else //audiotrack is mpeg
                            {
                                if (idxLangmpeg == -1)
                                {
                                    idxLangmpeg = i;
                                    mpegBasedOnLang = langSel;
                                }
                            }
                        }
                        if (idxLangAc3 > -1 && idxLangmpeg > -1) break;
                    } //for loop
                }
                if (idxFirstAc3 > -1 && idxFirstmpeg > -1 && idxLangAc3 > -1 && idxLangmpeg > -1) break;
            }

            if (_preferAC3)
            {
                if (_preferredLanguages != null)
                {
                    //did we find an ac3 track that matches our LANG prefs ?
                    if (idxLangAc3 > -1)
                    {
                        idx = idxLangAc3;
                        Log.Info("Audio stream: switching to preferred AC3 audio stream {0}, based on LANG {1}", idx, ac3BasedOnLang);
                    }
                    //if not, did we even find an ac3 track ?
                    else if (idxFirstAc3 > -1)
                    {
                        //we did find an AC3 track, but not based on LANG - should we choose this or the mpeg track which is based on LANG.
                        if (_preferAudioTypeOverLang || (idxLangmpeg == -1 && _preferAudioTypeOverLang))
                        {
                            idx = idxFirstAc3;
                            Log.Info("Audio stream: switching to preferred AC3 audio stream {0}, NOT based on LANG (none avail. matching {1})", idx, ac3BasedOnLang);
                        }
                        else
                        {
                            Log.Info("Audio stream: ignoring AC3 audio stream {0}", idxFirstAc3);
                        }
                    }
                    //if not then proceed with mpeg lang. selection below.
                }
                else
                {
                    //did we find an ac3 track ?
                    if (idxFirstAc3 > -1)
                    {
                        idx = idxFirstAc3;
                        Log.Info("Audio stream: switching to preferred AC3 audio stream {0}, NOT based on LANG", idx);
                    }
                    //if not then proceed with mpeg lang. selection below.
                }
            }

            if (idx == -1 && _preferAC3)
            {
                Log.Info("Audio stream: no preferred AC3 audio stream found, trying mpeg instead.");
            }

            if (idx == -1 || !_preferAC3) // we end up here if ac3 selection didnt happen (no ac3 avail.) or if preferac3 is disabled.
            {
                if (_preferredLanguages != null)
                {
                    //did we find a mpeg track that matches our LANG prefs ?
                    if (idxLangmpeg > -1)
                    {
                        idx = idxLangmpeg;
                        Log.Info("Audio stream: switching to preferred MPEG audio stream {0}, based on LANG {1}", idx, mpegBasedOnLang);
                    }
                    //if not, did we even find a mpeg track ?
                    else if (idxFirstmpeg > -1)
                    {
                        //we did find a AC3 track, but not based on LANG - should we choose this or the mpeg track which is based on LANG.
                        if (_preferAudioTypeOverLang || (idxLangAc3 == -1 && _preferAudioTypeOverLang))
                        {
                            idx = idxFirstmpeg;
                            Log.Info("Audio stream: switching to preferred MPEG audio stream {0}, NOT based on LANG (none avail. matching {1})", idx, mpegBasedOnLang);
                        }
                        else
                        {
                            if (idxLangAc3 > -1)
                            {
                                idx = idxLangAc3;
                                Log.Info("Audio stream: ignoring MPEG audio stream {0}", idx);
                            }
                        }
                    }
                }
                else
                {
                    idx = idxFirstmpeg;
                    Log.Info("Audio stream: switching to preferred MPEG audio stream {0}, NOT based on LANG", idx);
                }
            }

            if (idx == -1)
            {
                idx = 0;
                Log.Info("Audio stream: switching to preferred AC3/MPEG audio stream {0}", idx);
            }

            return idx;
        }
コード例 #4
0
    /// <summary>
    /// maps the correct pids to the TsFileSink filter and teletext pins
    /// </summary>
    /// <param name="info"></param>
    protected void SetMpegPidMapping(ChannelInfo info)
    {
      if (info == null)
        return;
      try
      {
        Log.Log.WriteFile("subch:{0} SetMpegPidMapping", _subChannelId);

        List<ushort> hwPids = new List<ushort>();
        hwPids.Add(0x0); //PAT
        hwPids.Add(0x1); //CAT
        hwPids.Add(0x10); //NIT
        hwPids.Add(0x11); //SDT
        hwPids.Add(0x12); //EPG

        Log.Log.WriteFile("subch:{0}  pid:{1:X} pcr", _subChannelId, info.pcrPid);
        Log.Log.WriteFile("subch:{0}  pid:{1:X} pmt", _subChannelId, info.network_pmt_PID);

        if (info.network_pmt_PID >= 0 && info.serviceID >= 0)
        {
          hwPids.Add((ushort)info.network_pmt_PID);
        }

        if (info.pids != null)
        {
          foreach (PidInfo pidInfo in info.pids)
          {
            Log.Log.WriteFile("subch:{0}  {1}", _subChannelId, pidInfo.ToString());
            if (pidInfo.pid == 0 || pidInfo.pid > 0x1fff)
              continue;
            if (pidInfo.isTeletext)
            {
              Log.Log.WriteFile("subch:{0}    map {1}", _subChannelId, pidInfo);
              if (GrabTeletext)
              {
                _tsFilterInterface.TTxSetTeletextPid(_subChannelIndex, pidInfo.pid);
              }
              hwPids.Add((ushort)pidInfo.pid);
              _hasTeletext = true;
            }
            if (pidInfo.isAC3Audio || pidInfo.isEAC3Audio || pidInfo.isAudio)
            {
              if (_currentAudioStream == null || pidInfo.isAC3Audio || pidInfo.isEAC3Audio)
              {
                _currentAudioStream = new DVBAudioStream();
                _currentAudioStream.Pid = pidInfo.pid;
                _currentAudioStream.Language = pidInfo.language;
                if (pidInfo.IsMpeg1Audio)
                  _currentAudioStream.StreamType = AudioStreamType.Mpeg1;
                else if (pidInfo.IsMpeg2Audio)
                  _currentAudioStream.StreamType = AudioStreamType.Mpeg2;
                if (pidInfo.isAC3Audio)
                  _currentAudioStream.StreamType = AudioStreamType.AC3;
                if (pidInfo.isEAC3Audio)
                  _currentAudioStream.StreamType = AudioStreamType.EAC3;
                if (pidInfo.IsAACAudio)
                  _currentAudioStream.StreamType = AudioStreamType.AAC;
                if (pidInfo.IsLATMAACAudio)
                  _currentAudioStream.StreamType = AudioStreamType.LATMAAC;
              }

              if (_currentAudioStream.Pid == pidInfo.pid)
              {
                Log.Log.WriteFile("subch:{0}    map {1}", _subChannelId, pidInfo);
                _tsFilterInterface.AnalyzerSetAudioPid(_subChannelIndex, pidInfo.pid);
              }
              hwPids.Add((ushort)pidInfo.pid);
            }

            if (pidInfo.isVideo)
            {
              Log.Log.WriteFile("subch:{0}    map {1}", _subChannelId, pidInfo);
              hwPids.Add((ushort)pidInfo.pid);
              _tsFilterInterface.AnalyzerSetVideoPid(_subChannelIndex, pidInfo.pid);
              if (info.pcrPid > 0 && info.pcrPid != pidInfo.pid)
              {
                hwPids.Add((ushort)info.pcrPid);
              }
            }

            if (pidInfo.isDVBSubtitle)
            {
              Log.Log.WriteFile("subch:{0}    map {1}", _subChannelId, pidInfo);
              hwPids.Add((ushort)pidInfo.pid);
            }
          }
        }

        if (_mdplugs != null)
        {
          // MDPlugins Active.. 
          // It's important that the ECM pids are not blocked by the HWPID Filter in the Tuner.
          // therefore they need to be explicitly added to HWPID list.

          // HWPIDS supports max number of 16 filtered pids - Total max of 16.
          // ECM Pids
          foreach (ECMEMM ecmValue in _channelInfo.caPMT.GetECM())
          {
            if (ecmValue.Pid != 0 && !hwPids.Contains((ushort)ecmValue.Pid))
            {
              hwPids.Add((ushort)ecmValue.Pid);
            }
          }
          //EMM Pids
          foreach (ECMEMM emmValue in _channelInfo.caPMT.GetEMM())
          {
            if (emmValue.Pid != 0 && !hwPids.Contains((ushort)emmValue.Pid))
            {
              hwPids.Add((ushort)emmValue.Pid);
            }
          }
          Log.Log.WriteFile("Number of HWPIDS that needs to be sent to tuner :{0} ", hwPids.Count);
        }

        if (_conditionalAccess != null && info.network_pmt_PID >= 0 && info.serviceID >= 0)
        {
          _conditionalAccess.SendPids(_subChannelId, (DVBBaseChannel)_currentChannel, hwPids);
        }

        if (_startTimeShifting)
        {
          _startTimeShifting = false;
          _tsFilterInterface.TimeShiftReset(_subChannelIndex);
          SetTimeShiftPids();

          Log.Log.WriteFile("Set video / audio observer");
          _tsFilterInterface.SetVideoAudioObserver(_subChannelIndex, this);

          _tsFilterInterface.TimeShiftStart(_subChannelIndex);

          _graphState = GraphState.TimeShifting;
        }
        if (_startRecording)
        {
          _startRecording = false;
          SetRecorderPids();

          Log.Log.WriteFile("Set video / audio observer");
          _tsFilterInterface.RecorderSetVideoAudioObserver(_subChannelIndex, this);

          int hr = _tsFilterInterface.RecordStartRecord(_subChannelIndex);
          if (hr != 0)
          {
            Log.Log.Error("subch:[0} StartRecord failed:{1:X}", _subChannelId, hr);
          }

          _graphState = GraphState.Recording;
        }
        else
        {
          if (IsTimeShifting)
          {
            SetTimeShiftPids();
          }
          if (IsRecording)
          {
            SetRecorderPids();
          }
        }
      }
      catch (Exception ex)
      {
        Log.Log.Write(ex);
      }
    }
コード例 #5
0
 /// <summary>
 /// Should be called before tuning to a new channel
 /// resets the state
 /// </summary>
 public override void OnBeforeTune()
 {
   Log.Log.WriteFile("subch:{0} OnBeforeTune", _subChannelId);
   if (IsTimeShifting && _subChannelIndex >= 0)
   {
     _tsFilterInterface.TimeShiftPause(_subChannelIndex, 1);
   }
   _startTimeShifting = false;
   _startRecording = false;
   _channelInfo = new ChannelInfo();
   _hasTeletext = false;
   _currentAudioStream = null;
 }