public HttpContent CreateHttpContent(byte[] ContentBytes, string MimeType, long?From, long?To)
        {
            long contentExtent = (long)ContentBytes.Length - 1;
            VideoStreamContentByteRange byteRange = VideoStreamFactoryHelper.ExtractByteRange(From, To, contentExtent);

            if (byteRange.From < 0 || byteRange.From > contentExtent || byteRange.To > contentExtent)
            {
                string errorMessage = "The requested range (bytes="
                                      + ((From.HasValue) ? From.Value.ToString() : "")
                                      + "-"
                                      + ((To.HasValue) ? To.Value.ToString() : "")
                                      + ") does not overlap with the current extent of the selected resource.";
                throw new InvalidByteRangeException(new ContentRangeHeaderValue(0, ContentBytes.Length), errorMessage);
            }

            VideoStreamContentByteRange[] singleByteRange = new VideoStreamContentByteRange[1];
            singleByteRange[0] = byteRange;

            var result = new VideoStreamContent(this, ContentBytes, MimeType, _bufferSize, _throttleRate, singleByteRange);

            result.Headers.ContentRange = new ContentRangeHeaderValue(byteRange.From, byteRange.To, ContentBytes.Length);
            result.Headers.ContentType  = new MediaTypeHeaderValue(MimeType);

            return(result);
        }
        public HttpContent CreateHttpContent(byte[] ContentBytes, string MimeType, RangeHeaderValue RequestRangeHeader)
        {
            long contentExtent = ContentBytes.Length - 1;
            var  byteRanges    = VideoStreamFactoryHelper.ExtractByteRanges(RequestRangeHeader, contentExtent);

            if (byteRanges.Length > 1)
            {
                var    result    = new VideoStreamContent(this, ContentBytes, MimeType, _bufferSize, _throttleRate, byteRanges);
                string mediaType = "multipart/byteranges";
                result.Headers.ContentType = new MediaTypeHeaderValue(mediaType);
                result.Headers.ContentType.Parameters.Add(new NameValueHeaderValue("boundary", _byteRangeBoundary.ToString()));

                return(result);
            }
            else
            {
                var from = RequestRangeHeader.Ranges.First().From;
                var to   = RequestRangeHeader.Ranges.First().To;

                return(CreateHttpContent(ContentBytes, MimeType, from, to));
            }
        }