Compare commits

...

4 commits

Author SHA1 Message Date
elliot chen f59e5571e3 Merge branch 'gstplay-fix-seek-failure-for-rstp-stream' into 'main'
gstplay: fix seek failure for rtsp stream

See merge request gstreamer/gstreamer!6730
2024-04-27 21:27:50 +00:00
Nirbheek Chauhan d7eeb62f38 meson: Fix Python library searching on Windows
Neither LIBDIR nor LIBPL are set with the native windows Python
(unlike MSYS2), so we need to use `prefix` which takes us to the
rootdir of the Python installation.

The name is also different: it's python312.dll, not python3.12.dll.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6734>
2024-04-27 01:30:21 +00:00
Nirbheek Chauhan 753aeccde7 meson: Fix Python library name fetching on Windows
`python.get_variable('FOO', [])` becomes `python.get_variable('FOO')`
due to how Meson treats empty arrays in arguments, which breaks the
fallback feature of get_variable().

So we need to actually check whether the variable exists before trying
to fetch it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6734>
2024-04-27 01:30:21 +00:00
Elliot Chen 853a3bef7b gstplay: seek in playing state for live stream 2024-04-25 17:13:42 +09:00
2 changed files with 70 additions and 26 deletions

View file

@ -1453,11 +1453,11 @@ state_changed_cb (G_GNUC_UNUSED GstBus * bus, GstMessage * msg,
}
}
/* Try to query seek information again for live stream */
if (self->is_live) {
gboolean seekable = FALSE;
gboolean updated = FALSE;
/* Try to query seek information again for live stream */
GstQuery *query = gst_query_new_seeking (GST_FORMAT_TIME);
if (gst_element_query (self->playbin, query))
gst_query_parse_seeking (query, NULL, &seekable, NULL, NULL);
@ -1473,6 +1473,30 @@ state_changed_cb (G_GNUC_UNUSED GstBus * bus, GstMessage * msg,
if (updated) {
on_media_info_updated (self);
}
/* Handle seek operation for live stream */
g_mutex_lock (&self->lock);
if (self->seek_pending) {
self->seek_pending = FALSE;
if (!self->media_info->seekable) {
GST_DEBUG_OBJECT (self, "Media is not seekable");
remove_seek_source (self);
self->seek_position = GST_CLOCK_TIME_NONE;
self->last_seek_time = GST_CLOCK_TIME_NONE;
} else if (self->seek_source) {
GST_DEBUG_OBJECT (self, "Seek finished but new seek is pending");
gst_play_seek_internal_locked (self);
} else {
GST_DEBUG_OBJECT (self, "Seek finished");
on_seek_done (self);
}
}
if (self->seek_position != GST_CLOCK_TIME_NONE) {
GST_DEBUG_OBJECT (self, "Seeking now that we reached PALYING state");
gst_play_seek_internal_locked (self);
}
g_mutex_unlock (&self->lock);
}
/* api_bus_post_message (self, GST_PLAY_MESSAGE_POSITION_UPDATED, */
/* GST_PLAY_MESSAGE_DATA_POSITION, GST_TYPE_CLOCK_TIME, 0, NULL); */
@ -3048,20 +3072,27 @@ gst_play_seek_internal_locked (GstPlay * self)
remove_seek_source (self);
/* Only seek in PAUSED */
if (self->current_state < GST_STATE_PAUSED) {
return;
} else if (self->current_state != GST_STATE_PAUSED) {
g_mutex_unlock (&self->lock);
state_ret = gst_element_set_state (self->playbin, GST_STATE_PAUSED);
if (state_ret == GST_STATE_CHANGE_FAILURE) {
on_error (self, g_error_new (GST_PLAY_ERROR, GST_PLAY_ERROR_FAILED,
"Failed to seek"), NULL);
if (!self->is_live) {
/* Only seek in PAUSED for non live stream */
if (self->current_state < GST_STATE_PAUSED) {
return;
} else if (self->current_state != GST_STATE_PAUSED) {
g_mutex_unlock (&self->lock);
state_ret = gst_element_set_state (self->playbin, GST_STATE_PAUSED);
if (state_ret == GST_STATE_CHANGE_FAILURE) {
on_error (self, g_error_new (GST_PLAY_ERROR, GST_PLAY_ERROR_FAILED,
"Failed to seek"), NULL);
g_mutex_lock (&self->lock);
return;
}
g_mutex_lock (&self->lock);
return;
}
g_mutex_lock (&self->lock);
return;
} else {
/* Only seek in PAYING for live stream */
if (self->current_state < GST_STATE_PLAYING) {
return;
}
}
self->last_seek_time = gst_util_get_timestamp ();

View file

@ -45,35 +45,53 @@ pylib_loc = get_option('libpython-dir')
fsmod = import('fs')
pylib_prefix = 'lib'
pylib_suffix = 'so'
pylib_ver = python_dep.version()
pylib_locs = []
if host_system == 'windows'
if cc.get_argument_syntax() == 'msvc'
pylib_prefix = ''
endif
pylib_suffix = 'dll'
pylib_ver = pylib_ver.replace('.', '')
elif host_system == 'darwin'
pylib_suffix = 'dylib'
endif
pylib_fnames = []
# Library name with soversion, non-devel package
pylib_fnames += python.get_variable('INSTSONAME', [])
if python.has_variable('INSTSONAME')
# For example, libpython3.12.so.1.0 (Linux), libpython3.11.dll.a (MSYS2), etc.
pylib_fnames += python.get_variable('INSTSONAME')
endif
# Library name without soversion, devel package, framework, etc.
pylib_fnames += python.get_variable('LDLIBRARY', [])
if python.has_variable('LDLIBRARY')
# For example, libpython3.12.so (Linux), libpython3.11.dll.a (MSYS2), etc.
pylib_fnames += python.get_variable('LDLIBRARY')
endif
# Manually construct name as a fallback
pylib_fnames += [
pylib_prefix + 'python' + python_dep.version() + python_abi_flags + '.' + pylib_suffix
pylib_prefix + 'python' + pylib_ver + python_abi_flags + '.' + pylib_suffix
]
if pylib_loc != ''
pylib_locs = [pylib_loc]
else
pylib_locs = [
python.get_variable('LIBDIR', ''),
python.get_variable('LIBPL', ''),
]
if python.has_variable('LIBDIR')
pylib_locs += python.get_variable('LIBDIR')
endif
if python.has_variable('LIBPL')
pylib_locs += python.get_variable('LIBPL')
endif
# On Windows, python312.dll is in the rootdir where Python is installed,
# which is configured as the "prefix" in sysconfig.
if host_system == 'windows'
pylib_locs += python.get_variable('prefix')
endif
endif
pylib_fname = ''
foreach loc: pylib_locs
foreach fname: pylib_fnames
if fsmod.exists(loc / fname)
fpath = loc / fname
debug(f'Looking for Python library at: @fpath@')
if fsmod.exists(fpath)
pylib_fname = fname
message(f'PY_LIB_FNAME = @fname@ (@loc@)')
break
@ -81,12 +99,7 @@ foreach loc: pylib_locs
endforeach
endforeach
if pylib_fname == ''
error_msg = 'Could not find python library to load'
if python_opt.enabled()
error(error_msg)
else
message(error_msg)
endif
message('Could not find python library to load, will try loading at runtime')
endif
pygi_override_dir = get_option('pygi-overrides-dir')