Skip to content

Commit 3a1f269

Browse files
committed
Review fixes
1 parent 9515da2 commit 3a1f269

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

lib/ex_webrtc_recorder/app.ex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
defmodule ExWebRTC.Recorder.App do
2+
@moduledoc false
3+
use Application
4+
5+
@impl true
6+
def start(_type, _args) do
7+
children = [{Task.Supervisor, name: ExWebRTC.Recorder.TaskSupervisor}]
8+
Supervisor.start_link(children, strategy: :one_for_one)
9+
end
10+
end

lib/ex_webrtc_recorder/converter.ex

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,15 @@ defmodule ExWebRTC.Recorder.Converter do
8686
@type options :: [option()]
8787

8888
@doc """
89-
Loads the recording manifest from file, then proceeds with `convert_manifest!/2`.
89+
Converts the saved dumps of tracks in the manifest to WEBM files.
90+
91+
If passed a path as the first argument, loads the recording manifest from file.
9092
"""
91-
@spec convert_path!(Path.t(), options()) :: __MODULE__.Manifest.t() | no_return()
92-
def convert_path!(recorder_manifest_path, options \\ []) do
93+
@spec convert!(Path.t() | Recorder.Manifest.t(), options()) ::
94+
__MODULE__.Manifest.t() | no_return()
95+
def convert!(recorder_manifest_or_path, options \\ [])
96+
97+
def convert!(recorder_manifest_path, options) when is_binary(recorder_manifest_path) do
9398
recorder_manifest_path =
9499
recorder_manifest_path
95100
|> Path.expand()
@@ -106,17 +111,10 @@ defmodule ExWebRTC.Recorder.Converter do
106111
|> Jason.decode!()
107112
|> Recorder.Manifest.from_json!()
108113

109-
convert_manifest!(recorder_manifest, options)
114+
convert!(recorder_manifest, options)
110115
end
111116

112-
@doc """
113-
Converts the saved dumps of tracks in the manifest to WEBM files.
114-
"""
115-
@spec convert_manifest!(Recorder.Manifest.t(), options()) ::
116-
__MODULE__.Manifest.t() | no_return()
117-
def convert_manifest!(recorder_manifest, options \\ [])
118-
119-
def convert_manifest!(manifest, options) when map_size(manifest) > 0 do
117+
def convert!(recorder_manifest, options) when map_size(recorder_manifest) > 0 do
120118
thumbnails_ctx =
121119
case Keyword.get(options, :thumbnails_ctx, nil) do
122120
nil ->
@@ -143,7 +141,7 @@ defmodule ExWebRTC.Recorder.Converter do
143141
end
144142

145143
output_manifest =
146-
manifest
144+
recorder_manifest
147145
|> fetch_remote_files!(download_path, download_config)
148146
|> do_convert_manifest!(output_path, thumbnails_ctx)
149147

@@ -170,7 +168,7 @@ defmodule ExWebRTC.Recorder.Converter do
170168
result_manifest
171169
end
172170

173-
def convert_manifest!(_empty_manifest, _options), do: %{}
171+
def convert!(_empty_manifest, _options), do: %{}
174172

175173
defp fetch_remote_files!(manifest, dl_path, dl_config) do
176174
Map.new(manifest, fn {track_id, %{location: location} = track_data} ->

lib/ex_webrtc_recorder/s3/upload_handler.ex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ if Enum.each([ExAws.S3, ExAws, SweetXml], &Code.ensure_loaded?/1) do
5656
{id, %{object_data | location: location}}
5757
end)
5858

59-
# FIXME: this links, ideally we should spawn a supervised task instead
60-
task = Task.async(fn -> upload(manifest, bucket_name, s3_paths, s3_config_overrides) end)
59+
# FIXME: this links, ideally we should use `async_nolink` instead
60+
# but this may require a slight change of the current UploadHandler logic
61+
task =
62+
Task.Supervisor.async(ExWebRTC.Recorder.TaskSupervisor, fn ->
63+
upload(manifest, bucket_name, s3_paths, s3_config_overrides)
64+
end)
6165

6266
{task.ref,
6367
%__MODULE__{handler | tasks: Map.put(handler.tasks, task.ref, download_manifest)}}

0 commit comments

Comments
 (0)