Implement Player Trait in ohos backend using Harmony OS MediaKit's[
AVPlayer](https://developer.huawei.com/consumer/en/doc/harmonyos-references/capi-avplayer-h).
The modular design of `VideoSink`, `InnerPlayer`, and `MediaSource` is
taken from the GStreamer backend.
Only support HarmonyOS SDK API 21, because the
`OH_AVPlayer_SetDataSource` only started to be exposed on API 21.
Testing: N/A, as there are no platform specific task.
Fixes: N/A, now we can play video on HarmonyOS phone using `<video>`
---------
Signed-off-by: rayguo17 <rayguo17@gmail.com>
Follow up of #43526. This addresses Nico's comment:
https://github.com/servo/servo/pull/43526#issuecomment-4104953308
- `bluetooth_traits` -> `servo_bluetooth_traits`
- `base` -> `servo_base`
- `bluetooth` -> `servo_bluetooth`
- `background_hang_monitor` -> `servo_background_hang_monitor`
Testing: This should not change any behaviour.
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This is no longer present in the spec. Instead, the
`process_request_body` is the new way. These two
methods were called right after each other and there was only 1
implementation in `htmlvideoelement`. That implementation is now moved
to `process_request_body` and hence we can remove the unnecessary
method.
Testing: It compiles
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Add the cx parameter to `fn process_response` in the
`FetchResponseListener` trait and the traits that that interface change
requires. Chose to add it as the first parameter, following the same
order that `FetchResponseListener::process_response_eof` uses.
Testing: Checked that servo builds locally as well as `./mach fmt` and
`./mach test-tidy`. I don't think more tests are needed as we are not
introducing new functionality
Fixes: #42840
---------
Signed-off-by: Javier Olaechea <pirata@gmail.com>
It pushes the `temp_cx` 1 level up to `element.rs` where the calling
chain begins. Other than that this was purely a mechanical change where
I used regexes to replace all patterns with the new ones.
Part of #42812
Testing: It compiles
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Pass `&mut JSContext` to `Element::create` and `create_html_element`
Testing: No functionality changes, covered by existing tests.
Part of #40600
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
Switch `VirtualMethods::children_changed` and
`VirtualMethods::adopting_steps` to `&mut JSContext`.
Testing: No behaviour change, a successful build is enough.
Part of #40600
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
- Use modern Rust conveniences such as `unwrap_or_default`
- Unabbreviate `attr`
- Unify the lowercase ASCII name assertion and make it a debug assertion
- Use `unreachable!` instead of panic
- Expose two attribute getters that follow the behavior of two
specification concepts and what we expect internally in Servo:
- One that takes a namespace, but does not require lowercase attribute
names. ([specification
concept](https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace>))
- One that does not take a namespace, but does require lowercase
attribute names. ([specification
concept](https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name))
Testing: This should not really change behavior so should be covered by
existing tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
I only wanted to get `&mut JSContext` in microtask chunk and checkpoint,
but this in turn needed `&mut JSContext` in servoparser, which then
caused need for even more changes in script.
I tried to limit the size by putting some `temp_cx` in:
- drops of `LoadBlocker`, `GenericAutoEntryScript`
- methods of `VirtualMethods`
- methods of `FetchResponseListener`
Testing: Just refactor, but should be covered by WPT tests.
Part of #40600
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
`process_response_eof` is the only method that needs cx at least right
now. This PR removes one temp_cx and introduces one, removing that one
will is hard (needs VirtualMethods and a lot of work)
Testing: Just refactor
Part of #40600
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This inserts a cache in painter that keeps data for animating images in
Painter.
We then can send cheap ImageUpdate::UpdateAnimation to just get the
required bytes from the cache.
There are some warts with the current design:
- ImageUpdate::AddImage only adds images in the cache that have the data
in SerializableImageData::Raw. Potentially there could be image
animations in other ways which then for a following
ImageUpdate::UpdateAnimation we do not have the data. We can probably
fix this on the sender side.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: Tested on the usecase in
https://github.com/servo/servo/issues/41818 and WPT test here:
https://github.com/Narfinger/servo/actions/runs/21063721427
Fixes: https://github.com/servo/servo/issues/41818
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This change finishes the big rename associated with the old
`compositing` crates. Long ago, these crates managed a compositor, like
you might find in a traditional web engine. These days, compositing is
done in WebRender so the name has stopped making much sense. Various
structs inside the crates have already been renamed and this is the
final big change necessary for the rename
Testing: This is just a rename so existing tests should cover it.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Rather than having each callside specifying the relevant
information from the GlobalScope, do this via a trait instead.
This would have saved us quite a bit of test debugging
since we would often forget to set relevant information
from the global context for a request.
Now, in the future when we need additional information from
the globalscope for a request, we only need to update this
method to make that happen.
Previously it would also sometimes use `document`, but
calling the relevant information on either `document` or
`globalscope` doesn't matter, since the `globalscope`
defers to the value from the `document` anyways.
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
These keep-alive records live on the `CoreResourceManager` since the vec
of records must be modified by the fetch thread. The script thread
sometimes
requires this information as well, which is why it can send a message to
obtain the total size.
The keep-alive records must be tracked per global. That's why all code
needs
to specify the `pipeline_id`. Requests optionally have this field, which
is why
the code expects it to be present. The relevant information is added to
the
navigator request to ensure it can compute it.
Fixes#41230
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Changed most #[allow]s to #[expect]s, mainly for
clippy::too_many_arguments
Removed unfulfilled expectations
This is my first opensource contribution, so please let me know if
anything should
be done differently.
Testing: Refactor
Part of: #40838
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: TimurBora <timurborisov5561@gmail.com>
Co-authored-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
In the future, servo components should depend on the generic channels in
base instead of IpcChannels to correctly optimize for multiprocess vs
non-multiprocess mode.
This reexports IpcSharedMemory as GenericSharedMemory in GenericChannel
and changes all dependencies on it.
Currently this is only a type/name change and does not change
functionality. But in the future we would want want to use non-ipc
things for the data.
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Testing: This changes types and does not need testing.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
In preparation for adding preload support for all requests, we need to
add relevant client information to all these entrypoints. Additionally,
for links we now also set the referrer correctly and initialize
documents. All of which are required to start loading preload
information when processing requests.
Part of #35035
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This implements the required plumbing for the keep-alive flag on
requests. The flag already exists on the request object, but now also
exists on the builder itself.
The flag is then passed into a canceller. While we could make canceller
optional, in many cases it isn't and would require a whole lot more
changes. To follow the spec more closely, opted to put the keep_alive
flag on the canceller as well.
Note that this doesn't pass any extra fetch-later tests since we are not
correctly unloading iframe documents. That will be fixed in a follow-up
PR.
Part of #41230
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
For a long time, the "Compositor" hasn't done any compositing. This is
handled by WebRender. In addition the "Compositor" does many other
tasks. This change renames `IOCompositor` to `Paint`.
`Paint` is Servo's paint subsystem and contains multiple `Painter`s.
This change does not rename the crate; that will be done in a
followup change.
Testing: This just renames types and updates comments, so no new tests
are necessary.
---------
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Added new invocation struct `HTMLMediaElementEventHandler` that allows
to decouple ownership of the `HTMLMediaElement` from the IPC router
callback (break cyclic reference dependency) by replacing a `Trusted`
wrapper with more suitable `WeakRef`.
Note that `WeakRef` is not thread-safe and MUST be rooted and/or deleted
on the script thread.
Testing: Regressions in the following tests caused by overly aggressive
GC on document activity change to `Inactive` and will be follow up in
https://github.com/servo/servo/issues/41138
-
html/semantics/embedded-content/media-elements/autoplay-allowed-by-feature-policy.https.sub.html
-
html/semantics/embedded-content/media-elements/autoplay-default-feature-policy.https.sub.html
-
html/semantics/embedded-content/media-elements/autoplay-disabled-by-feature-policy.https.sub.html
Fixes: https://github.com/servo/servo/issues/40243
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
Changed some allow to expects and removed the unfulfilled expectations.
Testing: Refactor
Part of: #40383
Signed-off-by: anonmiraj <nabilmalek48@gmail.com>
It's important to check the media player's `paused` state to avoid
unnecessary changes to its internal state (via `play`, `pause`),
including configuration the `playback rate` and `volume` properties.
Depends on https://github.com/servo/media/pull/467
Testing: The expected test results are unchanged because it is the
implicit performance improvements of the media stack, with the exception
of the following test, which is affected by the `playback rate` state
caching mechanism (the `seek` position is not overridden for default
playback rate (1.0)).
- html/semantics/embedded-content/media-elements/preserves-pitch.html
See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4762
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
The low-level media `seek` request could be initiated by script (DOM
method call or setting of an IDL attribute), by the user agent (seeking
data) or by the media engine itself (e.g. gst_play_set_rate()).
And to distinguish between them we will use the latest seek position (in
seconds) to be able abort processing the `seek` algorithm steps (13-17)
for a `seek` request initiated by the media engine.
See https://html.spec.whatwg.org/multipage/#dom-media-seek
If the `seeking` is in progress, any callback which affects the current
playback position (`position changed`, `end of the playback`) shouldn't
be processed (event marshalling over IPC router is non-state
conditional).
Testing: Regression in the following test causes by gstreamer issue when
the `gst_play_set_rate()` overrides the latest seek requested position
unconditionally and the user agent receives the `seek completion` event
with the unexpected seek position (0.5+ instead of 0.0).
- html/semantics/embedded-content/media-elements/preserves-pitch.html
See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4762
Fixes: https://github.com/servo/servo/issues/37057
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
Currently the sequence order of the DOM method calls and the media
player API calls is mismatched because some media player operations (*)
posted to media task with delayed processing (while should be processed
immediately).
- DOM (script): pause -> seek -> play
- Media: seek -> pause* -> play*
Also the associated queued media events can be fired and processed by
script somehow (e.g. by calling `seek` in event listener handler) even
before the calling of the media player `play/pause` API.
To handle it the application will try to update media state (by calling
media player API) on each DOM `play, pause` method calls and on some
`ready state` changes with checking if the media element can be
potencially playing.
See https://html.spec.whatwg.org/multipage/#potentially-playing
Testing: No expected testing results changes because there are
unexpected `seek completion` signals from the media engine with invalid
time positions which are affecting passing test score (by masking false
positive results).
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4762
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
The new audio/video tracks should be added to the media element from the
initial `metadata` event from the media engine because there are
possibility of the multiple `metadata` events without any associated
`media track` state changes and previously the application added new
tracks into lists unconditionally.
The registered issue to handle possible dynamic `media track` state
changes from the media engine gracefully.
https://github.com/servo/media/issues/473
Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-video-element/video_size_preserved_after_ended.html
Fixes: https://github.com/servo/servo/issues/32623
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
The media engine signals with the `PlayerEvent::EnoughData` event that
the media source has enough data and the application should stop pushing
more data to avoid excessive buffer queueing and wait
`PlayerEvent::NeedData` event to continue.
Note that the source buffer size - MAX_SRC_QUEUE_SIZE (50MB).
This event is reflecting the state of the media source so the
application shouldn't change the media element ready state somehow.
Testing: No expected testing results changes
Fixes (partially): https://github.com/servo/servo/issues/40740
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
The MediaSession `setPositionState` method should only update the
position state and propagate it to the platform media session UI
controller and shouldn't change somehow the properties of the media
element directly (duration, playback rate or position).
See
https://w3c.github.io/mediasession/#dom-mediasession-setpositionstate
Testing: Improvements in the following tests
- /mediasession/positionstate.html
The media session UI functionality is implemented for Android and didn't
test due lack of testing sample.
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
Currently, only the first `Painter` is used for all operations in the
`Compositor`. This change modifies the compositor API and message
handling to allow routing the operations to the correct `Painter` via a
provided `PainterId` or `WebViewId`.
This change is to enable support for per-`WebView`s `RenderingContext`s.
Testing: This change shouldn't change behavior, so existing WPT tests
should cover it.
---------
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Following the HTML specification, on the `volume` or `mute` attrubute
changes the user agent must queue a media element task given the media
element to fire an event named `volumechange` at the media element (the
`generation_id` value will be captured to allow cancel this task -
`media-element-load-algorithm` steps 3-5)
See https://html.spec.whatwg.org/multipage/#event-media-volumechange
See https://html.spec.whatwg.org/multipage/#media-element-load-algorithm
Changed the naming of the `playbackRate` and `defaultPlaybackRate`
members to match Rust naming conventions (`snake_case`).
Testing: Added the `cancellable` subtest to `event_volumechange` test
- html/semantics/embedded-content/media-elements/event_volumechange.html
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
I used find and replace to finish the job. All this PR does is replace
all `Error::<error_name>` occurrences with `Error::<error_name>(None)`.
Testing: Refactor
Fixes: #39053
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Fix RefCell already borrowed panic in
HTMLMediaElement::set_audio_renderer
Testing: new crash test should pass.
Fixes: #40720
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
The user agent on the `internal play steps` (step 2) must to seek to the
earliest possible position if the playback has ended, but the definition
of the `ended playback` prevents looping when the loop attribute was
added after playback has ended (already registered whatwg html issue).
```
- playback ended (`ended` event)
- loop = true
- play() (no seeking - playback hasn't ended)
```
Currently this edge case if not yet reflected in the HTML specification
so let's do the same as other browsers and ignore the `loop` attribute
for `play` seek.
See https://html.spec.whatwg.org/multipage/#internal-play-steps
See https://github.com/whatwg/html/issues/4487
Testing: Improvements in the following tests
-
html/semantics/embedded-content/media-elements/playing-the-media-resource/loop-from-ended.tentative.html
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
A new event `PlayerEvent::DurationChanged` has been added to the media
engine to simplify handling changes in the duration of a media stream
(sometimes the duration could be inaccurate or even determined by the
media engine with significant delay after the initial metadata was
ready).
This new event eliminates the need to check conditions for two
consecutive `MetadataUpdated` events (the initial metadata and the
metadata with the changed duration) during the loading phase.
servo-media:
- Add new `PlayerEvent::DurationChanged` event
(https://github.com/servo/media/pull/461)
Testing: No expected changes in test results
Fixes: https://github.com/servo/servo/issues/40626
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
The two are semantically equivalent, but `find_map` is more concise.
Testing: Covered by existing tests
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Follow the HTML specification and split the previous `playback position`
to `current playback position` (a time on the media timeline) and
`official playbac position` (an approximation of the current playback
position that is kept stable while scripts are running) which must be
set to `the current playback position` any time the user agent provides
a stable state.
See https://html.spec.whatwg.org/multipage/#current-playback-position
See https://html.spec.whatwg.org/multipage/#official-playback-position
Note that at this point, there are no difference between the `current`
and `official` playback positions (as the time on the media timeline),
except the `seek` case.
Testing: Improvements in the following tests
-
html/semantics/embedded-content/media-elements/seeking/seek-to-max-value.htm
-
html/semantics/embedded-content/media-elements/seeking/seek-to-negative-time.htm
Fixes: https://github.com/servo/servo/issues/34496
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
Following the HTML specification, a new internal method,
`ended_playback`, has been added to differentiate it from the `ended`
attribute:
- `ended_playback`: playback has ended for the `forward/backward`
directions
- `ended` attribute: playback has ended for the `forward` direction
See https://html.spec.whatwg.org/multipage/#ended-playback
Added descriptions for the steps of the `Play`, `Pause`,
`internal_play_steps` (new), `internal_pause_steps`,
`notify_about_playing`, `change_ready_state` methods.
Testing: No expected changes in test results.
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>