Bug 202101 - Support for callbacks for manifest events
Summary: Support for callbacks for manifest events
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Enhancement
Assignee: Eric Carlson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-09-23 05:00 PDT by shivaksk1
Modified: 2021-09-06 06:13 PDT (History)
8 users (show)

See Also:


Attachments
Patch (29.22 KB, patch)
2019-10-18 10:55 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff
Patch for landing (28.56 KB, patch)
2019-10-18 17:09 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff
Patch for landing. (28.74 KB, patch)
2019-10-25 11:04 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description shivaksk1 2019-09-23 05:00:33 PDT
Hi Team,

It would be good to have callbacks for manifest timed events (HLS).

E.g. EXT-X-DATERANGE.

This is required for Server Side Dynamic Ad Implementations. For example the Ad related metadata could be passed in this attribute. The App could listen for this metadata callback and take appropriate action based on this.

It's supported in the AV player in iOS, but there is no support on Safari.
Comment 1 Radar WebKit Bug Importer 2019-09-23 10:26:07 PDT
<rdar://problem/55627676>
Comment 2 Eric Carlson 2019-10-18 10:55:48 PDT
Created attachment 381314 [details]
Patch
Comment 3 Jer Noble 2019-10-18 13:56:39 PDT
Comment on attachment 381314 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=381314&action=review

> Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:3519
> +    UNUSED_PARAM(output);
> +    UNUSED_PARAM(track);
> +
> +    ensureOnMainThread([self, strongSelf = retainPtr(self), metadataGroups = retainPtr(groups)]() mutable {
> +        m_taskQueue.enqueueTask([player = m_player, metadataGroups = WTFMove(metadataGroups), currentTime = m_player->currentMediaTime()] {
> +            if (!player)
> +                return;
> +
> +            for (AVDateRangeMetadataGroup *group in metadataGroups.get())
> +                player->metadataDidArrive(retainPtr(group.items), currentTime);
> +        });
> +    });

Nit: why are we using a background queue if we're just going to dispatch to the main thread?
Comment 4 Eric Carlson 2019-10-18 17:09:01 PDT
Created attachment 381350 [details]
Patch for landing
Comment 5 Eric Carlson 2019-10-25 11:04:56 PDT
Created attachment 381943 [details]
Patch for landing.
Comment 6 WebKit Commit Bot 2019-10-25 19:37:54 PDT
The commit-queue encountered the following flaky tests while processing attachment 381943 [details]:

imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/integrity.html bug 203394 (author: ysuzuki@apple.com)
The commit-queue is continuing to process your patch.
Comment 7 WebKit Commit Bot 2019-10-25 19:38:47 PDT
Comment on attachment 381943 [details]
Patch for landing.

Clearing flags on attachment: 381943

Committed r251626: <https://trac.webkit.org/changeset/251626>
Comment 8 WebKit Commit Bot 2019-10-25 19:38:49 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 shivaksk1 2021-09-02 22:10:51 PDT
Hi, could you please explain how to listen to this event (EXT-X-DATERANGE) from the html5 video element in Safari browser (on Mac)?
Comment 10 Eric Carlson 2021-09-03 12:04:53 PDT
(In reply to shivaksk1 from comment #9)
> Hi, could you please explain how to listen to this event (EXT-X-DATERANGE)
> from the html5 video element in Safari browser (on Mac)?

EXT-X-DATERANGE metadata is exposed just like all timed metadata - as a text track with `kind=metadata`.

The scripts in this simple test page I wrote, which logs metadata cues as they are emitted, might be helpful: https://streaming-metadata.glitch.me
Comment 11 shivaksk1 2021-09-06 05:39:22 PDT
Hi Team, Thanks for the quick response.

May I know from which Safari browser version this feature is supported?
Comment 12 shivaksk1 2021-09-06 06:13:29 PDT
Also, I have a query:

#EXT-X-DATERANGE:ID="adbreak-100076-0",START-DATE="2021-09-06T12:05:34.000Z",DURATION=30,X-PRESENTATION-TIME=1630929934000,CLASS="com.xyz.dai.adbreak"

#EXT-X-DATERANGE:ID="tracking-100076-0-0",START-DATE="2021-09-06T12:05:34.000Z",DURATION=1,X-AD-URL="https://url_1",X-AD-ID="adbreak-100076-0",CLASS="com.xyz.dai.tracking"

In the above manifest, are we supposed to get two cues, one for each EXT-X-DATERANGE tag?

Cue 1: contains ID, DURATION, X-PRESENTATION-TIME, CLASS for cue 1
Cue 2: contains ID, DURATION, X-PRESENTATION-TIME, CLASS for cue 2


When I tried to run the sample script on the above manifest, I observed that:
- For the first EXT-X-DATERANGE tag, we get one cue, with key = X-PRESENTATION-TIME.
- For the second EXT-X-DATERANGE tag, we get 2 cues,
  - cue 1: {key: X-AD-ID, value: adbreak-100076-0}
  - cue 2: {key: X-AD-URL, value: https://url_1}

Could you please explain this behavior?