-
Notifications
You must be signed in to change notification settings - Fork 20
RTC-377 SIP Component #147
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2677471
WiP
Rados13 52605bb
WiP x2
Rados13 69deb4f
WIP x3
Rados13 2be6715
Improve SIP configuration
Rados13 c7a932d
Generate new api.spec
Rados13 3496abe
Fix dialyzer issues
Rados13 547cc4e
Rename SIP properties
Rados13 0bbdfab
Little fixes
Rados13 08332e1
Fixes after review
Rados13 0a4259a
Generate new OpenAPI spec
Rados13 a3617a0
Add default implementation of Jellyfish.Component behaviour
Rados13 bc3ff2b
Fix ApiSpec.Component.SIP
Rados13 6b60c77
Fix OpenAPISpex
Rados13 6f415ba
Update lib/jellyfish_web/router.ex
Rados13 99d31b0
Add missing unauthorized response
Rados13 ccfd64a
Fix SIP resource
Rados13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
💪 💪 💪