Skip to content

Add HLS Live/DVR support - #948

Closed
pajatopmr wants to merge 2 commits into
google:devfrom
pajatopmr:hls-live-dvr
Closed

pajatopmr wants to merge 2 commits into
google:devfrom
pajatopmr:hls-live-dvr

Conversation

@pajatopmr

Copy link
Copy Markdown

Rationale:

Support in ExoPlayer for HLS live streaming is not as polished as for non-live streaming. A number of issues exist against seeking (which implies DVR) in particular. This commit builds on the good work done in PR#848 (and others) to address these issues in the following way:

  • A live stream is added to the Demo samples for HLS.
  • The Demo player uses the available seek range to bracket the sliding DVR window.
  • Chunk processing takes into account the live edge on start.
  • A bug in live seeking is fixed.

Changes to be committed:

demo/src/main/java/com/google/android/exoplayer/demo/Samples.java

  • Add a live stream (the Israeli i24 TV news feed)

demo/src/main/java/com/google/android/exoplayer/demo/player/DemoPlayer.java (From PR#848)

  • Add an event listener for Chunk events.
  • Update the player on changes to the available seek range.

demo/src/main/java/com/google/android/exoplayer/demo/player/HlsRendererBuilder.java (From PR#848)

  • Inject the player and main handler into the chunk source object (using a new HlsChunkSource constructor).

library/src/main/java/com/google/android/exoplayer/hls/HlsChunkSource.java (Mostly from PR#848)

  • Extend the EventListener interface to handle changes to the available seek range.
  • Provide a constructor that injects the player and a handler to deal with available seek range changes.

In getChunkOperation():

  • Obtain the live start chunk media sequence only when seeking to playback position 0.
  • Fix a bug in live sseking that causes all chunks preceding the one containing the desired seek position to be loaded (which causes a huge delay in seeking towards the live edge).

In setMediaPlaylist():

  • Process changes to the available seek range.

library/src/main/java/com/google/android/exoplayer/util/PlayerControl.java (From PR#848)

  • Provide support for handling changes to the available seek range.

<h1>Rationale:</h1>

Support in ExoPlayer for HLS live streaming is not as polished as for non-live streaming.  A number of issues exist against seeking (which implies DVR) in particular.  This commit builds on the good work done in PR#848 (and others) to address these issues in the following way:

* A live stream is added to the Demo samples for HLS.

* The Demo player uses the available seek range to bracket the sliding DVR window.

* Chunk processing takes into account the live edge on start.

* A bug in live seeking is fixed.

<h1>Changes to be committed:</h1>

demo/src/main/java/com/google/android/exoplayer/demo/Samples.java

- Add a live stream (the Israeli i24 TV news feed)

demo/src/main/java/com/google/android/exoplayer/demo/player/DemoPlayer.java (From PR#848)

- Add an event listener for Chunk events.

- Update the player on changes to the available seek range.

demo/src/main/java/com/google/android/exoplayer/demo/player/HlsRendererBuilder.java (From PR#848)

- Inject the player and main handler into the chunk source object (using a new HlsChunkSource constructor).

library/src/main/java/com/google/android/exoplayer/hls/HlsChunkSource.java (Mostly from PR#848)

- Extend the EventListener interface to handle changes to the available seek range.

- Provide a constructor that injects the player and a handler to deal with available seek range changes.

In getChunkOperation():

- Obtain the live start chunk media sequence only when seeking to playback position 0.

- Fix a bug in live sseking that causes all chunks preceding the one containing the desired seem position to be loaded (which causes a huge delay in seeking towards the live edge).

In setMediaPlaylist():

- Process changes to the available seek range.

library/src/main/java/com/google/android/exoplayer/util/PlayerControl.java (From PR#848)

- Provide support for handling changes to the available seek range.
@googlebot

Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

@pajatopmr

Copy link
Copy Markdown
Author

Fwiw, I have signed CLAs under both email addresses I typically use when committing changes to Github. But I may have to add another commit to trigger a check to catch the CLA I signed this morning.

@googlebot

Copy link
Copy Markdown

CLAs look good, thanks!

@fredx21

fredx21 commented Nov 14, 2015

Copy link
Copy Markdown

@pajatopmr, I played with your patched files and it's a very good start to live HLS. I have a few suggestions to improve the result in the demo app:

  • In your implementation of "getChunkOperation" when the seekPositionUs != 0, you should prevent seeking beyond the "3 frame threshold" from stream end, as it is already done in "getLiveStartChunkMediaSequence".
  • The player position in the seek-bar should never move for live streams because it repensent a fixed reading position inside the server's DVR buffer, as opposed to the non-live streams where the time in the seek-bar represents a time-span since the beggining of the stream.

@pajatopmr

Copy link
Copy Markdown
Author

Thanks @fredx21 (and @thasso).

  • Ensuring that the seek does not go beyond the "live edge" is a good point. I will fix that as it feels consistent with the HLS spec.
  • As for your second point, I think there is some room for disagreement. My model is that live/EVENT and VOD both should use the seekbar to represent the player position from a start value of 0. For live with a fixed sliding window I think the current position can be interpreted/represented either from the live edge or the start of the window (my choice). I have seen both styles employed. I'd love to get the "official" ExoPlayer preference or hear about an existing, dominant player model. That said, I think app developers should be able to apply their own style where a spec does not clearly define behavior, which is the case here with the demo player. Using the available seek range gives the app developer wiggle room.

@pajatopmr

Copy link
Copy Markdown
Author

@fredx21 In testing my fix for your first point, your second point became clearer,especially to the extent that my representation of the stream showed one end as the current playhead position and the other end of the seekbar as the fixed window size. I am now inclined to change that to show playhead positions on both ends. I think this makes more sense.

<h1>Rationale:</h1>

This commit attempts to resolve the following issues:

- get the key changes required to support Live/DVR merged to master
  by separating them from changes supporting Live/EVENT (PR#848) in the
  hope that smaller is better in the eyes of the maintainers,

- address an @ojw28 concern that the Demo app not be made more
  complicated with additional features,

- the PR comment from @fredx21 that the Live/DVR demo has issues with
  the seek bar behavior: to fix this requires a more robust Demo app.

<h1>Changes to be committed:</h1>

demo/src/main/java/com/google/android/exoplayer/demo/Samples.java
demo/src/main/java/com/google/android/exoplayer/demo/player/DemoPlayer.java
demo/src/main/java/com/google/android/exoplayer/demo/player/HlsRendererBuilder.java
library/src/main/java/com/google/android/exoplayer/util/PlayerControl.java

- Revert PR google#848 changes.

library/src/main/java/com/google/android/exoplayer/hls/HlsChunkSource.java

- Prune out PR google#848 changes and ensure that seeking cannot enter the
  region beyond the live edge (the last three segments in the media
  playlist).
@TBoshoven

Copy link
Copy Markdown

When using this patch, the playlists don't seem to be updated frequently. This makes it possible to request very old segments by seeking after pausing. Furthermore, it makes it difficult to seek to "live".
Building on top of this patch, what would be a good approach to making sure that the playlists keep updating in a DVR stream?

@programkom

Copy link
Copy Markdown

when will this be merged to master branch? I've been using Pajatopmr's branch because on that variant LIVE streams can be rewinded, which is not true for current master branch

@ojw28 ojw28 closed this Jul 28, 2016
@google google locked and limited conversation to collaborators Jun 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants