mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
media: make method to retrieve the play range
Make a method to retrieve the playback range so that we can conditionally create a different range for the SDP and the PLAY requests.
This commit is contained in:
parent
915cd708ea
commit
4234d96314
4 changed files with 32 additions and 3 deletions
|
@ -708,7 +708,7 @@ handle_play_request (GstRTSPClient * client, GstRTSPUrl * uri,
|
|||
}
|
||||
|
||||
/* add the range */
|
||||
str = gst_rtsp_range_to_string (&media->media->range);
|
||||
str = gst_rtsp_media_get_range_string (media->media, TRUE);
|
||||
gst_rtsp_message_take_header (&response, GST_RTSP_HDR_RANGE, str);
|
||||
|
||||
send_response (client, session, &response);
|
||||
|
|
|
@ -353,7 +353,7 @@ collect_media_stats (GstRTSPMedia * media)
|
|||
GST_INFO ("stats: position %" GST_TIME_FORMAT ", duration %"
|
||||
GST_TIME_FORMAT, GST_TIME_ARGS (position), GST_TIME_ARGS (duration));
|
||||
|
||||
if (position == -1 || media->active > 0) {
|
||||
if (position == -1) {
|
||||
media->range.min.type = GST_RTSP_TIME_NOW;
|
||||
media->range.min.seconds = -1;
|
||||
} else {
|
||||
|
@ -560,6 +560,34 @@ gst_rtsp_media_get_stream (GstRTSPMedia * media, guint idx)
|
|||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_media_get_range_string:
|
||||
* @media: a #GstRTSPMedia
|
||||
* @play: for the PLAY request
|
||||
*
|
||||
* Get the current range as a string.
|
||||
*
|
||||
* Returns: The range as a string, g_free() after usage.
|
||||
*/
|
||||
gchar *
|
||||
gst_rtsp_media_get_range_string (GstRTSPMedia * media, gboolean play)
|
||||
{
|
||||
gchar *result;
|
||||
GstRTSPTimeRange range;
|
||||
|
||||
/* make copy */
|
||||
range = media->range;
|
||||
|
||||
if (!play && media->active > 0) {
|
||||
range.min.type = GST_RTSP_TIME_NOW;
|
||||
range.min.seconds = -1;
|
||||
}
|
||||
|
||||
result = gst_rtsp_range_to_string (&range);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_media_seek:
|
||||
* @media: a #GstRTSPMedia
|
||||
|
|
|
@ -283,6 +283,7 @@ guint gst_rtsp_media_n_streams (GstRTSPMedia *media);
|
|||
GstRTSPMediaStream * gst_rtsp_media_get_stream (GstRTSPMedia *media, guint idx);
|
||||
|
||||
gboolean gst_rtsp_media_seek (GstRTSPMedia *media, GstRTSPTimeRange *range);
|
||||
gchar * gst_rtsp_media_get_range_string (GstRTSPMedia *media, gboolean play);
|
||||
|
||||
GstFlowReturn gst_rtsp_media_stream_rtp (GstRTSPMediaStream *stream, GstBuffer *buffer);
|
||||
GstFlowReturn gst_rtsp_media_stream_rtcp (GstRTSPMediaStream *stream, GstBuffer *buffer);
|
||||
|
|
|
@ -43,7 +43,7 @@ gst_rtsp_sdp_from_media (GstSDPMessage * sdp, GstSDPInfo * info,
|
|||
|
||||
n_streams = gst_rtsp_media_n_streams (media);
|
||||
|
||||
rangestr = gst_rtsp_range_to_string (&media->range);
|
||||
rangestr = gst_rtsp_media_get_range_string (media, FALSE);
|
||||
gst_sdp_message_add_attribute (sdp, "range", rangestr);
|
||||
g_free (rangestr);
|
||||
|
||||
|
|
Loading…
Reference in a new issue