private void TestCount()
        {
            int hr;
            int c;

            hr = m_ss.Count(out c);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(c == 2, "Count");
        }
示例#2
0
        private void AddStreams(IAMStreamSelect pStrm)
        {
            int cStreams = 0;

            pStrm.Count(out cStreams);
            //GET STREAMS
            for (int istream = 0; istream < cStreams; istream++)
            {
                AMMediaType             sType;
                AMStreamSelectInfoFlags sFlag;
                int    sPDWGroup, sPLCid;
                string sName;
                object pppunk, ppobject;
                //STREAM INFO
                pStrm.Info(istream, out sType, out sFlag, out sPLCid,
                           out sPDWGroup, out sName, out pppunk, out ppobject);

                //SUBTITLE
                if (sPDWGroup == 2 && sName.LastIndexOf("No ") == -1)
                {
                    intSubs.Add(istream);
                    // Try Find Language by LCID
                    String langName = "";
                    if (sPLCid != 0)
                    {
                        int    size         = Util.Win32API.GetLocaleInfo(sPLCid, 2, null, 0);
                        String languageName = new String(' ', size);

                        Util.Win32API.GetLocaleInfo(sPLCid, 2, languageName, size);
                        if (!languageName.Equals(new String(' ', size)))
                        {
                            if (languageName.Contains("\0"))
                            {
                                langName = languageName.Substring(0, languageName.IndexOf("\0"));
                            }
                            else
                            {
                                langName = languageName;
                            }
                            int ipos = langName.IndexOf("(");
                            if (ipos > 0)
                            {
                                langName = langName.Substring(0, ipos);
                                langName = langName.Trim();
                            }
                        }
                    }
                    else
                    {
                        langName = sName;
                    }
                    intNames.Add(langName);
                }
            }
        }
示例#3
0
        public static bool SelectStream(this IAMStreamSelect pStreamSelect, int index)
        {
            var result = false;

            int count;
            var hr = pStreamSelect.Count(out count);

            if (DsHlp.SUCCEEDED(hr) && count > index)
            {
                hr     = pStreamSelect.Enable(index, AMStreamSelectEnableFlags.Enable);
                result = DsHlp.SUCCEEDED(hr);
            }

            return(result);
        }
示例#4
0
        public static bool IsStreamSelected(this IAMStreamSelect pStreamSelect, int index)
        {
            var result = false;

            int count;
            var hr = pStreamSelect.Count(out count);

            if (DsHlp.SUCCEEDED(hr) && count > index)
            {
                var stream = pStreamSelect.GetSelectableStream(index);
                if (stream != null)
                {
                    result = stream.Enabled;
                }
            }

            return(result);
        }
示例#5
0
        public static IEnumerable <SelectableStream> GetSelectableStreams(this IAMStreamSelect pStreamSelect)
        {
            var result = new List <SelectableStream>();

            int count;
            var hr = pStreamSelect.Count(out count);

            if (DsHlp.SUCCEEDED(hr) && count > 0)
            {
                for (var i = 0; i < count; i++)
                {
                    var stream = pStreamSelect.GetSelectableStream(i);
                    if (stream != null)
                    {
                        result.Add(stream);
                    }
                }
            }

            return(result);
        }
        private void AddStreams(IAMStreamSelect pStrm)
        {
            int cStreams = 0;

            pStrm.Count(out cStreams);
            //GET STREAMS
            for (int istream = 0; istream < cStreams; istream++)
            {
                AMMediaType             sType;
                AMStreamSelectInfoFlags sFlag;
                int    sPDWGroup, sPLCid;
                string sName;
                object pppunk, ppobject;
                //STREAM INFO
                pStrm.Info(istream, out sType, out sFlag, out sPLCid,
                           out sPDWGroup, out sName, out pppunk, out ppobject);

                //SUBTITLE
                if (sPDWGroup == 2 && sName.LastIndexOf("No ") == -1)
                {
                    intSubs.Add(istream);

                    // Add subtitle names
                    if (sName.ToLowerInvariant().Contains("forced"))
                    {
                        Regex regexLAVF  = new Regex(@"(?:S:\s)(?<lang_or_title>.+?)(?:\s*\[(?<lang>[^\]]*?)\])?(?:\s*\((?<info>[^\)]*?)\))?$");
                        Match resultLAVF = regexLAVF.Match(sName);
                        if (resultLAVF.Success)
                        {
                            string lang_or_title = resultLAVF.Groups[1].Value;
                            string lang          = resultLAVF.Groups[2].Value;
                            string info          = resultLAVF.Groups[3].Value;
                            if (lang.ToLowerInvariant().Contains("forced") || info.ToLowerInvariant().Contains("forced"))
                            {
                                if (!lang_or_title.ToLowerInvariant().Contains("forced"))
                                {
                                    sName = "S: " + lang_or_title + " Forced ";
                                }
                            }
                        }
                    }
                    SubtitleNames?.Add(sName);

                    // Add language names
                    // Try Find Language by LCID
                    string langName = "";
                    if (sPLCid != 0)
                    {
                        int    size         = Util.Win32API.GetLocaleInfo(sPLCid, 2, null, 0);
                        String languageName = new String(' ', size);

                        Util.Win32API.GetLocaleInfo(sPLCid, 2, languageName, size);
                        if (!languageName.Equals(new String(' ', size)))
                        {
                            if (languageName.Contains("\0"))
                            {
                                langName = languageName.Substring(0, languageName.IndexOf("\0"));
                            }
                            else
                            {
                                langName = languageName;
                            }
                            int ipos = langName.IndexOf("(");
                            if (ipos > 0)
                            {
                                langName = langName.Substring(0, ipos);
                                langName = langName.Trim();
                            }
                        }
                    }
                    else
                    {
                        langName = sName;
                    }
                    SubtitleLanguages.Add(langName);
                }
            }
        }
