3.6.5.2.4.3 Choosing Ranges

The client is given FRAGMENT_LENGTH in bytes, FRAGMENT_OFFSET in bytes, and the array of byte ranges APPLICATION_RANGES.

To set FRAGMENT_RANGES, the client MUST consider APPLICATION_RANGES as an aggregate collection of bytes, and FRAGMENT_OFFSET as the starting offset into it. Similarly, it MUST consider (FRAGMENT_OFFSET+FRAGMENT_LENGTH) as the ending offset. If (FRAGMENT_OFFSET+FRAGMENT_LENGTH) is greater than the number of bytes in APPLICATION_RANGES, then it MUST reduce FRAGMENT_LENGTH so that (FRAGMENT_OFFSET+FRAGMENT_LENGTH) equals the number of bytes in APPLICATION_RANGES.

The subset of ranges bounded by the starting and ending offsets MUST be stored in FRAGMENT_RANGES.

If SINGLE_RANGE_ONLY is TRUE, remove all but the first range from FRAGMENT_RANGES and set FRAGMENT_LENGTH to the length of that range.

As a concrete example, assume APPLICATION_RANGES contains the following array of ranges:

  • Offset 100, length 100

  • Offset 1000, length 100

  • Offset 200, length 100

and that FRAGMENT_OFFSET is 25, and FRAGMENT_LENGTH is 200. Then the starting offset is 25 bytes into the first range, and the ending offset is 200 bytes of APPLICATION_RANGES later, or 25 bytes into the third range. Thus, if SINGLE_RANGE_ONLY is false, FRAGMENT_RANGES is

  • Offset 125, length 75

  • Offset 1000, length 100

  • Offset 200, length 25

If SINGLE_RANGE_ONLY is true, then FRAGMENT_RANGES is

  • Offset 125, length 75

and FRAGMENT_LENGTH is 75.

Given the same APPLICATION_RANGES with FRAGMENT_OFFSET as 200 and FRAGMENT_LENGTH as 1000, the starting offset is the beginning of the third range. (FRAGMENT_OFFSET+FRAGMENT_LENGTH) is greater than the 100 bytes remaining in APPLICATION_RANGES, so FRAGMENT_LENGTH MUST be set to 100 and the resulting FRAGMENT_RANGES is

  • Offset 200, length 100