mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
media: convert_range replaces get_range_times
get_range_times worked for handling UTC ranges for seeks, but we also need to convert back from NPT to the requested unit in get_range_string. convert_range is now used for both. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=702084
This commit is contained in:
parent
3dbe0e17d4
commit
6151072a2e
3 changed files with 26 additions and 14 deletions
|
@ -882,8 +882,8 @@ handle_play_request (GstRTSPClient * client, GstRTSPClientState * state)
|
||||||
if (res == GST_RTSP_OK) {
|
if (res == GST_RTSP_OK) {
|
||||||
if (gst_rtsp_range_parse (str, &range) == GST_RTSP_OK) {
|
if (gst_rtsp_range_parse (str, &range) == GST_RTSP_OK) {
|
||||||
/* we have a range, seek to the position */
|
/* we have a range, seek to the position */
|
||||||
gst_rtsp_media_seek (gst_rtsp_session_media_get_media (media), range);
|
|
||||||
unit = range->unit;
|
unit = range->unit;
|
||||||
|
gst_rtsp_media_seek (gst_rtsp_session_media_get_media (media), range);
|
||||||
gst_rtsp_range_free (range);
|
gst_rtsp_range_free (range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,8 +123,9 @@ static gboolean default_handle_message (GstRTSPMedia * media,
|
||||||
GstMessage * message);
|
GstMessage * message);
|
||||||
static void finish_unprepare (GstRTSPMedia * media);
|
static void finish_unprepare (GstRTSPMedia * media);
|
||||||
static gboolean default_unprepare (GstRTSPMedia * media);
|
static gboolean default_unprepare (GstRTSPMedia * media);
|
||||||
static gboolean default_get_range_times (GstRTSPMedia * media,
|
static gboolean
|
||||||
const GstRTSPTimeRange * range, GstClockTime * min, GstClockTime * max);
|
default_convert_range (GstRTSPMedia * media, GstRTSPTimeRange * range,
|
||||||
|
GstRTSPRangeUnit unit);
|
||||||
|
|
||||||
static guint gst_rtsp_media_signals[SIGNAL_LAST] = { 0 };
|
static guint gst_rtsp_media_signals[SIGNAL_LAST] = { 0 };
|
||||||
|
|
||||||
|
@ -213,7 +214,7 @@ gst_rtsp_media_class_init (GstRTSPMediaClass * klass)
|
||||||
|
|
||||||
klass->handle_message = default_handle_message;
|
klass->handle_message = default_handle_message;
|
||||||
klass->unprepare = default_unprepare;
|
klass->unprepare = default_unprepare;
|
||||||
klass->get_range_times = default_get_range_times;
|
klass->convert_range = default_convert_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1076,11 +1077,14 @@ gchar *
|
||||||
gst_rtsp_media_get_range_string (GstRTSPMedia * media, gboolean play,
|
gst_rtsp_media_get_range_string (GstRTSPMedia * media, gboolean play,
|
||||||
GstRTSPRangeUnit unit)
|
GstRTSPRangeUnit unit)
|
||||||
{
|
{
|
||||||
|
GstRTSPMediaClass *klass;
|
||||||
GstRTSPMediaPrivate *priv;
|
GstRTSPMediaPrivate *priv;
|
||||||
gchar *result;
|
gchar *result;
|
||||||
GstRTSPTimeRange range;
|
GstRTSPTimeRange range;
|
||||||
|
|
||||||
|
klass = GST_RTSP_MEDIA_GET_CLASS (media);
|
||||||
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), NULL);
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), NULL);
|
||||||
|
g_return_val_if_fail (klass->convert_range != NULL, FALSE);
|
||||||
|
|
||||||
priv = media->priv;
|
priv = media->priv;
|
||||||
|
|
||||||
|
@ -1099,7 +1103,9 @@ gst_rtsp_media_get_range_string (GstRTSPMedia * media, gboolean play,
|
||||||
g_mutex_unlock (&priv->lock);
|
g_mutex_unlock (&priv->lock);
|
||||||
g_rec_mutex_unlock (&priv->state_lock);
|
g_rec_mutex_unlock (&priv->state_lock);
|
||||||
|
|
||||||
gst_rtsp_range_convert_units (&range, unit);
|
if (!klass->convert_range (media, &range, unit)) {
|
||||||
|
goto conversion_failed;
|
||||||
|
}
|
||||||
|
|
||||||
result = gst_rtsp_range_to_string (&range);
|
result = gst_rtsp_range_to_string (&range);
|
||||||
|
|
||||||
|
@ -1112,6 +1118,12 @@ not_prepared:
|
||||||
g_rec_mutex_unlock (&priv->state_lock);
|
g_rec_mutex_unlock (&priv->state_lock);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
conversion_failed:
|
||||||
|
{
|
||||||
|
GST_WARNING ("range conversion to unit %d failed", unit);
|
||||||
|
g_rec_mutex_unlock (&priv->state_lock);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1138,7 +1150,7 @@ gst_rtsp_media_seek (GstRTSPMedia * media, GstRTSPTimeRange * range)
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), FALSE);
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), FALSE);
|
||||||
g_return_val_if_fail (range != NULL, FALSE);
|
g_return_val_if_fail (range != NULL, FALSE);
|
||||||
g_return_val_if_fail (klass->get_range_times != NULL, FALSE);
|
g_return_val_if_fail (klass->convert_range != NULL, FALSE);
|
||||||
|
|
||||||
priv = media->priv;
|
priv = media->priv;
|
||||||
|
|
||||||
|
@ -1155,8 +1167,9 @@ gst_rtsp_media_seek (GstRTSPMedia * media, GstRTSPTimeRange * range)
|
||||||
|
|
||||||
start_type = stop_type = GST_SEEK_TYPE_NONE;
|
start_type = stop_type = GST_SEEK_TYPE_NONE;
|
||||||
|
|
||||||
if (!klass->get_range_times (media, range, &start, &stop))
|
if (!klass->convert_range (media, range, GST_RTSP_RANGE_NPT))
|
||||||
goto not_supported;
|
goto not_supported;
|
||||||
|
gst_rtsp_range_get_times (range, &start, &stop);
|
||||||
|
|
||||||
GST_INFO ("got %" GST_TIME_FORMAT " - %" GST_TIME_FORMAT,
|
GST_INFO ("got %" GST_TIME_FORMAT " - %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
|
GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
|
||||||
|
@ -1210,7 +1223,7 @@ not_seekable:
|
||||||
not_supported:
|
not_supported:
|
||||||
{
|
{
|
||||||
g_rec_mutex_unlock (&priv->state_lock);
|
g_rec_mutex_unlock (&priv->state_lock);
|
||||||
GST_WARNING ("seek unit %d not supported", range->unit);
|
GST_WARNING ("conversion to npt not supported");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2053,8 +2066,8 @@ not_prepared:
|
||||||
|
|
||||||
/* called with state-lock */
|
/* called with state-lock */
|
||||||
static gboolean
|
static gboolean
|
||||||
default_get_range_times (GstRTSPMedia * media,
|
default_convert_range (GstRTSPMedia * media, GstRTSPTimeRange * range,
|
||||||
const GstRTSPTimeRange * range, GstClockTime * min, GstClockTime * max)
|
GstRTSPRangeUnit unit)
|
||||||
{
|
{
|
||||||
return gst_rtsp_range_get_times (range, min, max);
|
return gst_rtsp_range_convert_units (range, unit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,9 +100,8 @@ struct _GstRTSPMediaClass {
|
||||||
/* vmethods */
|
/* vmethods */
|
||||||
gboolean (*handle_message) (GstRTSPMedia *media, GstMessage *message);
|
gboolean (*handle_message) (GstRTSPMedia *media, GstMessage *message);
|
||||||
gboolean (*unprepare) (GstRTSPMedia *media);
|
gboolean (*unprepare) (GstRTSPMedia *media);
|
||||||
gboolean (*get_range_times) (GstRTSPMedia *media,
|
gboolean (*convert_range) (GstRTSPMedia *media, GstRTSPTimeRange *range,
|
||||||
const GstRTSPTimeRange * range,
|
GstRTSPRangeUnit unit);
|
||||||
GstClockTime * min, GstClockTime * max);
|
|
||||||
|
|
||||||
/* signals */
|
/* signals */
|
||||||
void (*new_stream) (GstRTSPMedia *media, GstRTSPStream * stream);
|
void (*new_stream) (GstRTSPMedia *media, GstRTSPStream * stream);
|
||||||
|
|
Loading…
Reference in a new issue