public ChunkResponse DownloadChunkStatsOnly(SmoothStreamChunk chunk) { ChunkResponse cr = new ChunkResponse() { RequestedAt = DateTime.Now }; try { var response = GetWebPageContent(chunk.ChunkUrl, 1000); } catch (WebException webEx) { using (WebResponse response = webEx.Response) { ReturnStatusCode = (response as HttpWebResponse).StatusCode; } } catch (Exception) { } cr.ResponseCompletedAt = DateTime.Now; cr.Headers = _responseHeaders; cr.ReturnStatusCode = ReturnStatusCode; return cr; }
public ResponseRating RateChunkResponse(SmoothStreamChunk chunk, ChunkResponse response) { if (response.Elapsed.HasValue == false) { return ResponseRating.Unknown; } if (response.ReturnStatusCodeNumeric > 400) { return ResponseRating.Failed; } int[] thresholdMeasurement = _videoThresholds; if (chunk.IsAudio) { thresholdMeasurement = _audioThresholds; } for (int thresholdIndex = 0; thresholdIndex < thresholdMeasurement.Length; thresholdIndex++) { int responseThreshold = thresholdMeasurement[thresholdIndex]; if (response.Elapsed.Value.TotalMilliseconds < responseThreshold) { return (ResponseRating)thresholdIndex; } } if (response.Elapsed.Value.TotalMilliseconds > thresholdMeasurement.Max()) { return ResponseRating.Poor; } return ResponseRating.Unknown; }
public async Task<ChunkResponse> DownloadChunkStatsOnlyAsync(string chunkUrl) { ChunkResponse cr = new ChunkResponse() { RequestedAt = DateTime.Now }; try { var response = await GetWebPageContentAsync(chunkUrl, 1000); } catch (WebException webEx) { using (WebResponse response = webEx.Response) { ReturnStatusCode = (response as HttpWebResponse).StatusCode; } } catch (Exception) { } cr.ResponseCompletedAt = DateTime.Now; cr.Headers = _responseHeaders; cr.ReturnStatusCode = ReturnStatusCode; return cr; }
static void OnChunkTested(SmoothStreamPerformanceTest test, SmoothStreamChunk chunk, ChunkResponse chunkResponse) { var rating = new ChunkResponseAnalyzer().RateChunkResponse(chunk, chunkResponse); string ratingText = rating.ToString(); if (!_ratingCounters.ContainsKey(ratingText)) { _ratingCounters[ratingText] = 0; } _ratingCounters[ratingText] += 1; }