示例#7
0
    private void ParseStreams(IAMStreamSelect pStrm)
    {
      int cStreams = 0;
      pStrm.Count(out cStreams);

      _audioStreams.Clear();
      _subtitleStreams.Clear();

      for (int istream = 0; istream < cStreams; istream++)
      {
        AMMediaType sType;
        AMStreamSelectInfoFlags sFlag;
        int sPDWGroup;
        int sPLCid;
        string sName;
        object pppunk; 
        object ppobject;

        pStrm.Info(istream, out sType, out sFlag, out sPLCid, out sPDWGroup, out sName, out pppunk, out ppobject);

        if (sPDWGroup == 1)
        {
          StreamInfo info = new StreamInfo(istream, sName);
          _audioStreams.Add(info);
        }

        if (sPDWGroup == 2)
        {
          StreamInfo info = new StreamInfo(istream, sName);
          _subtitleStreams.Add(info);
        }
      }
    }
    private void AddStreams(IAMStreamSelect pStrm)
    {
      int cStreams = 0;
      pStrm.Count(out cStreams);
      //GET STREAMS
      for (int istream = 0; istream < cStreams; istream++)
      {
        AMMediaType sType;
        AMStreamSelectInfoFlags sFlag;
        int sPDWGroup, sPLCid;
        string sName;
        object pppunk, ppobject;
        //STREAM INFO
        pStrm.Info(istream, out sType, out sFlag, out sPLCid,
                   out sPDWGroup, out sName, out pppunk, out ppobject);

        //SUBTITLE
        if (sPDWGroup == 2 && sName.LastIndexOf("No ") == -1)
        {
          intSubs.Add(istream);
          // Try Find Language by LCID
          String langName = "";
          if (sPLCid != 0)
          {
            int size = Util.Win32API.GetLocaleInfo(sPLCid, 2, null, 0);
            String languageName = new String(' ', size);

            Util.Win32API.GetLocaleInfo(sPLCid, 2, languageName, size);
            if (!languageName.Equals(new String(' ', size)))
            {
              if (languageName.Contains("\0"))
                langName = languageName.Substring(0, languageName.IndexOf("\0"));
              else
                langName = languageName;
              int ipos = langName.IndexOf("(");
              if (ipos > 0)
              {
                langName = langName.Substring(0, ipos);
                langName = langName.Trim();
              }
            }
          }
          else
          {
            langName = sName;
          }
          intNames.Add(langName);
        }
      }
    }
    private void AddStreams(IAMStreamSelect pStrm)
    {
      int cStreams = 0;
      pStrm.Count(out cStreams);
      //GET STREAMS
      for (int istream = 0; istream < cStreams; istream++)
      {
        AMMediaType sType;
        AMStreamSelectInfoFlags sFlag;
        int sPDWGroup, sPLCid;
        string sName;
        object pppunk, ppobject;
        //STREAM INFO
        pStrm.Info(istream, out sType, out sFlag, out sPLCid,
                   out sPDWGroup, out sName, out pppunk, out ppobject);

        //SUBTITLE
        if (sPDWGroup == 2 && sName.LastIndexOf("No ") == -1)
        {
          intSubs.Add(istream);

          // Add subtitle names
          if (sName.ToLowerInvariant().Contains("forced"))
          {
            Regex regexLAVF = new Regex(@"(?:S:\s)(?<lang_or_title>.+?)(?:\s*\[(?<lang>[^\]]*?)\])?(?:\s*\((?<info>[^\)]*?)\))?$");
            Match resultLAVF = regexLAVF.Match(sName);
            if (resultLAVF.Success)
            {
              string lang_or_title = resultLAVF.Groups[1].Value;
              string lang = resultLAVF.Groups[2].Value;
              string info = resultLAVF.Groups[3].Value;
              if (lang.ToLowerInvariant().Contains("forced") || info.ToLowerInvariant().Contains("forced"))
              {
                if (!lang_or_title.ToLowerInvariant().Contains("forced"))
                {
                  sName = "S: " + lang_or_title + " Forced ";
                }
              }
            }
          }
          SubtitleNames?.Add(sName);

          // Add language names
          // Try Find Language by LCID
          string langName = "";
          if (sPLCid != 0)
          {
            int size = Util.Win32API.GetLocaleInfo(sPLCid, 2, null, 0);
            String languageName = new String(' ', size);

            Util.Win32API.GetLocaleInfo(sPLCid, 2, languageName, size);
            if (!languageName.Equals(new String(' ', size)))
            {
              if (languageName.Contains("\0"))
                langName = languageName.Substring(0, languageName.IndexOf("\0"));
              else
                langName = languageName;
              int ipos = langName.IndexOf("(");
              if (ipos > 0)
              {
                langName = langName.Substring(0, ipos);
                langName = langName.Trim();
              }
            }
          }
          else
          {
            langName = sName;
          }
          SubtitleLanguages.Add(langName);
        }
      }
    }