Example #1
0
        static BufferSizeResult GetBufferSize(TraceEntry entry)
        {
            string streamType = "";
            uint   bufferSize = 0;

            const string regexString = "Added (?<d2>.*) chunk with duration (?<d1>.*) to cache. Size including active chunk (?<v>.*) ms";
            Regex        regex       = new Regex(regexString);

            if (regex.IsMatch(entry.Text))
            {
                ChunkFailureEventArgs result = new ChunkFailureEventArgs();
                var matches      = regex.Matches(entry.Text);
                var valueCapture = matches[0].Groups["v"].Captures;
                if (valueCapture.Count > 0)
                {
                    uint.TryParse(valueCapture[0].Value, NumberStyles.None, CultureInfo.CurrentCulture, out bufferSize);
                }
                var data2Capture = matches[0].Groups["d2"].Captures;
                if (data2Capture.Count > 0)
                {
                    streamType = data2Capture[0].Value.ToLowerInvariant();
                }
            }
            return(new BufferSizeResult(streamType, bufferSize));
        }
Example #2
0
 void AdaptiveMonitor_ChunkFailure(object sender, ChunkFailureEventArgs e)
 {
     AddLog(new DownloadErrorLog()
     {
         ChunkId      = e.ChunkId,
         HttpResponse = e.HttpResponse
     });
 }
Example #3
0
        static ChunkFailureEventArgs GetChunkError(TraceEntry entry)
        {
            const string regexString = "Download error for (?<d1>.*) chunk id (?<d2>.*) startTime (?<d3>.*) timeout = .*";
            Regex        regex       = new Regex(regexString);

            if (regex.IsMatch(entry.Text))
            {
                string streamType = string.Empty;
                int    chunkId    = 0;
                ulong  startTime  = 0;

                var matches      = regex.Matches(entry.Text);
                var data1Capture = matches[0].Groups["d1"].Captures;
                if (data1Capture.Count > 0)
                {
                    streamType = data1Capture[0].Value;
                }
                var data2Capture = matches[0].Groups["d2"].Captures;
                if (data2Capture.Count > 0)
                {
                    int value;
                    if (int.TryParse(data2Capture[0].Value, out value))
                    {
                        chunkId = value;
                    }
                }
                var data3Capture = matches[0].Groups["d3"].Captures;
                if (data3Capture.Count > 0)
                {
                    ulong value;
                    if (ulong.TryParse(data2Capture[0].Value, out value))
                    {
                        startTime = value;
                    }
                }

                ChunkFailureEventArgs result = new ChunkFailureEventArgs();
                result.ChunkId = string.Format("{0}/{1}", streamType, chunkId);
                return(result);
            }
            return(null);
        }
Example #4
0
        static uint GetPerceivedBandwidth(TraceEntry entry)
        {
            const string regexString = "NetworkHeuristicsModule - Perceived bandwidth using .* sliding windows and .* method is (?<v>.*) bytes/sec \\[(?<d1>.*)\\]";
            Regex        regex       = new Regex(regexString);

            if (regex.IsMatch(entry.Text))
            {
                ChunkFailureEventArgs result = new ChunkFailureEventArgs();
                var matches      = regex.Matches(entry.Text);
                var valueCapture = matches[0].Groups["v"].Captures;
                if (valueCapture.Count > 0)
                {
                    uint value;
                    if (uint.TryParse(valueCapture[0].Value, NumberStyles.None, CultureInfo.CurrentCulture, out value))
                    {
                        return(value);
                    }
                }
            }
            return(0);
        }
