From 1687eb12ade67a4a9881cc6d814587741f97c3ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Ro=C5=BCnawski?= Date: Thu, 28 Dec 2023 14:14:56 +0100 Subject: [PATCH] Add properties --- config/test_local.exs | 4 ++-- lib/jellyfish/component/file.ex | 8 ++++++-- lib/jellyfish/component/rtsp.ex | 15 ++++++++++++++- test/jellyfish/room_test.exs | 16 +++++++++++++--- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/config/test_local.exs b/config/test_local.exs index 89993ce..58f9b3d 100644 --- a/config/test_local.exs +++ b/config/test_local.exs @@ -1,6 +1,6 @@ import Config config :jellyfish_server_sdk, - server_address: "localhost:5002", + server_address: "127.0.0.1:5002", server_api_token: "development", - webhook_address: "localhost" + webhook_address: "127.0.0.1" diff --git a/lib/jellyfish/component/file.ex b/lib/jellyfish/component/file.ex index 3a8bdc6..564000d 100644 --- a/lib/jellyfish/component/file.ex +++ b/lib/jellyfish/component/file.ex @@ -17,7 +17,11 @@ defmodule Jellyfish.Component.File do } @impl true - def properties_from_json(%{}) do - %{} + def properties_from_json(%{ + "filePath" => file_path + }) do + %{ + file_path: file_path + } end end diff --git a/lib/jellyfish/component/rtsp.ex b/lib/jellyfish/component/rtsp.ex index 07901a8..fe4a082 100644 --- a/lib/jellyfish/component/rtsp.ex +++ b/lib/jellyfish/component/rtsp.ex @@ -26,5 +26,18 @@ defmodule Jellyfish.Component.RTSP do } @impl true - def properties_from_json(_properties), do: %{} + def properties_from_json(%{ + "sourceUri" => source_uri, + "rtpPort" => rtp_port, + "reconnectDelay" => reconnect_delay, + "keepAliveInterval" => keep_alive_interval, + "pierceNat" => pierce_nat + }), + do: %{ + source_uri: source_uri, + rtp_port: rtp_port, + reconnect_delay: reconnect_delay, + keep_alive_interval: keep_alive_interval, + pierce_nat: pierce_nat + } end diff --git a/test/jellyfish/room_test.exs b/test/jellyfish/room_test.exs index 9248b4d..e385796 100644 --- a/test/jellyfish/room_test.exs +++ b/test/jellyfish/room_test.exs @@ -26,10 +26,20 @@ defmodule Jellyfish.RoomTest do @rtsp_component_opts %Component.RTSP{ source_uri: "rtsp://ef36c6dff23ecc5bbe311cc880d95dc8.se:2137/does/not/matter" } + @rtsp_properties %{ + source_uri: "rtsp://ef36c6dff23ecc5bbe311cc880d95dc8.se:2137/does/not/matter", + rtp_port: 20_000, + reconnect_delay: 15_000, + keep_alive_interval: 15_000, + pierce_nat: true + } @file_component_opts %Component.File{ file_path: "video.h264" } + @file_properties %{ + file_path: "video.h264" + } @video_filename "video.h264" @@ -192,13 +202,13 @@ defmodule Jellyfish.RoomTest do test "when request is valid with opts - rtsp", %{client: client, room_id: room_id} do assert {:ok, component} = Room.add_component(client, room_id, @rtsp_component_opts) - assert %Component{type: Component.RTSP, properties: %{}} = component + assert %Component{type: Component.RTSP, properties: @rtsp_properties} = component end @tag :file_component_sources test "when request is valid with opts - file", %{client: client, room_id: room_id} do assert {:ok, component} = Room.add_component(client, room_id, @file_component_opts) - assert %Component{type: Component.File, properties: %{}} = component + assert %Component{type: Component.File, properties: @file_properties} = component end test "HLS when request is valid with opts module", %{client: client, room_id: room_id} do @@ -263,7 +273,7 @@ defmodule Jellyfish.RoomTest do file_path: @video_filename }) - assert %Component{type: Component.File, properties: %{}} = component + assert %Component{type: Component.File, properties: @file_properties} = component end test "File when request is invalid - invalid path", %{client: client, room_id: room_id} do