New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RTC-333] Limit HLS components to 1 per room #72
Conversation
Codecov Report
@@ Coverage Diff @@
## main #72 +/- ##
==========================================
+ Coverage 83.59% 83.78% +0.19%
==========================================
Files 36 36
Lines 512 518 +6
==========================================
+ Hits 428 434 +6
Misses 84 84
Continue to review full report in Codecov by Sentry.
|
lib/jellyfish/room.ex
Outdated
defp check_component_allowed(Component.HLS, %{ | ||
config: %{video_codec: video_codec}, | ||
components: components | ||
}) do | ||
cond do | ||
video_codec != :h264 -> | ||
{:error, :incompatible_codec} | ||
|
||
Map.values(components) |> Enum.any?(&(&1.type == Component.HLS)) -> | ||
{:error, :reached_components_limit} | ||
|
||
true -> | ||
:ok | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about:
defp check_component_allowed(Component.HLS, %{ | |
config: %{video_codec: video_codec}, | |
components: components | |
}) do | |
cond do | |
video_codec != :h264 -> | |
{:error, :incompatible_codec} | |
Map.values(components) |> Enum.any?(&(&1.type == Component.HLS)) -> | |
{:error, :reached_components_limit} | |
true -> | |
:ok | |
end | |
end | |
defp check_component_allowed(Component.HLS, %{config: %{video_codec: video_codec}, components: components}) do | |
hls_components_present = components_includes_HLS?(components) | |
case {video_codec, hls_components_present} do | |
{:h264, false} -> :ok | |
{:h264, true} -> {:error, :reached_components_limit} | |
_ -> {:error, :incompatible_codec} | |
end | |
end | |
defp components_includes_HLS?(components) do | |
components | |
|> Map.values() | |
|> Enum.any?(&(&1.type == Component.HLS)) | |
end |
No description provided.