<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof">Hello, GStreamer dev team!<br>
</span></div>
<div class="elementToProof"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof"><br>
</span></div>
<div class="elementToProof"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0">We are developing a product that uses one of GStreamer
 plugins - qtdemux - and encountered problems after switching from version 1.10.4 to 1.18.5. I have a couple of questions related to the logic of qtdemux and would appreciate your support or redirecting me to the people who might be able to help.<br>
</span></div>
<div class="elementToProof"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0"><br>
</span></div>
<div class="elementToProof"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0"><b>Problem description</b></span></div>
<div class="elementToProof"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0"><b><br>
</b></span></div>
<div class="elementToProof"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0 ContentPasted1">qtdemux struct contains a segment
 member</span> <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0 ContentPasted1 ContentPasted2 ContentPasted3">
and the segment in turn has (among others) two members described in the header:<br class="ContentPasted3">
</span></div>
<div class="elementToProof">
<ul>
<li style="font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);" class="elementToProof">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0 ContentPasted1 ContentPasted2 ContentPasted3 ContentPasted4"><b>duration</b> -
 the duration of the segment is the maximum absolute difference between #GstSegment.start and #GstSegment.stop if stop is not set, otherwise it should be the difference between those two values. This should be set by elements that know the overall stream duration
 (like demuxers) and will be used when seeking with #GST_SEEK_TYPE_END.</span></li><li style="font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);" class="elementToProof">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0 ContentPasted1 ContentPasted2 ContentPasted3 ContentPasted4 ContentPasted5"><b>stop</b>
 - the stop time of the segment (in buffer timestamps)  [(PTS)](GstBuffer.pts), that is the timestamp of the last buffer to output inside the segment (first one during reverse playback). For example decoders will [clip](gst_segment_clip) out buffers after the
 stop time.</span></li></ul>
<div class="elementToProof ContentPasted6"><span style="font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">In the qtdemux function `<i>check_update_duration</i>` there is a logic updating:</span></div>
<div class="elementToProof ContentPasted6">
<div class="ContentPasted6">
<ul>
<li style="font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);" class="elementToProof">
<span style="font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">qtdemux->duration</span></li><li class="ContentPasted6 elementToProof" style="font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
<span style="font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">qtdemux->segment.duration</span></li><li class="elementToProof ContentPasted6" style="font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">
<span style="font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0);">qtdemux->segment.stop</span><br>
</li></ul>
</div>
</div>
<div class="elementToProof ContentPasted7" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
and this logic seems to have changed in 1.18.5 compared to 1.10.4.</div>
<div class="elementToProof ContentPasted7" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div class="elementToProof ContentPasted7 ContentPasted8 ContentPasted9" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
In GStreamer 1.10.4 both, qtdemux->segment.duration and qtdemux->segment.stop had the same value read from mvhd or mehd box in
<i>qtdemux_parse_tree</i>. I observe that it always has reasonable values, a duration of the content in timescale units, e.g. 730000000000 which corresponds to 730 seconds.</div>
<div class="elementToProof ContentPasted7 ContentPasted8 ContentPasted9" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div class="elementToProof ContentPasted7 ContentPasted8 ContentPasted9 ContentPasted10 ContentPasted11 ContentPasted12" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
In Gstreamer 1.18.5 a logic of assigning qtdemux->segment.duration and qtdemux->segment.stop in
<i>qtdemux_parse_tree</i> was put under if (!qtdemux->upstream_format_is_time), which in my case is always false (we use segments with GST_FORMAT_TIME). This in turn leads to updating qtdemux->segment.duration and qtdemux->segment.stop in
<i>check_update_duration</i> method to unreasonable values of duration, like 1669982447883159000. As per the description in the header segment.duration should hold the absolute difference between stop and start values, and it's not the case anymore.</div>
<div class="elementToProof ContentPasted7 ContentPasted8 ContentPasted9 ContentPasted10 ContentPasted11 ContentPasted12" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div class="elementToProof ContentPasted7 ContentPasted8 ContentPasted9 ContentPasted10 ContentPasted11 ContentPasted12" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<b>Questions</b></div>
<div class="elementToProof ContentPasted7 ContentPasted8 ContentPasted9 ContentPasted10 ContentPasted11 ContentPasted12" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<ol>
<li class="elementToProof">Do I understand correctly that qtdemux->segment.duration should always hold the duration of the segment, even if segment.start is not 0?</li><li class="elementToProof">If so, how can one explain logic in <i>check_update_duration</i>, where under specific conditions segment.duration and segment.stop will be equal? Isn't that true only if the start is 0?</li><li class="elementToProof ContentPasted13 ContentPasted15">I checked the commit introducing the beforementioned if (!qtdemux->upstream_format_is_time) in
<i class="ContentPasted14">qtdemux_parse_tree</i> - <a href="https://bugzilla.gnome.org/show_bug.cgi?id=752603" id="LPlnk418173">
https://bugzilla.gnome.org/show_bug.cgi?id=752603</a> - and in the commit description there is the following statement:<br>
<blockquote style="border-color: rgb(200, 200, 200); border-left: 3px solid rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102);" itemscope="" itemtype="https://schemas.microsoft.com/QuotedText">
<div>
<pre class="bz_comment_text ContentPasted16">qtdemux->segment.duration is no longer modified when
upstream_format_is_time, respecting in this way the durations provided
by dashdemux and fixing bugs in reverse playback tests where mangled
durations appeared in the emitted segments.</pre>
</div>
</blockquote>
</li></ol>
<div class="elementToProof"><span>      </span>do you know, which changes in dashdemux it refers to?
<br>
</div>
</div>
</div>
<div class="elementToProof"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0 ContentPasted1 ContentPasted2"><br>
</span></div>
<div class="elementToProof"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0 ContentPasted1 ContentPasted2">Thanks in advance for
 your help!</span></div>
<div class="elementToProof"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0 ContentPasted1 ContentPasted2"><br>
</span></div>
<div class="elementToProof"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0 ContentPasted1 ContentPasted2">Marcin Twardak<br>
</span></div>
</body>
</html>