From cecaa1e39d90a0de9ec54bf0b30f3c3c0234b874 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Thu, 12 Oct 2023 14:24:51 +1100 Subject: [PATCH 01/46] WIP --- media-source-respec.html | 248 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 246 insertions(+), 2 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 1ab07db..26f16af 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -273,6 +273,8 @@

MediaSource Object

a media element=] algorithm. The extended [=resource fetch algorithm=] uses this internal slot to conditionally fail attachment of a {{MediaSource}} using a {{MediaSourceHandle}} set on a {{HTMLMediaElement}}'s {{HTMLMediaElement/srcObject}} attribute.

+

Each {{MediaSource}} object has a [[\is actively managed flag]] internal slot that stores a boolean indicating if the MediaSource object is actively managing its content or not. + It is initialized to false when the MediaSource object is created.

enum ReadyState {
     "closed",
@@ -412,8 +414,17 @@ 

Attributes

  • If the {{MediaSource/readyState}} attribute is not in the {{ReadyState/""open""}} state then throw an {{InvalidStateError}} exception and abort these steps.
  • -
  • Create a new SourceBuffer object and associated resources.
  • -
  • Set the {{SourceBuffer/[[generate timestamps flag]]}} on the new object to the value in the "Generate +
  • +
    +
    If the {{MediaSource/[[is actively managed flag]]}} equals false:
    +
    + Create a new {{SourceBuffer}} object and associated resources. +
    +
    Otherwise:
    +
    + Create a new {{ManagedSourceBuffer}} object and associated resources. +
    +
    Set the {{SourceBuffer/[[generate timestamps flag]]}} on the new object to the value in the "Generate Timestamps Flag" column of the byte stream format registry [[MSE-REGISTRY]] entry that is associated with |type|.
  • @@ -2706,6 +2717,239 @@

    Event Summary

    +
    +

    ManagedMediaSource Object

    +

    The ManagedMediaSource object is a MediaSource object that actively manages its memory content. + Unlike a MediaSource object it can evict from its ManagedSourceBuffer objects when the User Agent is under memory pressure.

    + +

    Each {{ManagedMediaSource}} object has a [[\is actively managed flag]] internal + slot that stores a {{boolean}}. It is initialized to true when the {{ManagedMediaSource}} object is created.

    + +
    [Exposed=(Window,DedicatedWorker)]
    +interface ManagedMediaSource : MediaSource {
    +    constructor();
    +
    +    readonly attribute boolean          streaming;
    +             attribute EventHandler     onstartstreaming;
    +             attribute EventHandler     onendstreaming;
    +
    +             static boolean          isTypeSupported (DOMString type);
    + };
    +
    +

    Attributes

    +
    + +
    streaming of type boolean, readonly
    +

    On getting, run the following steps:

    +
      +
    1. If the {{MediaSource/readyState}} attribute is {{ReadyState/""closed""}} then return false and abort these steps.
    2. +
    3. Return the current value of the attribute.
    4. +
    +
    onstartstreaming of type {{EventHandler}}
    +

    The event handler for the {{startstreaming}} event.

    +
    onendstreaming of type {{EventHandler}}
    +

    The event handler for the {{endstreaming}} event.

    +
    isTypeSupported, static
    +

    Check to see whether the ManagedMediaSource is capable of creating ManagedSourceBuffer objects for the specified MIME type.

    + +
      +
    1. If |type:DOMString| is an empty string, then return false.
    2. +
    3. If |type| does not contain a valid MIME type string, then return false.
    4. +
    5. If |type| contains a media type or media subtype that the ManagedMediaSource does not support, then return false.
    6. +
    7. If |type| contains a codec that the ManagedMediaSource does not support, then return false.
    8. +
    9. If the ManagedMediaSource does not support the specified combination of media type, media subtype, and codecs then return false.
    10. +
    11. Return true.
    12. +
    +

    + If true is returned from this method, it only indicates that the ManagedMediaSource implementation is capable of creating ManagedSourceBuffer objects for the specified MIME type. An {{MediaSource/addSourceBuffer()}} call SHOULD still fail if sufficient resources are not available to support the addition of a new ManagedSourceBuffer. +

    +

    + This method returning true implies that HTMLMediaElement.canPlayType() will return "maybe" or "probably" since it does not make sense for a ManagedMediaSource to support a type the HTMLMediaElement knows it cannot play. +

    +
    ParameterTypeNullableOptionalDescription
    |type|{{DOMString}}
    Return type: {{boolean}}
    +
    + +
    +

    Event Summary

    + + + + + + + + + + + + + + + + + + + + +
    Event nameInterfaceDispatched when...
    startstreamingEvent{{ManagedMediaSource/streaming}} transitions from {{""false""}} to {{""true""}}.
    endstreamingEvent{{ManagedMediaSource/streaming}} transitions from {{""true""}} to {{""false""}}.
    +
    +
    +

    Algorithms

    +
    +

    ManagedSourceBuffer Monitoring

    +

    The following steps are run periodically, whenever the {{MediaSource}} SourceBuffer Monitoring algorithm was scheduled to be running.

    +

    Having enough managed data to ensure uninterrupted playback is an implementation specific condition where the user agent + determines that it currently has enough data to play the presentation without stalling for a meaningful period of time and that it can achieve a balance between optimal memory and energy usage. + This condition is constantly evaluated to determine when to transition the media element into and out of the {{HTMLMediaElement/HAVE_ENOUGH_DATA}} ready state. + These transitions indicate when the user agent believes it has enough data buffered or it needs more data respectively.

    +
      +
    1. +
      +
      If the {{MediaSource/readyState}} attribute is {{ReadyState/""closed""}}:
      +
      +
        +
      1. Set the {{ManagedMediaSource.streaming}} attribute to false.
      2. +
      3. Abort these steps.
      4. +
      +
      +
      +
    2. +
    3. Run the {{MediaSource}} SourceBuffer Monitoring algorithm
    4. +
    5. +
      +
      If {{HTMLMediaElement}}.{{HTMLMediaElement/buffered}} contains a {{TimeRanges}} that includes the current playback position and not [=enough managed data to ensure uninterrupted playback=]:
      +
      +
        +
      1. Set the {{ManagedMediaSource.streaming}} attribute to true.
      2. +
      3. Abort these steps.
      4. +
      +
      +
      +
    6. +
    7. +
      +
      If {{HTMLMediaElement}}.{{HTMLMediaElement/buffered}} contains a {{TimeRanges}} that includes the current playback position and [=enough managed data to ensure uninterrupted playback=]:
      +
      +
        +
      1. Set the {{ManagedMediaSource.streaming}} attribute to false.
      2. +
      3. Abort these steps.
      4. +
      +
      +
      +
    8. +
    +
    +
    +

    Memory pressure

    +
      +
    1. +
      +
      For each {{ManagedSourceBuffer}} found in {{MediaSource.sourceBuffers}}:
      +
      +
        +
      1. Run the ManagedSourceBuffer memory pressure algorithm.
      2. +
      +
      +
      +
    2. +
    +
    +
    +
    + +
    +

    ManagedSourceBuffer Object

    + + +
    [Exposed=Window,DedicatedWorker]
    +interface BufferedChangeEvent : Event {
    +    constructor(DOMString type, optional BufferedChangeEventInit eventInitDict);
    +
    +    [SameObject] readonly attribute TimeRanges? addedRanges;
    +    [SameObject] readonly attribute TimeRanges? removedRanges;
    +};
    +
    +dictionary BufferedChangeEventInit : EventInit {
    +    TimeRanges? addedRanges = null;
    +    TimeRanges? removedRanges = null;
    +};
    +
    Description of {{BufferedChangeEvent}} event
    ValueDescription
    addedRanges +

    The TimeRanges added during the last appendBuffer() operation.

    +
    removedRanges +

    The TimeRanges removed during the last remove() operation or if the User-Agent evicted content in response to a memory pressure.

    +
    + +
    [Exposed=(Window,DedicatedWorker)]
    +interface ManagedSourceBuffer : SourceBuffer {
    +                 attribute EventHandler     onbufferedchange;
    +};
    +

    Attributes

    +
    +
    onbufferedchange of type {{EventHandler}}
    +
    +

    The event handler for the {{bufferedchange}} event.

    +
    +
    +
    +

    Event Summary

    + + + + + + + + + + + + + + + +
    Event nameInterfaceDispatched when...
    bufferedchangeEventThe ManagedSourceBuffer's buffered range changed following an appendBuffer, remove or [=memory pressure algorithm=].
    +
    +
    +
    +

    Algorithms

    +
    +

    Buffered Change

    +

    The following steps are run whenever a change to the {{ManagedSourceBuffer}} is performed that would cause {{SourceBuffer.buffered}} to change. +

      +
    1. Let |previous buffered ranges:normalized TimeRanges| equal the {{SourceBuffer.buffered}} attribute before the changes occurred.
    2. +
    3. Let |new buffered ranges:normalized TimeRanges| equal the new {{SourceBuffer.buffered}} TimeRanges.
    4. +
    5. Let |added ranges:normalized TimeRanges| equal the |previous buffered ranges:normalized TimeRanges| substracted from |new buffered ranges:normalized TimeRanges|.
    6. +
    7. Let |removed ranges:normalized TimeRanges| equal the |new buffered ranges:normalized TimeRanges| substracted from |previous buffered ranges:normalized TimeRanges| .
    8. +
    9. and [=queue a task=] to [=fire an event=] named {{bufferedchange}} at {{ManagedSourceBuffer}} with the |added ranges| and |removed ranges|
    10. +
    +
    +
    +

    Memory pressure

    +
      +
    1. +
      +
      If |managedSourceBuffer| is not in {{MediaSource/activeSourceBuffers}}:
      +
      +
        +
      1. Run the Range Removal Algorithm with removal range set to [0, positive infinity].
      2. +
      3. Abort those steps.
      4. +
      +
      +
      +
    2. +
    3. Let |removal ranges:normalized TimeRanges| equal a list of presentation time ranges that can be evicted from the presentation to ensure uninterrupted playback from {{HTMLMediaElement.currentTime}} + until such presentation could be fetched again. +

      Implementations MAY use different methods for selecting |removal ranges| so web applications SHOULD NOT depend on a + specific behavior. The web application should listen to the {{ManagedSourceBuffer/bufferedchange}} event to observe whether portions of the buffered data have been evicted. +

      +
    4. +
    5. For each range in |removal ranges|, run the [=coded frame removal=] algorithm with |start:double| and |end:unrestricted double| equal to + the removal range start and end timestamp respectively.
    6. +
    +
    +
    + +

    HTMLMediaElement Extensions

    This section specifies what existing {{HTMLMediaElement}}.{{HTMLMediaElement/seekable}} and From 8b8b51fbc872d62854a2aad5d66746e0e89d7fa2 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Mon, 16 Oct 2023 17:53:49 +1100 Subject: [PATCH 02/46] Add examples --- media-source-respec.html | 67 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 26f16af..2dbbc24 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -3296,7 +3296,8 @@

    Byte Stream Formats

    Examples

    -

    Example use of the Media Source Extensions

    +
    +

    Use of the Media Source Extensions

    <script>
    @@ -3392,6 +3393,70 @@ 

    Examples

    +

    Example use of the Managed Media Source Extensions

    +
    +
    +
    <script>
    +async function setUpVideoStream(){
    +  // Specific video format and codec
    +  const mediaType = 'video/mp4; codecs="mp4a.40.2,avc1.4d4015"';
    +  
    +  // Check if the type of video format / codect is supported.
    +  if (!window.ManagedMediaSource || !ManagedMediaSource.isTypeSupported(mediaType)) {
    +    return; // Not supported, do something else.
    +  }
    +
    +  // Set up video and its managed source.
    +  const video = document.createElement("video");
    +  const source = new ManagedMediaSource();
    +
    +  video.disableRemotePlayback = true;
    +  video.controls = true;
    +
    +  await new Promise((resolve) => {
    +    video.src = URL.createObjectURL(source);
    +    source.addEventListener("sourceopen", resolve, { once: true });
    +    document.body.appendChild(video);
    +  });
    +  
    +  const sourceBuffer = source.addSourceBuffer(mediaType);
    +  
    +  // Set up the event handlers
    +  sourceBuffer.onbufferedchange = (e) => {
    +    console.log("onbufferedchange event fired.");
    +    console.log(`Added Ranges: [${timeRangesToString(e.addedRanges)}]`);
    +    console.log(`Removed Ranges: [${timeRangesToString(e.removedRanges)}]`);
    +  };
    +  
    +  source.onstartstreaming = async () => {
    +    const response = await fetch("./videos/bipbop.mp4");
    +    const buffer = await response.arrayBuffer();
    +    await new Promise((resolve) => {
    +      sourceBuffer.addEventListener("updateend", resolve, { once: true });
    +      sourceBuffer.appendBuffer(buffer);
    +    });
    +  };
    +  
    +  source.onendstreaming = async () => {
    +    // Stop fetching new segments here
    +  };
    +}
    +
    +// Helper function...
    +function timeRangesToString(timeRanges) {
    +  const ranges = [];
    +  for (let i = 0; i < timeRanges?.length; i++) {
    +    const range = [timeRanges.start(i), timeRanges.end(i)];
    +    ranges.push(range);
    +  }
    +  return ranges.toString();
    +}
    +
    +
    +      
    +
    +
    +
    From 6ce3f225f01113a9cb4961c0ae468298e1bf58b7 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Mon, 16 Oct 2023 17:55:44 +1100 Subject: [PATCH 03/46] make title consistent --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 2dbbc24..f35d693 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -3393,7 +3393,7 @@

