mssdemux: add timescale to the caps

This is important for downstream to properly timestamp the samples

The default value is 10000000, but this can be set in the stream
or at the top-level manifest entry
This commit is contained in:
Thiago Santos 2012-12-20 15:30:06 -03:00
parent 68d2719c9f
commit 3f15c9b05a
3 changed files with 32 additions and 4 deletions

View file

@ -349,7 +349,9 @@ gst_mss_demux_expose_stream (GstMssDemux * mssdemux, GstMssDemuxStream * stream)
media_caps = gst_mss_stream_get_caps (stream->manifest_stream);
caps = gst_caps_new_simple ("video/quicktime", "variant", G_TYPE_STRING,
"mss-fragmented", "media-caps", GST_TYPE_CAPS, media_caps, NULL);
"mss-fragmented", "timescale", G_TYPE_UINT64,
gst_mss_stream_get_timescale (stream->manifest_stream), "media-caps",
GST_TYPE_CAPS, media_caps, NULL);
gst_caps_unref (media_caps);
if (caps) {

View file

@ -30,6 +30,8 @@
#include "gstmssmanifest.h"
#define DEFAULT_TIMESCALE 10000000
#define MSS_NODE_STREAM_FRAGMENT "c"
#define MSS_NODE_STREAM_QUALITY "QualityLevel"
@ -37,6 +39,7 @@
#define MSS_PROP_DURATION "d"
#define MSS_PROP_NUMBER "n"
#define MSS_PROP_TIME "t"
#define MSS_PROP_TIMESCALE "TimeScale"
#define MSS_PROP_URL "Url"
/* TODO check if atoi is successful? */
@ -439,18 +442,40 @@ end:
return caps;
}
guint64
gst_mss_stream_get_timescale (GstMssStream * stream)
{
gchar *timescale;
guint64 ts = DEFAULT_TIMESCALE;
timescale =
(gchar *) xmlGetProp (stream->xmlnode, (xmlChar *) MSS_PROP_TIMESCALE);
if (!timescale) {
timescale =
(gchar *) xmlGetProp (stream->xmlnode->parent,
(xmlChar *) MSS_PROP_TIMESCALE);
}
if (timescale) {
ts = strtoull (timescale, NULL, 10);
g_free (timescale);
}
return ts;
}
GstCaps *
gst_mss_stream_get_caps (GstMssStream * stream)
{
GstMssStreamType streamtype = gst_mss_stream_get_type (stream);
xmlNodePtr qualitylevel = stream->current_quality->data;
GstCaps *caps = NULL;
if (streamtype == MSS_STREAM_TYPE_VIDEO)
return _gst_mss_stream_video_caps_from_qualitylevel_xml (qualitylevel);
caps = _gst_mss_stream_video_caps_from_qualitylevel_xml (qualitylevel);
else if (streamtype == MSS_STREAM_TYPE_AUDIO)
return _gst_mss_stream_audio_caps_from_qualitylevel_xml (qualitylevel);
caps = _gst_mss_stream_audio_caps_from_qualitylevel_xml (qualitylevel);
return NULL;
return caps;
}
GstFlowReturn

View file

@ -44,6 +44,7 @@ GSList * gst_mss_manifest_get_streams (GstMssManifest * manifest);
GstMssStreamType gst_mss_stream_get_type (GstMssStream *stream);
GstCaps * gst_mss_stream_get_caps (GstMssStream * stream);
guint64 gst_mss_stream_get_timescale (GstMssStream * stream);
GstFlowReturn gst_mss_stream_get_fragment_url (GstMssStream * stream, gchar ** url);
GstFlowReturn gst_mss_stream_advance_fragment (GstMssStream * stream);