public override bool SetAudioDualMonoMode(eAudioDualMonoMode mode)
        {
            if (_audioSwitcherFilter == null)
            {
                Log.Info("TsReaderPlayer: AudioDualMonoMode switching not available. Audioswitcher filter not loaded");
                return(false);
            }
            IMPAudioSwitcherFilter mpSwitcher = _audioSwitcherFilter as IMPAudioSwitcherFilter;

            if (mpSwitcher == null)
            {
                Log.Info("TsReaderPlayer: AudioDualMonoMode switching not available. Audioswitcher filter not loaded");
                return(false);
            }
            int hr = mpSwitcher.SetAudioDualMonoMode((uint)mode);

            if (hr != 0)
            {
                Log.Info("TsReaderPlayer: SetAudioDualMonoMode mode={0} failed 0x{1:X}", mode.ToString(), hr);
            }
            else
            {
                Log.Info("TsReaderPlayer: SetAudioDualMonoMode mode={0} succeeded", mode.ToString(), hr);
            }
            return(hr == 0);
        }
        public override eAudioDualMonoMode GetAudioDualMonoMode()
        {
            if (_audioSwitcherFilter == null)
            {
                Log.Info("TsReaderPlayer: AudioDualMonoMode switching not available. Audioswitcher filter not loaded");
                return(eAudioDualMonoMode.UNSUPPORTED);
            }
            IMPAudioSwitcherFilter mpSwitcher = _audioSwitcherFilter as IMPAudioSwitcherFilter;

            if (mpSwitcher == null)
            {
                Log.Info("TsReaderPlayer: AudioDualMonoMode switching not available. Audioswitcher filter not loaded");
                return(eAudioDualMonoMode.UNSUPPORTED);
            }
            uint iMode = 0;
            int  hr    = mpSwitcher.GetAudioDualMonoMode(out iMode);

            if (hr != 0)
            {
                Log.Info("TsReaderPlayer: GetAudioDualMonoMode failed 0x{0:X}", hr);
                return(eAudioDualMonoMode.UNSUPPORTED);
            }
            eAudioDualMonoMode mode = (eAudioDualMonoMode)iMode;

            Log.Info("TsReaderPlayer: GetAudioDualMonoMode mode={0} succeeded", iMode.ToString(), hr);
            return(mode);
        }
Example #3
0
        ///<summary>
        /// streams : 1
        /// stream1 : ac3, lang: dan.
        /// pref_lang : empty
        /// PreferAC3 : false
        /// PreferAudioTypeOverLang : false
        ///</summary>
        public void GetPreferedAudioStreamIndexTest2()
        {
            g_Player.Player = new PlayerSingleAudioStreamAC3Dan();

            List <string> prefLangs = new List <string>();

            TVHome.PreferredLanguages      = prefLangs; //empty
            TVHome.PreferAC3               = false;
            TVHome.PreferAudioTypeOverLang = false;

            eAudioDualMonoMode dualMonoMode = eAudioDualMonoMode.UNSUPPORTED;

            int index = TVHome.GetPreferedAudioStreamIndex(out dualMonoMode);

            Assert.AreEqual(0, index, "Wrong audio index returned");
            Assert.AreEqual(eAudioDualMonoMode.UNSUPPORTED, dualMonoMode, "dualMonoMode returned should be UNSUPPORTED");
        }
Example #4
0
        ///<summary>
        /// streams : 5
        /// stream1 : mpeg1         , lang: dan
        /// stream2 : mpeg1 dualmono, lang: left: dan right: eng.
        /// stream3 : mpeg1 dualmono, lang: left: deu right: swe.
        /// stream4 : ac3           , lang: eng
        /// stream5 : mpeg1         , lang: eng
        /// pref_lang : eng
        /// PreferAC3 : false
        /// PreferAudioTypeOverLang : false
        ///</summary>
        public void GetPreferedAudioStreamIndexTest25()
        {
            g_Player.Player = new PlayerMultipleDualMonoAudioStreams();

            List <string> prefLangs = new List <string>();

            prefLangs.Add("eng");
            TVHome.PreferredLanguages      = prefLangs; //empty
            TVHome.PreferAC3               = false;
            TVHome.PreferAudioTypeOverLang = false;

            eAudioDualMonoMode dualMonoMode = eAudioDualMonoMode.UNSUPPORTED;

            int index = TVHome.GetPreferedAudioStreamIndex(out dualMonoMode);

            Assert.AreEqual(1, index, "Wrong audio index returned");
            Assert.AreEqual(eAudioDualMonoMode.RIGHT_MONO, dualMonoMode, "dualMonoMode returned should be RIGHT_MONO");
        }
Example #5
0
 private static void UpdateAudioStreamIndexesAndPrioritiesBasedOnLanguage(IAudioStream[] streams, int priority,
                                                                          ref int idxStreamIndexmpeg,
                                                                          ref string mpegBasedOnLang,
                                                                          ref int idxStreamIndexAc3,
                                                                          int idxLangPriAc3, int idxLangPrimpeg,
                                                                          ref string ac3BasedOnLang,
                                                                          out eAudioDualMonoMode dualMonoMode)
 {
   dualMonoMode = eAudioDualMonoMode.UNSUPPORTED;
   if (IsPreferredAudioLanguageAvailable())
   {
     for (int i = 0; i < streams.Length; i++)
     {
       //now find the ones based on LANG prefs.        
       if (ShouldApplyDualMonoMode(streams[i].Language))
       {
         dualMonoMode = GetDualMonoMode(streams, i, ref priority, ref idxStreamIndexmpeg, ref mpegBasedOnLang);
         if (dualMonoMode != eAudioDualMonoMode.UNSUPPORTED)
         {
           break;
         }
       }
       else
       {
         // lower value means higher priority
         UpdateAudioStreamIndexesBasedOnLang(streams, i, ref idxStreamIndexmpeg, ref idxStreamIndexAc3,
                                             ref mpegBasedOnLang, ref idxLangPriAc3, ref idxLangPrimpeg, ref ac3BasedOnLang);
       }
     }
   }
 }
