Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdded AudioTrack, AudioTrackList, VideoTrack, and VideoTrackList inte… #22622
Conversation
|
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() |
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| pub fn set_selected(&self, idx: usize, value: bool) { | ||
| self.item(idx).unwrap().set_selected(value); |
This comment has been minimized.
This comment has been minimized.
| self.tracks.borrow_mut().push(Dom::from_ref(track)); | ||
| } | ||
| } else { | ||
| self.tracks.borrow_mut().push(Dom::from_ref(track)); |
This comment has been minimized.
This comment has been minimized.
jdm
Jan 7, 2019
Member
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")); |
This comment has been minimized.
This comment has been minimized.
jdm
Jan 7, 2019
Member
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) |
This comment has been minimized.
This comment has been minimized.
|
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 |
|
|
|
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. |
|
|
This is very close! |
| } | ||
|
|
||
| pub fn is_empty(&self) -> bool { | ||
| self.tracks.borrow().is_empty().clone() |
This comment has been minimized.
This comment has been minimized.
| event_handler!(onaddtrack, GetOnaddtrack, SetOnaddtrack); | ||
|
|
||
| // https://html.spec.whatwg.org/multipage/#handler-tracklist-onremovetrack | ||
| event_handler!(onremovetrack, GetOnremovetrack, SetOnremovetrack); |
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| // Steps 7 | ||
| // Fire an event named addtrack at this AudioTrackList object, using TrackEvent |
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| // Steps 7 | ||
| // Fire an event named addtrack at this VideoTrackList object, using TrackEvent |
This comment has been minimized.
This comment has been minimized.
| self.set_selected(idx, false); | ||
| } | ||
| } | ||
| self.tracks.borrow_mut().push(Dom::from_ref(track)); |
This comment has been minimized.
This comment has been minimized.
jdm
Jan 31, 2019
Member
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); |
This comment has been minimized.
This comment has been minimized.
| if let Some(track) = self.item(idx) { | ||
| track.set_selected(value); | ||
| } | ||
| self.upcast::<EventTarget>().fire_event(atom!("change")); |
This comment has been minimized.
This comment has been minimized.
jdm
Jan 31, 2019
Member
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
|
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+ |
|
|
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 -->
|
|
…ckEvent interfaces
|
Yep I missed one, sorry!. Hopefully this one will finally pass. |
|
@bors-servo r+ |
|
|
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 -->
|
|
|
Woohoo! Thanks for sticking with this! |
sreeise commentedJan 5, 2019
•
edited
…rfaces
Added AudioTrack, AudioTrackList, VideoTrack, VideoTrackList, and TrackEvent interfaces to support multiple media tracks.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is