Esempio n. 1
0
 /// <summary>
 /// Used to peek at the raw trace entries without actually removing them.
 /// This method is thread-safe
 /// </summary>
 /// <param name="BeforePeek">Optional thread-safe action to run before the peek occurs.</param>
 /// <returns>All SSME tracelogs currently in the queue.</returns>
 public static TraceEntry[] PeekTraceEntries(Action BeforePeek)
 {
     lock (traceLock)
     {
         if (BeforePeek != null)
         {
             BeforePeek();
         }
         return(Tracing.GetTraceEntries(false));
     }
 }
Esempio n. 2
0
        static void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            TraceEntry[] entries;
            lock (traceLock)
            {
                entries = Tracing.GetTraceEntries(true) ?? new TraceEntry[] { };
            }
            // The TraceClient will raise an event to tell us about it. Event is will fire synchronously.
            traceClient.ParseTraceEntries(entries);

            if (PulseBackground != null)
            {
                PulseBackground();
            }

            if (ReportTraceLog != null)
            {
                ReportTraceLog(entries);
            }
        }
Esempio n. 3
0
        public void Refresh()
        {
            TraceEntry[] entries;
            lock (traceLock)
            {
                entries = Tracing.GetTraceEntries(true) ?? new TraceEntry[] { };
            }

            foreach (var entry in entries)
            {
                if (entry.TraceLevel == TraceLevel.Warning || entry.TraceLevel == TraceLevel.Fatal ||
                    entry.TraceLevel == TraceLevel.Error || entry.TraceLevel == TraceLevel.Shutdown)
                {
                    if (entry.TraceArea == TraceArea.BufferingEngine)
                    {
                        if (entry.MethodName == "HandleDownloadError")
                        {
                            if (ChunkFailure != null)
                            {
                                var args = GetChunkError(entry);
                                if (args != null)
                                {
                                    ChunkFailure(this, args);
                                }
                            }
                        }
                    }
                }
                else
                {
                    switch (entry.TraceArea)
                    {
                    case TraceArea.Heuristics:
                        if (entry.MethodName == "GetPerceivedBandwidth")
                        {
                            PerceivedBandwidth = GetPerceivedBandwidth(entry);
                        }
                        break;

                    case TraceArea.Test:
                        if (ChunkDownloaded != null)
                        {
                            try
                            {
                                // this trace message sometimes had bad data in it
                                string[] s = entry.Text.Split(' ');
                                if (s.Length == 17 && (s[5] == "V" || s[5] == "A"))
                                {
                                    var result = new Microsoft.Media.Analytics.ChunkDownloadedEventArgs();

                                    TimeSpan downloadTime;
                                    if (TimeSpan.TryParse(s[2], CultureInfo.CurrentCulture, out downloadTime))
                                    {
                                        result.DownloadTimeMs = (uint)downloadTime.TotalMilliseconds;
                                    }
                                    result.Bitrate    = uint.Parse(s[10]);
                                    result.ChunkId    = int.Parse(s[9]);
                                    result.ByteCount  = uint.Parse(s[7]);
                                    result.StreamType = s[5].ToLowerInvariant();
                                    // TODO: result.PerceivedBandwidth = 0;
                                    // TODO: result.StartTime = 0;
                                    ChunkDownloaded(this, result);
                                }
                            }
                            catch { /* ignore this exception, must have been a bad trace message */ }
                        }
                        break;

                    case TraceArea.BufferingEngine:
                        if (entry.MethodName == "AddChunkToCache")
                        {
                            var bufferSizeChange = GetBufferSize(entry);
                            if (bufferSizeChange.StreamType == "video")
                            {
                                VideoBufferSize = bufferSizeChange.Size;
                            }
                            else if (bufferSizeChange.StreamType == "audio")
                            {
                                AudioBufferSize = bufferSizeChange.Size;
                            }
                        }
                        break;
                    }
                }
            }
        }