Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement cross-thread MediaSource attachments #4314

Merged

Conversation

at-ninja
Copy link
Contributor

@at-ninja at-ninja commented Oct 25, 2024

Port relevant Chromium code to the Cobalt 25 codebase to allow for
MediaSource objects on a Dedicated Worker to render frames on a
HTMLMediaElement owned by the main browser thread.

Usage of this feature is gated behind the MediaSource.EnableInWorkers
H5VCC flag. In addition, the
MediaElement.EnableUsingMediaSourceBufferedRange and
MediaElement.EnableUsingMediaSourceAttachmentMethods flags are also
required as pre-requisite features.

This commit does introduce mutex locks to the SourceBuffer and MediaSource
classes that cannot be fully gated behind H5VCC flags. However, current
usage of both classes is contained to single-threaded usecases. As such,
the mutex lock code should be an effective no-op.

This is based off of the following Chromium commits:

b/338425382

@at-ninja at-ninja requested a review from xiaomings October 25, 2024 21:24
@at-ninja at-ninja force-pushed the cross-thread-media-source-attachments branch from 55fac9b to 2e35a64 Compare October 30, 2024 19:24
@at-ninja at-ninja changed the title [draft] Cross thread media source attachments Implement cross-thread MediaSource attachments Oct 30, 2024
@jellefoks jellefoks requested a review from aee-google October 30, 2024 22:22
Port relevant Chromium code to the Cobalt 25 codebase to allow for
`MediaSource` objects on a Dedicated Worker to render frames on a
`HTMLMediaElement` owned by the main browser thread.

Usage of this feature is gated behind the `MediaSource.EnableInWorkers`
H5VCC flag. In addition, the
`MediaElement.EnableUsingMediaSourceBufferedRange` and
`MediaElement.EnableUsingMediaSourceAttachmentMethods` flags are also
required as pre-requisite features.

This commit does introduce mutex locks to the `SourceBuffer` and `MediaSource`
classes that cannot be fully gated behind H5VCC flags. However, current
usage of both classes is contained to single-threaded usecases. As such,
the mutex lock code should be an effective no-op.

This is based off of the following Chromium commits:

* https://chromium-review.googlesource.com/c/chromium/src/+/2459431
* https://chromium-review.googlesource.com/c/chromium/src/+/2617351
* https://chromium-review.googlesource.com/c/chromium/src/+/2909389

b/338425382
@at-ninja at-ninja force-pushed the cross-thread-media-source-attachments branch from 2e35a64 to 5fc5cd4 Compare October 31, 2024 20:04
@at-ninja at-ninja marked this pull request as ready for review October 31, 2024 20:05
@at-ninja at-ninja requested a review from jellefoks October 31, 2024 20:05
@at-ninja at-ninja requested a review from aee-google November 4, 2024 19:45
Copy link
Contributor

@aee-google aee-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@at-ninja at-ninja enabled auto-merge (squash) December 3, 2024 03:30
@at-ninja at-ninja merged commit 41c7254 into youtube:25.lts.1+ Dec 3, 2024
300 of 301 checks passed
@at-ninja at-ninja deleted the cross-thread-media-source-attachments branch December 13, 2024 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants