Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
Code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Karolk99 committed Jun 19, 2023
1 parent ad07fa1 commit c463e82
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions test/support/hls_storage.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ defmodule Membrane.RTC.Engine.Support.HLSStorage do
{result, file_storage} =
FileStorage.store(parent_id, resource_name, content, metadata, context, state.file_storage)

state =
if context.type == :manifest do
state = %{state | file_storage: file_storage}

case context.type do
:segment ->
send(state.pid, {context.type, resource_name})
{result, state}

:manifest ->
content = String.split(content, "\n")

video_segments = Enum.count(content, &String.match?(&1, ~r/^video.*\.m4s/))
Expand All @@ -55,16 +61,11 @@ defmodule Membrane.RTC.Engine.Support.HLSStorage do
{context.type, segments}
)

update_segments(segments, state)
else
state
end
{result, update_segments(segments, state)}

if context.type == :segment do
send(state.pid, {context.type, resource_name})
_other ->
{result, state}
end

{result, %{state | file_storage: file_storage}}
end

defp update_segments(
Expand Down

0 comments on commit c463e82

Please sign in to comment.