    Use of the Media Source Extensions

  • -

    Example use of the Managed Media Source Extensions

    +

    Use of the Managed Media Source Extensions

    <script>
    
    From 89e6791f3c873a9da8811bdc0d3916e5805722c2 Mon Sep 17 00:00:00 2001
    From: Jean-Yves Avenard 
    Date: Mon, 16 Oct 2023 18:24:13 +1100
    Subject: [PATCH 04/46] escape html so that body of example shows
    
    ---
     media-source-respec.html | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/media-source-respec.html b/media-source-respec.html
    index f35d693..45ea16d 100644
    --- a/media-source-respec.html
    +++ b/media-source-respec.html
    @@ -3452,7 +3452,7 @@ 

    Use of the Managed Media Source Extensions

    return ranges.toString(); } - +<body onload="setUpVideoStream()"></body>
    From bf2aa7151d7b207b3ab64abe03a315ea2409d7a8 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Mon, 16 Oct 2023 20:01:02 +1100 Subject: [PATCH 05/46] Add missing --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 45ea16d..732b4ea 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -3451,7 +3451,7 @@

    Use of the Managed Media Source Extensions

    } return ranges.toString(); } - +</script> <body onload="setUpVideoStream()"></body> From 6059e4f3699af59b9136acb4632123ef6a033f4a Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Tue, 17 Oct 2023 17:34:37 +1100 Subject: [PATCH 06/46] Editorial fixup --- media-source-respec.html | 718 +++++++++++++++++++++++---------------- 1 file changed, 433 insertions(+), 285 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 732b4ea..7b05bac 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -102,7 +102,7 @@ - +
    This specification extends {{HTMLMediaElement}} [[HTML]] to allow JavaScript to generate media streams for playback. @@ -273,9 +273,13 @@

    MediaSource Object

    a media element=] algorithm. The extended [=resource fetch algorithm=] uses this internal slot to conditionally fail attachment of a {{MediaSource}} using a {{MediaSourceHandle}} set on a {{HTMLMediaElement}}'s {{HTMLMediaElement/srcObject}} attribute.

    -

    Each {{MediaSource}} object has a [[\is actively managed flag]] internal slot that stores a boolean indicating if the MediaSource object is actively managing its content or not. - It is initialized to false when the MediaSource object is created. - +

    + Each {{MediaSource}} object has a + [[\is actively managed flag]] internal + slot that stores a boolean indicating if the {{MediaSource}} object is + actively managing its content or not. It is initialized to false when the + {{MediaSource}} object is created. +

    enum ReadyState {
         "closed",
         "open",
    @@ -415,36 +419,29 @@ 

    Attributes

  • If the {{MediaSource/readyState}} attribute is not in the {{ReadyState/""open""}} state then throw an {{InvalidStateError}} exception and abort these steps.
  • -
    -
    If the {{MediaSource/[[is actively managed flag]]}} equals false:
    -
    - Create a new {{SourceBuffer}} object and associated resources. -
    -
    Otherwise:
    -
    - Create a new {{ManagedSourceBuffer}} object and associated resources. -
    -
    Set the {{SourceBuffer/[[generate timestamps flag]]}} on the new object to the value in the "Generate - Timestamps Flag" column of the byte stream format registry [[MSE-REGISTRY]] entry that is associated with + Let |buffer| be a new instance created as follows: +
      +
    • + If [=this=]'s {{MediaSource/[[is actively managed flag]]}} is false, a newly created {{SourceBuffer}} instance along with its associated resources. +
    • +
    • + Otherwise, a newly created {{ManagedSourceBuffer}} instance and its associated resources. +
    • +
    +
  • +
  • + Set |buffer|'s {{SourceBuffer/[[generate timestamps flag]]}} to the value in the "Generate + Timestamps Flag" column of the [[[MSE-REGISTRY]]] entry that is associated with |type|. -
  • -
    -
    If the {{SourceBuffer/[[generate timestamps flag]]}} equals true:
    -
    - Set the {{SourceBuffer/mode}} attribute on the new object to - {{AppendMode/""sequence""}}. -
    -
    Otherwise:
    -
    - Set the {{SourceBuffer/mode}} attribute on the new object to - {{AppendMode/""segments""}}. -
    -
  • -
  • Add the new object to {{MediaSource/sourceBuffers}} and [=queue a task=] to [=fire an event=] named {{addsourcebuffer}} at {{MediaSource/sourceBuffers}}.
  • -
  • Return the new object.
  • +
  • + If |buffer|'s {{SourceBuffer/[[generate timestamps flag]]}} is true, set |buffer|'s {{SourceBuffer/mode}} to {{AppendMode/"sequence"}}. + Otherwise, set |buffer|'s {{SourceBuffer/mode}} to {{AppendMode/"segments"}}. +
  • +
  • [=List/Append=] |buffer| to |this|'s {{MediaSource/sourceBuffers}}.
  • +
  • [=Queue a task=] to [=fire an event=] named {{addsourcebuffer}} at |this|'s {{MediaSource/sourceBuffers}}.
  • +
  • Return |buffer|.
  • -
    ParameterTypeNullableOptionalDescription
    |type|{{DOMString}}
    Return type: SourceBuffer
    removeSourceBuffer

    Removes a {{SourceBuffer}} from {{MediaSource/sourceBuffers}}.

    @@ -2703,12 +2700,12 @@

    Event Summary

    - addsourcebuffer + addsourcebuffer Event When a SourceBuffer is added to the list. - removesourcebuffer + removesourcebuffer Event When a SourceBuffer is removed from the list. @@ -2717,59 +2714,90 @@

    Event Summary

    -
    -

    ManagedMediaSource Object

    -

    The ManagedMediaSource object is a MediaSource object that actively manages its memory content. - Unlike a MediaSource object it can evict from its ManagedSourceBuffer objects when the User Agent is under memory pressure.

    - -

    Each {{ManagedMediaSource}} object has a [[\is actively managed flag]] internal - slot that stores a {{boolean}}. It is initialized to true when the {{ManagedMediaSource}} object is created.

    - -
    [Exposed=(Window,DedicatedWorker)]
    -interface ManagedMediaSource : MediaSource {
    -    constructor();
    -
    -    readonly attribute boolean          streaming;
    -             attribute EventHandler     onstartstreaming;
    -             attribute EventHandler     onendstreaming;
    -
    -             static boolean          isTypeSupported (DOMString type);
    - };
    -
    -

    Attributes

    -
    +
    +

    ManagedMediaSource interface

    +

    + A {{ManagedMediaSource}} is a {{MediaSource}} that actively manages its + memory content. Unlike a {{MediaSource}}, the [=user agent=] MAY evict it + from a {{ManagedSourceBuffer}} when under [=ManagedMediaSource/memory pressure=]. +

    -
    streaming of type boolean, readonly
    -

    On getting, run the following steps:

    -
      -
    1. If the {{MediaSource/readyState}} attribute is {{ReadyState/""closed""}} then return false and abort these steps.
    2. -
    3. Return the current value of the attribute.
    4. -
    -
    onstartstreaming of type {{EventHandler}}
    -

    The event handler for the {{startstreaming}} event.

    -
    onendstreaming of type {{EventHandler}}
    -

    The event handler for the {{endstreaming}} event.

    -
    isTypeSupported, static
    -

    Check to see whether the ManagedMediaSource is capable of creating ManagedSourceBuffer objects for the specified MIME type.

    +
    +      [Exposed=(Window,DedicatedWorker)]
    +      interface ManagedMediaSource : MediaSource {
    +        constructor();
    +        readonly attribute boolean streaming;
    +        attribute EventHandler onstartstreaming;
    +        attribute EventHandler onendstreaming;
    +
    +        static boolean isTypeSupported(DOMString type);
    +      };
    +      
    +

    Attributes

    +
    +
    + streaming +
    +
    +

    On getting:

    +
      +
    1. + If [=this=]'s {{MediaSource/readyState}} attribute is + {{ReadyState/""closed""}} then return false. +
    2. +
    3. Otherwise, return true.
    4. +
    +
    +
    +

    Static Methods

    +
    +
    + isTypeSupported() +
    +
    +

    + Checks to see whether the user agent would be capable of instantiating + a {{ManagedSourceBuffer}} instance for the given [=MIME type=] + |type:DOMString|. +

      -
    1. If |type:DOMString| is an empty string, then return false.
    2. -
    3. If |type| does not contain a valid MIME type string, then return false.
    4. -
    5. If |type| contains a media type or media subtype that the ManagedMediaSource does not support, then return false.
    6. -
    7. If |type| contains a codec that the ManagedMediaSource does not support, then return false.
    8. -
    9. If the ManagedMediaSource does not support the specified combination of media type, media subtype, and codecs then return false.
    10. -
    11. Return true.
    12. +
    13. + Return false if any of the following conditions is met: +
        +
      • |type| is not a [=valid mime type string=].
      • +
      • + The user agent does not support |type|'s [=MIME type/type=]. +
      • +
      • + The user agent does not support |type|'s [=MIME type/subtype=]. +
      • +
      • + If |type| has [=MIME type/parameters=], if any of the codecs + passed as [=MIME type/parameters=] is not supported. +
      • +
      +
    14. +
    15. Otherwise, return true.

    - If true is returned from this method, it only indicates that the ManagedMediaSource implementation is capable of creating ManagedSourceBuffer objects for the specified MIME type. An {{MediaSource/addSourceBuffer()}} call SHOULD still fail if sufficient resources are not available to support the addition of a new ManagedSourceBuffer. + If true is returned from this method, it only indicates that the + {{ManagedMediaSource}} implementation is capable of creating + {{ManagedSourceBuffer}} objects for the specified MIME type. An + {{MediaSource/addSourceBuffer()}} call SHOULD still fail if there are + insufficient resources available to support the addition of a new + {{ManagedSourceBuffer}}.

    - This method returning true implies that HTMLMediaElement.canPlayType() will return "maybe" or "probably" since it does not make sense for a ManagedMediaSource to support a type the HTMLMediaElement knows it cannot play. + This method returning true implies that {{HTMLMediaElement}}'s {{HTMLMediaElement/canPlayType()}} + will return {{CanPlayTypeResult["maybe"]}} or {{CanPlayTypeResult/["probably"]}} + since it does not make sense for a {{ManagedMediaSource}} to support a type + the {{HTMLMediaElement}} knows it cannot play.

    -
    ParameterTypeNullableOptionalDescription
    |type|{{DOMString}}
    Return type: {{boolean}}
    -
    + +
    -
    +

    Event Summary

    @@ -2781,175 +2809,298 @@

    Event Summary

    - - - + + + - - - + + +
    startstreamingEvent{{ManagedMediaSource/streaming}} transitions from {{""false""}} to {{""true""}}. + startstreaming + {{Event}} + {{ManagedMediaSource/streaming}} transitions from `false` to + `true`. +
    endstreamingEvent{{ManagedMediaSource/streaming}} transitions from {{""true""}} to {{""false""}}. + endstreaming + {{Event}} + {{ManagedMediaSource/streaming}} transitions from `true` to + `false`. +
    -
    +

    Algorithms

    -
    +

    ManagedSourceBuffer Monitoring

    -

    The following steps are run periodically, whenever the {{MediaSource}} SourceBuffer Monitoring algorithm was scheduled to be running.

    -

    Having enough managed data to ensure uninterrupted playback is an implementation specific condition where the user agent - determines that it currently has enough data to play the presentation without stalling for a meaningful period of time and that it can achieve a balance between optimal memory and energy usage. - This condition is constantly evaluated to determine when to transition the media element into and out of the {{HTMLMediaElement/HAVE_ENOUGH_DATA}} ready state. - These transitions indicate when the user agent believes it has enough data buffered or it needs more data respectively.

    -
      -
    1. -
      -
      If the {{MediaSource/readyState}} attribute is {{ReadyState/""closed""}}:
      -
      -
        -
      1. Set the {{ManagedMediaSource.streaming}} attribute to false.
      2. -
      3. Abort these steps.
      4. -
      -
      -
      -
    2. -
    3. Run the {{MediaSource}} SourceBuffer Monitoring algorithm
    4. -
    5. -
      -
      If {{HTMLMediaElement}}.{{HTMLMediaElement/buffered}} contains a {{TimeRanges}} that includes the current playback position and not [=enough managed data to ensure uninterrupted playback=]:
      -
      -
        -
      1. Set the {{ManagedMediaSource.streaming}} attribute to true.
      2. -
      3. Abort these steps.
      4. -
      -
      -
      -
    6. -
    7. -
      -
      If {{HTMLMediaElement}}.{{HTMLMediaElement/buffered}} contains a {{TimeRanges}} that includes the current playback position and [=enough managed data to ensure uninterrupted playback=]:
      -
      -
        -
      1. Set the {{ManagedMediaSource.streaming}} attribute to false.
      2. -
      3. Abort these steps.
      4. -
      -
      -
      -
    8. +

      + The following steps are run periodically, whenever the {{MediaSource}} + {{SourceBuffer}} Monitoring algorithm is scheduled to run. +

      +

      + Having enough managed data to ensure uninterrupted playback + is an implementation specific condition where the user agent determines + that it currently has enough data to play the presentation without + stalling for a meaningful period of time and that it can achieve a + balance between optimal memory and energy usage. This condition is + constantly evaluated to determine when to transition the media element + into and out of the {{HTMLMediaElement/HAVE_ENOUGH_DATA}} ready state. + These transitions indicate when the user agent believes it has enough + data buffered or it needs more data respectively. +

      +
        +
      1. +
        +
        + If [=this=]'s {{MediaSource/readyState}} attribute is + {{ReadyState/"closed"}}: +
        +
        +
          +
        1. + Set the {{ManagedMediaSource/streaming}} attribute to false. +
        2. +
        +
        +
        +
      2. +
      3. Run the {{MediaSource}} SourceBuffer Monitoring algorithm
      4. +
      5. +
        +
        + If {{HTMLMediaElement}}.{{HTMLMediaElement/buffered}} contains a + {{TimeRanges}} that includes the current playback position and not + [=enough managed data to ensure uninterrupted playback=]: +
        +
        +
          +
        1. + Set the {{ManagedMediaSource.streaming}} attribute to true. +
        2. +
        3. Abort these steps.
        4. +
        +
        +
        +
      6. +
      7. +
        +
        + If {{HTMLMediaElement}}.{{HTMLMediaElement/buffered}} contains a + {{TimeRanges}} that includes the current playback position and + [=enough managed data to ensure uninterrupted playback=]: +
        +
        +
          +
        1. + Set the {{ManagedMediaSource.streaming}} attribute to false. +
        2. +
        3. Abort these steps.
        4. +
        +
        +
        +
    -
    -

    Memory pressure

    +
    +

    Memory pressure

    1. -
      -
      For each {{ManagedSourceBuffer}} found in {{MediaSource.sourceBuffers}}:
      -
      -
        -
      1. Run the ManagedSourceBuffer memory pressure algorithm.
      2. -
      -
      -
      -
    2. +
      +
      + For each |buffer:ManagedSourceBuffer| in [=this=]'s + {{MediaSource/sourceBuffers}}: +
      +
      +
        +
      1. Run the |buffer|'s memory pressure algorithm.
      2. +
      +
      +
      +
    -
    -

    ManagedSourceBuffer Object

    - - -
    [Exposed=Window,DedicatedWorker]
    -interface BufferedChangeEvent : Event {
    -    constructor(DOMString type, optional BufferedChangeEventInit eventInitDict);
    -
    -    [SameObject] readonly attribute TimeRanges? addedRanges;
    -    [SameObject] readonly attribute TimeRanges? removedRanges;
    -};
    -
    -dictionary BufferedChangeEventInit : EventInit {
    -    TimeRanges? addedRanges = null;
    -    TimeRanges? removedRanges = null;
    -};
    -
    Description of {{BufferedChangeEvent}} event
    ValueDescription
    addedRanges -

    The TimeRanges added during the last appendBuffer() operation.

    -
    removedRanges -

    The TimeRanges removed during the last remove() operation or if the User-Agent evicted content in response to a memory pressure.

    -
    - -
    [Exposed=(Window,DedicatedWorker)]
    -interface ManagedSourceBuffer : SourceBuffer {
    -                 attribute EventHandler     onbufferedchange;
    -};
    -

    Attributes

    -
    -
    onbufferedchange of type {{EventHandler}}
    -
    -

    The event handler for the {{bufferedchange}} event.

    -
    -
    -
    -

    Event Summary

    - - - - - - - - - - - - - - - -
    Event nameInterfaceDispatched when...
    bufferedchangeEventThe ManagedSourceBuffer's buffered range changed following an appendBuffer, remove or [=memory pressure algorithm=].
    -
    -
    -
    -

    Algorithms

    -
    -

    Buffered Change

    -

    The following steps are run whenever a change to the {{ManagedSourceBuffer}} is performed that would cause {{SourceBuffer.buffered}} to change. -

      -
    1. Let |previous buffered ranges:normalized TimeRanges| equal the {{SourceBuffer.buffered}} attribute before the changes occurred.
    2. -
    3. Let |new buffered ranges:normalized TimeRanges| equal the new {{SourceBuffer.buffered}} TimeRanges.
    4. -
    5. Let |added ranges:normalized TimeRanges| equal the |previous buffered ranges:normalized TimeRanges| substracted from |new buffered ranges:normalized TimeRanges|.
    6. -
    7. Let |removed ranges:normalized TimeRanges| equal the |new buffered ranges:normalized TimeRanges| substracted from |previous buffered ranges:normalized TimeRanges| .
    8. -
    9. and [=queue a task=] to [=fire an event=] named {{bufferedchange}} at {{ManagedSourceBuffer}} with the |added ranges| and |removed ranges|
    10. -
    -
    -
    -

    Memory pressure

    -
      -
    1. -
      -
      If |managedSourceBuffer| is not in {{MediaSource/activeSourceBuffers}}:
      +
      +

      ManagedSourceBuffer interface

      +
      +        [Exposed=(Window,DedicatedWorker)]
      +        interface BufferedChangeEvent : Event {
      +          constructor(DOMString type, optional BufferedChangeEventInit eventInitDict = {});
      +    
      +          [SameObject] readonly attribute TimeRanges? addedRanges;
      +          [SameObject] readonly attribute TimeRanges? removedRanges;
      +        };
      +    
      +        dictionary BufferedChangeEventInit : EventInit {
      +          TimeRanges? addedRanges = null;
      +          TimeRanges? removedRanges = null;
      +        };
      +      
      + + + + + + + + + + + + + + + + +
      + Description of {{BufferedChangeEvent}} event +
      ValueDescription
      + addedRanges + +

      The TimeRanges added during the last appendBuffer() operation.

      +
      + removedRanges + +

      + The TimeRanges removed during the last remove() operation or if the + User-Agent evicted content in response to a memory pressure. +

      +
      + +
      +        [Exposed=(Window,DedicatedWorker)]
      +        interface ManagedSourceBuffer : SourceBuffer {
      +          attribute EventHandler onbufferedchange;
      +        };
      +      
      +
      +

      Attributes

      +
      +
      + onbufferedchange of type {{EventHandler}} +
      -
        -
      1. Run the Range Removal Algorithm with removal range set to [0, positive infinity].
      2. -
      3. Abort those steps.
      4. -
      +

      The event handler for the {{bufferedchange}} event.

      -
      -
    2. -
    3. Let |removal ranges:normalized TimeRanges| equal a list of presentation time ranges that can be evicted from the presentation to ensure uninterrupted playback from {{HTMLMediaElement.currentTime}} - until such presentation could be fetched again. -

      Implementations MAY use different methods for selecting |removal ranges| so web applications SHOULD NOT depend on a - specific behavior. The web application should listen to the {{ManagedSourceBuffer/bufferedchange}} event to observe whether portions of the buffered data have been evicted. + +

      +

      Event Summary

      + + + + + + + + + + + + + + + +
      Event nameInterfaceDispatched when...
      + bufferedchange + {{Event}} + The {{ManagedSourceBuffer}}'s buffered range changed following an + appendBuffer, remove or [=ManagedSourceBuffer/memory pressure=] + algorithm. +
      +
      +
    +
    +

    Algorithms

    +
    +

    + Buffered Change +

    +

    + The following steps are run whenever a change to the + {{ManagedSourceBuffer}} is performed that would cause a + {{SourceBuffer}}'s {{SourceBuffer/buffered}} to change.

    - -
  • For each range in |removal ranges|, run the [=coded frame removal=] algorithm with |start:double| and |end:unrestricted double| equal to - the removal range start and end timestamp respectively.
  • - +
      +
    1. + Let |previous buffered ranges:normalized TimeRanges| equal the + {{SourceBuffer.buffered}} attribute before the changes occurred. +
    2. +
    3. + Let |new buffered ranges:normalized TimeRanges| equal the new + {{SourceBuffer.buffered}} TimeRanges. +
    4. +
    5. + Let |added ranges:normalized TimeRanges| equal the |previous buffered + ranges:normalized TimeRanges| substracted from |new buffered + ranges:normalized TimeRanges|. +
    6. +
    7. + Let |removed ranges:normalized TimeRanges| equal the |new buffered + ranges:normalized TimeRanges| substracted from |previous buffered + ranges:normalized TimeRanges| . +
    8. +
    9. + and [=queue a task=] to [=fire an event=] named {{bufferedchange}} at + {{ManagedSourceBuffer}} with the |added ranges| and |removed ranges|. +
    10. +
    +
    +
    +

    + Memory pressure +

    +
      +
    1. +
      +
      + If |managedSourceBuffer| is not in [=this=]'s + {{MediaSource/activeSourceBuffers}}: +
      +
      +
        +
      1. + Run the Range Removal Algorithm with removal range set to [0, + positive infinity]. +
      2. +
      +
      +
      +
    2. +
    3. + Let |removal ranges:normalized TimeRanges| equal a list of + presentation time ranges that can be evicted from the presentation to + ensure uninterrupted playback from {{HTMLMediaElement.currentTime}} + until such presentation could be fetched again. +

      + Implementations MAY use different methods for selecting |removal + ranges| so web applications SHOULD NOT depend on a specific + behavior. The web application should listen to the + {{ManagedSourceBuffer/bufferedchange}} event to observe whether + portions of the buffered data have been evicted. +

      +
    4. +
    5. + For each range in |removal ranges|, run the [=coded frame removal=] + algorithm with |start:double| and |end:unrestricted double| equal to + the removal range start and end timestamp respectively. +
    6. +
    +
    -

    HTMLMediaElement Extensions

    This section specifies what existing {{HTMLMediaElement}}.{{HTMLMediaElement/seekable}} and @@ -3394,68 +3545,65 @@

    Use of the Media Source Extensions

    Use of the Managed Media Source Extensions

    -
    -
    -
    <script>
    -async function setUpVideoStream(){
    -  // Specific video format and codec
    -  const mediaType = 'video/mp4; codecs="mp4a.40.2,avc1.4d4015"';
    -  
    -  // Check if the type of video format / codect is supported.
    -  if (!window.ManagedMediaSource || !ManagedMediaSource.isTypeSupported(mediaType)) {
    -    return; // Not supported, do something else.
    -  }
    -
    -  // Set up video and its managed source.
    -  const video = document.createElement("video");
    -  const source = new ManagedMediaSource();
    -
    -  video.disableRemotePlayback = true;
    -  video.controls = true;
    -
    -  await new Promise((resolve) => {
    -    video.src = URL.createObjectURL(source);
    -    source.addEventListener("sourceopen", resolve, { once: true });
    -    document.body.appendChild(video);
    -  });
    -  
    -  const sourceBuffer = source.addSourceBuffer(mediaType);
    -  
    -  // Set up the event handlers
    -  sourceBuffer.onbufferedchange = (e) => {
    -    console.log("onbufferedchange event fired.");
    -    console.log(`Added Ranges: [${timeRangesToString(e.addedRanges)}]`);
    -    console.log(`Removed Ranges: [${timeRangesToString(e.removedRanges)}]`);
    -  };
    -  
    -  source.onstartstreaming = async () => {
    -    const response = await fetch("./videos/bipbop.mp4");
    -    const buffer = await response.arrayBuffer();
    -    await new Promise((resolve) => {
    -      sourceBuffer.addEventListener("updateend", resolve, { once: true });
    -      sourceBuffer.appendBuffer(buffer);
    -    });
    -  };
    -  
    -  source.onendstreaming = async () => {
    -    // Stop fetching new segments here
    -  };
    -}
    -
    -// Helper function...
    -function timeRangesToString(timeRanges) {
    -  const ranges = [];
    -  for (let i = 0; i < timeRanges?.length; i++) {
    -    const range = [timeRanges.start(i), timeRanges.end(i)];
    -    ranges.push(range);
    -  }
    -  return ranges.toString();
    -}
    -</script>
    -<body onload="setUpVideoStream()"></body>
    -      
    -
    -
    +
    +      <script>
    +      async function setUpVideoStream() {
    +        // Specific video format and codec
    +        const mediaType = 'video/mp4; codecs="mp4a.40.2,avc1.4d4015"';
    +
    +        // Check if the type of video format / codec is supported.
    +        if (ManagedMediaSource?.isTypeSupported(mediaType)) {
    +          return; // Not supported, do something else.
    +        }
    +
    +        // Set up video and its managed source.
    +        const video = document.createElement("video");
    +        const source = new ManagedMediaSource();
    +
    +        video.disableRemotePlayback = true;
    +        video.controls = true;
    +
    +        await new Promise((resolve) => {
    +          video.src = URL.createObjectURL(source);
    +          source.addEventListener("sourceopen", resolve, { once: true });
    +          document.body.appendChild(video);
    +        });
    +
    +        const sourceBuffer = source.addSourceBuffer(mediaType);
    +
    +        // Set up the event handlers
    +        sourceBuffer.onbufferedchange = (e) => {
    +          console.log("onbufferedchange event fired.");
    +          console.log(`Added Ranges: [${timeRangesToString(e.addedRanges)}]`);
    +          console.log(`Removed Ranges: [${timeRangesToString(e.removedRanges)}]`);
    +        };
    +
    +        source.onstartstreaming = async () => {
    +          const response = await fetch("./videos/bipbop.mp4");
    +          const buffer = await response.arrayBuffer();
    +          await new Promise((resolve) => {
    +            sourceBuffer.addEventListener("updateend", resolve, { once: true });
    +            sourceBuffer.appendBuffer(buffer);
    +          });
    +        };
    +
    +        source.onendstreaming = async () => {
    +          // Stop fetching new segments here
    +        };
    +      }
    +
    +      // Helper function...
    +      function timeRangesToString(timeRanges) {
    +        const ranges = [];
    +        for (let i = 0; i < timeRanges?.length; i++) {
    +          const range = [timeRanges.start(i), timeRanges.end(i)];
    +          ranges.push(range);
    +        }
    +        return ranges.toString();
    +      }
    +    </script>
    +    <body onload="setUpVideoStream()"></body>
    +  
    From d50c0392ec25e33c085ddd83554253da3a2943ea Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Wed, 18 Oct 2023 17:29:18 +1100 Subject: [PATCH 07/46] Moar fixes --- media-source-respec.html | 557 ++++++++++++++++++--------------------- 1 file changed, 262 insertions(+), 295 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 7b05bac..dcba2da 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2714,12 +2714,13 @@

    Event Summary

    -
    +

    ManagedMediaSource interface

    A {{ManagedMediaSource}} is a {{MediaSource}} that actively manages its memory content. Unlike a {{MediaSource}}, the [=user agent=] MAY evict it - from a {{ManagedSourceBuffer}} when under [=ManagedMediaSource/memory pressure=]. + from a {{ManagedSourceBuffer}} when under [=ManagedMediaSource/memory + pressure=].

    @@ -2737,16 +2738,16 @@ 

    ManagedMediaSource interface

    Attributes

    - streaming + streaming

    On getting:

    1. If [=this=]'s {{MediaSource/readyState}} attribute is - {{ReadyState/""closed""}} then return false. + {{ReadyState/"closed"}} then return `false`.
    2. -
    3. Otherwise, return true.
    4. +
    5. Otherwise, return `true`.
    @@ -2757,13 +2758,13 @@

    Static Methods

    - Checks to see whether the user agent would be capable of instantiating - a {{ManagedSourceBuffer}} instance for the given [=MIME type=] + Checks to see whether the user agent would be capable of instantiating a + {{ManagedSourceBuffer}} object for the given [=MIME type=] |type:DOMString|.

    1. - Return false if any of the following conditions is met: + Return `false` if any of the following conditions is met:
      • |type| is not a [=valid mime type string=].
      • @@ -2778,327 +2779,294 @@

        Static Methods

    2. -
    3. Otherwise, return true.
    4. +
    5. Otherwise, return `true`.

    If true is returned from this method, it only indicates that the {{ManagedMediaSource}} implementation is capable of creating {{ManagedSourceBuffer}} objects for the specified MIME type. An - {{MediaSource/addSourceBuffer()}} call SHOULD still fail if there are + {{MediaSource/addSourceBuffer()}} call can still fail if there are insufficient resources available to support the addition of a new {{ManagedSourceBuffer}}.

    - This method returning true implies that {{HTMLMediaElement}}'s {{HTMLMediaElement/canPlayType()}} - will return {{CanPlayTypeResult["maybe"]}} or {{CanPlayTypeResult/["probably"]}} - since it does not make sense for a {{ManagedMediaSource}} to support a type + This method returning true implies that {{HTMLMediaElement}}'s + {{HTMLMediaElement/canPlayType()}} will return + {{CanPlayTypeResult/"maybe"}} or {{CanPlayTypeResult/"probably"}} since + it does not make sense for a {{ManagedMediaSource}} to support a type the {{HTMLMediaElement}} knows it cannot play.

    -
    -

    Event Summary

    - - - - - - - - - - - - - - - - - - - - -
    Event nameInterfaceDispatched when...
    - startstreaming - {{Event}} - {{ManagedMediaSource/streaming}} transitions from `false` to - `true`. -
    - endstreaming - {{Event}} - {{ManagedMediaSource/streaming}} transitions from `true` to - `false`. -
    -
    -
    -

    Algorithms

    -
    -

    ManagedSourceBuffer Monitoring

    -

    - The following steps are run periodically, whenever the {{MediaSource}} - {{SourceBuffer}} Monitoring algorithm is scheduled to run. -

    -

    - Having enough managed data to ensure uninterrupted playback - is an implementation specific condition where the user agent determines - that it currently has enough data to play the presentation without - stalling for a meaningful period of time and that it can achieve a - balance between optimal memory and energy usage. This condition is - constantly evaluated to determine when to transition the media element - into and out of the {{HTMLMediaElement/HAVE_ENOUGH_DATA}} ready state. - These transitions indicate when the user agent believes it has enough - data buffered or it needs more data respectively. -

    -
      -
    1. -
      -
      - If [=this=]'s {{MediaSource/readyState}} attribute is - {{ReadyState/"closed"}}: -
      -
      -
        -
      1. - Set the {{ManagedMediaSource/streaming}} attribute to false. -
      2. -
      -
      -
      -
    2. -
    3. Run the {{MediaSource}} SourceBuffer Monitoring algorithm
    4. -
    5. -
      -
      - If {{HTMLMediaElement}}.{{HTMLMediaElement/buffered}} contains a - {{TimeRanges}} that includes the current playback position and not - [=enough managed data to ensure uninterrupted playback=]: -
      -
      -
        -
      1. - Set the {{ManagedMediaSource.streaming}} attribute to true. -
      2. -
      3. Abort these steps.
      4. -
      -
      -
      -
    6. -
    7. -
      -
      - If {{HTMLMediaElement}}.{{HTMLMediaElement/buffered}} contains a - {{TimeRanges}} that includes the current playback position and - [=enough managed data to ensure uninterrupted playback=]: -
      -
      -
        -
      1. - Set the {{ManagedMediaSource.streaming}} attribute to false. -
      2. -
      3. Abort these steps.
      4. -
      -
      -
      -
    8. -
    -
    -
    -

    Memory pressure

    -
      -
    1. -
      -
      - For each |buffer:ManagedSourceBuffer| in [=this=]'s - {{MediaSource/sourceBuffers}}: -
      -
      -
        -
      1. Run the |buffer|'s memory pressure algorithm.
      2. -
      -
      -
      -
    2. -
    -
    -
    +

    Event Summary

    + + + + + + + + + + + + + + + + + + + + +
    Event nameInterfaceDispatched when...
    + startstreaming + {{Event}} + {{ManagedMediaSource/streaming}} attribute changes from `false` to `true`. +
    + endstreaming + {{Event}} + {{ManagedMediaSource/streaming}} attribute changes from `true` to `false`. +
    + +

    Algorithms

    +

    `ManagedSourceBuffer` Monitoring

    +

    + The following steps are run periodically, whenever the {{MediaSource}} + {{SourceBuffer}} Monitoring algorithm is scheduled to run. +

    +

    + Having enough managed data to ensure uninterrupted playback + is an implementation specific condition where the user agent determines that + it currently has enough data to play the presentation without stalling for a + meaningful period of time and that it can achieve a balance between optimal + memory and energy usage. This condition is constantly evaluated to determine + when to transition the media element into and out of the + {{HTMLMediaElement/HAVE_ENOUGH_DATA}} ready state. These transitions + indicate when the user agent believes it has enough data buffered or it + needs more data respectively. +

    +
      +
    1. +
      +
      + If [=this=]'s {{MediaSource/readyState}} attribute is + {{ReadyState/"closed"}}: +
      +
      +
        +
      1. + Set [=this=]'s {{ManagedMediaSource/streaming}} attribute to + false. +
      2. +
      3. Abort these steps.
      4. +
      +
      +
      +
    2. +
    3. Run the {{MediaSource}} [=MediaSource/SourceBuffer Monitoring=] algorithm.
    4. +
    5. +
      +
      + If {{HTMLMediaElement}}'s {{HTMLMediaElement/buffered}} attribute + contains a {{TimeRanges}} that includes the current playback position + and not [=enough managed data to ensure uninterrupted playback=]: +
      +
      +
        +
      1. + Set [=this=]'s {{ManagedMediaSource/streaming}} attribute to true. +
      2. +
      3. Abort these steps.
      4. +
      +
      +
      +
    6. +
    7. +
      +
      + If {{HTMLMediaElement}}'s {{HTMLMediaElement/buffered}} attribute + contains a {{TimeRanges}} that includes the current playback position and + [=enough managed data to ensure uninterrupted playback=]: +
      +
      +
        +
      1. + Set [=this=]'s {{ManagedMediaSource/streaming}} attribute to + false. +
      2. +
      3. Abort these steps.
      4. +
      +
      +
      +
    8. +
    + +

    Memory pressure

    +
      +
    1. +
      +
      + For each |buffer:ManagedSourceBuffer| in [=this=]'s + {{MediaSource/sourceBuffers}}: +
      +
      +
        +
      1. Run the |buffer|'s memory pressure algorithm.
      2. +
      +
      +
      +
    2. +
    -
    -

    ManagedSourceBuffer interface

    +
    +

    BufferedChangeEvent interface

             [Exposed=(Window,DedicatedWorker)]
             interface BufferedChangeEvent : Event {
               constructor(DOMString type, optional BufferedChangeEventInit eventInitDict = {});
    -    
    +
               [SameObject] readonly attribute TimeRanges? addedRanges;
               [SameObject] readonly attribute TimeRanges? removedRanges;
             };
    -    
    +
             dictionary BufferedChangeEventInit : EventInit {
               TimeRanges? addedRanges = null;
               TimeRanges? removedRanges = null;
             };
           
    - - - - - - - +

    Attributes

    +
    +
    + addedRanges +
    +
    + The time ranges added during the last {{SourceBuffer/appendBuffer()}} operation. +
    +
    + removedRanges +
    +
    + The time ranges removed during the last {{SourceBuffer/remove()}} operation or if the + user agent evicted content in response to a memory pressure. +
    +
    + + +
    +

    ManagedSourceBuffer interface

    +
    +        [Exposed=(Window,DedicatedWorker)]
    +        interface ManagedSourceBuffer : SourceBuffer {
    +          attribute EventHandler onbufferedchange;
    +        };
    +      
    +

    Attributes

    +
    +
    + onbufferedchange +
    +
    +

    The event handler for the {{bufferedchange}} event.

    +
    +
    + +

    Event Summary

    +
    - Description of {{BufferedChangeEvent}} event -
    ValueDescription
    + - - + + + + + +
    - addedRanges - -

    The TimeRanges added during the last appendBuffer() operation.

    -
    Event nameInterfaceDispatched when...
    - removedRanges + bufferedchange {{Event}} -

    - The TimeRanges removed during the last remove() operation or if the - User-Agent evicted content in response to a memory pressure. -

    + The {{ManagedSourceBuffer}}'s buffered range changed following a + call to {{SourceBuffer/appendBuffer()}}, {{ManagedSourceBuffer/remove()}}, + or as a consequence of the user agent running the + [=ManagedSourceBuffer/memory pressure=] algorithm.
    - -
    -        [Exposed=(Window,DedicatedWorker)]
    -        interface ManagedSourceBuffer : SourceBuffer {
    -          attribute EventHandler onbufferedchange;
    -        };
    -      
    -
    -

    Attributes

    -
    -
    - onbufferedchange of type {{EventHandler}} -
    -
    -

    The event handler for the {{bufferedchange}} event.

    -
    -
    -
    -

    Event Summary

    - - - - - - - - - - - - - - - -
    Event nameInterfaceDispatched when...
    - bufferedchange - {{Event}} - The {{ManagedSourceBuffer}}'s buffered range changed following an - appendBuffer, remove or [=ManagedSourceBuffer/memory pressure=] - algorithm. -
    -
    -
    -
    -

    Algorithms

    -
    -

    - Buffered Change -

    -

    - The following steps are run whenever a change to the - {{ManagedSourceBuffer}} is performed that would cause a - {{SourceBuffer}}'s {{SourceBuffer/buffered}} to change. + +

    Algorithms

    +

    Buffered Change

    +

    + The following steps are run whenever a change to the {{ManagedSourceBuffer}} + is performed that would cause a {{SourceBuffer}}'s {{SourceBuffer/buffered}} + to change. +

    +
      +
    1. + Let |previous buffered ranges:normalized TimeRanges| equal the + {{SourceBuffer/buffered}} attribute before the changes occurred. +
    2. +
    3. + Let |new buffered ranges:normalized TimeRanges| equal the new + {{SourceBuffer/buffered}} {{TimeRanges}}. +
    4. +
    5. + Let |added ranges:normalized TimeRanges| equal the |previous buffered + ranges:normalized TimeRanges| subtracted from |new buffered + ranges:normalized TimeRanges|. +
    6. +
    7. + Let |removed ranges:normalized TimeRanges| equal the |new buffered + ranges:normalized TimeRanges| subtracted from |previous buffered + ranges:normalized TimeRanges| . +
    8. +
    9. + [=Queue a task=] to [=fire an event=] named {{bufferedchange}} at + {{ManagedSourceBuffer}} with the |added ranges| and |removed ranges|. +
    10. +
    +

    + Memory pressure +

    +
      +
    1. +
      +
      + If |managedSourceBuffer| is not in [=this=]'s + {{MediaSource/activeSourceBuffers}}: +
      +
      +
        +
      1. + Run the [=range removal=] algorithm with removal range set to [0, + positive infinity]. +
      2. +
      +
      +
      +
    2. +
    3. + Let |removal ranges:normalized TimeRanges| equal a list of presentation + time ranges that can be evicted from the presentation to ensure + uninterrupted playback from {{HTMLMediaElement.currentTime}} until such + presentation could be fetched again. +

      + Implementations can use different methods for selecting |removal ranges| + so web applications shouldn't depend on a specific behavior. The web + application would listen to the {{bufferedchange}} event to observe + whether portions of the buffered data have been evicted.

      -
        -
      1. - Let |previous buffered ranges:normalized TimeRanges| equal the - {{SourceBuffer.buffered}} attribute before the changes occurred. -
      2. -
      3. - Let |new buffered ranges:normalized TimeRanges| equal the new - {{SourceBuffer.buffered}} TimeRanges. -
      4. -
      5. - Let |added ranges:normalized TimeRanges| equal the |previous buffered - ranges:normalized TimeRanges| substracted from |new buffered - ranges:normalized TimeRanges|. -
      6. -
      7. - Let |removed ranges:normalized TimeRanges| equal the |new buffered - ranges:normalized TimeRanges| substracted from |previous buffered - ranges:normalized TimeRanges| . -
      8. -
      9. - and [=queue a task=] to [=fire an event=] named {{bufferedchange}} at - {{ManagedSourceBuffer}} with the |added ranges| and |removed ranges|. -
      10. -
      -
    -
    -

    - Memory pressure -

    -
      -
    1. -
      -
      - If |managedSourceBuffer| is not in [=this=]'s - {{MediaSource/activeSourceBuffers}}: -
      -
      -
        -
      1. - Run the Range Removal Algorithm with removal range set to [0, - positive infinity]. -
      2. -
      -
      -
      -
    2. -
    3. - Let |removal ranges:normalized TimeRanges| equal a list of - presentation time ranges that can be evicted from the presentation to - ensure uninterrupted playback from {{HTMLMediaElement.currentTime}} - until such presentation could be fetched again. -

      - Implementations MAY use different methods for selecting |removal - ranges| so web applications SHOULD NOT depend on a specific - behavior. The web application should listen to the - {{ManagedSourceBuffer/bufferedchange}} event to observe whether - portions of the buffered data have been evicted. -

      -
    4. -
    5. - For each range in |removal ranges|, run the [=coded frame removal=] - algorithm with |start:double| and |end:unrestricted double| equal to - the removal range start and end timestamp respectively. -
    6. -
    -
    -
    + +
  • + For each range in |removal ranges|, run the [=coded frame removal=] + algorithm with |start:double| and |end:unrestricted double| equal to the + removal range start and end timestamp respectively. +
  • +
    @@ -3601,11 +3569,10 @@

    Use of the Managed Media Source Extensions

    } return ranges.toString(); } - </script> - <body onload="setUpVideoStream()"></body> - -
    - + </script> + <body onload="setUpVideoStream()"></body> + +

    Acknowledgments

    From 1cefa6d0da13ce586bd88f222debe7fab4f4f286 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Thu, 19 Oct 2023 16:13:51 +1100 Subject: [PATCH 08/46] Make BufferedChangeEvent ranges non-nullable --- media-source-respec.html | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index dcba2da..6050a86 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2926,15 +2926,15 @@

    BufferedChangeEvent interface

             [Exposed=(Window,DedicatedWorker)]
             interface BufferedChangeEvent : Event {
    -          constructor(DOMString type, optional BufferedChangeEventInit eventInitDict = {});
    +          constructor(DOMString type, BufferedChangeEventInit eventInitDict);
     
    -          [SameObject] readonly attribute TimeRanges? addedRanges;
    -          [SameObject] readonly attribute TimeRanges? removedRanges;
    +          [SameObject] readonly attribute TimeRanges addedRanges;
    +          [SameObject] readonly attribute TimeRanges removedRanges;
             };
     
             dictionary BufferedChangeEventInit : EventInit {
    -          TimeRanges? addedRanges = null;
    -          TimeRanges? removedRanges = null;
    +          TimeRanges addedRanges;
    +          TimeRanges removedRanges;
             };
           

    Attributes

    @@ -2990,7 +2990,7 @@

    Event Summary

    {{Event}} The {{ManagedSourceBuffer}}'s buffered range changed following a - call to {{SourceBuffer/appendBuffer()}}, {{ManagedSourceBuffer/remove()}}, + call to {{SourceBuffer/appendBuffer()}}, {{SourceBuffer/remove()}}, or as a consequence of the user agent running the [=ManagedSourceBuffer/memory pressure=] algorithm. @@ -3002,8 +3002,8 @@

    Algorithms

    Buffered Change

    The following steps are run whenever a change to the {{ManagedSourceBuffer}} - is performed that would cause a {{SourceBuffer}}'s {{SourceBuffer/buffered}} - to change. + |buffer:ManagedSourceBuffer| is performed that would cause a + a |buffer|'s {{SourceBuffer/buffered}} to change.

    1. @@ -3015,18 +3015,24 @@

      Buffered Change

      {{SourceBuffer/buffered}} {{TimeRanges}}.
    2. - Let |added ranges:normalized TimeRanges| equal the |previous buffered + Let |added:normalized TimeRanges| equal the |previous buffered ranges:normalized TimeRanges| subtracted from |new buffered ranges:normalized TimeRanges|.
    3. - Let |removed ranges:normalized TimeRanges| equal the |new buffered + Let |removed:normalized TimeRanges| equal the |new buffered ranges:normalized TimeRanges| subtracted from |previous buffered - ranges:normalized TimeRanges| . + ranges:normalized TimeRanges|. +
    4. +
    5. + Let |eventInitDict| be a new {{BufferedChangeEventInit}} dictionary + initialized with |added| as its {{BufferedChangeEventInit/addedRanges}} and + |removed| as its {{BufferedChangeEventInit/removedRanges}}
    6. - [=Queue a task=] to [=fire an event=] named {{bufferedchange}} at - {{ManagedSourceBuffer}} with the |added ranges| and |removed ranges|. + [=Queue a task=] to [=fire an event=] named {{bufferedchange}} at |buffer| + using the {{BufferedChangeEvent}} interface, initialized with + |eventInitDict|.

    From bfa03225ca9489b36e0ac76d80b7a6a43ccfc43c Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Thu, 19 Oct 2023 23:24:45 -0700 Subject: [PATCH 09/46] Provide further details related to buffered change: it is to be fired once per operation, not whenever the buffer changes. --- media-source-respec.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 6050a86..39eb233 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -3001,9 +3001,10 @@

    Event Summary

    Algorithms

    Buffered Change

    - The following steps are run whenever a change to the {{ManagedSourceBuffer}} - |buffer:ManagedSourceBuffer| is performed that would cause a - a |buffer|'s {{SourceBuffer/buffered}} to change. + The following steps are run at the completion of all operations to the {{ManagedSourceBuffer}} + |buffer:ManagedSourceBuffer| that would cause a |buffer|'s {{SourceBuffer/buffered}} to change. + That is once {{SourceBuffer/appendBuffer()}}, {{SourceBuffer/remove()}} or + [=ManagedSourceBuffer/memory pressure=] algorithm have completed.

    1. @@ -3048,8 +3049,7 @@

      1. - Run the [=range removal=] algorithm with removal range set to [0, - positive infinity]. + Run the [=coded frame removal=] algorithm with 0 and positive infinity equal to the removal range start and end timestamp respectively, and abort these steps.
      From c2bddbc3bdea3f5a67e8a9677a3ec768a666e190 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Mon, 23 Oct 2023 14:12:33 -0700 Subject: [PATCH 10/46] Make the TimeRangesToString helper more readable --- media-source-respec.html | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 39eb233..66bed2e 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -3569,11 +3569,10 @@

      Use of the Managed Media Source Extensions

      // Helper function... function timeRangesToString(timeRanges) { const ranges = []; - for (let i = 0; i < timeRanges?.length; i++) { - const range = [timeRanges.start(i), timeRanges.end(i)]; - ranges.push(range); + for (let i = 0; i < timeRanges.length; i++) { + ranges.push([timeRanges.start(i), timeRanges.end(i)]); } - return ranges.toString(); + return "[" + ranges.map(([start, end]) => `[${start}, ${end})` ) + "]"; } </script> <body onload="setUpVideoStream()"></body> From 5aeb68818d9c70fc110fccbe0c29936fa2c6dbe8 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Mon, 23 Oct 2023 15:22:53 -0700 Subject: [PATCH 11/46] Remove redundant brackets in log MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marcos Cáceres --- media-source-respec.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 66bed2e..6e68bc5 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -3548,8 +3548,8 @@

      Use of the Managed Media Source Extensions

      // Set up the event handlers sourceBuffer.onbufferedchange = (e) => { console.log("onbufferedchange event fired."); - console.log(`Added Ranges: [${timeRangesToString(e.addedRanges)}]`); - console.log(`Removed Ranges: [${timeRangesToString(e.removedRanges)}]`); + console.log(`Added Ranges: ${timeRangesToString(e.addedRanges)}`); + console.log(`Removed Ranges: ${timeRangesToString(e.removedRanges)}`); }; source.onstartstreaming = async () => { From 8084ac910839f824f7bda75b10d5686a250b126f Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Tue, 24 Oct 2023 20:44:27 -0700 Subject: [PATCH 12/46] rework ManagedMediaSource interface description per Dale Curtis comments --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 6e68bc5..994679d 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2719,7 +2719,7 @@

      ManagedMediaSource interface

      A {{ManagedMediaSource}} is a {{MediaSource}} that actively manages its memory content. Unlike a {{MediaSource}}, the [=user agent=] MAY evict it - from a {{ManagedSourceBuffer}} when under [=ManagedMediaSource/memory + from a {{ManagedSourceBuffer}} may evict content from its {{MediaSource/sourceBuffers}} for any reasons, including when under [=ManagedMediaSource/memory pressure=].

      From 1522ecc04f62af9550ea615f1d5eb3f8e2b3d019 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Tue, 24 Oct 2023 20:45:51 -0700 Subject: [PATCH 13/46] Remove ManagedMediaSource::isTypeSupported override --- media-source-respec.html | 49 ---------------------------------------- 1 file changed, 49 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 994679d..28ac1c7 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2730,8 +2730,6 @@

      ManagedMediaSource interface

      readonly attribute boolean streaming; attribute EventHandler onstartstreaming; attribute EventHandler onendstreaming; - - static boolean isTypeSupported(DOMString type); }; @@ -2751,53 +2749,6 @@

      Attributes

    -

    Static Methods

    -
    -
    - isTypeSupported() -
    -
    -

    - Checks to see whether the user agent would be capable of instantiating a - {{ManagedSourceBuffer}} object for the given [=MIME type=] - |type:DOMString|. -

    -
      -
    1. - Return `false` if any of the following conditions is met: -
        -
      • |type| is not a [=valid mime type string=].
      • -
      • - The user agent does not support |type|'s [=MIME type/type=]. -
      • -
      • - The user agent does not support |type|'s [=MIME type/subtype=]. -
      • -
      • - If |type| has [=MIME type/parameters=], if any of the codecs - passed as [=MIME type/parameters=] is not supported. -
      • -
      -
    2. -
    3. Otherwise, return `true`.
    4. -
    -

    - If true is returned from this method, it only indicates that the - {{ManagedMediaSource}} implementation is capable of creating - {{ManagedSourceBuffer}} objects for the specified MIME type. An - {{MediaSource/addSourceBuffer()}} call can still fail if there are - insufficient resources available to support the addition of a new - {{ManagedSourceBuffer}}. -

    -

    - This method returning true implies that {{HTMLMediaElement}}'s - {{HTMLMediaElement/canPlayType()}} will return - {{CanPlayTypeResult/"maybe"}} or {{CanPlayTypeResult/"probably"}} since - it does not make sense for a {{ManagedMediaSource}} to support a type - the {{HTMLMediaElement}} knows it cannot play. -

    -
    -

    Event Summary

    From 07d8728217e994d8a02945630e7caead3f8cafcf Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Tue, 24 Oct 2023 21:05:12 -0700 Subject: [PATCH 14/46] fix source buffer monitoring and `streaming` attribute definition --- media-source-respec.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 28ac1c7..47cb9a7 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2745,7 +2745,7 @@

    Attributes

    If [=this=]'s {{MediaSource/readyState}} attribute is {{ReadyState/"closed"}} then return `false`. -
  • Otherwise, return `true`.
  • +
  • Otherwise, return the current value of the attribute.
  • @@ -2793,8 +2793,7 @@

    `ManagedSourceBuffer` Monitoring

    it currently has enough data to play the presentation without stalling for a meaningful period of time and that it can achieve a balance between optimal memory and energy usage. This condition is constantly evaluated to determine - when to transition the media element into and out of the - {{HTMLMediaElement/HAVE_ENOUGH_DATA}} ready state. These transitions + when to transition the value of {{ManagedMediaSource/streaming}}. These transitions indicate when the user agent believes it has enough data buffered or it needs more data respectively.

    From 0764561f53c8552ff33713d741117611c6eb44db Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Tue, 24 Oct 2023 21:11:41 -0700 Subject: [PATCH 15/46] More rework on ManagedMediaSource interface definition --- media-source-respec.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 47cb9a7..89891f6 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2718,8 +2718,8 @@

    Event Summary

    ManagedMediaSource interface

    A {{ManagedMediaSource}} is a {{MediaSource}} that actively manages its - memory content. Unlike a {{MediaSource}}, the [=user agent=] MAY evict it - from a {{ManagedSourceBuffer}} may evict content from its {{MediaSource/sourceBuffers}} for any reasons, including when under [=ManagedMediaSource/memory + memory content. Unlike a {{MediaSource}}, the [=user agent=] MAY evict evict content + from its {{MediaSource/sourceBuffers}} (populated with {{ManagedSourceBuffer}}) for any reasons, including when under [=ManagedMediaSource/memory pressure=].

    From e245ae244cfb0cf9bafc24cff42fa19a82b68d4c Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 25 Oct 2023 10:32:24 -0700 Subject: [PATCH 16/46] Remove references to [[actively managed]] per Paul's suggestion --- media-source-respec.html | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 408ce88..379920d 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -273,13 +273,6 @@

    MediaSource Object

    a media element=] algorithm. The extended [=resource fetch algorithm=] uses this internal slot to conditionally fail attachment of a {{MediaSource}} using a {{MediaSourceHandle}} set on a {{HTMLMediaElement}}'s {{HTMLMediaElement/srcObject}} attribute.

    -

    - Each {{MediaSource}} object has a - [[\is actively managed flag]] internal - slot that stores a boolean indicating if the {{MediaSource}} object is - actively managing its content or not. It is initialized to false when the - {{MediaSource}} object is created. -

             enum ReadyState {
               "closed",
    @@ -431,16 +424,7 @@ 

    Attributes

  • If the {{MediaSource/readyState}} attribute is not in the {{ReadyState/""open""}} state then throw an {{InvalidStateError}} exception and abort these steps.
  • - Let |buffer| be a new instance created as follows: -
      -
    • - If [=this=]'s {{MediaSource/[[is actively managed flag]]}} is false, a newly created {{SourceBuffer}} instance along with its associated resources. -
    • -
    • - Otherwise, a newly created {{ManagedSourceBuffer}} instance and its associated resources. -
    • -
    -
  • + Let |buffer| be a new instance of a {{ManagedSourceBuffer}} if |this| is a {{ManagedMediaSource}}, or a {{SourceBuffer}} otherwise, with their respective associated resources.
  • Set |buffer|'s {{SourceBuffer/[[generate timestamps flag]]}} to the value in the "Generate Timestamps Flag" column of the [[[MSE-REGISTRY]]] entry that is associated with @@ -2730,8 +2714,8 @@

    Event Summary

    ManagedMediaSource interface

    A {{ManagedMediaSource}} is a {{MediaSource}} that actively manages its - memory content. Unlike a {{MediaSource}}, the [=user agent=] MAY evict evict content - from its {{MediaSource/sourceBuffers}} (populated with {{ManagedSourceBuffer}}) for any reasons, including when under [=ManagedMediaSource/memory + memory content. Unlike a {{MediaSource}}, the [=user agent=] can evict evict content + from its {{MediaSource/sourceBuffers}} (populated with {{ManagedSourceBuffer}}) for any reason, including when under [=ManagedMediaSource/memory pressure=].

    From 8681a225db47a6d519514ffdd990645c3c1c84ac Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 25 Oct 2023 10:44:46 -0700 Subject: [PATCH 17/46] set streaming attribute to false when detaching the ManagedMediaSource per Paul's suggestion --- media-source-respec.html | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 379920d..dbab112 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -913,6 +913,7 @@

    Detaching from a media element

  • Set {{MediaSource/[[port to main]]}} null.
  • Set the {{MediaSource/readyState}} attribute to {{ReadyState/""closed""}}.
  • +
  • If [=this=] is a {{ManagedMediaSource}} set {{ManagedMediaSource/streaming}} attribute to `false`
  • Update {{MediaSource/duration}} to NaN.
  • Remove all the SourceBuffer objects from {{MediaSource/activeSourceBuffers}}.
  • @@ -2737,11 +2738,7 @@

    Attributes

    On getting:

      -
    1. - If [=this=]'s {{MediaSource/readyState}} attribute is - {{ReadyState/"closed"}} then return `false`. -
    2. -
    3. Otherwise, return the current value of the attribute.
    4. +
    5. Return the current value of the attribute.
    @@ -2794,23 +2791,6 @@

    `ManagedSourceBuffer` Monitoring

    needs more data respectively.

      -
    1. -
      -
      - If [=this=]'s {{MediaSource/readyState}} attribute is - {{ReadyState/"closed"}}: -
      -
      -
        -
      1. - Set [=this=]'s {{ManagedMediaSource/streaming}} attribute to - false. -
      2. -
      3. Abort these steps.
      4. -
      -
      -
      -
    2. Run the {{MediaSource}} [=MediaSource/SourceBuffer Monitoring=] algorithm.
    3. @@ -3007,7 +2987,7 @@

      uninterrupted playback from {{HTMLMediaElement.currentTime}} until such presentation could be fetched again.

      - Implementations can use different methods for selecting |removal ranges| + Implementations can use different strategies for selecting |removal ranges| so web applications shouldn't depend on a specific behavior. The web application would listen to the {{bufferedchange}} event to observe whether portions of the buffered data have been evicted. From 2077f302a8ed666356e5451766f6e129f6ea075f Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 25 Oct 2023 10:45:20 -0700 Subject: [PATCH 18/46] remove use of disableRemotePlayback --- media-source-respec.html | 1 - 1 file changed, 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index dbab112..614a980 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -3460,7 +3460,6 @@

      Use of the Managed Media Source Extensions

      const video = document.createElement("video"); const source = new ManagedMediaSource(); - video.disableRemotePlayback = true; video.controls = true; await new Promise((resolve) => { From 73f7ebe72b1c022c653c901d7938263a78e6356c Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 25 Oct 2023 10:48:21 -0700 Subject: [PATCH 19/46] used changed instead of changes for start/end streaming definition --- media-source-respec.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 614a980..5cc25e2 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2759,7 +2759,7 @@

      Event Summary

  • @@ -2768,7 +2768,7 @@

    Event Summary

    From 976805612c196b840f4cd95c2abe085d85184c66 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 25 Oct 2023 11:33:24 -0700 Subject: [PATCH 20/46] Add markup around true and false --- media-source-respec.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 5cc25e2..247abd1 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2777,12 +2777,11 @@

    Event Summary

    Algorithms

    `ManagedSourceBuffer` Monitoring

    - The following steps are run periodically, whenever the {{MediaSource}} - {{SourceBuffer}} Monitoring algorithm is scheduled to run. + The following steps are run periodically, whenever the [=MediaSource/SourceBuffer Monitoring=] algorithm is scheduled to run.

    Having enough managed data to ensure uninterrupted playback - is an implementation specific condition where the user agent determines that + is an implementation defined condition where the user agent determines that it currently has enough data to play the presentation without stalling for a meaningful period of time and that it can achieve a balance between optimal memory and energy usage. This condition is constantly evaluated to determine @@ -2802,7 +2801,7 @@

    `ManagedSourceBuffer` Monitoring

    1. - Set [=this=]'s {{ManagedMediaSource/streaming}} attribute to true. + Set [=this=]'s {{ManagedMediaSource/streaming}} attribute to `true`.
    2. Abort these steps.
    @@ -2820,7 +2819,7 @@

    `ManagedSourceBuffer` Monitoring

    1. Set [=this=]'s {{ManagedMediaSource/streaming}} attribute to - false. + `false`.
    2. Abort these steps.
    From 9a608b836cc8ed6c27c73ed723ef4aeb2f2494da Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 25 Oct 2023 14:27:18 -0700 Subject: [PATCH 21/46] Rework ManagedSourceBuffer Monitoring per Paul's comments --- media-source-respec.html | 42 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 247abd1..c4829fa 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2783,45 +2783,29 @@

    `ManagedSourceBuffer` Monitoring

    Having enough managed data to ensure uninterrupted playback is an implementation defined condition where the user agent determines that it currently has enough data to play the presentation without stalling for a - meaningful period of time and that it can achieve a balance between optimal - memory and energy usage. This condition is constantly evaluated to determine + meaningful period of time. This condition is constantly evaluated to determine when to transition the value of {{ManagedMediaSource/streaming}}. These transitions indicate when the user agent believes it has enough data buffered or it needs more data respectively.

    +

    + Being able to retrieve and buffer data in an efficient way + is an implementation defined condition where the user agent determines that + it can fetch new data in an energy efficient manner while able to achieve the desired memory usage. +

    1. Run the {{MediaSource}} [=MediaSource/SourceBuffer Monitoring=] algorithm.
    2. -
    3. +
    4. Let |can play uninterupted and efficiently| be a flag that is true if the {{HTMLMediaElement/buffered}} attribute contains a {{TimeRanges}} that includes the current playback position and [=enough managed data to ensure uninterrupted playback=] + and [=able to retrieve and buffer data in an efficient way=]
      -
      - If {{HTMLMediaElement}}'s {{HTMLMediaElement/buffered}} attribute - contains a {{TimeRanges}} that includes the current playback position - and not [=enough managed data to ensure uninterrupted playback=]: +
      If |can play uninterupted and efficiently| is not equal to {{ManagedMediaSource/streaming}}, [=queue an element task=] on the [=media element=] + that runs the following steps:
        -
      1. - Set [=this=]'s {{ManagedMediaSource/streaming}} attribute to `true`. -
      2. -
      3. Abort these steps.
      4. -
      -
      -
      -
    5. -
    6. -
      -
      - If {{HTMLMediaElement}}'s {{HTMLMediaElement/buffered}} attribute - contains a {{TimeRanges}} that includes the current playback position and - [=enough managed data to ensure uninterrupted playback=]: -
      -
      -
        -
      1. - Set [=this=]'s {{ManagedMediaSource/streaming}} attribute to - `false`. -
      2. -
      3. Abort these steps.
      4. +
      5. Set |this| {{ManagedMediaSource/streaming}} attribute to |can play uninterupted and efficiently|.
      6. +
      7. If |can play uninterupted and efficiently| is false [=fire an event=] called {{startstreaming}} at the {{ManagedMediaSource}}.
      8. +
      9. Else [=fire an event=] called {{endstreaming}} at the {{ManagedMediaSource}}.
      From fa835521e2a35cb626871e1ce46c55c647fcc86f Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 25 Oct 2023 17:06:14 -0700 Subject: [PATCH 22/46] Rename "memory pressure" algorithm to "memory cleanup" --- media-source-respec.html | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index c4829fa..2b1625b 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2716,8 +2716,9 @@

      ManagedMediaSource interface

      A {{ManagedMediaSource}} is a {{MediaSource}} that actively manages its memory content. Unlike a {{MediaSource}}, the [=user agent=] can evict evict content - from its {{MediaSource/sourceBuffers}} (populated with {{ManagedSourceBuffer}}) for any reason, including when under [=ManagedMediaSource/memory - pressure=]. + through the [=ManagedMediaSource/memory + cleanup=] algorithm from its {{MediaSource/sourceBuffers}} (populated with {{ManagedSourceBuffer}}) + for any reason.

      @@ -2812,7 +2813,7 @@ 

      `ManagedSourceBuffer` Monitoring

    -

    Memory pressure

    +

    Memory Cleanup

    1. @@ -2822,7 +2823,7 @@

      Memory pressure

        -
      1. Run the |buffer|'s memory pressure algorithm.
      2. +
      3. Run the |buffer|'s [=ManagedSourceBuffer/memory cleanup=] algorithm.
      @@ -2852,14 +2853,14 @@

      Attributes

      addedRanges
      - The time ranges added during the last {{SourceBuffer/appendBuffer()}} operation. + The time ranges added during the last run of the [=coded frame processing=] algorithm.
      removedRanges
      - The time ranges removed during the last {{SourceBuffer/remove()}} operation or if the - user agent evicted content in response to a memory pressure. + The time ranges removed during the last run of the [=coded frame removal=] or [=coded frame eviction=] algorithm or if the + user agent evicted content in response to a [=ManagedSourceBuffer/memory cleanup=].
      @@ -2901,7 +2902,7 @@

      Event Summary

      The {{ManagedSourceBuffer}}'s buffered range changed following a call to {{SourceBuffer/appendBuffer()}}, {{SourceBuffer/remove()}}, or as a consequence of the user agent running the - [=ManagedSourceBuffer/memory pressure=] algorithm. + [=ManagedSourceBuffer/memory cleanup=] algorithm. @@ -2913,7 +2914,7 @@

      Buffered Change

      The following steps are run at the completion of all operations to the {{ManagedSourceBuffer}} |buffer:ManagedSourceBuffer| that would cause a |buffer|'s {{SourceBuffer/buffered}} to change. That is once {{SourceBuffer/appendBuffer()}}, {{SourceBuffer/remove()}} or - [=ManagedSourceBuffer/memory pressure=] algorithm have completed. + [=ManagedSourceBuffer/memory cleanup=] algorithm have completed.

      1. @@ -2946,13 +2947,13 @@

        Buffered Change

      - Memory pressure + Memory cleanup

      1. - If |managedSourceBuffer| is not in [=this=]'s + If [=this=] is not in [=this=]'s {{ManagedMediaSource}} parent {{MediaSource/activeSourceBuffers}}:
        From e218a754fcec3ee467b1aa9a8e63ef86b954f966 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 25 Oct 2023 17:34:00 -0700 Subject: [PATCH 23/46] Change onbufferedchange definition per Paul's comment --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 2b1625b..49f80f0 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2879,7 +2879,7 @@

        Attributes

        onbufferedchange
        -

        The event handler for the {{bufferedchange}} event.

        +

        An [=event handler IDL attribute=] whose [=event handler event type=] is {{bufferedchange}}.

        From e3219473d31fe0b8279b1de0c62aeb30aceb6acb Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 25 Oct 2023 18:07:48 -0700 Subject: [PATCH 24/46] Update media-source-respec.html MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marcos Cáceres --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 49f80f0..ca76e56 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -913,7 +913,7 @@

        Detaching from a media element

      2. Set {{MediaSource/[[port to main]]}} null.
      3. Set the {{MediaSource/readyState}} attribute to {{ReadyState/""closed""}}.
      4. -
      5. If [=this=] is a {{ManagedMediaSource}} set {{ManagedMediaSource/streaming}} attribute to `false`
      6. +
      7. If [=this=] is a {{ManagedMediaSource}}, then set {{ManagedMediaSource/streaming}} attribute to `false`.
      8. Update {{MediaSource/duration}} to NaN.
      9. Remove all the SourceBuffer objects from {{MediaSource/activeSourceBuffers}}.
      10. From e988b782ef2d54eddd2c708ed8078b9d8fff9799 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 25 Oct 2023 19:11:08 -0700 Subject: [PATCH 25/46] Fix grammar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marcos Cáceres --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index ca76e56..4c03964 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2797,7 +2797,7 @@

        `ManagedSourceBuffer` Monitoring

        1. Run the {{MediaSource}} [=MediaSource/SourceBuffer Monitoring=] algorithm.
        2. Let |can play uninterupted and efficiently| be a flag that is true if the {{HTMLMediaElement/buffered}} attribute contains a {{TimeRanges}} that includes the current playback position and [=enough managed data to ensure uninterrupted playback=] - and [=able to retrieve and buffer data in an efficient way=] + and is [=able to retrieve and buffer data in an efficient way=]
          If |can play uninterupted and efficiently| is not equal to {{ManagedMediaSource/streaming}}, [=queue an element task=] on the [=media element=] that runs the following steps: From ebd9fe5257f15b1ddb7aca35aa986715a3d6c8e2 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 25 Oct 2023 19:31:42 -0700 Subject: [PATCH 26/46] Expand streaming changed algorithm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marcos Cáceres --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 4c03964..b5af09e 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2760,7 +2760,7 @@

          Event Summary

    From cb0ab99dc08542cbe6d1dd5e4906940d24e91159 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 25 Oct 2023 19:31:56 -0700 Subject: [PATCH 27/46] update streaming change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marcos Cáceres --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index b5af09e..2696afc 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2769,7 +2769,7 @@

    Event Summary

    From 31ac8e08faf31a491be2e3ade9a765307ee82e78 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Fri, 27 Oct 2023 11:44:17 +1100 Subject: [PATCH 28/46] Fix typo. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marcos Cáceres --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 2696afc..9034477 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2715,7 +2715,7 @@

    Event Summary

    ManagedMediaSource interface

    A {{ManagedMediaSource}} is a {{MediaSource}} that actively manages its - memory content. Unlike a {{MediaSource}}, the [=user agent=] can evict evict content + memory content. Unlike a {{MediaSource}}, the [=user agent=] can evict content through the [=ManagedMediaSource/memory cleanup=] algorithm from its {{MediaSource/sourceBuffers}} (populated with {{ManagedSourceBuffer}}) for any reason. From 88d45740b1d6f5156b0ba38b37d3acc41c73a2cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Fri, 10 Nov 2023 13:30:36 +1100 Subject: [PATCH 29/46] Update media-source-respec.html --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 9034477..ac158cf 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -435,7 +435,7 @@

    Attributes

    Otherwise, set |buffer|'s {{SourceBuffer/mode}} to {{AppendMode/"segments"}}.
  • [=List/Append=] |buffer| to |this|'s {{MediaSource/sourceBuffers}}.
  • -
  • [=Queue a task=] to [=fire an event=] named {{addsourcebuffer}} at |this|'s {{MediaSource/sourceBuffers}}.
  • +
  • [=Queue a task=] to [=fire an event=] named {{addsourcebuffer}} at [=this=]'s {{MediaSource/sourceBuffers}}.
  • Return |buffer|.
  • From 3799ad665a7011c980c5990025265bdb6f6ef8aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Fri, 10 Nov 2023 13:31:15 +1100 Subject: [PATCH 30/46] Update media-source-respec.html --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index ac158cf..067db92 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -424,7 +424,7 @@

    Attributes

  • If the {{MediaSource/readyState}} attribute is not in the {{ReadyState/""open""}} state then throw an {{InvalidStateError}} exception and abort these steps.
  • - Let |buffer| be a new instance of a {{ManagedSourceBuffer}} if |this| is a {{ManagedMediaSource}}, or a {{SourceBuffer}} otherwise, with their respective associated resources.
  • + Let |buffer| be a new instance of a {{ManagedSourceBuffer}} if [=this=] is a {{ManagedMediaSource}}, or a {{SourceBuffer}} otherwise, with their respective associated resources.
  • Set |buffer|'s {{SourceBuffer/[[generate timestamps flag]]}} to the value in the "Generate Timestamps Flag" column of the [[[MSE-REGISTRY]]] entry that is associated with From c16cad603bdaa65ab0e0e6da6335f3d87c412e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Fri, 10 Nov 2023 13:31:54 +1100 Subject: [PATCH 31/46] Update media-source-respec.html --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 067db92..d570ba6 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -434,7 +434,7 @@

    Attributes

    If |buffer|'s {{SourceBuffer/[[generate timestamps flag]]}} is true, set |buffer|'s {{SourceBuffer/mode}} to {{AppendMode/"sequence"}}. Otherwise, set |buffer|'s {{SourceBuffer/mode}} to {{AppendMode/"segments"}}.
  • -
  • [=List/Append=] |buffer| to |this|'s {{MediaSource/sourceBuffers}}.
  • +
  • [=List/Append=] |buffer| to [=this=]'s {{MediaSource/sourceBuffers}}.
  • [=Queue a task=] to [=fire an event=] named {{addsourcebuffer}} at [=this=]'s {{MediaSource/sourceBuffers}}.
  • Return |buffer|.
  • From d51901381d948c4020e82c86f553fe646a5ef8d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Fri, 10 Nov 2023 13:32:34 +1100 Subject: [PATCH 32/46] Update media-source-respec.html --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index d570ba6..54400ea 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2804,7 +2804,7 @@

    `ManagedSourceBuffer` Monitoring

      -
    1. Set |this| {{ManagedMediaSource/streaming}} attribute to |can play uninterupted and efficiently|.
    2. +
    3. Set [=this=] {{ManagedMediaSource/streaming}} attribute to |can play uninterrupted and efficiently|.
    4. If |can play uninterupted and efficiently| is false [=fire an event=] called {{startstreaming}} at the {{ManagedMediaSource}}.
    5. Else [=fire an event=] called {{endstreaming}} at the {{ManagedMediaSource}}.
    From 7d2375887133bb78db4127bdc2d3b1ef8cfa6da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Fri, 10 Nov 2023 13:35:30 +1100 Subject: [PATCH 33/46] s/uninterupted/uninterrupted --- media-source-respec.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 54400ea..45d7f5c 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2796,16 +2796,16 @@

    `ManagedSourceBuffer` Monitoring

    1. Run the {{MediaSource}} [=MediaSource/SourceBuffer Monitoring=] algorithm.
    2. -
    3. Let |can play uninterupted and efficiently| be a flag that is true if the {{HTMLMediaElement/buffered}} attribute contains a {{TimeRanges}} that includes the current playback position and [=enough managed data to ensure uninterrupted playback=] +
    4. Let |can play uninterrupted and efficiently| be a flag that is true if the {{HTMLMediaElement/buffered}} attribute contains a {{TimeRanges}} that includes the current playback position and [=enough managed data to ensure uninterrupted playback=] and is [=able to retrieve and buffer data in an efficient way=]
      -
      If |can play uninterupted and efficiently| is not equal to {{ManagedMediaSource/streaming}}, [=queue an element task=] on the [=media element=] +
      If |can play uninterrupted and efficiently| is not equal to {{ManagedMediaSource/streaming}}, [=queue an element task=] on the [=media element=] that runs the following steps:
      1. Set [=this=] {{ManagedMediaSource/streaming}} attribute to |can play uninterrupted and efficiently|.
      2. -
      3. If |can play uninterupted and efficiently| is false [=fire an event=] called {{startstreaming}} at the {{ManagedMediaSource}}.
      4. +
      5. If |can play uninterrupted and efficiently| is false [=fire an event=] called {{startstreaming}} at the {{ManagedMediaSource}}.
      6. Else [=fire an event=] called {{endstreaming}} at the {{ManagedMediaSource}}.
      From a0212255bb477c631b27d5715a26fc23ac32e78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Fri, 10 Nov 2023 13:36:09 +1100 Subject: [PATCH 34/46] Update media-source-respec.html --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 45d7f5c..8a8d6d8 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2806,7 +2806,7 @@

      `ManagedSourceBuffer` Monitoring

      1. Set [=this=] {{ManagedMediaSource/streaming}} attribute to |can play uninterrupted and efficiently|.
      2. If |can play uninterrupted and efficiently| is false [=fire an event=] called {{startstreaming}} at the {{ManagedMediaSource}}.
      3. -
      4. Else [=fire an event=] called {{endstreaming}} at the {{ManagedMediaSource}}.
      5. +
      6. Otherwise, [=fire an event=] called {{endstreaming}} at the {{ManagedMediaSource}}.
    From 966297a05d07b63a924e476281753e8ab2db5090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Fri, 10 Nov 2023 13:39:39 +1100 Subject: [PATCH 35/46] Update media-source-respec.html --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 8a8d6d8..2564cc3 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -3436,7 +3436,7 @@

    Use of the Managed Media Source Extensions

    const mediaType = 'video/mp4; codecs="mp4a.40.2,avc1.4d4015"'; // Check if the type of video format / codec is supported. - if (ManagedMediaSource?.isTypeSupported(mediaType)) { + if (!window.ManagedMediaSource?.isTypeSupported(mediaType)) { return; // Not supported, do something else. } From a7fe3aaeaded2424b806c9a894e19819373cbc8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 5 Dec 2023 17:11:02 +1100 Subject: [PATCH 36/46] Update media-source-respec.html --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 593f60d..311453a 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2969,7 +2969,7 @@

  • Let |removal ranges:normalized TimeRanges| equal a list of presentation time ranges that can be evicted from the presentation to ensure - uninterrupted playback from {{HTMLMediaElement.currentTime}} until such + uninterrupted playback from {{HTMLMediaElement/currentTime}} until such presentation could be fetched again.

    Implementations can use different strategies for selecting |removal ranges| From 97848699ec48012c13612625cdc2d61e0fe8c088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 5 Dec 2023 17:57:12 +1100 Subject: [PATCH 37/46] Update media-source-respec.html --- media-source-respec.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 59420c2..386017a 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2697,7 +2697,11 @@

    ManagedMediaSource interface

    cleanup=] algorithm from its {{MediaSource/sourceBuffers}} (populated with {{ManagedSourceBuffer}}) for any reason.

    - +
           [Exposed=(Window,DedicatedWorker)]
           interface ManagedMediaSource : MediaSource {
    
    From b48aeb3d0786344c71713ffece090513276138cc Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= 
    Date: Tue, 5 Dec 2023 17:59:49 +1100
    Subject: [PATCH 38/46] Update media-source-respec.html
    
    ---
     media-source-respec.html | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/media-source-respec.html b/media-source-respec.html
    index 386017a..4a46dc8 100644
    --- a/media-source-respec.html
    +++ b/media-source-respec.html
    @@ -2699,7 +2699,7 @@ 

    ManagedMediaSource interface

    
    From 12d290a1cddc49c7879b34a0a17edd32537fec16 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= 
    Date: Tue, 5 Dec 2023 18:31:06 +1100
    Subject: [PATCH 39/46] Update media-source-respec.html
    
    ---
     media-source-respec.html | 1 +
     1 file changed, 1 insertion(+)
    
    diff --git a/media-source-respec.html b/media-source-respec.html
    index 4a46dc8..0109276 100644
    --- a/media-source-respec.html
    +++ b/media-source-respec.html
    @@ -2882,6 +2882,7 @@ 

    Event Summary

  • From 4fc0c11974efdf0335f374e1f343f0aab07c5a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 5 Dec 2023 18:33:28 +1100 Subject: [PATCH 40/46] Update media-source-respec.html --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 0109276..9b36d23 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2941,7 +2941,7 @@

    1. - Run the [=coded frame removal=] algorithm with 0 and positive infinity equal to the removal range start and end timestamp respectively, and abort these steps. + Run the [=coded frame removal=] algorithm with start set to 0, end set to positive infinity, and abort these steps.
    From 4cde048e4edb97b5d3661c087b53ea54e75689fd Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Tue, 5 Dec 2023 18:37:30 +1100 Subject: [PATCH 41/46] Update sotd --- media-source-respec.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 9b36d23..8bcd8e0 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -87,10 +87,13 @@
    -

    On top of editorial updates, substantives changes since publication as a W3C Recommendation in November 2016 are the addition of a {{SourceBuffer/changeType()}} method to switch codecs, the possibility to create and use {{MediaSource}} objects off the main thread in dedicated workers, and the removal of the createObjectURL() extension to the {{URL}} object following its integration in the File API [[FILEAPI]]. For a full list of changes done since the previous version, see the commits.

    +

    On top of editorial updates, substantives changes since publication as a W3C Recommendation in November 2016 are the addition of a {{SourceBuffer/changeType()}} method to switch codecs, the possibility to create and use {{MediaSource}} objects off the main thread in dedicated workers, the removal of the createObjectURL() extension to the {{URL}} object following its integration in the File API [[FILEAPI]], and the addition of {{ManagedMediaSource}}, ManagedSourceBuffer}}, and {{BufferedChangeEvent}} interfaces supporting power-efficient streaming and active buffered media cleanup by the user agent. For a full list of changes done since the previous version, see the commits.

    The working group maintains a list of all bug reports that the editors have not yet tried to address.

    Implementors should be aware that this specification is not stable. Implementors who are not taking part in the discussions are likely to find the specification changing out from under them in incompatible ways. Vendors interested in implementing this specification before it eventually reaches the Candidate Recommendation stage should track the GitHub repository and take part in the discussions.

    +

    Changes since last publication

    +

    On top of editorial updates, substantives changes since publication as a W3C Recommendation in + November 2016 are the addition of a {{SourceBuffer/changeType()}} method to switch codecs, the possibility to create and use {{MediaSource}} objects off the main thread in dedicated workers, the removal of the createObjectURL() extension to the {{URL}} object following its integration in the File API [[FILEAPI]], and the addition of {{ManagedMediaSource}}, ManagedSourceBuffer}}, and {{BufferedChangeEvent}} interfaces supporting power-efficient streaming and active buffered media cleanup by the user agent. For a full list of changes done since the previous version, see the commits.

    From 2f5ef0d0441c6fd2e29d0779587340bdbb59f64c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 5 Dec 2023 18:39:07 +1100 Subject: [PATCH 42/46] Update media-source-respec.html Co-authored-by: Jean-Yves Avenard --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 8bcd8e0..9e81ea5 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2837,7 +2837,7 @@

    Attributes

    addedRanges
    - The time ranges added during the last run of the [=coded frame processing=] algorithm. + The time ranges added between the last {{updatestart}} and {{updateeend}} events (which would have occurred during the last run of the [=coded frame processing=] algorithm).
    removedRanges From 8aa78d1e631970ad1da1d2ed2ab277d34bcf9bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 5 Dec 2023 18:39:27 +1100 Subject: [PATCH 43/46] Update media-source-respec.html Co-authored-by: Jean-Yves Avenard --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 9e81ea5..d022ea5 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2843,7 +2843,7 @@

    Attributes

    removedRanges
    - The time ranges removed during the last run of the [=coded frame removal=] or [=coded frame eviction=] algorithm or if the + The time ranges removed between the last `updatestart` and `updateend` events (which would have occurred during the last run of the [=coded frame removal=] or [=coded frame eviction=] algorithm or if the user agent evicted content in response to a [=ManagedSourceBuffer/memory cleanup=].
    From f8a0b3cb20e30347b5d5ae396833fb6e17d940f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 5 Dec 2023 18:39:54 +1100 Subject: [PATCH 44/46] Apply suggestions from code review Co-authored-by: Jean-Yves Avenard --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index d022ea5..4ba09d2 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2844,7 +2844,7 @@

    Attributes

    The time ranges removed between the last `updatestart` and `updateend` events (which would have occurred during the last run of the [=coded frame removal=] or [=coded frame eviction=] algorithm or if the - user agent evicted content in response to a [=ManagedSourceBuffer/memory cleanup=]. + user agent evicted content in response to a [=ManagedSourceBuffer/memory cleanup=]).
    From 5158cc63f6d378fff81f0ad8d0400c9a52b9c850 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Tue, 5 Dec 2023 22:10:32 +1100 Subject: [PATCH 45/46] Update media-source-respec.html --- media-source-respec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media-source-respec.html b/media-source-respec.html index 4ba09d2..5e9bd78 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -2954,7 +2954,7 @@

    Let |removal ranges:normalized TimeRanges| equal a list of presentation time ranges that can be evicted from the presentation to ensure uninterrupted playback from {{HTMLMediaElement/currentTime}} until such - presentation could be fetched again. + presentation could be retrieved again.

    Implementations can use different strategies for selecting |removal ranges| so web applications shouldn't depend on a specific behavior. The web From 12fc650cf4faf3c2746097b82fb60a6e0afc5a1d Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Wed, 6 Dec 2023 10:27:21 +1100 Subject: [PATCH 46/46] fix event name --- media-source-respec.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 5e9bd78..d3d907b 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -92,7 +92,7 @@

    The working group maintains a list of all bug reports that the editors have not yet tried to address.

    Implementors should be aware that this specification is not stable. Implementors who are not taking part in the discussions are likely to find the specification changing out from under them in incompatible ways. Vendors interested in implementing this specification before it eventually reaches the Candidate Recommendation stage should track the GitHub repository and take part in the discussions.

    Changes since last publication

    -

    On top of editorial updates, substantives changes since publication as a W3C Recommendation in +

    On top of editorial updates, substantives changes since publication as a W3C Recommendation in November 2016 are the addition of a {{SourceBuffer/changeType()}} method to switch codecs, the possibility to create and use {{MediaSource}} objects off the main thread in dedicated workers, the removal of the createObjectURL() extension to the {{URL}} object following its integration in the File API [[FILEAPI]], and the addition of {{ManagedMediaSource}}, ManagedSourceBuffer}}, and {{BufferedChangeEvent}} interfaces supporting power-efficient streaming and active buffered media cleanup by the user agent. For a full list of changes done since the previous version, see the commits.

    @@ -2837,7 +2837,7 @@

    Attributes

    addedRanges
    - The time ranges added between the last {{updatestart}} and {{updateeend}} events (which would have occurred during the last run of the [=coded frame processing=] algorithm). + The time ranges added between the last {{updatestart}} and {{updateend}} events (which would have occurred during the last run of the [=coded frame processing=] algorithm).
    removedRanges

    {{Event}} - {{ManagedMediaSource/streaming}} attribute changes from `false` to `true`. + {{ManagedMediaSource/streaming}} attribute changed from `false` to `true`.
    {{Event}} - {{ManagedMediaSource/streaming}} attribute changes from `true` to `false`. + {{ManagedMediaSource/streaming}} attribute changed from `true` to `false`.
    {{Event}} - {{ManagedMediaSource/streaming}} attribute changed from `false` to `true`. + A {{ManagedMediaSource}}'s {{ManagedMediaSource/streaming}} attribute changed from `false` to `true`.
    {{Event}} - {{ManagedMediaSource/streaming}} attribute changed from `true` to `false`. + A {{ManagedMediaSource}}'s {{ManagedMediaSource/streaming}} attribute changed from `true` to `false`.
    The {{ManagedSourceBuffer}}'s buffered range changed following a call to {{SourceBuffer/appendBuffer()}}, {{SourceBuffer/remove()}}, + {{MediaSource/endOfStream()}}, or as a consequence of the user agent running the [=ManagedSourceBuffer/memory cleanup=] algorithm.