<divclass="fragment"><divclass="line"><aname="l00001"></a><spanclass="lineno"> 1</span> <spanclass="comment">// Copyright 2017 Google Inc. All rights reserved.</span></div>
<divclass="line"><aname="l00003"></a><spanclass="lineno"> 3</span> <spanclass="comment">// Use of this source code is governed by a BSD-style</span></div>
<divclass="line"><aname="l00004"></a><spanclass="lineno"> 4</span> <spanclass="comment">// license that can be found in the LICENSE file or at</span></div>
<divclass="line"><aname="l00030"></a><spanclass="lineno"> 30</span> <spanclass="stringliteral">"Invalid stream data type for this handler"</span>);</div>
<divclass="line"><aname="l00035"></a><spanclass="lineno"> 35</span> <spanclass="comment">// Keep outputting segments until all the samples leave the system. Calling</span></div>
<divclass="line"><aname="l00036"></a><spanclass="lineno"> 36</span> <spanclass="comment">// |DispatchSegment| will remove samples over time.</span></div>
<divclass="line"><aname="l00052"></a><spanclass="lineno"> 52</span> <spanclass="comment">// We are going to end the current segment prematurely using the cue event's</span></div>
<divclass="line"><aname="l00053"></a><spanclass="lineno"> 53</span> <spanclass="comment">// time as the new segment end.</span></div>
<divclass="line"><aname="l00055"></a><spanclass="lineno"> 55</span> <spanclass="comment">// Because the cue should have been inserted into the stream such that no</span></div>
<divclass="line"><aname="l00056"></a><spanclass="lineno"> 56</span> <spanclass="comment">// later sample could start before it does, we know that there should</span></div>
<divclass="line"><aname="l00057"></a><spanclass="lineno"> 57</span> <spanclass="comment">// be no later samples starting before the cue event.</span></div>
<divclass="line"><aname="l00059"></a><spanclass="lineno"> 59</span> <spanclass="comment">// Convert the event's time to be scaled to the time of each sample.</span></div>
<divclass="line"><aname="l00062"></a><spanclass="lineno"> 62</span> <spanclass="comment">// Output all full segments before the segment that the cue event interupts.</span></div>
<divclass="line"><aname="l00074"></a><spanclass="lineno"> 74</span> <spanclass="comment">// Output all segments that come before our new sample.</span></div>
<divclass="line"><aname="l00077"></a><spanclass="lineno"> 77</span> <spanclass="comment">// If we have not seen a sample yet, base all segments off the first sample's</span></div>
<divclass="line"><aname="l00080"></a><spanclass="lineno"> 80</span> <spanclass="comment">// Force the first segment to start at the segment that would have started</span></div>
<divclass="line"><aname="l00081"></a><spanclass="lineno"> 81</span> <spanclass="comment">// before the sample. This should allow segments from different streams to</span></div>
<divclass="line"><aname="l00086"></a><spanclass="lineno"> 86</span> <spanclass="comment">// We need to write all the segments that would have ended before the new</span></div>
<divclass="line"><aname="l00099"></a><spanclass="lineno"> 99</span>  DCHECK_GT(duration, 0) <<<spanclass="stringliteral">"Segment duration should always be positive"</span>;</div>
<divclass="line"><aname="l00101"></a><spanclass="lineno"> 101</span> <spanclass="comment">// Output all the samples that are part of the segment.</span></div>
<divclass="line"><aname="l00116"></a><spanclass="lineno"> 116</span> <spanclass="comment">// Remove all samples that end before the (new) current segment started.</span></div>
<divclass="line"><aname="l00119"></a><spanclass="lineno"> 119</span> <spanclass="comment">// For the sample to even be in this list, it should have started</span></div>
<divclass="line"><aname="l00120"></a><spanclass="lineno"> 120</span> <spanclass="comment">// before the (new) current segment.</span></div>
<divclass="ttc"id="aclassshaka_1_1media_1_1MediaHandler_html_a0dcba8fa849d5f031ab3e2b4803a7804"><divclass="ttname"><ahref="../../da/dfd/classshaka_1_1media_1_1MediaHandler.html#a0dcba8fa849d5f031ab3e2b4803a7804">shaka::media::MediaHandler::DispatchCueEvent</a></div><divclass="ttdeci">Status DispatchCueEvent(size_t stream_index, std::shared_ptr< const CueEvent > cue_event) const</div><divclass="ttdoc">Dispatch the cue event to downstream handlers.</div><divclass="ttdef"><b>Definition:</b><ahref="../../d3/d93/media__handler_8h_source.html#l00240">media_handler.h:240</a></div></div>
<divclass="ttc"id="anamespaceshaka_html"><divclass="ttname"><ahref="../../d8/daf/namespaceshaka.html">shaka</a></div><divclass="ttdoc">All the methods that are virtual are virtual for mocking.</div><divclass="ttdef"><b>Definition:</b><ahref="../../d4/d15/gflags__hex__bytes_8cc_source.html#l00011">gflags_hex_bytes.cc:11</a></div></div>
<divclass="ttc"id="aclassshaka_1_1media_1_1MediaHandler_html_ad165375cd0a2074c5a740b42f847c499"><divclass="ttname"><ahref="../../da/dfd/classshaka_1_1media_1_1MediaHandler.html#ad165375cd0a2074c5a740b42f847c499">shaka::media::MediaHandler::DispatchStreamInfo</a></div><divclass="ttdeci">Status DispatchStreamInfo(size_t stream_index, std::shared_ptr< const StreamInfo > stream_info) const</div><divclass="ttdoc">Dispatch the stream info to downstream handlers.</div><divclass="ttdef"><b>Definition:</b><ahref="../../d3/d93/media__handler_8h_source.html#l00199">media_handler.h:199</a></div></div>
<divclass="ttc"id="aclassshaka_1_1media_1_1MediaHandler_html_ab644ca7b0a0dbcbc42936f2dfb979ca5"><divclass="ttname"><ahref="../../da/dfd/classshaka_1_1media_1_1MediaHandler.html#ab644ca7b0a0dbcbc42936f2dfb979ca5">shaka::media::MediaHandler::FlushAllDownstreams</a></div><divclass="ttdeci">Status FlushAllDownstreams()</div><divclass="ttdoc">Flush all connected downstream handlers.</div><divclass="ttdef"><b>Definition:</b><ahref="../../d2/de9/media__handler_8cc_source.html#l00114">media_handler.cc:114</a></div></div>
<divclass="ttc"id="aclassshaka_1_1media_1_1MediaHandler_html_a9c44df529fead65c007ee27b84ebd32a"><divclass="ttname"><ahref="../../da/dfd/classshaka_1_1media_1_1MediaHandler.html#a9c44df529fead65c007ee27b84ebd32a">shaka::media::MediaHandler::DispatchTextSample</a></div><divclass="ttdeci">Status DispatchTextSample(size_t stream_index, std::shared_ptr< const TextSample > text_sample) const</div><divclass="ttdoc">Dispatch the text sample to downstream handlers.</div><divclass="ttdef"><b>Definition:</b><ahref="../../d3/d93/media__handler_8h_source.html#l00216">media_handler.h:216</a></div></div>
<divclass="ttc"id="aclassshaka_1_1media_1_1MediaHandler_html_a2acc1c84a61aee93229d493aa93308d5"><divclass="ttname"><ahref="../../da/dfd/classshaka_1_1media_1_1MediaHandler.html#a2acc1c84a61aee93229d493aa93308d5">shaka::media::MediaHandler::DispatchSegmentInfo</a></div><divclass="ttdeci">Status DispatchSegmentInfo(size_t stream_index, std::shared_ptr< const SegmentInfo > segment_info) const</div><divclass="ttdoc">Dispatch the segment info to downstream handlers.</div><divclass="ttdef"><b>Definition:</b><ahref="../../d3/d93/media__handler_8h_source.html#l00224">media_handler.h:224</a></div></div>