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

ARRISEOS-45973: Initial support for instant rate #404

Open
wants to merge 2 commits into
base: sprint_196_2.38
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Source/WebCore/html/HTMLMediaElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4164,7 +4164,7 @@ void HTMLMediaElement::scanTimerFired()

// The spec says to fire periodic timeupdate events (those sent while playing) every
// "15 to 250ms", we choose the slowest frequency
static const Seconds maxTimeupdateEventFrequency { 250_ms };
static const Seconds maxTimeupdateEventFrequency { 200_ms };

void HTMLMediaElement::startPlaybackProgressTimer()
{
Expand Down Expand Up @@ -4211,8 +4211,8 @@ void HTMLMediaElement::scheduleTimeupdateEvent(bool periodicEvent)
MonotonicTime now = MonotonicTime::now();
Seconds timedelta = now - m_clockTimeAtLastUpdateEvent;

// throttle the periodic events
if (periodicEvent && timedelta < maxTimeupdateEventFrequency)
// Throttle the periodic events, but leave some room for timers that run slightly faster than expected.
if (periodicEvent && timedelta < (maxTimeupdateEventFrequency - 50_ms))
return;

// Some media engines make multiple "time changed" callbacks at the same time, but we only want one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,20 @@ void MediaPlayerPrivateGStreamer::updatePlaybackRate()
GST_INFO_OBJECT(pipeline(), mute ? "Need to mute audio" : "Do not need to mute audio");

if (m_lastPlaybackRate != m_playbackRate) {
#if ENABLE(INSTANT_RATE_CHANGE)
bool didInstantRateChange = false;
if (!paused()) {
GstStructure* s = gst_structure_new("custom-instant-rate-change",
"rate", G_TYPE_DOUBLE, m_playbackRate, nullptr);
didInstantRateChange = gst_element_send_event(
pipeline(), gst_event_new_custom(GST_EVENT_CUSTOM_DOWNSTREAM_OOB, s));
}
if (didInstantRateChange) {
g_object_set(m_pipeline.get(), "mute", mute, nullptr);
m_lastPlaybackRate = m_playbackRate;
}
else
#endif
if (doSeek(playbackPosition(), m_playbackRate, static_cast<GstSeekFlags>(GST_SEEK_FLAG_FLUSH))) {
g_object_set(m_pipeline.get(), "mute", mute, nullptr);
m_lastPlaybackRate = m_playbackRate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,8 @@ static void webKitMediaSrcStreamFlush(Stream* stream, bool isSeekingFlush, GstCl
GST_DEBUG_OBJECT(stream->source, "Resetting segment to current pipeline running time (%" GST_TIME_FORMAT " and stream time (%" GST_TIME_FORMAT " = %s)",
GST_TIME_ARGS(pipelineRunningTime), GST_TIME_ARGS(pipelineStreamTime), streamTime.toString().ascii().data());
streamingMembers->segment.base = pipelineRunningTime;
streamingMembers->segment.start = streamingMembers->segment.time = static_cast<GstClockTime>(pipelineStreamTime);
streamingMembers->segment.rate = stream->source->priv->rate;
streamingMembers->segment.position = streamingMembers->segment.start = streamingMembers->segment.time = static_cast<GstClockTime>(pipelineStreamTime);
}
}
}
Expand Down Expand Up @@ -952,6 +953,19 @@ static gboolean webKitMediaSrcSendEvent(GstElement* element, GstEvent* event)
webKitMediaSrcSeek(WEBKIT_MEDIA_SRC(element), start, rate);
return true;
}
case GST_EVENT_CUSTOM_DOWNSTREAM_OOB: {
WebKitMediaSrc* source = WEBKIT_MEDIA_SRC(element);
gboolean result = !source->priv->streams.isEmpty();
for (const RefPtr<Stream>& stream : source->priv->streams.values())
result &= gst_pad_push_event(stream->pad.get(), gst_event_ref(event));
if (gst_event_has_name(event, "custom-instant-rate-change")) {
gdouble rate = 1.0;
if (gst_structure_get_double(gst_event_get_structure(event), "rate", &rate))
source->priv->rate = rate;
}
gst_event_unref(event);
return result;
}
default:
return GST_ELEMENT_CLASS(webkit_media_src_parent_class)->send_event(element, event);
}
Expand Down
1 change: 1 addition & 0 deletions Source/cmake/OptionsWPE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ WEBKIT_OPTION_DEFINE(USE_GSTREAMER_HOLEPUNCH "Whether to enable GStreamer holepu
WEBKIT_OPTION_DEFINE(USE_EXTERNAL_HOLEPUNCH "Whether to enable external holepunch" PRIVATE OFF)
WEBKIT_OPTION_DEFINE(ENABLE_ACCELERATED_2D_CANVAS "Whether to enable accelerated 2D canvas" PRIVATE OFF)
WEBKIT_OPTION_DEFINE(ENABLE_OIPF_VK "Whether to enable OIPF keys for DAE applications" PRIVATE OFF)
WEBKIT_OPTION_DEFINE(ENABLE_INSTANT_RATE_CHANGE "Whether to enable instant rate change" PRIVATE OFF)

# Supported platforms.
WEBKIT_OPTION_DEFINE(USE_WPEWEBKIT_PLATFORM_WESTEROS "Whether to enable support for the Westeros platform" PUBLIC OFF)
Expand Down