コード例 #1
0
        public BasicMediaFormatInfo(string filename)
        {
            string mediaInfo = Converter.GetMediaInfo(filename);

            Cll.JSON.Element info   = Cll.JSON.SyntacticAnalyzer.Read(mediaInfo);
            Cll.JSON.Object  format = (Cll.JSON.Object)info.Value.GetValue("format");

            FileName = ((Cll.JSON.String)format.GetValue("filename")).Value;
            Size     = Convert.ToInt64(((Cll.JSON.String)format.GetValue("size")).Value);
            Format   = ((Cll.JSON.String)format.GetValue("format_name")).Value;
            Duration = Convert.ToDouble(((Cll.JSON.String)format.GetValue("duration")).Value);
            Bitrate  = Convert.ToInt32(((Cll.JSON.String)format.GetValue("bit_rate")).Value);

            if (format.Contains("tags") && ((Cll.JSON.Object)format.GetValue("tags")).Contains("title"))
            {
                Title = ((Cll.JSON.String)format.GetValue("tags").GetValue("title")).Value;
            }
            else
            {
                Title = "";
            }

            int numStreams = Convert.ToInt32(((Cll.JSON.Number)info.Value.GetValue("format").GetValue("nb_streams")).Value);

            MediaInfo = new BasicMediaInfo[numStreams];

            for (int i = 0; i < MediaInfo.Length; i++)
            {
                Cll.JSON.Object streamInfo = (Cll.JSON.Object)info.Value.GetValue("streams").GetValue(i);
                string          codecType  = ((Cll.JSON.String)streamInfo.GetValue("codec_type")).Value;
                if (codecType == "video")
                {
                    MediaInfo[i] = new BasicVideoInfo(streamInfo);
                }
                else if (codecType == "audio")
                {
                    MediaInfo[i] = new BasicAudioInfo(streamInfo);
                }
                else if (codecType == "subtitle")
                {
                    MediaInfo[i] = new BasicSubtitleInfo(streamInfo);
                }
                else
                {
                    MediaInfo[i] = new BasicMediaInfo(streamInfo);
                }
            }
        }
コード例 #2
0
 public BasicVideoInfo(Cll.JSON.Object streamInfo)
     : base(streamInfo)
 {
     if (streamInfo.Contains("profile"))
     {
         Profile = ((Cll.JSON.String)streamInfo.GetValue("profile")).Value;
     }
     else
     {
         Profile = "none";
     }
     Level = ((Cll.JSON.Number)streamInfo.GetValue("level")).Value;
     if (Level > 10.0)
     {
         Level /= 10.0;
     }
     Width  = Convert.ToInt32(((Cll.JSON.Number)streamInfo.GetValue("width")).Value);
     Height = Convert.ToInt32(((Cll.JSON.Number)streamInfo.GetValue("height")).Value);
 }
コード例 #3
0
        public Configuration(Cll.JSON.Element json)
        {
            Cll.JSON.Object config = (Cll.JSON.Object)json.Value.GetValue("configuration");
            Cll.JSON.Array  layout = (Cll.JSON.Array)config.GetValue("layouts").GetValue("layout");
            Cll.JSON.Array  groups = (Cll.JSON.Array)config.GetValue("layouts").GetValue("groups");

            Layouts          = new Layout[layout.Count];
            Groups           = new int[groups.Count];
            Bilinear         = Convert.ToInt32(((Cll.JSON.Number)config.GetValue("3DRendering").GetValue("Bilinear")).Value);
            RenderScale      = Convert.ToInt32(((Cll.JSON.Number)config.GetValue("3DRendering").GetValue("RenderScale")).Value);
            PixelArtUpscaler = Convert.ToInt32(((Cll.JSON.Number)config.GetValue("Display").GetValue("PixelArtUpscaler")).Value);
            Brightness       = Convert.ToInt32(((Cll.JSON.Number)config.GetValue("Display").GetValue("Brightness")).Value);

            if (config.Contains("arguments"))
            {
                FoldOnPause = ((Cll.JSON.Boolean)config.GetValue("arguments").GetValue("fold_on_pause")).Value;
                FoldOnResumeFadeFromBlackDuration = Convert.ToInt32(((Cll.JSON.Number)config.GetValue("arguments").GetValue("fold_on_resume_fade_from_black_duration")).Value);
                FoldOnPauseTimeout = Convert.ToInt32(((Cll.JSON.Number)config.GetValue("arguments").GetValue("fold_on_pause_timeout")).Value);
            }
            else
            {
                FoldOnPause = false;
                FoldOnResumeFadeFromBlackDuration = 1000;
                FoldOnPauseTimeout = 3000;
            }

            for (int i = 0; i < Layouts.Length; i++)
            {
                Layouts[i] = new Layout((Cll.JSON.Object)layout.GetValue(i));
            }

            for (int i = 0; i < Groups.Length; i++)
            {
                Groups[i] = Convert.ToInt32(((Cll.JSON.Number)groups.GetValue(i)).Value);
            }
        }
