From ecd79711dc705422b609d4d96393bbfbf005298d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=9Aled=C5=BA?= Date: Fri, 17 May 2024 14:47:10 +0200 Subject: [PATCH] Rename Jellyfish to Fishjam (#67) --- .gitmodules | 2 +- README.md | 32 ++--- compile_proto.sh | 4 +- config/dev.exs | 2 +- config/test.exs | 4 +- config/test_local.exs | 2 +- docker-compose-dev.yaml | 26 ++--- docker-compose-test.yaml | 12 +- examples/server_socket.exs | 10 +- lib/jellyfish/client.ex | 30 ++--- lib/jellyfish/component.ex | 12 +- lib/jellyfish/component/deserializer.ex | 2 +- lib/jellyfish/component/file.ex | 8 +- lib/jellyfish/component/hls.ex | 8 +- lib/jellyfish/component/recording.ex | 10 +- lib/jellyfish/component/rtsp.ex | 8 +- lib/jellyfish/component/sip.ex | 8 +- lib/jellyfish/exception.ex | 6 +- lib/jellyfish/health.ex | 24 ++-- lib/jellyfish/metrics_report.ex | 4 +- lib/jellyfish/notification.ex | 6 +- lib/jellyfish/peer.ex | 12 +- lib/jellyfish/peer/webrtc.ex | 6 +- lib/jellyfish/recording.ex | 12 +- lib/jellyfish/room.ex | 48 ++++---- lib/jellyfish/track.ex | 6 +- lib/jellyfish/utils.ex | 12 +- lib/jellyfish/webhook_notifier.ex | 14 +-- lib/jellyfish/ws_notifier.ex | 62 +++++----- lib/mix/tasks/test_with_docker.ex | 2 +- .../server_notifications.pb.ex | 110 +++++++++--------- mix.exs | 26 ++--- protos | 2 +- test/jellyfish/client_test.exs | 20 ++-- test/jellyfish/health_test.exs | 6 +- test/jellyfish/notifier_test.exs | 66 +++++------ test/jellyfish/recording_test.exs | 6 +- test/jellyfish/room_test.exs | 52 ++++----- .../peer_notifications.pb.ex | 14 +-- test/support/webhook_plug.ex | 4 +- test/support/ws.ex | 4 +- 41 files changed, 347 insertions(+), 357 deletions(-) rename lib/protos/{jellyfish => fishjam}/server_notifications.pb.ex (68%) rename test/support/protos/{jellyfish => fishjam}/peer_notifications.pb.ex (57%) diff --git a/.gitmodules b/.gitmodules index 9fc0cb9..d97d52f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "protos"] path = protos - url = https://github.com/jellyfish-dev/protos.git + url = https://github.com/fishjam-dev/protos.git branch = master diff --git a/README.md b/README.md index a63164f..44d81bd 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,12 @@ Currently it allows for: ## Installation -The package can be installed by adding `jellyfish_server_sdk` to your list of dependencies in `mix.exs`: +The package can be installed by adding `fishjam_server_sdk` to your list of dependencies in `mix.exs`: ```elixir def deps do [ - {:jellyfish_server_sdk, "~> 0.5.0"} + {:fishjam_server_sdk, "~> 0.6.0"} ] end ``` @@ -29,22 +29,22 @@ Define the connection configuration in the mix config, specifying server address and authentication token (for more information see [Fishjam docs](https://fishjam-dev.github.io/fishjam-docs/getting_started/authentication)) ``` config.exs -config :jellyfish_server_sdk, +config :fishjam_server_sdk, server_address: "localhost:5002", - server_api_token: "your-jellyfish-token", + server_api_token: "your-fishjam-token", secure?: true ``` -Alternatively, the connection options can be provided when creating a `Jellyfish.Client` or starting `Jellyfish.WSNotifier`: +Alternatively, the connection options can be provided when creating a `Fishjam.Client` or starting `Fishjam.WSNotifier`: ```elixir client = - Jellyfish.Client.new(server_address: "localhost:5002", server_api_token: "your-jellyfish-token") + Fishjam.Client.new(server_address: "localhost:5002", server_api_token: "your-fishjam-token") {:ok, notifier} = - Jellyfish.WSNotifier.start( + Fishjam.WSNotifier.start( server_address: "localhost:5002", - server_api_token: "your-jellyfish-token" + server_api_token: "your-fishjam-token" ) ``` @@ -54,29 +54,29 @@ Make API calls to Fishjam and receive server events: ```elixir # start process responsible for receiving events -{:ok, notifier} = Jellyfish.WSNotifier.start() -:ok = Jellyfish.WSNotifier.subscribe_server_notifications(notifier) +{:ok, notifier} = Fishjam.WSNotifier.start() +:ok = Fishjam.WSNotifier.subscribe_server_notifications(notifier) # create HTTP client instance -client = Jellyfish.Client.new() +client = Fishjam.Client.new() # Create room -{:ok, %Jellyfish.Room{id: room_id}, jellyfish_address} = Jellyfish.Room.create(client, max_peers: 10) +{:ok, %Fishjam.Room{id: room_id}, fishjam_address} = Fishjam.Room.create(client, max_peers: 10) room_id # => "8878cd13-99a6-40d6-8d7e-8da23d803dab" # Add peer -{:ok, %Jellyfish.Peer{id: peer_id}, peer_token} = - Jellyfish.Room.add_peer(client, room_id, Jellyfish.Peer.WebRTC) +{:ok, %Fishjam.Peer{id: peer_id}, peer_token} = + Fishjam.Room.add_peer(client, room_id, Fishjam.Peer.WebRTC) receive do - {:jellyfish, %Jellyfish.Notification.PeerConnected{room_id: ^room_id, peer_id: ^peer_id}} -> + {:fishjam, %Fishjam.Notification.PeerConnected{room_id: ^room_id, peer_id: ^peer_id}} -> # handle the notification end # Delete peer -:ok = Jellyfish.Room.delete_peer(client, room_id, peer_id) +:ok = Fishjam.Room.delete_peer(client, room_id, peer_id) ``` List of structs representing events can be found in the [docs](https://hexdocs.pm/fishjam_server_sdk). diff --git a/compile_proto.sh b/compile_proto.sh index 27fdc07..f3e106e 100755 --- a/compile_proto.sh +++ b/compile_proto.sh @@ -9,12 +9,12 @@ git submodule sync --recursive >> /dev/null git submodule update --recursive --remote --init >> /dev/null printf "DONE\n\n" -server_file="./protos/jellyfish/server_notifications.proto" +server_file="./protos/fishjam/server_notifications.proto" printf "Compiling: file $server_file" protoc --elixir_out=./lib/ $server_file printf "\tDONE\n" -peer_file="./protos/jellyfish/peer_notifications.proto" +peer_file="./protos/fishjam/peer_notifications.proto" printf "Compiling: file $peer_file" protoc --elixir_out=./test/support $peer_file printf "\tDONE\n" diff --git a/config/dev.exs b/config/dev.exs index db4745c..7bcd517 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -1,5 +1,5 @@ import Config -config :jellyfish_server_sdk, +config :fishjam_server_sdk, server_address: "localhost:5002", server_api_token: "development" diff --git a/config/test.exs b/config/test.exs index 16882d2..7c7b9d9 100644 --- a/config/test.exs +++ b/config/test.exs @@ -1,6 +1,6 @@ import Config -config :jellyfish_server_sdk, - server_address: "jellyfish:5002", +config :fishjam_server_sdk, + server_address: "fishjam:5002", server_api_token: "development", webhook_address: "test" diff --git a/config/test_local.exs b/config/test_local.exs index 58f9b3d..a2e59e1 100644 --- a/config/test_local.exs +++ b/config/test_local.exs @@ -1,6 +1,6 @@ import Config -config :jellyfish_server_sdk, +config :fishjam_server_sdk, server_address: "127.0.0.1:5002", server_api_token: "development", webhook_address: "127.0.0.1" diff --git a/docker-compose-dev.yaml b/docker-compose-dev.yaml index e99a3da..336f116 100644 --- a/docker-compose-dev.yaml +++ b/docker-compose-dev.yaml @@ -1,9 +1,7 @@ -version: "3" - services: - jellyfish: - image: "ghcr.io/fishjam-dev/jellyfish:${TAG:-edge}" - container_name: jellyfish + fishjam: + image: "ghcr.io/fishjam-dev/fishjam:${TAG:-edge}" + container_name: fishjam restart: on-failure healthcheck: test: > @@ -13,15 +11,15 @@ services: timeout: 2s start_period: 30s environment: - JF_HOST: "localhost:5002" - JF_INTEGRATED_TURN_IP: "${INTEGRATED_TURN_IP:-127.0.0.1}" - JF_INTEGRATED_TURN_LISTEN_IP: "0.0.0.0" - JF_INTEGRATED_TURN_PORT_RANGE: "50000-50050" - JF_INTEGRATED_TCP_TURN_PORT: "49999" - JF_SERVER_API_TOKEN: "development" - JF_SIP_USED: "true" - JF_SIP_IP: "127.0.0.1" - JF_PORT: 5002 + FJ_HOST: "localhost:5002" + FJ_PORT: 5002 + FJ_SERVER_API_TOKEN: "development" + FJ_COMPONENTS_USED: "file hls rtsp sip recording" + FJ_WEBRTC_TURN_IP: "${INTEGRATED_TURN_IP:-127.0.0.1}" + FJ_WEBRTC_TURN_LISTEN_IP: "0.0.0.0" + FJ_WEBRTC_TURN_PORT_RANGE: "50000-50050" + FJ_WEBRTC_TURN_TCP_PORT: "49999" + FJ_SIP_IP: "127.0.0.1" ports: - "5002:5002" - "49999:49999" diff --git a/docker-compose-test.yaml b/docker-compose-test.yaml index 85233b5..95f418c 100644 --- a/docker-compose-test.yaml +++ b/docker-compose-test.yaml @@ -1,5 +1,3 @@ -version: "3" - services: test: image: membraneframeworklabs/docker_membrane:v2.2.0 @@ -11,14 +9,14 @@ services: ports: - "4000:4000" depends_on: - jellyfish: + fishjam: condition: service_healthy - jellyfish: + fishjam: extends: file: docker-compose-dev.yaml - service: jellyfish + service: fishjam environment: - - JF_HOST=jellyfish:5002 + - FJ_HOST=fishjam:5002 volumes: - - ./test/fixtures:/app/jellyfish_resources/file_component_sources + - ./test/fixtures:/app/fishjam_resources/file_component_sources diff --git a/examples/server_socket.exs b/examples/server_socket.exs index 2ff3361..d5ffb1d 100644 --- a/examples/server_socket.exs +++ b/examples/server_socket.exs @@ -1,6 +1,6 @@ Mix.install( [ - {:jellyfish_server_sdk, path: __DIR__ |> Path.join("..") |> Path.expand()} + {:fishjam_server_sdk, path: __DIR__ |> Path.join("..") |> Path.expand()} ], force: true ) @@ -9,14 +9,14 @@ server_address = "localhost:5002" server_api_token = "development" {:ok, notifier} = - Jellyfish.WSNotifier.start(server_address: server_address, server_api_token: server_api_token) + Fishjam.WSNotifier.start(server_address: server_address, server_api_token: server_api_token) -{:ok, _rooms} = Jellyfish.WSNotifier.subscribe_server_notifications(notifier, :all) -:ok = Jellyfish.WSNotifier.subscribe_metrics(notifier) +{:ok, _rooms} = Fishjam.WSNotifier.subscribe_server_notifications(notifier, :all) +:ok = Fishjam.WSNotifier.subscribe_metrics(notifier) receive_notification = fn receive_notification -> receive do - {:jellyfish, event} -> + {:fishjam, event} -> IO.inspect(event, label: :event) after 150_000 -> diff --git a/lib/jellyfish/client.ex b/lib/jellyfish/client.ex index a97716f..b15a17b 100644 --- a/lib/jellyfish/client.ex +++ b/lib/jellyfish/client.ex @@ -1,11 +1,11 @@ -defmodule Jellyfish.Client do +defmodule Fishjam.Client do @moduledoc """ - Defines a `t:Jellyfish.Client.t/0`. + Defines a `t:Fishjam.Client.t/0`. By default, Mint adapter for [Tesla](https://github.com/elixir-tesla/tesla) is used to make HTTP requests, but it can be changed: ``` # config.exs - config :jellyfish_server_sdk, tesla_adapter: Tesla.Adapter.Hackney + config :fishjam_server_sdk, tesla_adapter: Tesla.Adapter.Hackney # mix.exs defp deps do @@ -17,7 +17,7 @@ defmodule Jellyfish.Client do For the list of supported Tesla adapters refer to [Tesla docs](https://hexdocs.pm/tesla/readme.html#adapters). """ - alias Jellyfish.Utils + alias Fishjam.Utils @enforce_keys [ :http_client @@ -29,19 +29,19 @@ defmodule Jellyfish.Client do } @typedoc """ - Options needed to open connection to Jellyfish server. + Options needed to open connection to Fishjam server. - * `:server_address` - address of the Jellyfish server instance. + * `:server_address` - address of the Fishjam server instance. * `:server_api_token` - token used for authorizing HTTP requests and WebSocket connection. - It's the same token as the one configured in Jellyfish. + It's the same token as the one configured in Fishjam. * `:secure?` - if `true`, use HTTPS and WSS instead of HTTP and WS, `false` by default. When an option is not explicily passed, value set in `config.exs` is used: ``` # in config.exs - config :jellyfish_server_sdk, + config :fishjam_server_sdk, server_address: "localhost:5002", - server_api_token: "your-jellyfish-token", + server_api_token: "your-fishjam-token", secure?: true ``` """ @@ -52,7 +52,7 @@ defmodule Jellyfish.Client do ] @doc """ - Creates a new instance of `t:Jellyfish.Client.t/0`. + Creates a new instance of `t:Fishjam.Client.t/0`. For information about options, see `t:connection_options/0`. """ @@ -60,7 +60,7 @@ defmodule Jellyfish.Client do def new(opts \\ []) do {address, api_token, secure?} = Utils.get_options_or_defaults(opts) address = if secure?, do: "https://#{address}", else: "http://#{address}" - adapter = Application.get_env(:jellyfish_server_sdk, :tesla_adapter, Tesla.Adapter.Mint) + adapter = Application.get_env(:fishjam_server_sdk, :tesla_adapter, Tesla.Adapter.Mint) middleware = [ {Tesla.Middleware.BaseUrl, address}, @@ -74,11 +74,11 @@ defmodule Jellyfish.Client do end @doc """ - Updates Jellyfish address. + Updates Fishjam address. - When running Jellyfish in a cluster, user has to - manually update Jellyfish address after creating a room. - See also `Jellyfish.Room.create/2`. + When running Fishjam in a cluster, user has to + manually update Fishjam address after creating a room. + See also `Fishjam.Room.create/2`. """ @spec update_address(t(), String.t()) :: t() def update_address(client, new_address) do diff --git a/lib/jellyfish/component.ex b/lib/jellyfish/component.ex index 8467f76..71ca484 100644 --- a/lib/jellyfish/component.ex +++ b/lib/jellyfish/component.ex @@ -1,14 +1,14 @@ -defmodule Jellyfish.Component do +defmodule Fishjam.Component do @moduledoc """ - Defines `t:Jellyfish.Component.t/0`. + Defines `t:Fishjam.Component.t/0`. Component is a server-side entity that can publish, subscribe to and process tracks. - For more information refer to [Jellyfish documentation](https://jellyfish-dev.github.io/jellyfish-docs/introduction/basic_concepts). + For more information refer to [Fishjam documentation](https://fishjam-dev.github.io/fishjam-docs/introduction/basic_concepts). """ - alias Jellyfish.Component.{File, HLS, Recording, RTSP, SIP} - alias Jellyfish.Exception.StructureError - alias Jellyfish.Track + alias Fishjam.Component.{File, HLS, Recording, RTSP, SIP} + alias Fishjam.Exception.StructureError + alias Fishjam.Track @enforce_keys [ :id, diff --git a/lib/jellyfish/component/deserializer.ex b/lib/jellyfish/component/deserializer.ex index f104ce1..5a9b547 100644 --- a/lib/jellyfish/component/deserializer.ex +++ b/lib/jellyfish/component/deserializer.ex @@ -1,4 +1,4 @@ -defmodule Jellyfish.Component.Deserializer do +defmodule Fishjam.Component.Deserializer do @moduledoc false @callback properties_from_json(map()) :: map() end diff --git a/lib/jellyfish/component/file.ex b/lib/jellyfish/component/file.ex index 990d143..e111947 100644 --- a/lib/jellyfish/component/file.ex +++ b/lib/jellyfish/component/file.ex @@ -1,12 +1,12 @@ -defmodule Jellyfish.Component.File do +defmodule Fishjam.Component.File do @moduledoc """ Options for the File component. - For the description of these options refer to [Jellyfish - documentation](https://jellyfish-dev.github.io/jellyfish-docs/getting_started/components/file). + For the description of these options refer to [Fishjam + documentation](https://fishjam-dev.github.io/fishjam-docs/getting_started/components/file). """ - @behaviour Jellyfish.Component.Deserializer + @behaviour Fishjam.Component.Deserializer @enforce_keys [:file_path] defstruct @enforce_keys ++ [framerate: nil] diff --git a/lib/jellyfish/component/hls.ex b/lib/jellyfish/component/hls.ex index 65e2301..438dc29 100644 --- a/lib/jellyfish/component/hls.ex +++ b/lib/jellyfish/component/hls.ex @@ -1,12 +1,12 @@ -defmodule Jellyfish.Component.HLS do +defmodule Fishjam.Component.HLS do @moduledoc """ Options for the HLS component. - For the description of these options refer to [Jellyfish - documentation](https://jellyfish-dev.github.io/jellyfish-docs/getting_started/components/hls). + For the description of these options refer to [Fishjam + documentation](https://fishjam-dev.github.io/fishjam-docs/getting_started/components/hls). """ - @behaviour Jellyfish.Component.Deserializer + @behaviour Fishjam.Component.Deserializer @type credentials :: %{ access_key_id: String.t(), diff --git a/lib/jellyfish/component/recording.ex b/lib/jellyfish/component/recording.ex index c72ea06..0e8dd75 100644 --- a/lib/jellyfish/component/recording.ex +++ b/lib/jellyfish/component/recording.ex @@ -1,14 +1,14 @@ -defmodule Jellyfish.Component.Recording do +defmodule Fishjam.Component.Recording do @moduledoc """ Options for the recording component. - For the description of these options refer to [Jellyfish - documentation](https://jellyfish-dev.github.io/jellyfish-docs/getting_started/components/recording). + For the description of these options refer to [Fishjam + documentation](https://fishjam-dev.github.io/fishjam-docs/getting_started/components/recording). """ - @behaviour Jellyfish.Component.Deserializer + @behaviour Fishjam.Component.Deserializer - alias Jellyfish.Component.HLS + alias Fishjam.Component.HLS @enforce_keys [] defstruct @enforce_keys ++ [credentials: nil, path_prefix: nil, subscribe_mode: :auto] diff --git a/lib/jellyfish/component/rtsp.ex b/lib/jellyfish/component/rtsp.ex index fe4a082..4200632 100644 --- a/lib/jellyfish/component/rtsp.ex +++ b/lib/jellyfish/component/rtsp.ex @@ -1,12 +1,12 @@ -defmodule Jellyfish.Component.RTSP do +defmodule Fishjam.Component.RTSP do @moduledoc """ Options for the RTSP component. - For the description of these options refer to [Jellyfish - documentation](https://jellyfish-dev.github.io/jellyfish-docs/getting_started/components/rtsp). + For the description of these options refer to [Fishjam + documentation](https://fishjam-dev.github.io/fishjam-docs/getting_started/components/rtsp). """ - @behaviour Jellyfish.Component.Deserializer + @behaviour Fishjam.Component.Deserializer @enforce_keys [:source_uri] defstruct @enforce_keys ++ diff --git a/lib/jellyfish/component/sip.ex b/lib/jellyfish/component/sip.ex index 86cbcb4..892a45e 100644 --- a/lib/jellyfish/component/sip.ex +++ b/lib/jellyfish/component/sip.ex @@ -1,12 +1,12 @@ -defmodule Jellyfish.Component.SIP do +defmodule Fishjam.Component.SIP do @moduledoc """ Options for the SIP component. - For the description of these options refer to [Jellyfish - documentation](https://jellyfish-dev.github.io/jellyfish-docs/getting_started/components/sip). + For the description of these options refer to [Fishjam + documentation](https://fishjam-dev.github.io/fishjam-docs/getting_started/components/sip). """ - @behaviour Jellyfish.Component.Deserializer + @behaviour Fishjam.Component.Deserializer @enforce_keys [:registrar_credentials] defstruct @enforce_keys diff --git a/lib/jellyfish/exception.ex b/lib/jellyfish/exception.ex index 75fc349..10d20b6 100644 --- a/lib/jellyfish/exception.ex +++ b/lib/jellyfish/exception.ex @@ -1,4 +1,4 @@ -defmodule Jellyfish.Exception do +defmodule Fishjam.Exception do @moduledoc false defmodule StructureError do @@ -8,7 +8,7 @@ defmodule Jellyfish.Exception do def exception(structure) do msg = """ Received server response or notification with unexpected structure. - Make sure you are using correct combination of Jellyfish and SDK versions. + Make sure you are using correct combination of Fishjam and SDK versions. Passed structure: #{inspect(structure)} """ @@ -37,7 +37,7 @@ defmodule Jellyfish.Exception do def exception(_opts) do msg = """ Passed component options that doesn't match function spec. - Look closely on `Jellyfish.Room.add_component/3` spec. + Look closely on `Fishjam.Room.add_component/3` spec. """ %__MODULE__{message: msg} diff --git a/lib/jellyfish/health.ex b/lib/jellyfish/health.ex index 991f50d..f9bf9fa 100644 --- a/lib/jellyfish/health.ex +++ b/lib/jellyfish/health.ex @@ -1,18 +1,18 @@ -defmodule Jellyfish.Health do +defmodule Fishjam.Health do @moduledoc """ - Utilities for managing the health of Jellyfish instances. + Utilities for managing the health of Fishjam instances. ## Examples ``` - iex> client = Jellyfish.Client.new() - iex> assert {:ok, %Jellyfish.Health{ + iex> client = Fishjam.Client.new() + iex> assert {:ok, %Fishjam.Health{ ...> status: :up, - ...> }} = Jellyfish.Health.check(client) + ...> }} = Fishjam.Health.check(client) ``` """ - alias Jellyfish.{Client, Utils} - alias Jellyfish.Exception.StructureError + alias Fishjam.{Client, Utils} + alias Fishjam.Exception.StructureError @enforce_keys [ :status, @@ -22,19 +22,19 @@ defmodule Jellyfish.Health do defstruct @enforce_keys @typedoc """ - The status of Jellyfish or a specific service. + The status of Fishjam or a specific service. """ @type status :: :up | :down @typedoc """ - Stores a health report of Jellyfish. + Stores a health report of Fishjam. * `:status` - overall status * `:uptime` - uptime in seconds * `:distribution` - distribution health report: - `:enabled` - whether distribution is enabled - - `:node_status` - status of this Jellyfish's node - - `:nodes_in_cluster` - amount of nodes (including this Jellyfish's node) + - `:node_status` - status of this Fishjam's node + - `:nodes_in_cluster` - amount of nodes (including this Fishjam's node) in the distribution cluster """ @type t :: %__MODULE__{ @@ -48,7 +48,7 @@ defmodule Jellyfish.Health do } @doc """ - Perform a health check of Jellyfish. + Perform a health check of Fishjam. """ @spec check(Client.t()) :: {:ok, t()} | {:error, atom() | String.t()} def check(client) do diff --git a/lib/jellyfish/metrics_report.ex b/lib/jellyfish/metrics_report.ex index fa52a7a..31d3a09 100644 --- a/lib/jellyfish/metrics_report.ex +++ b/lib/jellyfish/metrics_report.ex @@ -1,4 +1,4 @@ -defmodule Jellyfish.MetricsReport do +defmodule Fishjam.MetricsReport do @moduledoc nil @enforce_keys [:metrics] @@ -11,7 +11,7 @@ defmodule Jellyfish.MetricsReport do Here is a sample report: ``` - %Jellyfish.MetricsReport{ + %Fishjam.MetricsReport{ metrics: %{ "inbound-rtp.frames" => 406, "inbound-rtp.keyframes" => 9, diff --git a/lib/jellyfish/notification.ex b/lib/jellyfish/notification.ex index 1720d53..6cc3df1 100644 --- a/lib/jellyfish/notification.ex +++ b/lib/jellyfish/notification.ex @@ -1,8 +1,8 @@ -defmodule Jellyfish.Notification do +defmodule Fishjam.Notification do @moduledoc false - alias Jellyfish.{Component, Peer, Room, Track} - alias Jellyfish.ServerMessage.{TrackAdded, TrackMetadataUpdated, TrackRemoved} + alias Fishjam.{Component, Peer, Room, Track} + alias Fishjam.ServerMessage.{TrackAdded, TrackMetadataUpdated, TrackRemoved} defmodule RoomCreated do @moduledoc nil diff --git a/lib/jellyfish/peer.ex b/lib/jellyfish/peer.ex index 64bd8ff..e7cb0ee 100644 --- a/lib/jellyfish/peer.ex +++ b/lib/jellyfish/peer.ex @@ -1,15 +1,15 @@ -defmodule Jellyfish.Peer do +defmodule Fishjam.Peer do @moduledoc """ - Defines `t:Jellyfish.Peer.t/0`. + Defines `t:Fishjam.Peer.t/0`. Peer is an entity that connects to the server to publish, subscribe to or publish and subscribe to tracks published by components and other peers. - For more information refer to [Jellyfish documentation](https://jellyfish-dev.github.io/jellyfish-docs/introduction/basic_concepts). + For more information refer to [Fishjam documentation](https://fishjam-dev.github.io/fishjam-docs/introduction/basic_concepts). """ - alias Jellyfish.Exception.StructureError - alias Jellyfish.Peer.WebRTC - alias Jellyfish.Track + alias Fishjam.Exception.StructureError + alias Fishjam.Peer.WebRTC + alias Fishjam.Track @enforce_keys [ :id, diff --git a/lib/jellyfish/peer/webrtc.ex b/lib/jellyfish/peer/webrtc.ex index fb07260..80d8682 100644 --- a/lib/jellyfish/peer/webrtc.ex +++ b/lib/jellyfish/peer/webrtc.ex @@ -1,9 +1,9 @@ -defmodule Jellyfish.Peer.WebRTC do +defmodule Fishjam.Peer.WebRTC do @moduledoc """ Options for the WebRTC peer. - For the description of these options refer to [Jellyfish - documentation](https://jellyfish-dev.github.io/jellyfish-docs/getting_started/peers/webrtc). + For the description of these options refer to [Fishjam + documentation](https://fishjam-dev.github.io/fishjam-docs/getting_started/peers/webrtc). """ @enforce_keys [] diff --git a/lib/jellyfish/recording.ex b/lib/jellyfish/recording.ex index ce741e0..057cd6c 100644 --- a/lib/jellyfish/recording.ex +++ b/lib/jellyfish/recording.ex @@ -1,20 +1,20 @@ -defmodule Jellyfish.Recording do +defmodule Fishjam.Recording do @moduledoc """ Utilites for manipulating the recordings. ## Examples ``` - iex> client = Jellyfish.Client.new() - iex> assert {:ok, []} = Jellyfish.Recording.get_list(client) - iex> assert {:error, "Request failed: Recording not found"} = Jellyfish.Recording.delete(client, "not_exisiting_recording") + iex> client = Fishjam.Client.new() + iex> assert {:ok, []} = Fishjam.Recording.get_list(client) + iex> assert {:error, "Request failed: Recording not found"} = Fishjam.Recording.delete(client, "not_exisiting_recording") ``` """ - alias Jellyfish.{Client, Utils} + alias Fishjam.{Client, Utils} alias Tesla.Env @typedoc """ - Id for the recording, unique within Jellyfish instance. + Id for the recording, unique within Fishjam instance. """ @type id :: String.t() diff --git a/lib/jellyfish/room.ex b/lib/jellyfish/room.ex index af5a625..6618b91 100644 --- a/lib/jellyfish/room.ex +++ b/lib/jellyfish/room.ex @@ -1,42 +1,42 @@ -defmodule Jellyfish.Room do +defmodule Fishjam.Room do @moduledoc """ Utilities for manipulating the rooms. ## Examples ``` - iex> client = Jellyfish.Client.new() - iex> assert {:ok, %Jellyfish.Room{ + iex> client = Fishjam.Client.new() + iex> assert {:ok, %Fishjam.Room{ ...> components: [], ...> config: %{max_peers: 10, video_codec: nil}, ...> peers: [] - ...> } = room, _jellyfish_address} = Jellyfish.Room.create(client, max_peers: 10) - iex> room == %Jellyfish.Room{ + ...> } = room, _fishjam_address} = Fishjam.Room.create(client, max_peers: 10) + iex> room == %Fishjam.Room{ ...> id: room.id, ...> components: [], ...> config: %{max_peers: 10, video_codec: nil}, ...> peers: []} true - iex> assert {:ok, %{peer: %Jellyfish.Peer{ + iex> assert {:ok, %{peer: %Fishjam.Peer{ ...> status: :disconnected, - ...> type: Jellyfish.Peer.WebRTC, + ...> type: Fishjam.Peer.WebRTC, ...> tracks: [] - ...> } = peer}} = Jellyfish.Room.add_peer(client, room.id, Jellyfish.Peer.WebRTC) - iex> %Jellyfish.Peer{ + ...> } = peer}} = Fishjam.Room.add_peer(client, room.id, Fishjam.Peer.WebRTC) + iex> %Fishjam.Peer{ ...> id: peer.id, ...> status: :disconnected, - ...> type: Jellyfish.Peer.WebRTC, + ...> type: Fishjam.Peer.WebRTC, ...> tracks: [], ...> metadata: nil} == peer true - iex> :ok = Jellyfish.Room.delete(client, room.id) + iex> :ok = Fishjam.Room.delete(client, room.id) :ok ``` """ alias Tesla.Env - alias Jellyfish.Component.{File, HLS, Recording, RTSP, SIP} - alias Jellyfish.{Client, Component, Peer, Utils} - alias Jellyfish.Exception.StructureError + alias Fishjam.Component.{File, HLS, Recording, RTSP, SIP} + alias Fishjam.{Client, Component, Peer, Utils} + alias Fishjam.Exception.StructureError @s3_keys [:access_key_id, :secret_access_key, :region, :bucket] @subscribe_modes [:auto, :manual] @@ -50,24 +50,24 @@ defmodule Jellyfish.Room do defstruct @enforce_keys @typedoc """ - Id of the room, unique within Jellyfish instance. + Id of the room, unique within Fishjam instance. """ @type id :: String.t() @typedoc """ - Id of the track, unique within Jellyfish instance. + Id of the track, unique within Fishjam instance. """ @type track_id :: String.t() @typedoc """ - Peer token, created by Jellyfish. Required by client application to open connection to Jellyfish. + Peer token, created by Fishjam. Required by client application to open connection to Fishjam. """ @type peer_token :: String.t() @typedoc """ - Jellyfish response to adding a peer to room. It consists of: + Fishjam response to adding a peer to room. It consists of: * peer structure - * token used for authentication when connecting through websocket to jellyfish + * token used for authentication when connecting through websocket to fishjam * ws_url that is a websocket adress to which this specific peer have to connect """ @type peer_create_response :: %{peer: Peer.t(), token: peer_token(), ws_url: String.t()} @@ -133,10 +133,10 @@ defmodule Jellyfish.Room do @doc """ Creates a new room. - Returns an address of Jellyfish where the room was created. - When running Jellyfish in a cluster, this address might be different + Returns an address of Fishjam where the room was created. + When running Fishjam in a cluster, this address might be different than the one used in the initial call. - Therefore, it is important to call `Jellyfish.Client.update_address/2` + Therefore, it is important to call `Fishjam.Client.update_address/2` before subsequent operations like adding peers or components. """ @spec create(Client.t(), options()) :: {:ok, t(), String.t()} | {:error, atom() | String.t()} @@ -151,9 +151,9 @@ defmodule Jellyfish.Room do "peerDisconnectedTimeout" => Keyword.get(opts, :peer_disconnected_timeout) }), room_json <- Map.fetch!(data, "room"), - jellyfish_address <- Map.fetch!(data, "jellyfish_address"), + fishjam_address <- Map.fetch!(data, "fishjam_address"), result <- from_json(room_json) do - {:ok, result, jellyfish_address} + {:ok, result, fishjam_address} end end diff --git a/lib/jellyfish/track.ex b/lib/jellyfish/track.ex index a192b67..fe709a1 100644 --- a/lib/jellyfish/track.ex +++ b/lib/jellyfish/track.ex @@ -1,11 +1,11 @@ -defmodule Jellyfish.Track do +defmodule Fishjam.Track do @moduledoc """ - Defines `t:Jellyfish.Track.t/0`. + Defines `t:Fishjam.Track.t/0`. It represents a single media track, either audio or video. """ - alias Jellyfish.Exception.StructureError + alias Fishjam.Exception.StructureError @enforce_keys [ :id, diff --git a/lib/jellyfish/utils.ex b/lib/jellyfish/utils.ex index 88eec3e..a230d82 100644 --- a/lib/jellyfish/utils.ex +++ b/lib/jellyfish/utils.ex @@ -1,8 +1,8 @@ -defmodule Jellyfish.Utils do +defmodule Fishjam.Utils do @moduledoc false - alias Jellyfish.Client - alias Jellyfish.Exception.{OptionsError, ProtocolPrefixError, StructureError} + alias Fishjam.Client + alias Fishjam.Exception.{OptionsError, ProtocolPrefixError, StructureError} alias Tesla.Env @protocol_prefixes ["http://", "https://", "ws://", "wss://"] @@ -11,13 +11,13 @@ defmodule Jellyfish.Utils do {String.t(), String.t(), boolean()} def get_options_or_defaults(opts) do server_address = - opts[:server_address] || Application.fetch_env!(:jellyfish_server_sdk, :server_address) + opts[:server_address] || Application.fetch_env!(:fishjam_server_sdk, :server_address) server_api_token = - opts[:server_api_token] || Application.fetch_env!(:jellyfish_server_sdk, :server_api_token) + opts[:server_api_token] || Application.fetch_env!(:fishjam_server_sdk, :server_api_token) secure? = - Keyword.get(opts, :secure?, Application.get_env(:jellyfish_server_sdk, :secure?, false)) + Keyword.get(opts, :secure?, Application.get_env(:fishjam_server_sdk, :secure?, false)) check_prefixes(server_address) diff --git a/lib/jellyfish/webhook_notifier.ex b/lib/jellyfish/webhook_notifier.ex index cde5a73..50ec1e0 100644 --- a/lib/jellyfish/webhook_notifier.ex +++ b/lib/jellyfish/webhook_notifier.ex @@ -1,11 +1,11 @@ -defmodule Jellyfish.WebhookNotifier do +defmodule Fishjam.WebhookNotifier do @moduledoc """ - Module defining a function allowing decoding received webhook notification from jellyfish to notification structs. + Module defining a function allowing decoding received webhook notification from fishjam to notification structs. """ require Logger - alias Jellyfish.{Notification, ServerMessage} + alias Fishjam.{Notification, ServerMessage} @doc """ Decodes received webhook to notification structs. @@ -16,12 +16,12 @@ defmodule Jellyfish.WebhookNotifier do ...> 56, 98, 18, 36, 99, 55, 50, 51, 54, 53, 56, 55, 45, 53, 100, 102, 56, 45, 52, ...> 98, 52, 49, 45, 98, 54, 101, 52, 45, 50, 54, 56, 101, 55, 49, 49, 51, 51, 101, ...> 101, 50>> - ...> |> Jellyfish.WebhookNotifier.receive() - %Jellyfish.Notification.PeerConnected{ + ...> |> Fishjam.WebhookNotifier.receive() + %Fishjam.Notification.PeerConnected{ room_id: "fbf4190c-5c76-415c-8939-52c6ed20868b", peer_id: "c7236587-5df8-4b41-b6e4-268e71133ee2" } - iex> Jellyfish.WebhookNotifier.receive(<<>>) + iex> Fishjam.WebhookNotifier.receive(<<>>) {:error, :unknown_server_message} ``` """ @@ -33,7 +33,7 @@ defmodule Jellyfish.WebhookNotifier do %ServerMessage{content: nil, __unknown_fields__: _binary} -> Logger.warning( - "Can't decode received notification. This probably means that jellyfish is using a different version of protobuffs." + "Can't decode received notification. This probably means that fishjam is using a different version of protobuffs." ) {:error, :unknown_server_message} diff --git a/lib/jellyfish/ws_notifier.ex b/lib/jellyfish/ws_notifier.ex index 98ce50c..00a88c7 100644 --- a/lib/jellyfish/ws_notifier.ex +++ b/lib/jellyfish/ws_notifier.ex @@ -1,25 +1,25 @@ -defmodule Jellyfish.WSNotifier do +defmodule Fishjam.WSNotifier do @moduledoc """ Module defining a process responsible for establishing - WebSocket connection and receiving events from Jellyfish server. + WebSocket connection and receiving events from Fishjam server. - First, [configure the connection options](README.md#jellyfish-connection-configuration). + First, [configure the connection options](README.md#fishjam-connection-configuration). ``` # Start the Notifier - iex> {:ok, notifier} = Jellyfish.WSNotifier.start() + iex> {:ok, notifier} = Fishjam.WSNotifier.start() {:ok, #PID<0.301.0>} ``` ``` # Subscribe current process to server notifications. - iex> :ok = Jellyfish.WSNotifier.subscribe_server_notifications(notifier) + iex> :ok = Fishjam.WSNotifier.subscribe_server_notifications(notifier) - # here add a room and a peer using functions from `Jellyfish.Room` module + # here add a room and a peer using functions from `Fishjam.Room` module # you should receive a notification after the peer established connection iex> flush() - {:jellyfish, %Jellyfish.Notification.PeerConnected{ + {:fishjam, %Fishjam.Notification.PeerConnected{ room_id: "21604fbe-8ac8-44e6-8474-98b5f50f1863", peer_id: "ae07f94e-0887-44c3-81d5-bfa9eac96252" }} @@ -28,7 +28,7 @@ defmodule Jellyfish.WSNotifier do When starting the Notifier, you can provide the name under which the process will be registered. ``` - iex> {:ok, notifier} = Jellyfish.WSNotifier.start_link(name: Jellyfish.WSNotifier) + iex> {:ok, notifier} = Fishjam.WSNotifier.start_link(name: Fishjam.WSNotifier) ``` """ @@ -37,10 +37,10 @@ defmodule Jellyfish.WSNotifier do require Logger - alias Jellyfish.Utils - alias Jellyfish.{Notification, ServerMessage} + alias Fishjam.Utils + alias Fishjam.{Notification, ServerMessage} - alias Jellyfish.ServerMessage.{ + alias Fishjam.ServerMessage.{ Authenticated, AuthRequest, MetricsReport, @@ -57,7 +57,7 @@ defmodule Jellyfish.WSNotifier do @type notifier() :: GenServer.server() @typedoc """ - Connection options used to connect to Jellyfish server. + Connection options used to connect to Fishjam server. """ @type options() :: [ server_address: String.t(), @@ -67,7 +67,7 @@ defmodule Jellyfish.WSNotifier do ] @doc """ - Starts the Notifier process and connects to Jellyfish. + Starts the Notifier process and connects to Fishjam. Acts like `start/1` but links to the calling process. @@ -79,11 +79,11 @@ defmodule Jellyfish.WSNotifier do end @doc """ - Starts the Notifier process and connects to Jellyfish. + Starts the Notifier process and connects to Fishjam. To learn how to receive notifications, see `subscribe/3`. - For information about options, see `t:Jellyfish.Client.connection_options/0`. + For information about options, see `t:Fishjam.Client.connection_options/0`. """ @spec start(options()) :: {:ok, pid()} | {:error, term()} def start(opts \\ []) do @@ -93,16 +93,16 @@ defmodule Jellyfish.WSNotifier do @doc """ Subscribes the process to receive server notifications from all the rooms. - Notifications are sent to the process in a form of `{:jellyfish, msg}`, - where `msg` is one of structs defined under "Jellyfish.Notification" section in the docs, - for example `{:jellyfish, %Jellyfish.Notification.RoomCrashed{room_id: "some_id"}}`. + Notifications are sent to the process in a form of `{:fishjam, msg}`, + where `msg` is one of structs defined under "Fishjam.Notification" section in the docs, + for example `{:fishjam, %Fishjam.Notification.RoomCrashed{room_id: "some_id"}}`. """ @spec subscribe_server_notifications(notifier()) :: :ok | {:error, atom()} def subscribe_server_notifications(notifier) do WebSockex.cast(notifier, {:subscribe_server_notifications, self()}) receive do - {:jellyfish, {:subscribe_answer, :ok}} -> :ok + {:fishjam, {:subscribe_answer, :ok}} -> :ok {:error, _reason} = error -> error after @subscribe_timeout -> {:error, :timeout} @@ -112,8 +112,8 @@ defmodule Jellyfish.WSNotifier do @doc """ Subscribes the process to the WebRTC metrics from all the rooms. - Metrics are periodically sent to the process in a form of `{:jellyfish, metrics_report}`, - where `metrics_report` is the `Jellyfish.MetricsReport` struct. + Metrics are periodically sent to the process in a form of `{:fishjam, metrics_report}`, + where `metrics_report` is the `Fishjam.MetricsReport` struct. """ @spec subscribe_metrics(notifier()) :: :ok | {:error, :timeout} @@ -121,7 +121,7 @@ defmodule Jellyfish.WSNotifier do WebSockex.cast(notifier, {:subscribe_metrics, self()}) receive do - {:jellyfish, {:subscribe_answer, :ok}} -> :ok + {:fishjam, {:subscribe_answer, :ok}} -> :ok after @subscribe_timeout -> {:error, :timeout} end @@ -146,7 +146,7 @@ defmodule Jellyfish.WSNotifier do %ServerMessage{content: nil, __unknown_fields__: _binary} -> Logger.warning( - "Can't decode received notification. This probably means that jellyfish is using a different version of protobuffs." + "Can't decode received notification. This probably means that fishjam is using a different version of protobuffs." ) {:ok, state} @@ -166,7 +166,7 @@ defmodule Jellyfish.WSNotifier do @impl true def terminate({:remote, 1000, "invalid token"}, state) do - send(state.caller_pid, {:jellyfish, :invalid_token}) + send(state.caller_pid, {:fishjam, :invalid_token}) end @impl true @@ -201,10 +201,10 @@ defmodule Jellyfish.WSNotifier do ]), :ok <- WebSockex.send_frame(ws, {:binary, auth_msg}) do receive do - {:jellyfish, :authenticated} -> + {:fishjam, :authenticated} -> {:ok, ws} - {:jellyfish, :invalid_token} -> + {:fishjam, :invalid_token} -> {:error, :invalid_token} after @auth_timeout -> @@ -218,7 +218,7 @@ defmodule Jellyfish.WSNotifier do end defp handle_notification(%Authenticated{}, state) do - send(state.caller_pid, {:jellyfish, :authenticated}) + send(state.caller_pid, {:fishjam, :authenticated}) {:ok, state} end @@ -234,7 +234,7 @@ defmodule Jellyfish.WSNotifier do pending_subscriptions |> Enum.reduce(state, fn pid, state -> - send(pid, {:jellyfish, {:subscribe_answer, :ok}}) + send(pid, {:fishjam, {:subscribe_answer, :ok}}) update_in(state.subscriptions[event_type], &MapSet.put(&1, pid)) end) end @@ -243,11 +243,11 @@ defmodule Jellyfish.WSNotifier do end defp handle_notification(%MetricsReport{metrics: metrics}, state) do - notification = %Jellyfish.MetricsReport{metrics: Jason.decode!(metrics)} + notification = %Fishjam.MetricsReport{metrics: Jason.decode!(metrics)} state.subscriptions.metrics |> Enum.each(fn pid -> - send(pid, {:jellyfish, notification}) + send(pid, {:fishjam, notification}) end) {:ok, state} @@ -255,7 +255,7 @@ defmodule Jellyfish.WSNotifier do defp handle_notification(%{room_id: _room_id} = message, state) do state.subscriptions.server_notification - |> Enum.each(&send(&1, {:jellyfish, Notification.to_notification(message)})) + |> Enum.each(&send(&1, {:fishjam, Notification.to_notification(message)})) {:ok, state} end diff --git a/lib/mix/tasks/test_with_docker.ex b/lib/mix/tasks/test_with_docker.ex index 164254a..dd67fe4 100644 --- a/lib/mix/tasks/test_with_docker.ex +++ b/lib/mix/tasks/test_with_docker.ex @@ -1,6 +1,6 @@ defmodule Mix.Tasks.TestWithDocker do @moduledoc """ - Test the SDK with Jellyfish running in Docker + Test the SDK with Fishjam running in Docker """ use Mix.Task diff --git a/lib/protos/jellyfish/server_notifications.pb.ex b/lib/protos/fishjam/server_notifications.pb.ex similarity index 68% rename from lib/protos/jellyfish/server_notifications.pb.ex rename to lib/protos/fishjam/server_notifications.pb.ex index 5e59913..e44c852 100644 --- a/lib/protos/jellyfish/server_notifications.pb.ex +++ b/lib/protos/fishjam/server_notifications.pb.ex @@ -1,4 +1,4 @@ -defmodule Jellyfish.ServerMessage.EventType do +defmodule Fishjam.ServerMessage.EventType do @moduledoc false use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -8,7 +8,7 @@ defmodule Jellyfish.ServerMessage.EventType do field :EVENT_TYPE_METRICS, 2 end -defmodule Jellyfish.ServerMessage.TrackType do +defmodule Fishjam.ServerMessage.TrackType do @moduledoc false use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -18,7 +18,7 @@ defmodule Jellyfish.ServerMessage.TrackType do field :TRACK_TYPE_AUDIO, 2 end -defmodule Jellyfish.ServerMessage.RoomCrashed do +defmodule Fishjam.ServerMessage.RoomCrashed do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -26,7 +26,7 @@ defmodule Jellyfish.ServerMessage.RoomCrashed do field :room_id, 1, type: :string, json_name: "roomId" end -defmodule Jellyfish.ServerMessage.PeerAdded do +defmodule Fishjam.ServerMessage.PeerAdded do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -35,7 +35,7 @@ defmodule Jellyfish.ServerMessage.PeerAdded do field :peer_id, 2, type: :string, json_name: "peerId" end -defmodule Jellyfish.ServerMessage.PeerDeleted do +defmodule Fishjam.ServerMessage.PeerDeleted do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -44,7 +44,7 @@ defmodule Jellyfish.ServerMessage.PeerDeleted do field :peer_id, 2, type: :string, json_name: "peerId" end -defmodule Jellyfish.ServerMessage.PeerConnected do +defmodule Fishjam.ServerMessage.PeerConnected do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -53,7 +53,7 @@ defmodule Jellyfish.ServerMessage.PeerConnected do field :peer_id, 2, type: :string, json_name: "peerId" end -defmodule Jellyfish.ServerMessage.PeerDisconnected do +defmodule Fishjam.ServerMessage.PeerDisconnected do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -62,7 +62,7 @@ defmodule Jellyfish.ServerMessage.PeerDisconnected do field :peer_id, 2, type: :string, json_name: "peerId" end -defmodule Jellyfish.ServerMessage.PeerCrashed do +defmodule Fishjam.ServerMessage.PeerCrashed do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -72,7 +72,7 @@ defmodule Jellyfish.ServerMessage.PeerCrashed do field :reason, 3, type: :string end -defmodule Jellyfish.ServerMessage.ComponentCrashed do +defmodule Fishjam.ServerMessage.ComponentCrashed do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -81,13 +81,13 @@ defmodule Jellyfish.ServerMessage.ComponentCrashed do field :component_id, 2, type: :string, json_name: "componentId" end -defmodule Jellyfish.ServerMessage.Authenticated do +defmodule Fishjam.ServerMessage.Authenticated do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" end -defmodule Jellyfish.ServerMessage.AuthRequest do +defmodule Fishjam.ServerMessage.AuthRequest do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -95,29 +95,23 @@ defmodule Jellyfish.ServerMessage.AuthRequest do field :token, 1, type: :string end -defmodule Jellyfish.ServerMessage.SubscribeRequest do +defmodule Fishjam.ServerMessage.SubscribeRequest do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" - field :event_type, 1, - type: Jellyfish.ServerMessage.EventType, - json_name: "eventType", - enum: true + field :event_type, 1, type: Fishjam.ServerMessage.EventType, json_name: "eventType", enum: true end -defmodule Jellyfish.ServerMessage.SubscribeResponse do +defmodule Fishjam.ServerMessage.SubscribeResponse do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" - field :event_type, 1, - type: Jellyfish.ServerMessage.EventType, - json_name: "eventType", - enum: true + field :event_type, 1, type: Fishjam.ServerMessage.EventType, json_name: "eventType", enum: true end -defmodule Jellyfish.ServerMessage.RoomCreated do +defmodule Fishjam.ServerMessage.RoomCreated do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -125,7 +119,7 @@ defmodule Jellyfish.ServerMessage.RoomCreated do field :room_id, 1, type: :string, json_name: "roomId" end -defmodule Jellyfish.ServerMessage.RoomDeleted do +defmodule Fishjam.ServerMessage.RoomDeleted do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -133,7 +127,7 @@ defmodule Jellyfish.ServerMessage.RoomDeleted do field :room_id, 1, type: :string, json_name: "roomId" end -defmodule Jellyfish.ServerMessage.MetricsReport do +defmodule Fishjam.ServerMessage.MetricsReport do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -141,7 +135,7 @@ defmodule Jellyfish.ServerMessage.MetricsReport do field :metrics, 1, type: :string end -defmodule Jellyfish.ServerMessage.HlsPlayable do +defmodule Fishjam.ServerMessage.HlsPlayable do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -150,7 +144,7 @@ defmodule Jellyfish.ServerMessage.HlsPlayable do field :component_id, 2, type: :string, json_name: "componentId" end -defmodule Jellyfish.ServerMessage.HlsUploaded do +defmodule Fishjam.ServerMessage.HlsUploaded do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -158,7 +152,7 @@ defmodule Jellyfish.ServerMessage.HlsUploaded do field :room_id, 1, type: :string, json_name: "roomId" end -defmodule Jellyfish.ServerMessage.HlsUploadCrashed do +defmodule Fishjam.ServerMessage.HlsUploadCrashed do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -166,7 +160,7 @@ defmodule Jellyfish.ServerMessage.HlsUploadCrashed do field :room_id, 1, type: :string, json_name: "roomId" end -defmodule Jellyfish.ServerMessage.PeerMetadataUpdated do +defmodule Fishjam.ServerMessage.PeerMetadataUpdated do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -176,17 +170,17 @@ defmodule Jellyfish.ServerMessage.PeerMetadataUpdated do field :metadata, 3, type: :string end -defmodule Jellyfish.ServerMessage.Track do +defmodule Fishjam.ServerMessage.Track do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" field :id, 1, type: :string - field :type, 2, type: Jellyfish.ServerMessage.TrackType, enum: true + field :type, 2, type: Fishjam.ServerMessage.TrackType, enum: true field :metadata, 3, type: :string end -defmodule Jellyfish.ServerMessage.TrackAdded do +defmodule Fishjam.ServerMessage.TrackAdded do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -196,10 +190,10 @@ defmodule Jellyfish.ServerMessage.TrackAdded do field :room_id, 1, type: :string, json_name: "roomId" field :peer_id, 2, type: :string, json_name: "peerId", oneof: 0 field :component_id, 3, type: :string, json_name: "componentId", oneof: 0 - field :track, 4, type: Jellyfish.ServerMessage.Track + field :track, 4, type: Fishjam.ServerMessage.Track end -defmodule Jellyfish.ServerMessage.TrackRemoved do +defmodule Fishjam.ServerMessage.TrackRemoved do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -209,10 +203,10 @@ defmodule Jellyfish.ServerMessage.TrackRemoved do field :room_id, 1, type: :string, json_name: "roomId" field :peer_id, 2, type: :string, json_name: "peerId", oneof: 0 field :component_id, 3, type: :string, json_name: "componentId", oneof: 0 - field :track, 4, type: Jellyfish.ServerMessage.Track + field :track, 4, type: Fishjam.ServerMessage.Track end -defmodule Jellyfish.ServerMessage.TrackMetadataUpdated do +defmodule Fishjam.ServerMessage.TrackMetadataUpdated do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -222,10 +216,10 @@ defmodule Jellyfish.ServerMessage.TrackMetadataUpdated do field :room_id, 1, type: :string, json_name: "roomId" field :peer_id, 2, type: :string, json_name: "peerId", oneof: 0 field :component_id, 3, type: :string, json_name: "componentId", oneof: 0 - field :track, 4, type: Jellyfish.ServerMessage.Track + field :track, 4, type: Fishjam.ServerMessage.Track end -defmodule Jellyfish.ServerMessage do +defmodule Fishjam.ServerMessage do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -233,101 +227,101 @@ defmodule Jellyfish.ServerMessage do oneof :content, 0 field :room_crashed, 1, - type: Jellyfish.ServerMessage.RoomCrashed, + type: Fishjam.ServerMessage.RoomCrashed, json_name: "roomCrashed", oneof: 0 field :peer_connected, 2, - type: Jellyfish.ServerMessage.PeerConnected, + type: Fishjam.ServerMessage.PeerConnected, json_name: "peerConnected", oneof: 0 field :peer_disconnected, 3, - type: Jellyfish.ServerMessage.PeerDisconnected, + type: Fishjam.ServerMessage.PeerDisconnected, json_name: "peerDisconnected", oneof: 0 field :peer_crashed, 4, - type: Jellyfish.ServerMessage.PeerCrashed, + type: Fishjam.ServerMessage.PeerCrashed, json_name: "peerCrashed", oneof: 0 field :component_crashed, 5, - type: Jellyfish.ServerMessage.ComponentCrashed, + type: Fishjam.ServerMessage.ComponentCrashed, json_name: "componentCrashed", oneof: 0 - field :authenticated, 6, type: Jellyfish.ServerMessage.Authenticated, oneof: 0 + field :authenticated, 6, type: Fishjam.ServerMessage.Authenticated, oneof: 0 field :auth_request, 7, - type: Jellyfish.ServerMessage.AuthRequest, + type: Fishjam.ServerMessage.AuthRequest, json_name: "authRequest", oneof: 0 field :subscribe_request, 8, - type: Jellyfish.ServerMessage.SubscribeRequest, + type: Fishjam.ServerMessage.SubscribeRequest, json_name: "subscribeRequest", oneof: 0 field :subscribe_response, 9, - type: Jellyfish.ServerMessage.SubscribeResponse, + type: Fishjam.ServerMessage.SubscribeResponse, json_name: "subscribeResponse", oneof: 0 field :room_created, 10, - type: Jellyfish.ServerMessage.RoomCreated, + type: Fishjam.ServerMessage.RoomCreated, json_name: "roomCreated", oneof: 0 field :room_deleted, 11, - type: Jellyfish.ServerMessage.RoomDeleted, + type: Fishjam.ServerMessage.RoomDeleted, json_name: "roomDeleted", oneof: 0 field :metrics_report, 12, - type: Jellyfish.ServerMessage.MetricsReport, + type: Fishjam.ServerMessage.MetricsReport, json_name: "metricsReport", oneof: 0 field :hls_playable, 13, - type: Jellyfish.ServerMessage.HlsPlayable, + type: Fishjam.ServerMessage.HlsPlayable, json_name: "hlsPlayable", oneof: 0 field :hls_uploaded, 14, - type: Jellyfish.ServerMessage.HlsUploaded, + type: Fishjam.ServerMessage.HlsUploaded, json_name: "hlsUploaded", oneof: 0 field :hls_upload_crashed, 15, - type: Jellyfish.ServerMessage.HlsUploadCrashed, + type: Fishjam.ServerMessage.HlsUploadCrashed, json_name: "hlsUploadCrashed", oneof: 0 field :peer_metadata_updated, 16, - type: Jellyfish.ServerMessage.PeerMetadataUpdated, + type: Fishjam.ServerMessage.PeerMetadataUpdated, json_name: "peerMetadataUpdated", oneof: 0 field :track_added, 17, - type: Jellyfish.ServerMessage.TrackAdded, + type: Fishjam.ServerMessage.TrackAdded, json_name: "trackAdded", oneof: 0 field :track_removed, 18, - type: Jellyfish.ServerMessage.TrackRemoved, + type: Fishjam.ServerMessage.TrackRemoved, json_name: "trackRemoved", oneof: 0 field :track_metadata_updated, 19, - type: Jellyfish.ServerMessage.TrackMetadataUpdated, + type: Fishjam.ServerMessage.TrackMetadataUpdated, json_name: "trackMetadataUpdated", oneof: 0 - field :peer_added, 20, type: Jellyfish.ServerMessage.PeerAdded, json_name: "peerAdded", oneof: 0 + field :peer_added, 20, type: Fishjam.ServerMessage.PeerAdded, json_name: "peerAdded", oneof: 0 field :peer_deleted, 21, - type: Jellyfish.ServerMessage.PeerDeleted, + type: Fishjam.ServerMessage.PeerDeleted, json_name: "peerDeleted", oneof: 0 end diff --git a/mix.exs b/mix.exs index 22b6d97..e036ecd 100644 --- a/mix.exs +++ b/mix.exs @@ -1,13 +1,13 @@ -defmodule Membrane.Template.Mixfile do +defmodule Fishjam.Mixfile do use Mix.Project - @version "0.5.0" - @github_url "https://github.com/jellyfish-dev/elixir_server_sdk" - @homepage_url "https://membrane.stream" + @version "0.6.0" + @github_url "https://github.com/fishjam-dev/elixir_server_sdk" + @homepage_url "https://fishjam-dev.github.io/fishjam-docs/" def project do [ - app: :jellyfish_server_sdk, + app: :fishjam_server_sdk, version: @version, elixir: "~> 1.13", elixirc_paths: elixirc_paths(Mix.env()), @@ -17,11 +17,11 @@ defmodule Membrane.Template.Mixfile do dialyzer: dialyzer(), # hex - description: "Jellyfish Server SDK", + description: "Fishjam Server SDK", package: package(), # docs - name: "Jellyfish Server SDK", + name: "Fishjam Server SDK", source_url: @github_url, homepage_url: @homepage_url, docs: docs(), @@ -88,11 +88,11 @@ defmodule Membrane.Template.Mixfile do defp package do [ - maintainers: ["Membrane Team"], + maintainers: ["Fishjam Team"], licenses: ["Apache-2.0"], links: %{ "GitHub" => @github_url, - "Membrane Framework Homepage" => @homepage_url + "Fishjam" => @homepage_url } ] end @@ -104,12 +104,12 @@ defmodule Membrane.Template.Mixfile do formatters: ["html"], source_ref: "v#{@version}", nest_modules_by_prefix: [ - Jellyfish, - Jellyfish.Exception, - Jellyfish.Notification + Fishjam, + Fishjam.Exception, + Fishjam.Notification ], groups_for_modules: [ - Events: ~r/^Jellyfish\.((\bNotification\.[a-zA-Z]*$)|(\bMetricsReport))/ + Events: ~r/^Fishjam\.((\bNotification\.[a-zA-Z]*$)|(\bMetricsReport))/ ] ] end diff --git a/protos b/protos index 7da5da1..83aa151 160000 --- a/protos +++ b/protos @@ -1 +1 @@ -Subproject commit 7da5da127c8e018ee0c845c921f598b10209271c +Subproject commit 83aa151401f9cd03fe91029d4ef2f8175fcf58f2 diff --git a/test/jellyfish/client_test.exs b/test/jellyfish/client_test.exs index fa22ecb..c5acec4 100644 --- a/test/jellyfish/client_test.exs +++ b/test/jellyfish/client_test.exs @@ -1,15 +1,15 @@ -defmodule Jellyfish.ClientTest do +defmodule Fishjam.ClientTest do use ExUnit.Case, async: false - alias Jellyfish.Client + alias Fishjam.Client @server_address "localhost:5002" @server_api_token "valid-token" describe "creates client struct" do setup do - env_state = Application.get_all_env(:jellyfish_server_sdk) - on_exit(fn -> Application.put_all_env([{:jellyfish_server_sdk, env_state}]) end) + env_state = Application.get_all_env(:fishjam_server_sdk) + on_exit(fn -> Application.put_all_env([{:fishjam_server_sdk, env_state}]) end) end test "with connection options passed explictly" do @@ -38,7 +38,7 @@ defmodule Jellyfish.ClientTest do :ok = Application.put_all_env([ { - :jellyfish_server_sdk, + :fishjam_server_sdk, [ {:server_address, @server_address}, {:server_api_token, @server_api_token}, @@ -61,14 +61,14 @@ defmodule Jellyfish.ClientTest do } } = client - Application.delete_env(:jellyfish_server_sdk, :secure?) + Application.delete_env(:fishjam_server_sdk, :secure?) end test "when address contains protocol prefix" do address_with_prefix = "http://#{@server_address}" assert_raise( - Jellyfish.Exception.ProtocolPrefixError, + Fishjam.Exception.ProtocolPrefixError, fn -> Client.new(server_address: address_with_prefix, server_api_token: @server_api_token) end @@ -76,8 +76,8 @@ defmodule Jellyfish.ClientTest do end test "when options are not passed and config is not set" do - :ok = Application.delete_env(:jellyfish_server_sdk, :server_address, []) - :ok = Application.delete_env(:jellyfish_server_sdk, :server_api_token, []) + :ok = Application.delete_env(:fishjam_server_sdk, :server_address, []) + :ok = Application.delete_env(:fishjam_server_sdk, :server_api_token, []) assert_raise( ArgumentError, @@ -107,7 +107,7 @@ defmodule Jellyfish.ClientTest do } } = client - new_address = "jellyfish2:5005" + new_address = "fishjam2:5005" addres_with_prefix = "https://#{new_address}" client = Client.update_address(client, new_address) diff --git a/test/jellyfish/health_test.exs b/test/jellyfish/health_test.exs index f57a7ac..50985f2 100644 --- a/test/jellyfish/health_test.exs +++ b/test/jellyfish/health_test.exs @@ -1,9 +1,9 @@ -defmodule Jellyfish.HealthTest do +defmodule Fishjam.HealthTest do use ExUnit.Case - doctest Jellyfish.Health + doctest Fishjam.Health - alias Jellyfish.{Client, Health} + alias Fishjam.{Client, Health} setup do %{client: Client.new()} diff --git a/test/jellyfish/notifier_test.exs b/test/jellyfish/notifier_test.exs index 539479c..aaf199e 100644 --- a/test/jellyfish/notifier_test.exs +++ b/test/jellyfish/notifier_test.exs @@ -1,13 +1,13 @@ -defmodule Jellyfish.NotifierTest do +defmodule Fishjam.NotifierTest do use ExUnit.Case - doctest Jellyfish.WebhookNotifier - alias Jellyfish.{Client, Component, Peer, Room, Track, WSNotifier} - alias Jellyfish.Component.File + doctest Fishjam.WebhookNotifier + alias Fishjam.{Client, Component, Peer, Room, Track, WSNotifier} + alias Fishjam.Component.File - alias Jellyfish.PeerMessage - alias Jellyfish.PeerMessage.AuthRequest + alias Fishjam.PeerMessage + alias Fishjam.PeerMessage.AuthRequest - alias Jellyfish.Notification.{ + alias Fishjam.Notification.{ ComponentTrackAdded, ComponentTrackRemoved, PeerAdded, @@ -19,9 +19,9 @@ defmodule Jellyfish.NotifierTest do RoomDeleted } - alias Jellyfish.MetricsReport + alias Fishjam.MetricsReport - alias Jellyfish.WS + alias Fishjam.WS alias Phoenix.PubSub @peer_opts %Peer.WebRTC{} @@ -35,15 +35,15 @@ defmodule Jellyfish.NotifierTest do @peerless_purge_timeout_s 1 @peer_disconnected_timeout_s 1 @webhook_port 4000 - @webhook_host Application.compile_env!(:jellyfish_server_sdk, :webhook_address) + @webhook_host Application.compile_env!(:fishjam_server_sdk, :webhook_address) @webhook_address "http://#{@webhook_host}:#{@webhook_port}/" - @pubsub Jellyfish.PubSub + @pubsub Fishjam.PubSub setup_all do children = [ {Plug.Cowboy, plug: WebHookPlug, scheme: :http, options: [port: @webhook_port, ip: {0, 0, 0, 0}]}, - {Phoenix.PubSub, name: Jellyfish.PubSub} + {Phoenix.PubSub, name: Fishjam.PubSub} ] {:ok, _pid} = @@ -84,19 +84,19 @@ defmodule Jellyfish.NotifierTest do test "when room gets created and then deleted", %{ client: client } do - {:ok, %Jellyfish.Room{id: room_id}, _jellyfish_address} = + {:ok, %Fishjam.Room{id: room_id}, _fishjam_address} = Room.create(client, max_peers: @max_peers, video_codec: @video_codec, webhook_url: @webhook_address ) - assert_receive {:jellyfish, %RoomCreated{room_id: ^room_id}} + assert_receive {:fishjam, %RoomCreated{room_id: ^room_id}} assert_receive {:webhook, %RoomCreated{room_id: ^room_id}}, 2_500 :ok = Room.delete(client, room_id) - assert_receive {:jellyfish, %RoomDeleted{room_id: ^room_id}} + assert_receive {:fishjam, %RoomDeleted{room_id: ^room_id}} assert_receive {:webhook, %RoomDeleted{room_id: ^room_id}}, 2_500 end @@ -105,7 +105,7 @@ defmodule Jellyfish.NotifierTest do } do {room_id, peer_id, peer_ws} = create_room_and_auth_ws(client) - assert_receive {:jellyfish, + assert_receive {:fishjam, %PeerConnected{peer_id: ^peer_id, room_id: ^room_id} = peer_connected} assert_receive {:webhook, ^peer_connected}, 2_500 @@ -123,7 +123,7 @@ defmodule Jellyfish.NotifierTest do :ok = WS.send_frame(peer_ws, media_event) - assert_receive {:jellyfish, + assert_receive {:fishjam, %PeerMetadataUpdated{ peer_id: ^peer_id, room_id: ^room_id, @@ -135,7 +135,7 @@ defmodule Jellyfish.NotifierTest do :ok = Room.delete_peer(client, room_id, peer_id) - assert_receive {:jellyfish, + assert_receive {:fishjam, %PeerDisconnected{peer_id: ^peer_id, room_id: ^room_id} = peer_disconnected}, 1_000 @@ -147,7 +147,7 @@ defmodule Jellyfish.NotifierTest do test "when peer connects and then disconnects peer is removed with timeout", %{ client: client } do - {:ok, %Jellyfish.Room{id: room_id}, jellyfish_address} = + {:ok, %Fishjam.Room{id: room_id}, fishjam_address} = Room.create(client, max_peers: @max_peers, video_codec: @video_codec, @@ -156,40 +156,40 @@ defmodule Jellyfish.NotifierTest do peer_disconnected_timeout_s: @peer_disconnected_timeout_s ) - {:ok, %{peer: %Jellyfish.Peer{id: peer_id}, token: peer_token}} = + {:ok, %{peer: %Fishjam.Peer{id: peer_id}, token: peer_token}} = Room.add_peer(client, room_id, @peer_opts) - assert_receive {:jellyfish, %PeerAdded{peer_id: ^peer_id, room_id: ^room_id} = peer_added}, + assert_receive {:fishjam, %PeerAdded{peer_id: ^peer_id, room_id: ^room_id} = peer_added}, 1_000 assert_receive {:webhook, ^peer_added}, 2_500 - {:ok, peer_ws} = WS.start_link("ws://#{jellyfish_address}/socket/peer/websocket") + {:ok, peer_ws} = WS.start_link("ws://#{fishjam_address}/socket/peer/websocket") auth_request = %PeerMessage{content: {:auth_request, %AuthRequest{token: peer_token}}} :ok = WS.send_frame(peer_ws, auth_request) {room_id, peer_id, peer_ws} - assert_receive {:jellyfish, + assert_receive {:fishjam, %PeerConnected{peer_id: ^peer_id, room_id: ^room_id} = peer_connected} assert_receive {:webhook, ^peer_connected}, 2_500 GenServer.stop(peer_ws) - assert_receive {:jellyfish, + assert_receive {:fishjam, %PeerDisconnected{peer_id: ^peer_id, room_id: ^room_id} = peer_disconnected}, 1_000 assert_receive {:webhook, ^peer_disconnected}, 2_500 - assert_receive {:jellyfish, + assert_receive {:fishjam, %PeerDeleted{peer_id: ^peer_id, room_id: ^room_id} = peer_deleted}, 2_500 assert_receive {:webhook, ^peer_deleted}, 2_500 - assert_receive {:jellyfish, %RoomDeleted{room_id: ^room_id} = room_deleted}, + assert_receive {:fishjam, %RoomDeleted{room_id: ^room_id} = room_deleted}, 2_500 assert_receive {:webhook, ^room_deleted}, 2_500 @@ -204,7 +204,7 @@ defmodule Jellyfish.NotifierTest do {:ok, %Component{id: component_id}} = Room.add_component(client, room_id, @file_component_opts) - assert_receive {:jellyfish, + assert_receive {:fishjam, %ComponentTrackAdded{ room_id: ^room_id, component_id: ^component_id, @@ -216,7 +216,7 @@ defmodule Jellyfish.NotifierTest do :ok = Room.delete_component(client, room_id, component_id) - assert_receive {:jellyfish, + assert_receive {:fishjam, %ComponentTrackRemoved{ room_id: ^room_id, component_id: ^component_id, @@ -242,27 +242,27 @@ defmodule Jellyfish.NotifierTest do test "with one peer", %{client: client} do {room_id, peer_id, _peer_ws} = create_room_and_auth_ws(client) - assert_receive {:jellyfish, %PeerConnected{peer_id: ^peer_id, room_id: ^room_id}} + assert_receive {:fishjam, %PeerConnected{peer_id: ^peer_id, room_id: ^room_id}} assert_receive {:webhook, %PeerConnected{peer_id: ^peer_id, room_id: ^room_id}}, 2_500 - assert_receive {:jellyfish, %MetricsReport{metrics: metrics}} when metrics != %{}, 1500 + assert_receive {:fishjam, %MetricsReport{metrics: metrics}} when metrics != %{}, 1500 :ok = Room.delete(client, room_id) end end defp create_room_and_auth_ws(client, room_opts \\ []) do - {:ok, %Jellyfish.Room{id: room_id}, _jellyfish_address} = + {:ok, %Fishjam.Room{id: room_id}, _fishjam_address} = Room.create(client, max_peers: Keyword.get(room_opts, :max_peers, @max_peers), video_codec: Keyword.get(room_opts, :video_codec, @video_codec), webhook_url: Keyword.get(room_opts, :webhook_url, @webhook_address) ) - {:ok, %{peer: %Jellyfish.Peer{id: peer_id}, token: peer_token, ws_url: peer_ws_url}} = + {:ok, %{peer: %Fishjam.Peer{id: peer_id}, token: peer_token, ws_url: peer_ws_url}} = Room.add_peer(client, room_id, @peer_opts) - assert_receive {:jellyfish, %PeerAdded{peer_id: ^peer_id, room_id: ^room_id} = peer_added}, + assert_receive {:fishjam, %PeerAdded{peer_id: ^peer_id, room_id: ^room_id} = peer_added}, 1_000 assert_receive {:webhook, ^peer_added}, 2_500 diff --git a/test/jellyfish/recording_test.exs b/test/jellyfish/recording_test.exs index 0bba404..8c3cdf4 100644 --- a/test/jellyfish/recording_test.exs +++ b/test/jellyfish/recording_test.exs @@ -1,8 +1,8 @@ -defmodule Jellyfish.RecordingTest do +defmodule Fishjam.RecordingTest do use ExUnit.Case - doctest Jellyfish.Recording + doctest Fishjam.Recording - alias Jellyfish.{Client, Recording} + alias Fishjam.{Client, Recording} setup do %{client: Client.new()} diff --git a/test/jellyfish/room_test.exs b/test/jellyfish/room_test.exs index 628aed7..10524ba 100644 --- a/test/jellyfish/room_test.exs +++ b/test/jellyfish/room_test.exs @@ -1,8 +1,8 @@ -defmodule Jellyfish.RoomTest do +defmodule Fishjam.RoomTest do use ExUnit.Case - doctest Jellyfish.Room - alias Jellyfish.Exception.OptionsError - alias Jellyfish.{Client, Component, Peer, Room} + doctest Fishjam.Room + alias Fishjam.Exception.OptionsError + alias Fishjam.{Client, Component, Peer, Room} @server_api_token "development" @@ -115,19 +115,19 @@ defmodule Jellyfish.RoomTest do describe "auth" do test "correct token", %{client: client} do - assert {:ok, room, jellyfish_address} = + assert {:ok, room, fishjam_address} = Room.create(client, max_peers: @max_peers, video_codec: @video_codec) - assert %Jellyfish.Room{ + assert %Fishjam.Room{ components: [], config: %{max_peers: 10, video_codec: @video_codec}, id: _id, peers: [] } = room - server_address = Application.fetch_env!(:jellyfish_server_sdk, :server_address) + server_address = Application.fetch_env!(:fishjam_server_sdk, :server_address) - assert ^server_address = jellyfish_address + assert ^server_address = fishjam_address end test "invalid token" do @@ -139,39 +139,39 @@ defmodule Jellyfish.RoomTest do describe "Room.create/2" do test "when request is valid", %{client: client} do - assert {:ok, room, jellyfish_address} = Room.create(client, max_peers: @max_peers) + assert {:ok, room, fishjam_address} = Room.create(client, max_peers: @max_peers) - assert %Jellyfish.Room{ + assert %Fishjam.Room{ components: [], config: %{max_peers: 10}, id: _id, peers: [] } = room - server_address = Application.fetch_env!(:jellyfish_server_sdk, :server_address) + server_address = Application.fetch_env!(:fishjam_server_sdk, :server_address) - assert ^server_address = jellyfish_address + assert ^server_address = fishjam_address end test "when request is valid with room_id", %{client: client} do room_id = UUID.uuid4() - assert {:ok, room, jellyfish_address} = Room.create(client, room_id: room_id) + assert {:ok, room, fishjam_address} = Room.create(client, room_id: room_id) - assert %Jellyfish.Room{ + assert %Fishjam.Room{ components: [], config: %{video_codec: nil, max_peers: nil}, id: ^room_id, peers: [] } = room - server_address = Application.fetch_env!(:jellyfish_server_sdk, :server_address) + server_address = Application.fetch_env!(:fishjam_server_sdk, :server_address) - assert ^server_address = jellyfish_address + assert ^server_address = fishjam_address end test "when request is invalid, room already exists", %{client: client} do room_id = UUID.uuid4() - assert {:ok, _room, _jellyfish_address} = Room.create(client, room_id: room_id) + assert {:ok, _room, _fishjam_address} = Room.create(client, room_id: room_id) error_msg = "Request failed: Cannot add room with id \"#{room_id}\" - room already exists" assert {:error, ^error_msg} = Room.create(client, room_id: room_id) @@ -227,7 +227,7 @@ defmodule Jellyfish.RoomTest do test "when request is valid", %{client: client, room_id: room_id, component_id: component_id} do assert {:ok, - %Jellyfish.Room{ + %Fishjam.Room{ components: [component], config: %{max_peers: @max_peers, video_codec: @video_codec}, id: ^room_id, @@ -420,10 +420,10 @@ defmodule Jellyfish.RoomTest do test "when request is valid", %{client: client, room_id: room_id} do assert {:ok, %{peer: peer}} = Room.add_peer(client, room_id, @peer_opts) - assert %Jellyfish.Peer{type: Peer.WebRTC} = peer + assert %Fishjam.Peer{type: Peer.WebRTC} = peer assert {:ok, %{peer: peer}} = Room.add_peer(client, room_id, @peer_opts_module) - assert %Jellyfish.Peer{type: Peer.WebRTC} = peer + assert %Fishjam.Peer{type: Peer.WebRTC} = peer end test "when request is invalid", %{client: client} do @@ -437,12 +437,12 @@ defmodule Jellyfish.RoomTest do end test "when request is invalid, too many peers", %{client: client} do - {:ok, %Jellyfish.Room{id: room_id}, _jellyfish_address} = + {:ok, %Fishjam.Room{id: room_id}, _fishjam_address} = Room.create(client, max_peers: 1, video_codec: @video_codec) assert {:ok, _response} = Room.add_peer(client, room_id, @peer_opts) - error_msg = "Request failed: Reached peer limit in room #{room_id}" + error_msg = "Request failed: Reached webrtc peers limit in room #{room_id}" assert {:error, ^error_msg} = Room.add_peer(client, room_id, @peer_opts) end @@ -493,7 +493,7 @@ defmodule Jellyfish.RoomTest do test "when component has subscribe mode :auto", %{client: client, room_id: room_id} do assert {:ok, %Component{id: id, properties: %{subscribe_mode: "auto"}}} = - Room.add_component(client, room_id, %Jellyfish.Component.HLS{subscribe_mode: :auto}) + Room.add_component(client, room_id, %Fishjam.Component.HLS{subscribe_mode: :auto}) text = "Request failed: Component #{id} option `subscribe_mode` is set to :auto" @@ -575,21 +575,21 @@ defmodule Jellyfish.RoomTest do end defp create_room(state) do - assert {:ok, %Jellyfish.Room{id: id}, _jellyfish_address} = + assert {:ok, %Fishjam.Room{id: id}, _fishjam_address} = Room.create(state.client, max_peers: @max_peers, video_codec: @video_codec) %{room_id: id} end defp create_peer(state) do - assert {:ok, %{peer: %Jellyfish.Peer{id: id}}} = + assert {:ok, %{peer: %Fishjam.Peer{id: id}}} = Room.add_peer(state.client, state.room_id, @peer_opts) %{peer_id: id} end defp create_component_hls(state) do - assert {:ok, %Jellyfish.Component{id: id}} = + assert {:ok, %Fishjam.Component{id: id}} = Room.add_component(state.client, state.room_id, @hls_component_opts) %{component_id: id} diff --git a/test/support/protos/jellyfish/peer_notifications.pb.ex b/test/support/protos/fishjam/peer_notifications.pb.ex similarity index 57% rename from test/support/protos/jellyfish/peer_notifications.pb.ex rename to test/support/protos/fishjam/peer_notifications.pb.ex index 452c83e..33cb2c5 100644 --- a/test/support/protos/jellyfish/peer_notifications.pb.ex +++ b/test/support/protos/fishjam/peer_notifications.pb.ex @@ -1,10 +1,10 @@ -defmodule Jellyfish.PeerMessage.Authenticated do +defmodule Fishjam.PeerMessage.Authenticated do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" end -defmodule Jellyfish.PeerMessage.AuthRequest do +defmodule Fishjam.PeerMessage.AuthRequest do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -12,7 +12,7 @@ defmodule Jellyfish.PeerMessage.AuthRequest do field :token, 1, type: :string end -defmodule Jellyfish.PeerMessage.MediaEvent do +defmodule Fishjam.PeerMessage.MediaEvent do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" @@ -20,19 +20,19 @@ defmodule Jellyfish.PeerMessage.MediaEvent do field :data, 1, type: :string end -defmodule Jellyfish.PeerMessage do +defmodule Fishjam.PeerMessage do @moduledoc false use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" oneof :content, 0 - field :authenticated, 1, type: Jellyfish.PeerMessage.Authenticated, oneof: 0 + field :authenticated, 1, type: Fishjam.PeerMessage.Authenticated, oneof: 0 field :auth_request, 2, - type: Jellyfish.PeerMessage.AuthRequest, + type: Fishjam.PeerMessage.AuthRequest, json_name: "authRequest", oneof: 0 - field :media_event, 3, type: Jellyfish.PeerMessage.MediaEvent, json_name: "mediaEvent", oneof: 0 + field :media_event, 3, type: Fishjam.PeerMessage.MediaEvent, json_name: "mediaEvent", oneof: 0 end diff --git a/test/support/webhook_plug.ex b/test/support/webhook_plug.ex index 605a476..2a06536 100644 --- a/test/support/webhook_plug.ex +++ b/test/support/webhook_plug.ex @@ -1,10 +1,10 @@ defmodule WebHookPlug do @moduledoc false import Plug.Conn - alias Jellyfish.WebhookNotifier + alias Fishjam.WebhookNotifier alias Phoenix.PubSub - @pubsub Jellyfish.PubSub + @pubsub Fishjam.PubSub def init(opts) do opts diff --git a/test/support/ws.ex b/test/support/ws.ex index 4ded26e..af26930 100644 --- a/test/support/ws.ex +++ b/test/support/ws.ex @@ -1,9 +1,9 @@ -defmodule Jellyfish.WS do +defmodule Fishjam.WS do @moduledoc false use WebSockex - alias Jellyfish.PeerMessage + alias Fishjam.PeerMessage def start_link(url) do WebSockex.start_link(url, __MODULE__, %{caller: self()})