Skip to content

Commit 46bdf06

Browse files
committed
Apply review suggestions
1 parent 88a3571 commit 46bdf06

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The package can be installed by adding `ex_hls` to your list of dependencies in
1515
```elixir
1616
def deps do
1717
[
18-
{:ex_hls, "~> 0.0.1"}
18+
{:ex_hls, "~> 0.1.0"}
1919
]
2020
end
2121
```
@@ -53,7 +53,7 @@ where `<id>` is the `id` field of the entry returned by `ExHLS.Client.get_varian
5353

5454
Now you can get the Elixir stream containing media chunks:
5555
```elixir
56-
stream = ExHLS.Clinet.generate_stream(client)
56+
stream = ExHLS.Client.generate_stream(client)
5757
Enum.take(stream, 5)
5858
# Returns:
5959
# [
@@ -105,7 +105,7 @@ Enum.take(stream, 5)
105105
# ]
106106
```
107107

108-
To pop only single elements from the stream containing ExHLS Chunks, you can use [`StreamSplit.pop/1](https://hexdocs.pm/stream_split/StreamSplit.html#pop/1).
108+
To pop only single elements from the stream containing ExHLS Chunks, you can use [`StreamSplit.pop/1`](https://hexdocs.pm/stream_split/StreamSplit.html#pop/1).
109109

110110
Note: If the HLS playlist type is Live (not VoD), you can generate stream from single `ExHLS.Client` instance only once and only from the process, that created that `ExHLS.Client`. If you want to genereate more streams with Live HLS, you have to create a new `ExHLS.Client` each time.
111111

lib/ex_hls/client.ex

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ defmodule ExHLS.Client do
1717
:media_playlist_url,
1818
:multivariant_playlist,
1919
:root_playlist_url,
20-
:root_playlist_string,
20+
:root_playlist_raw_content,
2121
:base_url,
2222
:vod_client,
2323
:live_reader,
@@ -62,8 +62,10 @@ defmodule ExHLS.Client do
6262
|> Keyword.validate!(parent_process: self(), how_much_to_skip_ms: 0)
6363
|> Map.new()
6464

65-
root_playlist_string = Utils.download_or_read_file!(url)
66-
multivariant_playlist = root_playlist_string |> ExM3U8.deserialize_multivariant_playlist!([])
65+
root_playlist_raw_content = Utils.download_or_read_file!(url)
66+
67+
multivariant_playlist =
68+
root_playlist_raw_content |> ExM3U8.deserialize_multivariant_playlist!([])
6769

6870
%__MODULE__{
6971
parent_process: parent_process,
@@ -72,7 +74,7 @@ defmodule ExHLS.Client do
7274
media_playlist_url: nil,
7375
multivariant_playlist: multivariant_playlist,
7476
root_playlist_url: url,
75-
root_playlist_string: root_playlist_string,
77+
root_playlist_raw_content: root_playlist_raw_content,
7678
base_url: Path.dirname(url),
7779
vod_client: nil,
7880
live_reader: nil,
@@ -147,7 +149,7 @@ defmodule ExHLS.Client do
147149

148150
defp treat_root_playlist_as_media_playlist(%__MODULE__{media_playlist: nil} = client) do
149151
media_playlist =
150-
client.root_playlist_string
152+
client.root_playlist_raw_content
151153
|> ExM3U8.deserialize_media_playlist!([])
152154

153155
%{

lib/ex_hls/client/live/reader.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ defmodule ExHLS.Client.Live.Reader do
190190
end
191191

192192
defp schedule_next_playlist_check(%{playlist_check_scheduled?: false} = state) do
193+
# Playlist check interval is 1/4 of target duration, while the RFC says to set it
194+
# to 1/2 of target duration. We do it this way to reduce the chance of race condition
195+
# occuring when we check the playlist just before the server updates it.
196+
193197
playlist_check_timeout_ms =
194198
(state.media_playlist.info.target_duration * 250) |> round()
195199

lib/ex_hls/client/vod.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ defmodule ExHLS.Client.VOD do
33
# Module providing functionality to read and demux HLS VOD streams.
44
# It allows reading chunks from the stream, choosing variants, and managing media playlists.
55

6+
# TODO: It would be nice to refactor this module a little, maybe to make it similar to Reader
7+
68
use Bunch.Access
79

810
require Logger

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule ExHLS.Mixfile do
22
use Mix.Project
33

4-
@version "0.0.1"
4+
@version "0.1.0"
55
@github_url "https://github.com/membraneframework/ex_hls"
66

77
def project do

0 commit comments

Comments
 (0)