Skip to content

Commit

Permalink
Merge pull request #7 from The-Del-Mar-Code-Company/parse-media-indep…
Browse files Browse the repository at this point in the history
…endent-segments-tag

handle #EXT-X-INDEPENDENT-SEGMENTS tag in media playlists
  • Loading branch information
Qizot authored Mar 13, 2024
2 parents e8505d5 + d62ca85 commit f475623
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The package can be installed by adding `ex_m3u8` into your list of dependencies
```elixir
def deps do
[
{:ex_m3u8, "~> 0.13.0"}
{:ex_m3u8, "~> 0.14.0"}
]
end
```
Expand Down
1 change: 1 addition & 0 deletions lib/ex_m3u8/deserializer/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ defmodule ExM3U8.Deserializer.Parser do
:target_duration,
version: nil,
playlist_type: nil,
independent_segments: false,
server_control: nil,
part_inf: nil,
media_sequence: 0,
Expand Down
6 changes: 6 additions & 0 deletions lib/ex_m3u8/media_playlist/info.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule ExM3U8.MediaPlaylist.Info do

typedstruct enforce: true do
field :version, pos_integer() | nil
field :independent_segments, boolean(), default: false
field :playlist_type, :vod | :event | nil, default: nil
field :target_duration, pos_integer()
field :server_control, ExM3U8.MediaPlaylist.ServerControl.t() | nil, default: nil
Expand Down Expand Up @@ -33,6 +34,7 @@ defmodule ExM3U8.MediaPlaylist.Info do
Helpers.generate_sorter(tag, [
:version,
:playlist_type,
:independent_segments,
:target_duration,
:server_control,
:part_inf,
Expand Down Expand Up @@ -62,6 +64,10 @@ defmodule ExM3U8.MediaPlaylist.Info do
tag: "TARGETDURATION",
skip_empty?: false

defp dump({:independent_segments, true}), do: [Helpers.tag_prefix(), "INDEPENDENT-SEGMENTS"]

defp dump({:independent_segments, false}), do: []

defp dump({:server_control, nil}), do: []

defp dump({:server_control, server_control}), do: ExM3U8.Serializer.serialize(server_control)
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule ExM3U8.MixProject do
use Mix.Project

@version "0.13.0"
@version "0.14.0"
@github_url "https://github.com/membraneframework/ex_m3u8"

def project do
Expand Down
4 changes: 4 additions & 0 deletions test/ex_m3u8/media_playlist_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule ExM3U8.MediaPlaylistTest do
info = %ExM3U8.MediaPlaylist.Info{
playlist_type: :vod,
target_duration: 6,
independent_segments: true,
version: 7,
server_control: %ExM3U8.MediaPlaylist.ServerControl{
can_block_reload?: true,
Expand All @@ -22,6 +23,7 @@ defmodule ExM3U8.MediaPlaylistTest do
assert """
#EXT-X-VERSION:7
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-TARGETDURATION:6
#EXT-X-SERVER-CONTROL:CAN-BLOCK-RELOAD=YES,PART-HOLD-BACK=3.0,HOLD-BACK=6.0,CAN-SKIP-UNTIL=12.0
#EXT-X-PART-INF:PART-TARGET=1.0
Expand Down Expand Up @@ -148,6 +150,7 @@ defmodule ExM3U8.MediaPlaylistTest do
manifest = """
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-TARGETDURATION:6
#EXT-X-SERVER-CONTROL:CAN-BLOCK-RELOAD=YES,PART-HOLD-BACK=3.0,HOLD-BACK=6.0,CAN-SKIP-UNTIL=12.0
#EXT-X-PART-INF:PART-TARGET=1.0
Expand Down Expand Up @@ -177,6 +180,7 @@ defmodule ExM3U8.MediaPlaylistTest do
info = %ExM3U8.MediaPlaylist.Info{
target_duration: 6,
version: 7,
independent_segments: true,
server_control: %ExM3U8.MediaPlaylist.ServerControl{
can_block_reload?: true,
part_hold_back: 3.0,
Expand Down

0 comments on commit f475623

Please sign in to comment.