After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 754864 - qtdemux: check multi trex to find track id in mp4 (DASH) stream.
qtdemux: check multi trex to find track id in mp4 (DASH) stream.
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
1.4.5
Other Linux
: Normal enhancement
: 1.7.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-09-11 05:43 UTC by manasa.athreya
Modified: 2015-10-02 14:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
This is the mpd file. (151 bytes, text/plain)
2015-09-11 05:43 UTC, manasa.athreya
  Details
This is the diff patch. (5.78 KB, patch)
2015-09-11 06:07 UTC, manasa.athreya
needs-work Details | Review
Patch with necessary changes. (1.36 KB, patch)
2015-09-14 04:51 UTC, manasa.athreya
none Details | Review
This patch is according to changes. (1.67 KB, patch)
2015-09-22 11:53 UTC, manasa.athreya
none Details | Review
Patch with changes (1.92 KB, patch)
2015-09-23 03:50 UTC, manasa.athreya
committed Details | Review
This is the mpd file (4.40 KB, text/plain)
2015-09-23 10:10 UTC, manasa.athreya
  Details

Description manasa.athreya 2015-09-11 05:43:57 UTC
Created attachment 311109 [details]
This is the mpd file.

Overview: In case the stream has more than one trex box which is not matched to actual track id, it makes qtdemux crashed. 

This patch improves to check multi trex to find track id in mp4 mpeg-dash stream.

Steps to Reproduce:

1) Play the attached mpd file.

Actual Results:
Playback crashes.

Expected Results:
Expectation is to play without any crash.

Build Date & Hardware:
Build 2014-12-18 on Ubuntu 12.04
Comment 1 manasa.athreya 2015-09-11 06:07:19 UTC
Created attachment 311110 [details] [review]
This is the diff patch.
Comment 2 Sebastian Dröge (slomo) 2015-09-11 08:12:44 UTC
Review of attachment 311110 [details] [review]:

Thanks for the patch!

::: gst/isomp4/qtdemux.c
@@ +80,2 @@
 #ifdef HAVE_ZLIB
+#include <zlib.h>

Please don't include irrelevant changes in the same patch

@@ +613,3 @@
   qtdemux->flowcombiner = gst_flow_combiner_new ();
+  memset (qtdemux->track_fragment_id, 0,
+  sizeof (guint32) * GST_QTDEMUX_MAX_STREAMS);

memset (qtdemux->track_fragment_id, 0, sizeof (qtdemux->track_fragment_id));

That way this code doesn't have to be changed if the array is ever changed

@@ +4350,3 @@
 
+  if (G_UNLIKELY (QTSEGMENT_IS_EMPTY (&stream->
+              segments[stream->segment_index]))) {

No indentation changes in the same patch please :)

@@ +5102,3 @@
   /* If we're doing a keyframe-only trickmode, only push keyframes on video streams */
+  if (G_UNLIKELY (qtdemux->segment.
+          flags & GST_SEGMENT_FLAG_TRICKMODE_KEY_UNITS)) {

No indentation changes of unrelated code in the same patch please :)

@@ +8455,3 @@
       goto skip_track;
     }
+  if (qtdemux_check_track_fragment (qtdemux, track_id)) {

qtdemux_check_track_is_in_trex() or similar seems more descriptive here

If I'm not mistaken you can also just use qtdemux_parse_trex() here instead, which is called many lines below in this function... instead of adding and calling the new get_track_fragment_id()

@@ +8460,3 @@
+  } else {
+    GST_WARNING_OBJECT (qtdemux, "skip track id %u, it's not fragmented",track_id);
+    return TRUE;

There's a "skip_track" goto label for this here

@@ +11645,3 @@
   }
+  memset (qtdemux->track_fragment_id, 0,sizeof (guint32) * GST_QTDEMUX_MAX_STREAMS);
+  qtdemux_get_track_fragment_id (qtdemux, mvex);

You don't necessarily have mvex here, see the "if (mvex)" a few lines above. It should probably be moved in that if block
Comment 3 Sebastian Dröge (slomo) 2015-09-11 08:14:06 UTC
So I guess qtdemux_parse_trex() should be called earlier, before the code where it currently would crash.
Comment 4 manasa.athreya 2015-09-11 09:03:56 UTC
In reply to Sebastian Dröge (slomo) from comment #2)
> Review of attachment 311110 [details] [review] [review]:
> 
> Thanks for the patch!
> 
> ::: gst/isomp4/qtdemux.c
> @@ +80,2 @@
>  #ifdef HAVE_ZLIB
> +#include <zlib.h>
> 
> Please don't include irrelevant changes in the same patch

On gst-indent command some changes have occurred by mistake. Will correct the same. 
> 
> @@ +613,3 @@
>    qtdemux->flowcombiner = gst_flow_combiner_new ();
> +  memset (qtdemux->track_fragment_id, 0,
> +  sizeof (guint32) * GST_QTDEMUX_MAX_STREAMS);
> 
> memset (qtdemux->track_fragment_id, 0, sizeof (qtdemux->track_fragment_id));
> 
> That way this code doesn't have to be changed if the array is ever changed

Will incorporate the mentioned change.
> 
> @@ +4350,3 @@
>  
> +  if (G_UNLIKELY (QTSEGMENT_IS_EMPTY (&stream->
> +              segments[stream->segment_index]))) {
> 
> No indentation changes in the same patch please :)