Example #6
0
    /// <summary>
    /// unit test enabled method. please respect this.
    /// run and/or modify the unit tests accordingly.
    /// </summary>
    public static int GetPreferedAudioStreamIndex(out eAudioDualMonoMode dualMonoMode)
    // also used from tvrecorded class
    {
      int idxFirstAc3 = -1; // the index of the first avail. ac3 found
      int idxFirstmpeg = -1; // the index of the first avail. mpg found
      int idxStreamIndexAc3 = -1; // the streamindex of ac3 found based on lang. pref
      int idxStreamIndexmpeg = -1; // the streamindex of mpg found based on lang. pref   
      int idx = -1; // the chosen audio index we return
      int idxLangPriAc3 = -1; // the lang priority of ac3 found based on lang. pref
      int idxLangPrimpeg = -1; // the lang priority of mpg found based on lang. pref         
      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 ?      

      dualMonoMode = eAudioDualMonoMode.UNSUPPORTED;

      IAudioStream[] streams = GetStreamsList();

      if (IsPreferredAudioLanguageAvailable())
      {
        Log.Debug(
          "TVHome.GetPreferedAudioStreamIndex(): preferred LANG(s):{0} preferAC3:{1} preferAudioTypeOverLang:{2}",
          String.Join(";", _preferredLanguages.ToArray()), _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);
      bool dualMonoModeEnabled = (g_Player.GetAudioDualMonoMode() != eAudioDualMonoMode.UNSUPPORTED);

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

      int priority = int.MaxValue;
      idxFirstAc3 = GetFirstAC3Index(streams);
      idxFirstmpeg = GetFirstMpegIndex(streams);

      UpdateAudioStreamIndexesAndPrioritiesBasedOnLanguage(streams, priority, ref idxStreamIndexmpeg,
                                                           ref mpegBasedOnLang, ref idxStreamIndexAc3, idxLangPriAc3,
                                                           idxLangPrimpeg, ref ac3BasedOnLang, out dualMonoMode);
      idx = GetAC3AudioStreamIndex(idxStreamIndexmpeg, idxStreamIndexAc3, ac3BasedOnLang, idx, idxFirstAc3);

      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 (IsPreferredAudioLanguageAvailable())
        {
          //did we find a mpeg track that matches our LANG prefs ?
          idx = GetMpegAudioStreamIndexBasedOnLanguage(idxStreamIndexmpeg, mpegBasedOnLang, idxStreamIndexAc3, idx,
                                                       idxFirstmpeg);
        }
        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: no preferred stream found - switching to audio stream 0");
      }

      return idx;
    }
    private void ShowAudioDualMonoModeMenu(eAudioDualMonoMode dualMonoMode)
    {
      if (dlg == null)
      {
        return;
      }
      dlg.Reset();
      dlg.SetHeading(200059); // audio dual mono mode 

      dlg.AddLocalizedString(200060); // stereo 
      dlg.AddLocalizedString(200061); // Left channel to the left and right speakers
      dlg.AddLocalizedString(200062); // Right channel to the left and right speakers
      dlg.AddLocalizedString(200063); // Mix both

      dlg.SelectedLabel = (int)dualMonoMode;

      dlg.DoModal(GetID);

      if (dlg.SelectedLabel < 0)
      {
        return;
      }
      g_Player.SetAudioDualMonoMode((eAudioDualMonoMode)dlg.SelectedLabel);
    }
Example #8
0
 public virtual bool SetAudioDualMonoMode(eAudioDualMonoMode mode)
 {
     return(false);
 }
Example #9
0
 public static bool SetAudioDualMonoMode(eAudioDualMonoMode mode)
 {
   if (_player == null)
   {
     return false;
   }
   else
   {
     return _player.SetAudioDualMonoMode(mode);
   }
 }
 public override bool SetAudioDualMonoMode(eAudioDualMonoMode mode)
 {
   if (_audioSwitcherFilter == null)
   {
     Log.Info("TsReaderPlayer: AudioDualMonoMode switching not available. Audioswitcher filter not loaded");
     return false;
   }
   IMPAudioSwitcherFilter mpSwitcher = _audioSwitcherFilter as IMPAudioSwitcherFilter;
   if (mpSwitcher == null)
   {
     Log.Info("TsReaderPlayer: AudioDualMonoMode switching not available. Audioswitcher filter not loaded");
     return false;
   }
   int hr = mpSwitcher.SetAudioDualMonoMode((uint)mode);
   if (hr != 0)
   {
     Log.Info("TsReaderPlayer: SetAudioDualMonoMode mode={0} failed 0x{1:X}", mode.ToString(), hr);
   }
   else
   {
     Log.Info("TsReaderPlayer: SetAudioDualMonoMode mode={0} succeeded", mode.ToString(), hr);
   }
   return (hr == 0);
 }
Example #11
0
 public virtual bool SetAudioDualMonoMode(eAudioDualMonoMode mode)
 {
   return false;
 }