コード例 #4
0
ファイル: Layout.cs プロジェクト: phacoxcll/VCNDSLayout
        public Layout(Cll.JSON.Object layout)
        {
            Cll.JSON.Array screen     = (Cll.JSON.Array)layout.GetValue("screen");
            Cll.JSON.Array background = (Cll.JSON.Array)layout.GetValue("background");

            if (screen.Count < 1 || screen.Count > 4)
            {
                throw new Exception("Screens count must be greater than 0 and less than 5.");
            }

            if (background.Count != 2)
            {
                throw new Exception("Backgrounds count must be equal to 2.");
            }

            ScreenStruct[]     screens     = new ScreenStruct[screen.Count];
            BackgroundStruct[] backgrounds = new BackgroundStruct[background.Count];

            for (int i = 0; i < screens.Length; i++)
            {
                screens[i] = new ScreenStruct((Cll.JSON.Object)screen.GetValue(i));
            }

            if (screens[0].Source == "upper" && screens[0].Target == "tv")
            {
                ScreenUpperTV = screens[0];
            }
            else if (screens.Length > 1 && screens[1].Source == "upper" && screens[1].Target == "tv")
            {
                ScreenUpperTV = screens[1];
            }
            else if (screens.Length > 2 && screens[2].Source == "upper" && screens[2].Target == "tv")
            {
                ScreenUpperTV = screens[2];
            }
            else if (screens.Length > 3 && screens[3].Source == "upper" && screens[3].Target == "tv")
            {
                ScreenUpperTV = screens[3];
            }
            else
            {
                ScreenUpperTV = new ScreenStruct("upper", "tv", 0, 0, 0, 0);
            }

            if (screens[0].Source == "lower" && screens[0].Target == "tv")
            {
                ScreenLowerTV = screens[0];
            }
            else if (screens.Length > 1 && screens[1].Source == "lower" && screens[1].Target == "tv")
            {
                ScreenLowerTV = screens[1];
            }
            else if (screens.Length > 2 && screens[2].Source == "lower" && screens[2].Target == "tv")
            {
                ScreenLowerTV = screens[2];
            }
            else if (screens.Length > 3 && screens[3].Source == "lower" && screens[3].Target == "tv")
            {
                ScreenLowerTV = screens[3];
            }
            else
            {
                ScreenLowerTV = new ScreenStruct("lower", "tv", 0, 0, 0, 0);
            }

            if (screens[0].Source == "upper" && screens[0].Target == "drc")
            {
                ScreenUpperGamePad = screens[0];
            }
            else if (screens.Length > 1 && screens[1].Source == "upper" && screens[1].Target == "drc")
            {
                ScreenUpperGamePad = screens[1];
            }
            else if (screens.Length > 2 && screens[2].Source == "upper" && screens[2].Target == "drc")
            {
                ScreenUpperGamePad = screens[2];
            }
            else if (screens.Length > 3 && screens[3].Source == "upper" && screens[3].Target == "drc")
            {
                ScreenUpperGamePad = screens[3];
            }
            else
            {
                ScreenUpperGamePad = new ScreenStruct("upper", "drc", 0, 0, 0, 0);
            }

            if (screens[0].Source == "lower" && screens[0].Target == "drc")
            {
                ScreenLowerGamePad = screens[0];
            }
            else if (screens.Length > 1 && screens[1].Source == "lower" && screens[1].Target == "drc")
            {
                ScreenLowerGamePad = screens[1];
            }
            else if (screens.Length > 2 && screens[2].Source == "lower" && screens[2].Target == "drc")
            {
                ScreenLowerGamePad = screens[2];
            }
            else if (screens.Length > 3 && screens[3].Source == "lower" && screens[3].Target == "drc")
            {
                ScreenLowerGamePad = screens[3];
            }
            else
            {
                ScreenLowerGamePad = new ScreenStruct("lower", "drc", 0, 0, 0, 0);
            }

            backgrounds[0] = new BackgroundStruct((Cll.JSON.Object)background.GetValue(0));
            backgrounds[1] = new BackgroundStruct((Cll.JSON.Object)background.GetValue(1));

            if (backgrounds[0].Target == "tv")
            {
                BackgroundTV = backgrounds[0];
            }
            else if (backgrounds[1].Target == "tv")
            {
                BackgroundTV = backgrounds[1];
            }
            else
            {
                BackgroundTV = new BackgroundStruct("tv");
            }

            if (backgrounds[0].Target == "drc")
            {
                BackgroundGamePad = backgrounds[0];
            }
            else if (backgrounds[1].Target == "drc")
            {
                BackgroundGamePad = backgrounds[1];
            }
            else
            {
                BackgroundGamePad = new BackgroundStruct("drc");
            }

            if (layout.Contains("pad_rotation"))
            {
                PadRotation = Convert.ToInt32(((Cll.JSON.Number)layout.GetValue("pad_rotation")).Value);
            }
            else
            {
                PadRotation = 0;
            }
            if (layout.Contains("drc_rotation"))
            {
                DRCRotation = Convert.ToInt32(((Cll.JSON.Number)layout.GetValue("drc_rotation")).Value);
            }
            else
            {
                DRCRotation = 0;
            }
            if (layout.Contains("buttons_rotation"))
            {
                ButtonsRotation = Convert.ToInt32(((Cll.JSON.Number)layout.GetValue("buttons_rotation")).Value);
            }
            else
            {
                ButtonsRotation = 0;
            }

            if (layout.Contains("name_string_id"))
            {
                NameID = ((Cll.JSON.String)layout.GetValue("name_string_id")).Value;
            }
            else
            {
                NameID = "";
            }
            if (layout.Contains("desc_string_id"))
            {
                DescriptionID = ((Cll.JSON.String)layout.GetValue("desc_string_id")).Value;
            }
            else
            {
                DescriptionID = "";
            }

            Name        = StringLanguages.Empty;
            Description = StringLanguages.Empty;
        }