On gst-indent command some changes have occurred by mistake.:(
 
> @@ +5102,3 @@
>    /* If we're doing a keyframe-only trickmode, only push keyframes on video
> streams */
> +  if (G_UNLIKELY (qtdemux->segment.
> +          flags & GST_SEGMENT_FLAG_TRICKMODE_KEY_UNITS)) {
> 
> No indentation changes of unrelated code in the same patch please :)
> 
On gst-indent command some changes have occurred by mistake.
> @@ +8455,3 @@
>        goto skip_track;
>      }
> +  if (qtdemux_check_track_fragment (qtdemux, track_id)) {
> 
> qtdemux_check_track_is_in_trex() or similar seems more descriptive here
> 
> If I'm not mistaken you can also just use qtdemux_parse_trex() here instead,
> which is called many lines below in this function... instead of adding and
> calling the new get_track_fragment_id()
>
Will check the suggestion.

> @@ +8460,3 @@
> +  } else {
> +    GST_WARNING_OBJECT (qtdemux, "skip track id %u, it's not
> fragmented",track_id);
> +    return TRUE;
> 
> There's a "skip_track" goto label for this here

Yes, will incorporate.  
> @@ +11645,3 @@
>    }
> +  memset (qtdemux->track_fragment_id, 0,sizeof (guint32) *
> GST_QTDEMUX_MAX_STREAMS);
> +  qtdemux_get_track_fragment_id (qtdemux, mvex);
> 
> You don't necessarily have mvex here, see the "if (mvex)" a few lines above.
> It should probably be moved in that if block

I think this might not be possible, as we require for complete box parsing from mvex  this function needs the mvex node qtdemux_tree_get_child_by_type_full.
Comment 5 Tim-Philipp Müller 2015-09-11 09:25:04 UTC
GNU indent might behave slightly different with different versions. If you're working on 12.04, you could try installing a newer GNU indent ('indent' package) from a more recent ubuntu/debian version. I think it just depends on libc.
Comment 6 manasa.athreya 2015-09-11 09:35:06 UTC
Thanks Tim :)
Comment 7 manasa.athreya 2015-09-14 04:51:07 UTC
Created attachment 311253 [details] [review]
Patch with necessary changes.
Comment 8 manasa.athreya 2015-09-14 04:52:30 UTC
I have tried to reduce the code as u said by using qtdemux_parse_trex function instead of instead of adding and calling the new get_track_fragment_id().
Comment 9 manasa.athreya 2015-09-22 11:53:15 UTC
Created attachment 311850 [details] [review]
This patch is according to changes.
Comment 10 Sebastian Dröge (slomo) 2015-09-22 13:02:20 UTC
Review of attachment 311850 [details] [review]:

::: gst/isomp4/qtdemux.c
@@ +8450,3 @@
     }
+    /* need defaults for fragments */
+    qtdemux_parse_trex (qtdemux, stream, &dummy, &dummy, &dummy);

Should this maybe be one line below? After the flushing?

@@ -10041,3 @@
           GSTTIME_TO_QTSTREAMTIME (stream, qtdemux->segment.duration);
-    /* need defaults for fragments */
-    qtdemux_parse_trex (qtdemux, stream, &dummy, &dummy, &dummy);

You should remove the dummy declaration from this block. It's unused now.
Comment 11 manasa.athreya 2015-09-23 03:50:48 UTC
Created attachment 311919 [details] [review]
Patch with changes
Comment 12 Sebastian Dröge (slomo) 2015-09-23 08:27:44 UTC
Comment on attachment 311919 [details] [review]
Patch with changes

Looks good now, thanks!
Comment 13 Sebastian Dröge (slomo) 2015-09-23 08:32:44 UTC
The test stream doesn't work anymore it seems, can you provide a new one? And did you actually test the latest patch to see if it really works? It seems that all your patches explicitly added the trex parsing *before* the flushing...
Comment 14 manasa.athreya 2015-09-23 08:59:41 UTC
1. Multiple trex supporting test stream that I have is the above enclosed one.
2. Initially I had added trex parsing *before* flushing as we were checking track was fragmented based on track id.
3.Now we are using existing parse_trex function, after your comments I checked the other way of adding parse_trex *after* flushing, The scenario worked fine for me.
Comment 15 Sebastian Dröge (slomo) 2015-09-23 09:59:53 UTC
Thanks, makes sense :) Can you make a test stream available again nonetheless?
Comment 17 Sebastian Dröge (slomo) 2015-09-23 10:20:49 UTC
That streams uses DRM, so doesn't really work here. Do you have a DRM-less stream? :)
Comment 18 manasa.athreya 2015-09-23 10:35:57 UTC
Sorry :( I don't have DRM-less stream.
Can you just try to remove the DRM from the stream? if possible !!!

This location contains mpd of such kind, but streams are not accessible... 
http://bitlivedemo-a.akamaihd.net/mpds/stream.php?streamkey=bitcodin

I am trying ,if possible I will give mpd of such kind.
Comment 19 Sebastian Dröge (slomo) 2015-09-23 11:02:35 UTC
The bitcodin one works fine here without your patches, except for bug #755115.

I can't remove the DRM, sorry :) That's the whole point of DRM, no? Also I don't have any GStreamer elements that could handle this protection scheme used there.
Comment 20 Sebastian Dröge (slomo) 2015-10-02 14:39:39 UTC
commit e6a4c81af5fb8049d27c4bb114f3d629c2675276
Author: Manasa Athreya <manasa.athreya@lge.com>
Date:   Wed Sep 23 12:39:35 2015 +0900

    qtdemux: Check multi trex to find track id in mp4 mpeg-dash stream
    
    If stream has more than one trex box which is not matched to actual
    track id, it makes qtdemux crashed.
    
    Author : Manasa Athreya (manasa.athreya@lge.com)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=754864