Exemple #1
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);
                }
            }
        }
        private void TestInfo()
        {
            int                     hr;
            AMMediaType             pmt;
            AMStreamSelectInfoFlags f;
            int                     id;
            int                     g;
            string                  name;
            object                  o1, o2;

            hr = m_ss.Info(0, out pmt, out f, out id, out g, out name, out o1, out o2);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(pmt != null, "Info");
        }
Exemple #3
0
        public static void InspectStream(this IAMStreamSelect pStreamSelect, int index, Action <AMMediaType, string, bool> inspect)
        {
            IntPtr ppmt;
            AMStreamSelectInfoFlags pdwFlags;
            int    plcid;
            int    pdwGroup;
            IntPtr ppszName;
            IntPtr ppObject;
            IntPtr ppUnk;

            var hr = pStreamSelect.Info(index, out ppmt, out pdwFlags, out plcid, out pdwGroup, out ppszName, out ppObject, out ppUnk);

            if (DsHlp.SUCCEEDED(hr))
            {
                var mt      = ppmt != IntPtr.Zero ? (AMMediaType)Marshal.PtrToStructure(ppmt, typeof(AMMediaType)) : new AMMediaType();
                var name    = Marshal.PtrToStringAuto(ppszName);
                var enabled = (pdwFlags & AMStreamSelectInfoFlags.Enabled) != AMStreamSelectInfoFlags.Disabled ||
                              (pdwFlags & AMStreamSelectInfoFlags.Exclusive) != AMStreamSelectInfoFlags.Disabled;

                inspect(mt, name, enabled);

                if (ppmt != IntPtr.Zero)
                {
                    DsUtils.FreeFormatBlock(ppmt);
                    Marshal.FreeCoTaskMem(ppmt);
                }

                Marshal.FreeCoTaskMem(ppszName);
                if (ppObject != IntPtr.Zero)
                {
                    Marshal.Release(ppObject);
                }
                if (ppUnk != IntPtr.Zero)
                {
                    Marshal.Release(ppUnk);
                }
            }
        }
        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);
                }
            }
        }
    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);
        }
      }
    }