public TwitchVideo(JToken apiResponse) { int length, views, audioFps; double mediumFps, mobileFps, highFps, lowFps, chunkedFps; if (int.TryParse(apiResponse.SelectToken("length").ToString(), out length)) _length = length; if (int.TryParse(apiResponse.SelectToken("views").ToString(), out views)) _views = views; int.TryParse(apiResponse.SelectToken("fps").SelectToken("audio_only").ToString(), out audioFps); double.TryParse(apiResponse.SelectToken("fps").SelectToken("medium").ToString(), out mediumFps); double.TryParse(apiResponse.SelectToken("fps").SelectToken("mobile").ToString(), out mobileFps); double.TryParse(apiResponse.SelectToken("fps").SelectToken("high").ToString(), out highFps); double.TryParse(apiResponse.SelectToken("fps").SelectToken("low").ToString(), out lowFps); double.TryParse(apiResponse.SelectToken("fps").SelectToken("chunked").ToString(), out chunkedFps); _broadcastId = apiResponse.SelectToken("broadcast_id").ToString(); _description = apiResponse.SelectToken("description").ToString(); _fps = new FpsData(audioFps, mediumFps, mobileFps, highFps, lowFps, chunkedFps); _game = apiResponse.SelectToken("game").ToString(); _id = apiResponse.SelectToken("_id").ToString(); _preview = apiResponse.SelectToken("preview").ToString(); _recordedAt = apiResponse.SelectToken("recorded_at").ToString(); _status = apiResponse.SelectToken("status").ToString(); _tagList = apiResponse.SelectToken("tag_list").ToString(); _title = apiResponse.SelectToken("title").ToString(); _url = apiResponse.SelectToken("url").ToString(); _resolutions = new ResolutionsData(apiResponse.SelectToken("resolutions").SelectToken("medium").ToString(), apiResponse.SelectToken("resolutions").SelectToken("mobile").ToString(), apiResponse.SelectToken("resolutions").SelectToken("high").ToString(), apiResponse.SelectToken("resolutions").SelectToken("low").ToString(), apiResponse.SelectToken("resolutions").SelectToken("chunked").ToString()); _channel = new ChannelData(apiResponse.SelectToken("channel").SelectToken("name").ToString(), apiResponse.SelectToken("channel").SelectToken("display_name").ToString()); }
private void Update() { #if UNITY_EDITOR if (!UnityEditor.EditorApplication.isPlaying) { return; } #endif FpsData.Update(); SendDbgInfo(); }
/// <summary> /// 添加/更新 自定义帧率统计 /// </summary> /// <param name="key"></param> public void UpdateCustomFps(string key) { FpsData data; if (!customFps.TryGetValue(key, out data)) { data = new FpsData { name = key } } ; data.fpsCount++; }
/// <summary> /// Record the current framerate. /// </summary> public static void SampleFramerate(float avgFps) { if (ReportData == null) { return; } FpsData fpsData = new FpsData(); fpsData.CurrentStepDataName = ReportData.Tests.Any() && ReportData.Tests.Last().Steps.Any() ? $"{ReportData.Tests.Last().TestName} > [{ReportData.Tests.Last().Steps.Last().ActionType.ToUpper()} {ReportData.Tests.Last().Steps.Last().Hierarchy} > {ReportData.Tests.Last().Steps.Last().Name}]" : string.Empty; fpsData.Fps = Math.Round(avgFps, 0).ToString(); fpsData.TimeStamp = Math.Round(Time.time, 1).ToString(); ReportData.FpsData.Add(fpsData); }
/// <summary> /// Video constructor /// </summary> /// <param name="apiResponse">API response string from Twitch call.</param> public Video(JToken apiResponse) { int length = -1; int views = -1; int audioFps = -1; double mediumFps = -1; double mobileFps = -1; double highFps = -1; double lowFps = -1; double chunkedFps = -1; if (int.TryParse(apiResponse.SelectToken("length").ToString(), out length)) Length = length; if (int.TryParse(apiResponse.SelectToken("views").ToString(), out views)) Views = views; if(apiResponse.SelectToken("fps").SelectToken("audio_only") != null) int.TryParse(apiResponse.SelectToken("fps").SelectToken("audio_only").ToString(), out audioFps); if(apiResponse.SelectToken("fps").SelectToken("medium") != null) double.TryParse(apiResponse.SelectToken("fps").SelectToken("medium").ToString(), out mediumFps); if(apiResponse.SelectToken("fps").SelectToken("mobile") != null) double.TryParse(apiResponse.SelectToken("fps").SelectToken("mobile").ToString(), out mobileFps); if(apiResponse.SelectToken("fps").SelectToken("high") != null) double.TryParse(apiResponse.SelectToken("fps").SelectToken("high").ToString(), out highFps); if(apiResponse.SelectToken("fps").SelectToken("low") != null) double.TryParse(apiResponse.SelectToken("fps").SelectToken("low").ToString(), out lowFps); if(apiResponse.SelectToken("fps").SelectToken("chunked") != null) double.TryParse(apiResponse.SelectToken("fps").SelectToken("chunked").ToString(), out chunkedFps); BroadcastId = apiResponse.SelectToken("broadcast_id").ToString(); Description = apiResponse.SelectToken("description").ToString(); Fps = new FpsData(audioFps, mediumFps, mobileFps, highFps, lowFps, chunkedFps); Game = apiResponse.SelectToken("game").ToString(); Id = apiResponse.SelectToken("_id").ToString(); Preview = apiResponse.SelectToken("preview").ToString(); RecordedAt = Common.DateTimeStringToObject(apiResponse.SelectToken("recorded_at").ToString()); TimeSinceRecorded = DateTime.UtcNow - RecordedAt; Status = apiResponse.SelectToken("status").ToString(); TagList = apiResponse.SelectToken("tag_list").ToString(); Title = apiResponse.SelectToken("title").ToString(); Url = apiResponse.SelectToken("url").ToString(); Resolutions = new ResolutionsData(apiResponse.SelectToken("resolutions").SelectToken("medium").ToString(), apiResponse.SelectToken("resolutions").SelectToken("mobile").ToString(), apiResponse.SelectToken("resolutions").SelectToken("high").ToString(), apiResponse.SelectToken("resolutions").SelectToken("low").ToString(), apiResponse.SelectToken("resolutions").SelectToken("chunked").ToString()); Channel = new ChannelData(apiResponse.SelectToken("channel").SelectToken("name").ToString(), apiResponse.SelectToken("channel").SelectToken("display_name").ToString()); }
public TwitchVideo(JToken apiResponse) { int length, views, audioFps; double mediumFps, mobileFps, highFps, lowFps, chunkedFps; if (int.TryParse(apiResponse.SelectToken("length").ToString(), out length)) { _length = length; } if (int.TryParse(apiResponse.SelectToken("views").ToString(), out views)) { _views = views; } int.TryParse(apiResponse.SelectToken("fps").SelectToken("audio_only").ToString(), out audioFps); double.TryParse(apiResponse.SelectToken("fps").SelectToken("medium").ToString(), out mediumFps); double.TryParse(apiResponse.SelectToken("fps").SelectToken("mobile").ToString(), out mobileFps); double.TryParse(apiResponse.SelectToken("fps").SelectToken("high").ToString(), out highFps); double.TryParse(apiResponse.SelectToken("fps").SelectToken("low").ToString(), out lowFps); double.TryParse(apiResponse.SelectToken("fps").SelectToken("chunked").ToString(), out chunkedFps); _broadcastId = apiResponse.SelectToken("broadcast_id").ToString(); _description = apiResponse.SelectToken("description").ToString(); _fps = new FpsData(audioFps, mediumFps, mobileFps, highFps, lowFps, chunkedFps); _game = apiResponse.SelectToken("game").ToString(); _id = apiResponse.SelectToken("_id").ToString(); _preview = apiResponse.SelectToken("preview").ToString(); _recordedAt = apiResponse.SelectToken("recorded_at").ToString(); _status = apiResponse.SelectToken("status").ToString(); _tagList = apiResponse.SelectToken("tag_list").ToString(); _title = apiResponse.SelectToken("title").ToString(); _url = apiResponse.SelectToken("url").ToString(); _resolutions = new ResolutionsData(apiResponse.SelectToken("resolutions").SelectToken("medium").ToString(), apiResponse.SelectToken("resolutions").SelectToken("mobile").ToString(), apiResponse.SelectToken("resolutions").SelectToken("high").ToString(), apiResponse.SelectToken("resolutions").SelectToken("low").ToString(), apiResponse.SelectToken("resolutions").SelectToken("chunked").ToString()); _channel = new ChannelData(apiResponse.SelectToken("channel").SelectToken("name").ToString(), apiResponse.SelectToken("channel").SelectToken("display_name").ToString()); }
private void Update() { FpsData.Update(); SendDbgInfo(); }
/// <summary> /// Video constructor /// </summary> /// <param name="apiResponse">API response string from Twitch call.</param> public Video(JToken apiResponse) { int length = -1; int views = -1; int audioFps = -1; double mediumFps = -1; double mobileFps = -1; double highFps = -1; double lowFps = -1; double chunkedFps = -1; if (int.TryParse(apiResponse.SelectToken("length").ToString(), out length)) { Length = length; } if (int.TryParse(apiResponse.SelectToken("views").ToString(), out views)) { Views = views; } if (apiResponse.SelectToken("fps").SelectToken("audio_only") != null) { int.TryParse(apiResponse.SelectToken("fps").SelectToken("audio_only").ToString(), out audioFps); } if (apiResponse.SelectToken("fps").SelectToken("medium") != null) { double.TryParse(apiResponse.SelectToken("fps").SelectToken("medium").ToString(), out mediumFps); } if (apiResponse.SelectToken("fps").SelectToken("mobile") != null) { double.TryParse(apiResponse.SelectToken("fps").SelectToken("mobile").ToString(), out mobileFps); } if (apiResponse.SelectToken("fps").SelectToken("high") != null) { double.TryParse(apiResponse.SelectToken("fps").SelectToken("high").ToString(), out highFps); } if (apiResponse.SelectToken("fps").SelectToken("low") != null) { double.TryParse(apiResponse.SelectToken("fps").SelectToken("low").ToString(), out lowFps); } if (apiResponse.SelectToken("fps").SelectToken("chunked") != null) { double.TryParse(apiResponse.SelectToken("fps").SelectToken("chunked").ToString(), out chunkedFps); } BroadcastId = apiResponse.SelectToken("broadcast_id").ToString(); Description = apiResponse.SelectToken("description").ToString(); Fps = new FpsData(audioFps, mediumFps, mobileFps, highFps, lowFps, chunkedFps); Game = apiResponse.SelectToken("game").ToString(); Id = apiResponse.SelectToken("_id").ToString(); Preview = apiResponse.SelectToken("preview").ToString(); RecordedAt = Common.DateTimeStringToObject(apiResponse.SelectToken("recorded_at").ToString()); TimeSinceRecorded = DateTime.UtcNow - RecordedAt; Status = apiResponse.SelectToken("status").ToString(); TagList = apiResponse.SelectToken("tag_list").ToString(); Title = apiResponse.SelectToken("title").ToString(); Url = apiResponse.SelectToken("url").ToString(); Resolutions = new ResolutionsData(apiResponse.SelectToken("resolutions").SelectToken("medium").ToString(), apiResponse.SelectToken("resolutions").SelectToken("mobile").ToString(), apiResponse.SelectToken("resolutions").SelectToken("high").ToString(), apiResponse.SelectToken("resolutions").SelectToken("low").ToString(), apiResponse.SelectToken("resolutions").SelectToken("chunked").ToString()); Channel = new ChannelData(apiResponse.SelectToken("channel").SelectToken("name").ToString(), apiResponse.SelectToken("channel").SelectToken("display_name").ToString()); }