-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WiP * WiP x2 * WIP x3 * Improve SIP configuration * Generate new api.spec * Fix dialyzer issues * Rename SIP properties * Little fixes * Fixes after review * Generate new OpenAPI spec * Add default implementation of Jellyfish.Component behaviour * Fix ApiSpec.Component.SIP * Fix OpenAPISpex * Update lib/jellyfish_web/router.ex Co-authored-by: Jakub Pisarek <[email protected]> * Add missing unauthorized response * Fix SIP resource --------- Co-authored-by: Jakub Pisarek <[email protected]>
- Loading branch information
Showing
25 changed files
with
930 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
defmodule Jellyfish.Component.SIP do | ||
@moduledoc """ | ||
Module representing the SIP component. | ||
""" | ||
|
||
@behaviour Jellyfish.Endpoint.Config | ||
use Jellyfish.Component | ||
|
||
alias Membrane.RTC.Engine.Endpoint.SIP | ||
alias Membrane.RTC.Engine.Endpoint.SIP.RegistrarCredentials | ||
|
||
alias JellyfishWeb.ApiSpec.Component.SIP.Options | ||
|
||
@type properties :: %{ | ||
registrar_credentials: %{ | ||
address: String.t(), | ||
username: String.t(), | ||
password: String.t() | ||
} | ||
} | ||
|
||
@impl true | ||
def config(%{engine_pid: engine} = options) do | ||
sip_config = Application.fetch_env!(:jellyfish, :sip_config) | ||
|
||
external_ip = | ||
if sip_config[:sip_used?] do | ||
Application.fetch_env!(:jellyfish, :sip_config)[:sip_external_ip] | ||
else | ||
raise """ | ||
SIP components can only be used if JF_SIP_USED environmental variable is set to \"true\" | ||
""" | ||
end | ||
|
||
with {:ok, serialized_opts} <- serialize_options(options, Options.schema()) do | ||
endpoint_spec = %SIP{ | ||
rtc_engine: engine, | ||
external_ip: external_ip, | ||
registrar_credentials: create_register_credentials(serialized_opts.registrar_credentials) | ||
} | ||
|
||
properties = serialized_opts | ||
|
||
{:ok, %{endpoint: endpoint_spec, properties: properties}} | ||
else | ||
{:error, [%OpenApiSpex.Cast.Error{reason: :missing_field, name: name} | _rest]} -> | ||
{:error, {:missing_parameter, name}} | ||
|
||
{:error, _reason} = error -> | ||
error | ||
end | ||
end | ||
|
||
defp create_register_credentials(credentials) do | ||
credentials | ||
|> Map.to_list() | ||
|> Keyword.new() | ||
|> RegistrarCredentials.new() | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.