From 3f15c9b05a6e1bc0d1e29c800b54d42bf17f9b8b Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Thu, 20 Dec 2012 15:30:06 -0300 Subject: [PATCH] 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 --- ext/smoothstreaming/gstmssdemux.c | 4 +++- ext/smoothstreaming/gstmssmanifest.c | 31 +++++++++++++++++++++++++--- ext/smoothstreaming/gstmssmanifest.h | 1 + 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/ext/smoothstreaming/gstmssdemux.c b/ext/smoothstreaming/gstmssdemux.c index a9a1b72667..243a40e97c 100644 --- a/ext/smoothstreaming/gstmssdemux.c +++ b/ext/smoothstreaming/gstmssdemux.c @@ -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) { diff --git a/ext/smoothstreaming/gstmssmanifest.c b/ext/smoothstreaming/gstmssmanifest.c index d8923bc157..8f20ab8025 100644 --- a/ext/smoothstreaming/gstmssmanifest.c +++ b/ext/smoothstreaming/gstmssmanifest.c @@ -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 diff --git a/ext/smoothstreaming/gstmssmanifest.h b/ext/smoothstreaming/gstmssmanifest.h index c2bf37ecd3..7b5f1f7af0 100644 --- a/ext/smoothstreaming/gstmssmanifest.h +++ b/ext/smoothstreaming/gstmssmanifest.h @@ -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); -- 2.34.1