Skip to content

Commit

Permalink
Fix HLS OpenAPI warning (#202)
Browse files Browse the repository at this point in the history
* Try fix S3 openapi issue

* Fix credo issue

* Run only test ci

* Experimental fix of auth cache error

* Return circleci to previous version

* Modify test

* WiP

* Remove IO.inspect

* Update circleci config

* Apply review changes

* Update deps

* Update lib/fishjam/component/hls/manager.ex

Co-authored-by: Jakub Pisarek <99591440+sgfn@users.noreply.github.com>

* Return purging logs from engine

* Add TODO

* Update deps

* Add purging SRTP warnings

---------

Co-authored-by: Jakub Pisarek <99591440+sgfn@users.noreply.github.com>
  • Loading branch information
Rados13 and sgfn authored Jun 4, 2024
1 parent 453531f commit f20d6b9
Show file tree
Hide file tree
Showing 20 changed files with 206 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ orbs:
executors:
machine_executor_amd64:
machine:
image: ubuntu-2204:2022.04.2
image: default
environment:
architecture: "amd64"
platform: "linux/amd64"
Expand Down
5 changes: 4 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Config

config :membrane_core, :enable_metrics, false

config :fishjam, FishjamWeb.Endpoint,
url: [host: "localhost"],
render_errors: [
Expand Down Expand Up @@ -34,7 +36,8 @@ config :logger,
[application: :membrane_rtc_engine_hls, level_lower_than: :warning],
[application: :membrane_rtc_engine_rtsp, level_lower_than: :warning],
[application: :membrane_rtc_engine_file, level_lower_than: :warning],
[application: :membrane_rtc_engine_sip, level_lower_than: :warning]
[application: :membrane_rtc_engine_sip, level_lower_than: :warning],
[module: Membrane.SRTP.Encryptor, level_lower_than: :error]
]

config :ex_aws,
Expand Down
2 changes: 2 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ config :logger, level: :warning
config :phoenix, :plug_init_mode, :runtime

config :ex_aws, :http_client, ExAws.Request.HttpMock

config :ex_aws, :awscli_auth_adapter, Fishjam.Adapter
2 changes: 2 additions & 0 deletions lib/fishjam/component/hls/manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ defmodule Fishjam.Component.HLS.Manager do
unless is_nil(hls_options.s3), do: upload_to_s3(hls_dir, room_id, hls_options.s3)
unless hls_options.persistent, do: remove_hls(hls_dir, room_id)

Logger.info("Engine is down and HLS manager finished uploading stream")

{:stop, :normal, state}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/fishjam/room_service.ex
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ defmodule Fishjam.RoomService do
def handle_info({:DOWN, _ref, :process, pid, :normal}, state) do
{room_id, state} = pop_in(state, [:rooms, pid])

Logger.debug("Room #{room_id} is down with reason: normal")
Logger.debug("Room #{inspect(room_id)} is down with reason: normal")

Phoenix.PubSub.broadcast(Fishjam.PubSub, room_id, :room_stopped)
Event.broadcast_server_notification({:room_deleted, room_id})
Expand Down
32 changes: 32 additions & 0 deletions lib/fishjam_web/api_spec/component/HLS/S3.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
defmodule FishjamWeb.ApiSpec.Component.HLS.S3 do
@moduledoc false

require OpenApiSpex
alias OpenApiSpex.Schema

OpenApiSpex.schema(%{
title: "S3Credentials",
description:
"An AWS S3 credential that will be used to send HLS stream. The stream will only be uploaded if credentials are provided",
type: :object,
properties: %{
accessKeyId: %Schema{
type: :string,
description: "An AWS access key identifier, linked to your AWS account."
},
secretAccessKey: %Schema{
type: :string,
description: "The secret key that is linked to the Access Key ID."
},
region: %Schema{
type: :string,
description: "The AWS region where your bucket is located."
},
bucket: %Schema{
type: :string,
description: "The name of the S3 bucket where your data will be stored."
}
},
required: [:accessKeyId, :secretAccessKey, :region, :bucket]
})
end
41 changes: 3 additions & 38 deletions lib/fishjam_web/api_spec/component/hls.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,42 +43,12 @@ defmodule FishjamWeb.ApiSpec.Component.HLS do
})
end

defmodule S3 do
@moduledoc false

require OpenApiSpex

OpenApiSpex.schema(%{
title: "S3Credentials",
description:
"An AWS S3 credential that will be used to send HLS stream. The stream will only be uploaded if credentials are provided",
type: :object,
properties: %{
accessKeyId: %Schema{
type: :string,
description: "An AWS access key identifier, linked to your AWS account."
},
secretAccessKey: %Schema{
type: :string,
description: "The secret key that is linked to the Access Key ID."
},
region: %Schema{
type: :string,
description: "The AWS region where your bucket is located."
},
bucket: %Schema{
type: :string,
description: "The name of the S3 bucket where your data will be stored."
}
},
required: [:accessKeyId, :secretAccessKey, :region, :bucket]
})
end