Example #5
0
        void OnStatusUpdated(AdaptiveSourceStatusUpdatedEventArgs args)
        {
            switch (args.UpdateType)
            {
            case AdaptiveSourceStatusUpdateType.NextChunkHttpInvalid:
            case AdaptiveSourceStatusUpdateType.ChunkConnectHttpInvalid:
                if (ChunkFailure != null)
                {
                    var failureEventArgs = new ChunkFailureEventArgs();
                    failureEventArgs.HttpResponse = args.HttpResponse;
                    failureEventArgs.ChunkId      = args.AdditionalInfo;
                    ChunkFailure(this, failureEventArgs);
                }
                break;

            case AdaptiveSourceStatusUpdateType.BitrateChanged:
                var videoStream = VideoStream;
                if (videoStream != null)
                {
                    var bitrateInfo   = args.AdditionalInfo.Split(';');
                    var bitrate       = uint.Parse(bitrateInfo[0]);
                    var timeStamp     = long.Parse(bitrateInfo[1]);
                    var selectedTrack = videoStream.SelectedTracks.FirstOrDefault(t => t.Bitrate == bitrate);
                    if (selectedTrack != null)
                    {
                        lock (bitrateLog)     // make this is thread safe since we'll be accessing it from the UI thread in .RefreshState
                        {
                            bitrateLog.Add(new BitrateLogEntry(timeStamp, selectedTrack));
                        }
                    }
                }
                break;

            case AdaptiveSourceStatusUpdateType.ChunkDownloaded:
                var addtionalInfo               = args.AdditionalInfo.Split(';');
                var chunkIndex                  = int.Parse(addtionalInfo[0]);
                var url                         = addtionalInfo[1];
                var mediaStreamType             = (Microsoft.Media.AdaptiveStreaming.MediaStreamType) int.Parse(addtionalInfo[2]);
                var chunkStartTimeHns           = ulong.Parse(addtionalInfo[3]);
                var chunkDurationns             = ulong.Parse(addtionalInfo[4]);
                var chunkBitrate                = uint.Parse(addtionalInfo[5]);
                var chunkByteCount              = uint.Parse(addtionalInfo[6]);
                var downloadRequestTimeMs       = uint.Parse(addtionalInfo[7]);
                var downloadCompletedTimeMs     = uint.Parse(addtionalInfo[8]);
                var chunkPerceivedBandwidth     = uint.Parse(addtionalInfo[9]);
                var avgPerceivedBandwidth       = uint.Parse(addtionalInfo[10]);
                var bufferLevelAtRequested90kHz = uint.Parse(addtionalInfo[11]);
                var bufferLevelAtCompleted90kHz = uint.Parse(addtionalInfo[12]);
                var responseHeaders             = addtionalInfo[13];

                // update properties
                PerceivedBandwidth = avgPerceivedBandwidth;
                switch (mediaStreamType)
                {
                case MediaStreamType.Audio:
                    AudioBufferSize = bufferLevelAtCompleted90kHz;
                    break;

                case MediaStreamType.Video:
                    VideoBufferSize = bufferLevelAtCompleted90kHz;
                    break;
                }

                if (ChunkDownloaded != null)     // notify that a new chunk has downloaded
                {
                    var chunkInfo = new ChunkDownloadedEventArgs();
                    chunkInfo.ChunkId            = chunkIndex;
                    chunkInfo.DownloadTimeMs     = downloadCompletedTimeMs - downloadRequestTimeMs;
                    chunkInfo.StartTime          = chunkStartTimeHns;
                    chunkInfo.StreamType         = mediaStreamType.ToString().ToLowerInvariant();
                    chunkInfo.PerceivedBandwidth = chunkPerceivedBandwidth;
                    chunkInfo.Bitrate            = chunkBitrate;
                    chunkInfo.ByteCount          = chunkByteCount;
                    ChunkDownloaded(this, chunkInfo);
                }
                break;
            }
        }
        static ChunkFailureEventArgs GetChunkError(TraceEntry entry)
        {
            const string regexString = "Download error for (?<d1>.*) chunk id (?<d2>.*) startTime (?<d3>.*) timeout = .*";
            Regex regex = new Regex(regexString);
            if (regex.IsMatch(entry.Text))
            {
                string streamType = string.Empty;
                int chunkId = 0;
                ulong startTime = 0;

                var matches = regex.Matches(entry.Text);
                var data1Capture = matches[0].Groups["d1"].Captures;
                if (data1Capture.Count > 0)
                {
                    streamType = data1Capture[0].Value;
                }
                var data2Capture = matches[0].Groups["d2"].Captures;
                if (data2Capture.Count > 0)
                {
                    int value;
                    if (int.TryParse(data2Capture[0].Value, out value))
                    {
                        chunkId = value;
                    }
                }
                var data3Capture = matches[0].Groups["d3"].Captures;
                if (data3Capture.Count > 0)
                {
                    ulong value;
                    if (ulong.TryParse(data2Capture[0].Value, out value))
                    {
                        startTime = value;
                    }
                }

                ChunkFailureEventArgs result = new ChunkFailureEventArgs();
                result.ChunkId = string.Format("{0}/{1}", streamType, chunkId);
                return result;
            }
            return null;
        }
 static uint GetPerceivedBandwidth(TraceEntry entry)
 {
     const string regexString = "NetworkHeuristicsModule - Perceived bandwidth using .* sliding windows and .* method is (?<v>.*) bytes/sec \\[(?<d1>.*)\\]";
     Regex regex = new Regex(regexString);
     if (regex.IsMatch(entry.Text))
     {
         ChunkFailureEventArgs result = new ChunkFailureEventArgs();
         var matches = regex.Matches(entry.Text);
         var valueCapture = matches[0].Groups["v"].Captures;
         if (valueCapture.Count > 0)
         {
             uint value;
             if (uint.TryParse(valueCapture[0].Value, NumberStyles.None, CultureInfo.CurrentCulture, out value))
             {
                 return value;
             }
         }
     }
     return 0;
 }
        static BufferSizeResult GetBufferSize(TraceEntry entry)
        {
            string streamType = "";
            uint bufferSize = 0;

            const string regexString = "Added (?<d2>.*) chunk with duration (?<d1>.*) to cache. Size including active chunk (?<v>.*) ms";
            Regex regex = new Regex(regexString);
            if (regex.IsMatch(entry.Text))
            {
                ChunkFailureEventArgs result = new ChunkFailureEventArgs();
                var matches = regex.Matches(entry.Text);
                var valueCapture = matches[0].Groups["v"].Captures;
                if (valueCapture.Count > 0)
                {
                    uint.TryParse(valueCapture[0].Value, NumberStyles.None, CultureInfo.CurrentCulture, out bufferSize);
                }
                var data2Capture = matches[0].Groups["d2"].Captures;
                if (data2Capture.Count > 0)
                {
                    streamType = data2Capture[0].Value.ToLowerInvariant();
                }
            }
            return new BufferSizeResult(streamType, bufferSize);
        }