[mythtv-commits] Ticket #13187: HLSPlaylist doesn't follow 302 redirects correctly

MythTV noreply at mythtv.org
Mon Dec 11 04:15:29 UTC 2017


#13187: HLSPlaylist doesn't follow 302 redirects correctly
--------------------------------------+------------------------------
 Reporter:  Steven Ellis <support@…>  |          Owner:  jpoet
     Type:  Bug Report - General      |         Status:  assigned
 Priority:  minor                     |      Milestone:  needs_triage
Component:  MythTV - HTTP Streaming   |        Version:  v29-fixes
 Severity:  medium                    |     Resolution:
 Keywords:                            |  Ticket locked:  0
--------------------------------------+------------------------------

Comment (by Steven Ellis <support@…>):

 Some additional debug output of mythtv-backend by modifying
 /etc/mythtv/additional.args
 {{{
 ADDITIONAL_ARGS="-v playback,record"
 }}}

 Clarified the sequence as follows

 Part 1 - fetch m3u8 file - which allows for re-direct rule.
 {{{
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 iptvtuningdata.h:235 (IsHLSPlaylist) IsHLSPlaylist url ends with either
 .m3u8 or .m3u http:/
 /iptv.matthuisman.nz/nz/tv.9.m3u8
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 mythsingledownload.cpp:75 (DownloadURL)
 http://iptv.matthuisman.nz/nz/tv.9.m3u8 -> https://t
 vnzioslive04-i.akamaihd.net/hls/live/267188/1924997895001/channel1/masterR_55.m3u8
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 channelutil.cpp:2001 (GetIPTVTuningData) Loaded
 [data]http://iptv.matthuisman.nz/nz/tv.9.m3u8[fectype][fec0][fec1] for
 9401
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I StreamHandler
 recorders/hlsstreamhandler.cpp:125 (run)
 HLSSH(http://iptv.matthuisman.nz/nz/tv.9.m3u8(0)): run() -- begin
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 recorders/hlsstreamhandler.cpp:43 (Get) HLSSH: Creating new stream handler
 http://iptv.matthuisman.nz/nz/tv.9.m3u8(0) for
 [data]http://iptv.matthuisman.nz/nz/tv.9.m3u8[fectype][fec0][fec1]
 }}}

 Part 2 - Create the Live TV Buffer
 {{{
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 tv_rec.cpp:4670 (CreateLiveTVRingBuffer) TVRec[48]:
 CreateLiveTVRingBuffer(401)
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I StreamHandler
 recorders/HLS/HLSReader.cpp:196 (Throttle) HLSReader: Throttle(false)
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I StreamHandler
 recorders/HLS/HLSReader.cpp:48 (Open) HLSReader: Opening
 'http://iptv.matthuisman.nz/nz/tv.9.m3u8'
 }}}

 Download the playlist
 {{{
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I StreamHandler
 mythsingledownload.cpp:75 (DownloadURL)
 http://iptv.matthuisman.nz/nz/tv.9.m3u8 ->
 https://tvnzioslive04-i.akamaihd.net/hls/live/267188/1924997895001/channel1/masterR_55.m3u8
 }}}

 Attempt to stream but without the re-direct
 {{{
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 recorders/streamhandler.cpp:81 (AddListener)
 SH(http://iptv.matthuisman.nz/nz/tv.9.m3u8(0)):
  AddListener(0x7f0b44049fd0) -- begin
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 recorders/streamhandler.cpp:93 (AddListener)
 SH(http://iptv.matthuisman.nz/nz/tv.9.m3u8(0)):
  AddListener(0x7f0b44049fd0) -- locked
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 recorders/streamhandler.cpp:124 (AddListener)
 SH(http://iptv.matthuisman.nz/nz/tv.9.m3u8(0))
 : AddListener(0x7f0b44049fd0) -- end
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 mpeg/mpegstreamdata.cpp:90 (SetDesiredProgram)
 MPEGStream[48](0x7f0b44049fd0): SetDesiredPro
 gram(0)
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 tv_rec.cpp:1992 (SetupDTVSignalMonitor) TVRec[48]: Successfully set up
 MPEG table monitoring.
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 tv_rec.cpp:4453 (SetFlags) TVRec[48]: SetFlags(SignalMonitorRunning,) ->
 RunMainLoop,SignalMonitorRunning, @ tv_rec.cpp:3858
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 tv_rec.cpp:4462 (ClearFlags) TVRec[48]: ClearFlags(WaitingForSignal,) ->
 RunMainLoop,SignalMonitorRunning, @ tv_rec.cpp:3859
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 tv_rec.cpp:4453 (SetFlags) TVRec[48]: SetFlags(WaitingForSignal,) ->
 RunMainLoop,WaitingForSignal,SignalMonitorRunning, @ tv_rec.cpp:3864
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 tv_rec.cpp:4453 (SetFlags) TVRec[48]: SetFlags(DummyRecorderRunning,) ->
 RunMainLoop,WaitingForSignal,SignalMonitorRunning,DummyRecorderRunning, @
 tv_rec.cpp:3913
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 tv_rec.cpp:3914 (TuningFrequency) DummyDTVRecorder -- started
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 tv_rec.cpp:4453 (SetFlags) TVRec[48]: SetFlags(RingBufferReady,) ->
 RunMainLoop,WaitingForSignal,SignalMonitorRunning,DummyRecorderRunning,RingBufferReady,
 @ tv_rec.cpp:3915
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 tv_rec.cpp:4462 (ClearFlags) TVRec[48]: ClearFlags(NeedToStartRecorder,)
 ->
 RunMainLoop,WaitingForSignal,SignalMonitorRunning,DummyRecorderRunning,RingBufferReady,
 @ tv_rec.cpp:3925
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 tv_rec.cpp:4453 (SetFlags) TVRec[48]: SetFlags(NeedToStartRecorder,) ->
 RunMainLoop,WaitingForSignal,NeedToStartRecorder,SignalMonitorRunning,DummyRecorderRunning,RingBufferReady,
 @ tv_rec.cpp:3927
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I TVRecEvent
 tv_rec.cpp:4049 (TuningSignalCheck) TVRec[48]: TuningSignalCheck: Still
 waiting.  Will timeout @ 20:30:00.000
 Dec  5 20:08:12 mythtv mythbackend: mythbackend[23065]: I ProcessRequest
 tv_rec.cpp:4453 (SetFlags) TVRec[48]: SetFlags(CancelNextRecording,) ->
 RunMainLoop,CancelNextRecording,WaitingForSignal,NeedToStartRecorder,SignalMonitorRunning,DummyRecorderRunning,RingBufferReady,
 @ tv_rec.cpp:2682
 Dec  5 20:08:13 mythtv mythbackend: mythbackend[23065]: I StreamHandler
 recorders/HLS/HLSReader.cpp:401 (ParseM3U8) HLSReader: Adding new stream
 'http://iptv.matthuisman.nz/nz/tv.9.m3u8'
 Dec  5 20:08:13 mythtv mythbackend: mythbackend[23065]: I StreamHandler
 HLS/m3u.cpp:321 (ParseKey) playback of AES-128 encrypted HTTP Live media
 detected.
 Dec  5 20:08:13 mythtv mythbackend: mythbackend[23065]: I StreamHandler
 recorders/HLS/HLSReader.cpp:132 (Open)
 http://iptv.matthuisman.nz/nz/tv.9.m3u8: Selected stream with 0 bitrate
 Dec  5 20:08:13 mythtv mythbackend: mythbackend[23065]: I StreamHandler
 recorders/HLS/HLSReader.cpp:140 (Open)
 http://iptv.matthuisman.nz/nz/tv.9.m3u8: Open -- end
 Dec  5 20:08:13 mythtv mythbackend: mythbackend[23065]: I thread_unknown
 recorders/HLS/HLSPlaylistWorker.cpp:37 (run)
 http://iptv.matthuisman.nz/nz/tv.9.m3u8 playlist: run -- begin
 Dec  5 20:08:13 mythtv mythbackend: mythbackend[23065]: I thread_unknown
 recorders/HLS/HLSStreamWorker.cpp:38 (run)
 http://iptv.matthuisman.nz/nz/tv.9.m3u8 worker: run -- begin
 Dec  5 20:08:13 mythtv mythbackend: mythbackend[23065]: I StreamHandler
 recorders/HLS/HLSReader.cpp:196 (Throttle)
 http://iptv.matthuisman.nz/nz/tv.9.m3u8: Throttle(true)
 Dec  5 20:08:13 mythtv mythbackend: mythbackend[23065]: I HLSStream
 mythsingledownload.cpp:75 (DownloadURL)
 http://iptv.matthuisman.nz/nz/20171202T050147/masterR_55/00017/masterR_55_01244.ts
 ->
 https://cdn.rawgit.com/matthuisman/iptv/7aa3714923f88a8fc141e520a5d8a6f58976ac45/nz/20171202T050147/masterR_55/00017/masterR_55_01244.ts
 Dec  5 20:08:14 mythtv mythbackend: mythbackend[23065]: E HLSStream
 recorders/HLS/HLSReader.cpp:936 (DownloadSegmentData)
 http://iptv.matthuisman.nz/nz/tv.9.m3u8: 52244 failed: Error downloading
 https://cdn.rawgit.com/matthuisman/iptv/7aa3714923f88a8fc141e520a5d8a6f58976ac45/nz/20171202T050147/masterR_55/00017/masterR_55_01244.ts
 - server replied: Not Found
 }}}

 Critical file appears to be
  *
 https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythtv/recorders/HLS/HLSReader.cpp

 Useful docs
  * https://code.mythtv.org/doxygen/classHLSReader.html

 My take is that
  * HLSReader::Open(const QString & m3u, int bitrate_index)
 Should be called with the re-directed M3U URL rather than the original URL
 from the channel entry.


 Stepping back to the call
  * void HLSStreamHandler::run(void)

 This calls
 {{{
 QString url = m_tuning.GetURL(0).toString();


 m_hls->Throttle(false);

 HLSReader: Throttle


    while (_running_desired)
     {
         if (!m_hls->IsOpen(url))
         {
             if (!m_hls->Open(url, m_tuning.GetBitrate(0)))

 }}}

 So unless the URL has been re-directed before we call Open we're using the
 wrong Base URL for the streamed content requests further on.

--
Ticket URL: <https://code.mythtv.org/trac/ticket/13187#comment:9>
MythTV <http://www.mythtv.org>
MythTV Media Center


More information about the mythtv-commits mailing list