defmodule Options do
@moduledoc false

require OpenApiSpex
alias FishjamWeb.ApiSpec.Component.HLS.S3
alias OpenApiSpex.Schema

OpenApiSpex.schema(%{
title: "ComponentOptionsHLS",
Expand All @@ -100,12 +70,7 @@ defmodule FishjamWeb.ApiSpec.Component.HLS do
description: "Whether the video is stored after end of stream",
default: false
},
s3: %Schema{
type: :object,
description: "Credentials to AWS S3 bucket.",
oneOf: [S3],
nullable: true
},
s3: S3.schema(),
subscribeMode: %Schema{
type: :string,
description:
Expand Down
7 changes: 1 addition & 6 deletions lib/fishjam_web/api_spec/component/recording.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ defmodule FishjamWeb.ApiSpec.Component.Recording do
default: nil,
nullable: true
},
credentials: %Schema{
type: :object,
description: "Credentials to AWS S3 bucket.",
oneOf: [S3],
nullable: true
},
credentials: S3.schema(),
subscribeMode: %Schema{
type: :string,
description:
Expand Down
2 changes: 1 addition & 1 deletion lib/fishjam_web/peer_socket.ex
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ defmodule FishjamWeb.PeerSocket do

@impl true
def terminate(reason, _state) do
Logger.info("Peer socket terminates with reason #{reason}")
Logger.info("Peer socket terminates with reason #{inspect(reason)}")
:ok
end

Expand Down
32 changes: 25 additions & 7 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ defmodule Fishjam.MixProject do
aliases: aliases(),
deps: deps(),
dialyzer: dialyzer(),
# TODO: Remove once core fix bug
consolidate_protocols: false,

# hex
description: "Fishjam media server",
Expand Down Expand Up @@ -52,7 +54,7 @@ defmodule Fishjam.MixProject do
{:plug_cowboy, "~> 2.5"},
{:elixir_uuid, "~> 1.2"},
{:cors_plug, "~> 3.0"},
{:open_api_spex, "~> 3.16"},
{:open_api_spex, "~> 3.19"},
{:ymlr, "~> 3.0"},
{:bunch, "~> 1.6"},
{:logger_json, "~> 5.1"},
Expand All @@ -66,18 +68,34 @@ defmodule Fishjam.MixProject do
{:protobuf, "~> 0.12.0"},

# Membrane deps
{:membrane_core, "1.1.0-rc0", override: true},
{:membrane_core, "~> 1.1.0-rc1", override: true},
{:membrane_rtc_engine,
github: "fishjam-dev/membrane_rtc_engine", sparse: "engine", override: true},
github: "fishjam-dev/membrane_rtc_engine",
sparse: "engine",
ref: "a3786d2f4a2b4171bfaf7ffcfd79528845762b45",
override: "true"},
{:membrane_rtc_engine_webrtc,
github: "fishjam-dev/membrane_rtc_engine", sparse: "webrtc", override: true},
github: "fishjam-dev/membrane_rtc_engine",
sparse: "webrtc",
ref: "a3786d2f4a2b4171bfaf7ffcfd79528845762b45",
override: "true"},
{:membrane_rtc_engine_hls, "~> 0.7.0"},
{:membrane_rtc_engine_recording, "~> 0.1.0"},
{:membrane_rtc_engine_recording,
github: "fishjam-dev/membrane_rtc_engine",
sparse: "recording",
ref: "a3786d2f4a2b4171bfaf7ffcfd79528845762b45",
override: "true"},
{:membrane_rtc_engine_rtsp,
github: "fishjam-dev/membrane_rtc_engine", sparse: "rtsp", override: true},
github: "fishjam-dev/membrane_rtc_engine",
sparse: "rtsp",
ref: "a3786d2f4a2b4171bfaf7ffcfd79528845762b45",
override: "true"},
{:membrane_rtc_engine_file, "~> 0.5.0"},
{:membrane_rtc_engine_sip,
github: "fishjam-dev/membrane_rtc_engine", sparse: "sip", override: true},
github: "fishjam-dev/membrane_rtc_engine",
sparse: "sip",
ref: "a3786d2f4a2b4171bfaf7ffcfd79528845762b45",
override: "true"},
{:membrane_telemetry_metrics, "~> 0.1.0"},

# HLS endpoints deps
Expand Down
Loading

0 comments on commit f20d6b9

Please sign in to comment.