void ReportSnapshotData(QualityData data) { VideoQualitySnapshotLog qualityLog = new VideoQualitySnapshotLog(); PopulateQualityLog(data, qualityLog); SendLog(qualityLog); }
void DoSomethingWithLog(Log log) { if (log is VideoQualitySnapshotLog) { VideoQualitySnapshotLog qualityLog = (VideoQualitySnapshotLog)log; double kbps = qualityLog.PerceivedBandwidth.GetValueOrDefault(0) / 1024; Bandwidth.Text = kbps.ToString() + " Kbps"; } }
void ProcessEvent(Log log) { if (log.Type != VideoLogTypes.Trace && log.Type != VideoLogTypes.VideoQualitySnapshot) { // weed these out, there are way too many of them. This is consistent with what a logagent that sends to the server would do too. Logs.Add(log); } IEnumerable <ChartViewModel> charts = ChartViewModel.Charts; switch (log.Type) { case VideoLogTypes.VideoQuality: QualityData = new QualityDataViewModel(log.CastLog <VideoQualityLog>()); break; case VideoLogTypes.VideoQualitySnapshot: VideoQualitySnapshotLog qualityLog = log.CastLog <VideoQualitySnapshotLog>(); foreach (ChartViewModel chartVM in charts) { if (log.Data.ContainsKey(chartVM.QualityAttribute)) { if (chartVM.QualityAttribute == VideoLogAttributes.PerceivedBandwidth) { chartVM.AddDataPoint(qualityLog.PerceivedBandwidth.GetValueOrDefault(0) / 1024); } else { chartVM.AddDataPoint(Convert.ToDouble(log.Data[chartVM.QualityAttribute])); } } } ClientIP = qualityLog.ClientIP.ToString(); EdgeServerIP = qualityLog.EdgeIP; SmoothStreamingUrl = qualityLog.VideoUrl; ProcessCPU = qualityLog.ProcessCPULoad.GetValueOrDefault(0); SystemCPU = qualityLog.SystemCPULoad.GetValueOrDefault(0); break; case VideoLogTypes.VideoStarted: case VideoLogTypes.VideoLoaded: VideoLoadLog loadLog = log.CastLog <VideoLoadLog>(); var bitrateChartData = charts.First(vm => vm.QualityAttribute == VideoLogAttributes.BitRate); if (loadLog.MaxBitRate.HasValue) { bitrateChartData.MaxValue = loadLog.MaxBitRate.Value; } ClientIP = loadLog.ClientIP.ToString(); EdgeServerIP = loadLog.EdgeIP; SmoothStreamingUrl = loadLog.VideoUrl; break; case VideoLogTypes.Trace: TraceLogs.Add(log.CastLog <TraceLog>()); break; } }