summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-06-15 22:40:35 +0200
committerWim Taymans <wim@metal.(none)>2009-06-15 22:42:45 +0200
commita2cef3e5c214e09b8cdcb2ae24e61c781690464f (patch)
tree7e0dd7921950e04deb235673b7401aa776e75a4c
parentcf58ba0fa527f9816b49ac6cefe7b6f86f79de7d (diff)
mp4gdepay: guess constantDuration better
Do a better job at guessing the constantDuration parameter when it is not present in the caps. Fixes #585205
-rw-r--r--gst/rtp/gstrtpmp4gdepay.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/gst/rtp/gstrtpmp4gdepay.c b/gst/rtp/gstrtpmp4gdepay.c
index 2d4a79f08..e12357aa4 100644
--- a/gst/rtp/gstrtpmp4gdepay.c
+++ b/gst/rtp/gstrtpmp4gdepay.c
@@ -245,14 +245,10 @@ gst_rtp_mp4g_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
if (strcmp (str, "audio") == 0) {
srccaps = gst_caps_new_simple ("audio/mpeg",
"mpegversion", G_TYPE_INT, 4, NULL);
- /* AAC always has a default constant duration of 1024 but it can be
- * overriden below. */
- rtpmp4gdepay->constantDuration = 1024;
} else if (strcmp (str, "video") == 0) {
srccaps = gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, 4,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
- rtpmp4gdepay->constantDuration = 0;
}
}
if (srccaps == NULL)
@@ -279,8 +275,7 @@ gst_rtp_mp4g_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
rtpmp4gdepay->constantSize =
gst_rtp_mp4g_depay_parse_int (structure, "constantsize", 0);
rtpmp4gdepay->constantDuration =
- gst_rtp_mp4g_depay_parse_int (structure, "constantduration",
- rtpmp4gdepay->constantDuration);
+ gst_rtp_mp4g_depay_parse_int (structure, "constantduration", 0);
/* get config string */
@@ -511,6 +506,7 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
* reconstruct the AU ordering when interleaving. */
if (i == 0) {
AU_index = gst_bs_parse_read (&bs, rtpmp4gdepay->indexlength);
+
if (AU_index == 0 && rtpmp4gdepay->prev_AU_index == 0) {
gint diff;
@@ -524,6 +520,13 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
else
diff = -(rtpmp4gdepay->prev_rtptime - rtptime);
+ /* if no constantDuration was given, make one */
+ if (rtpmp4gdepay->constantDuration == 0) {
+ rtpmp4gdepay->constantDuration = diff / num_AU_headers;
+ GST_DEBUG_OBJECT (depayload, "guessing constantDuration %d",
+ rtpmp4gdepay->constantDuration);
+ }
+
/* get the number of packets by dividing with the duration */
diff /= rtpmp4gdepay->constantDuration;