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;
        }
Exemple #3
0
        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;
        }
        private ChunkResponse TestChunk(SmoothStreamChunk chunk)
        {
            ChunkRetriever cr = new ChunkRetriever();
            var response = cr.DownloadChunkStatsOnly(chunk);

            _responses[chunk] = response;

            if (ChunkTested != null)
            {
                try
                {
                    this.ChunkTested(this, chunk, response);
                }
                catch (Exception ex)
                {
                    Log("Exception raising chunk tested event: " + ex.Message, false);
                }
            }

            return response;
        }
Exemple #5
0
 public void AddChunk(double fragmentIndex, int duration, int bitrate)
 {
     SmoothStreamChunk ssc = new SmoothStreamChunk(this, fragmentIndex, duration, bitrate);
     AddChunk(ssc);
 }
Exemple #6
0
 public void AddChunk(SmoothStreamChunk ssChunk)
 {
     _childChunks.Add(ssChunk);
 }
        private async Task<ChunkResponse> TestChunkAsync(SmoothStreamChunk chunk)
        {
            ChunkRetriever cr = new ChunkRetriever();
            var response = await cr.DownloadChunkStatsOnlyAsync(chunk.ChunkUrl);

            _responsesCon[chunk] = response;

            if (ChunkTested != null)
            {
                try
                {
                    this.ChunkTested(this, chunk, response);
                }
                catch (Exception ex)
                {
                    Log("Exception raising chunk tested event: " + ex.Message, false);
                }
            }

            return response;
        }