コード例 #5
0
 public BasicMediaInfo(Cll.JSON.Object streamInfo)
 {
     if (streamInfo.Contains("codec_name"))
     {
         CodecName = ((Cll.JSON.String)streamInfo.GetValue("codec_name")).Value;
     }
     else
     {
         CodecName = "";
     }
     if (streamInfo.Contains("codec_type"))
     {
         CodecType = ((Cll.JSON.String)streamInfo.GetValue("codec_type")).Value;
     }
     else
     {
         CodecType = "";
     }
     if (streamInfo.Contains("bit_rate"))
     {
         Bitrate = Convert.ToInt32(((Cll.JSON.String)streamInfo.GetValue("bit_rate")).Value);
     }
     else
     {
         Bitrate = 0;
     }
     if (streamInfo.Contains("r_frame_rate"))
     {
         string   frameRate = ((Cll.JSON.String)streamInfo.GetValue("r_frame_rate")).Value;
         string[] a         = frameRate.Split(new char[] { '/' });
         if (a[1] != "0")
         {
             FrameRate = Convert.ToDouble(a[0]) / Convert.ToDouble(a[1]);
         }
         else
         {
             FrameRate = Double.NaN;
         }
     }
     else
     {
         FrameRate = Double.NaN;
     }
     if (streamInfo.Contains("duration"))
     {
         Duration = Convert.ToDouble(((Cll.JSON.String)streamInfo.GetValue("duration")).Value);
     }
     else
     {
         Duration = 0;
     }
     if (streamInfo.Contains("tags") && ((Cll.JSON.Object)streamInfo.GetValue("tags")).Contains("title"))
     {
         Title = ((Cll.JSON.String)streamInfo.GetValue("tags").GetValue("title")).Value;
     }
     else
     {
         Title = "";
     }
     if (streamInfo.Contains("tags") && ((Cll.JSON.Object)streamInfo.GetValue("tags")).Contains("language"))
     {
         Language = ((Cll.JSON.String)streamInfo.GetValue("tags").GetValue("language")).Value;
     }
     else
     {
         Language = "";
     }
 }