-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Added AudioTrack, AudioTrackList, VideoTrack, and VideoTrackList inte… #22622
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the code for the audio and video tracks is so similar, please consider whether each comment made about the video track list implementation could be applied to the audio track list implementation. My one concern about this PR is that we're adding a bunch of code that does not get executed, since there are no callers for AudioTrackList::add and VideoTrackList::add. You can get the information about audio and video tracks from the Metadata value that's in PlayerEvent::MetadataUpdated.
} | ||
|
||
pub fn is_empty(&self) -> bool { | ||
self.tracks.borrow().is_empty().clone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clone should not be necessary here.
} | ||
|
||
pub fn set_selected(&self, idx: usize, value: bool) { | ||
self.item(idx).unwrap().set_selected(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably silently ignore this instead of unwrapping.
self.tracks.borrow_mut().push(Dom::from_ref(track)); | ||
} | ||
} else { | ||
self.tracks.borrow_mut().push(Dom::from_ref(track)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like we can rewrite this as:
if track.selected() {
if let Some(idx) = self.selected_index() {
self.set_selected(idx, false);
}
}
self.tracks.borrow_mut().push(Dom::from_ref(track));
} else { | ||
self.tracks.borrow_mut().push(Dom::from_ref(track)); | ||
} | ||
self.upcast::<EventTarget>().fire_event(atom!("addtrack")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the steps in https://html.spec.whatwg.org/multipage/media.html#media-data-processing-steps-list that create these tracks, the events are supposed to be TrackEvent objects, not just simple Event objects.
self.tracks | ||
.borrow() | ||
.iter() | ||
.filter(|track| track.id() == id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can use find
instead of filter
& next
.
Welp, I totally forgot to read the long useful description in the pull request that you provided, but I think we came to similar conclusions. |
As for the contents of those vectors that you mentioned, the string values are the names of the codecs associated with those media tracks. We can add a TODO comment about using the codec information to choose the optimal track to enable. |
No worries! You actually answered all of questions I had and was actually going to ask now so it works for me. Thanks for the helpful information and ill get back with a much cleaner pr soon :). |
@jdm servo/components/script/dom/htmlmediaelement.rs Line 1134 in 6197f1a
It seems that only the Also, is the correct way to retrieve the rest of the track values by getting the attribute with the local_name! macro? Something like:
Thanks for the help! |
The format contains a string that corresponds with https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-bad-libs/html/GstPlayerMediaInfo.html#gst-player-media-info-get-container-format, which doesn't give any meaningful information about what it might contain. I'm not sure that it will be useful here. If the media tracks have a |
☔ The latest upstream changes (presumably #22692) made this pull request unmergeable. Please resolve the merge conflicts. |
6707d45
to
5507362
Compare
5507362
to
652f949
Compare
Hello, I am sorry for getting back to this so late. I added a part of the media processing steps but I am currently stuck on the kind attribute. I added an inline comment discussing the video and audio formats and how they are determined for this. Thanks for the help. |
652f949
to
b4c8b40
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very close!
} | ||
|
||
pub fn is_empty(&self) -> bool { | ||
self.tracks.borrow().is_empty().clone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to clone this value.
event_handler!(onaddtrack, GetOnaddtrack, SetOnaddtrack); | ||
|
||
// https://html.spec.whatwg.org/multipage/#handler-tracklist-onremovetrack | ||
event_handler!(onremovetrack, GetOnremovetrack, SetOnremovetrack); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the on
prefix from the first argument for event handlers.
} | ||
|
||
// Steps 7 | ||
// Fire an event named addtrack at this AudioTrackList object, using TrackEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we implement this step in this PR?
} | ||
|
||
// Steps 7 | ||
// Fire an event named addtrack at this VideoTrackList object, using TrackEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we implement this step in this PR?
self.set_selected(idx, false); | ||
} | ||
} | ||
self.tracks.borrow_mut().push(Dom::from_ref(track)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should push this before calling set_selected, otherwise the event handler for the change event could see an unexpected intermediate state.
event_handler!(onaddtrack, GetOnaddtrack, SetOnaddtrack); | ||
|
||
// https://html.spec.whatwg.org/multipage/#handler-tracklist-onremovetrack | ||
event_handler!(onremovetrack, GetOnremovetrack, SetOnremovetrack); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the on
prefix from the first argument to these event handlers.
if let Some(track) = self.item(idx) { | ||
track.set_selected(value); | ||
} | ||
self.upcast::<EventTarget>().fire_event(atom!("change")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per https://html.spec.whatwg.org/multipage/media.html#toggle-audio-track, this needs to be a queued task like
servo/components/script/dom/htmlmediaelement.rs
Lines 328 to 334 in f1dd31f
task_source | |
.queue( | |
task!(resolve_pending_play_promises: move || { | |
let this = this.root(); | |
if generation_id != this.generation_id.get() { | |
return; | |
} |
b4c8b40
to
fa722a7
Compare
4c79042
to
094777c
Compare
Hopefully the changes are correct. I am having an issue testing these locally. When I try run
which begins at The other thing I noticed on development builds, which happened before I changed the test expectations, is this warning:
I am not sure what the cause of these are. They could just be happening for me locally. |
@bors-servo r+ |
📌 Commit 094777c has been approved by |
Added AudioTrack, AudioTrackList, VideoTrack, and VideoTrackList inte… …rfaces <!-- Please describe your changes on the following line: --> Added AudioTrack, AudioTrackList, VideoTrack, VideoTrackList, and TrackEvent interfaces to support multiple media tracks. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #22301 (GitHub issue number if applicable) <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22622) <!-- Reviewable:end -->
💔 Test failed - linux-rel-wpt |
…ckEvent interfaces
094777c
to
cac4aa5
Compare
Yep I missed one, sorry!. Hopefully this one will finally pass. |
@bors-servo r+ |
📌 Commit cac4aa5 has been approved by |
Added AudioTrack, AudioTrackList, VideoTrack, and VideoTrackList inte… …rfaces <!-- Please describe your changes on the following line: --> Added AudioTrack, AudioTrackList, VideoTrack, VideoTrackList, and TrackEvent interfaces to support multiple media tracks. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #22301 (GitHub issue number if applicable) <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22622) <!-- Reviewable:end -->
☀️ Test successful - android-mac, arm32, arm64, linux-rel-css, linux-rel-wpt, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, magicleap, status-taskcluster |
Woohoo! Thanks for sticking with this! |
…rfaces
Added AudioTrack, AudioTrackList, VideoTrack, VideoTrackList, and TrackEvent interfaces to support multiple media tracks.
./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is