public HealthMonitor(DiagnosticsConfig config) { if (config == null) { throw new ArgumentNullException("config"); } ClientIP = EdgeServerDataClient.IpNA; EdgeServer = EdgeServerDataClient.IpNA; VideoSessionId = Guid.NewGuid(); Configuration = config; agent = new SamplingAgent(); if (config.TrackQuality) { agent.Agents.Add(new QualityAggregationAgent(config.AggregationInterval, config.QualityConfig)); } if (config.TrackQualitySnapshot) { agent.Agents.Add(new QualitySnapshotAgent(config.SnapshotInterval, config.QualityConfig)); } if (config.TrackDownloadErrors) { agent.Agents.Add(new DownloadErrorSampleAgent(Configuration)); } if (Configuration.InitTraceMonitor) { TraceMonitor.Init(Configuration.TracingConfig); } }
void ProcessQueuedEntries(SmoothStreamingEvent entry) { lock (realtimeEventQueue) { while (realtimeEventQueue.Count > 0 && (entry == null || realtimeEventQueue.Peek().Ticks < entry.Ticks)) { SmoothStreamingEvent queuedEntry = realtimeEventQueue.Dequeue(); if (queuedEntry.EventType == EventType.ClipStarted) { CurrentClipId = queuedEntry.ClipId; if (entry != null) { entry.ClipId = queuedEntry.ClipId; } } else if (queuedEntry.EventType == EventType.StreamLoaded) { CurrentStreamId = TraceMonitor.GenerateStreamIdentifier(); queuedEntry.StreamId = CurrentStreamId; if (entry != null) { entry.StreamId = CurrentStreamId; } } else { queuedEntry.ClipId = CurrentClipId; queuedEntry.StreamId = CurrentStreamId; } AddEvent(queuedEntry); } } }
/// <summary> /// Disconnects the SmoothStreamingMediaElement that was passed to the Attach method /// </summary> public void Detach() { TraceMonitor.Stop(); DetachEvents(); if (agent != null) { agent.Dispose(); } mediaElement = null; }
/// <summary> /// Forces a trace log to occur and then analyzes the MediaElementId used. This is only necessary if SSME.Name is not set. /// </summary> string GetMediaElementId() { TraceEntry[] trace = TraceMonitor.PeekTraceEntries(mediaElement.RequestLog); var log = trace.LastOrDefault(t => t.MethodName == "RequestLog"); if (log != null) { return(log.MediaElementId); } else { return(null); // the only way that this could happen is if someone else called Tracing.GetTraceEntries(true) on another thread } }
void mediaElement_ClipProgressUpdate(object sender, ClipPlaybackEventArgs e) { if (e.Progress == ClipProgress.Start) { SmoothStreamingEvent ssEvent = new SmoothStreamingEvent(); ssEvent.Data1 = e.Context.ClipInformation.ClipUri.ToString(); ssEvent.EventType = EventType.ClipStarted; ssEvent.ClipId = TraceMonitor.GenerateStreamIdentifier(); Enqueue(ssEvent); } else if (e.Progress == ClipProgress.Complete) { SmoothStreamingEvent ssEvent = new SmoothStreamingEvent(); ssEvent.EventType = EventType.ClipEnded; ssEvent.Data1 = e.Context.ClipInformation.ClipUri.ToString(); Enqueue(ssEvent); } }
/// <summary> /// Connects a SmoothStreamingMediaElement that needs to be monitored /// </summary> public void Attach(SmoothStreamingMediaElement smoothStreamingMediaElement) { if (smoothStreamingMediaElement == null) { throw new ArgumentNullException("smoothStreamingMediaElement"); } mediaElement = smoothStreamingMediaElement; if (!string.IsNullOrEmpty(mediaElement.Name)) // this allows TraceMonitor events to be filtered so we only capture ones associated with this instance of the SSME { mediaElementId = mediaElement.Name; } else { mediaElementId = GetMediaElementId(); } AttachEvents(); TraceMonitor.Start(); }