Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Membrane Live dev #188

Merged
merged 64 commits into from
Feb 16, 2023
Merged

Membrane Live dev #188

merged 64 commits into from
Feb 16, 2023

Conversation

Karolk99
Copy link
Contributor

@Karolk99 Karolk99 commented Nov 4, 2022

after merging this PR draft (#182) will be cloused.

@Karolk99 Karolk99 requested a review from mickel8 as a code owner November 4, 2022 10:43
@Karolk99 Karolk99 requested a review from Rados13 November 4, 2022 10:43
@Karolk99 Karolk99 marked this pull request as draft November 4, 2022 10:44
Copy link
Contributor

@mickel8 mickel8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't manage to take a look at HLS Endpoint itself but will do this tomorrow

Copy link
Contributor

@Rados13 Rados13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, hls tests fail on CI, so my question is whether these tests are deterministic?

@Karolk99 Karolk99 force-pushed the add-compositor-with-synchronization branch 7 times, most recently from cbab3f3 to b1395a9 Compare November 9, 2022 16:13
@Karolk99 Karolk99 requested review from mickel8 and Rados13 November 9, 2022 16:34
@Karolk99 Karolk99 changed the title Add compositor and audio mixer to hls Membrane Live dev Nov 10, 2022
@Karolk99 Karolk99 requested a review from mickel8 November 14, 2022 16:30
Returns FFmpeg filtergraph that is used to create compositor output.
https://ffmpeg.org/ffmpeg-filters.html#toc-Filtergraph-description

Used ffmpeg options:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's much better 🙂

@Karolk99 Karolk99 requested a review from mickel8 November 15, 2022 09:49
@Karolk99 Karolk99 requested a review from Rados13 November 15, 2022 13:14
Rados13
Rados13 previously approved these changes Nov 17, 2022
@LVala LVala force-pushed the add-compositor-with-synchronization branch from fd74911 to 48b71a4 Compare November 22, 2022 13:55
@roznawsk roznawsk force-pushed the add-compositor-with-synchronization branch from 48b71a4 to bd5f80b Compare November 23, 2022 10:41
@mickel8 mickel8 removed their request for review December 5, 2022 12:46
@mickel8
Copy link
Contributor

mickel8 commented Dec 5, 2022

Unpinning myself from CR as the whole development is done in PRs to this branch

@Karolk99 Karolk99 requested review from Rados13 and LVala February 3, 2023 15:23
@codecov
Copy link

codecov bot commented Feb 3, 2023

Codecov Report

Merging #188 (688705f) into master (d5c4263) will increase coverage by 2.82%.
The diff coverage is 74.44%.

❗ Current head 688705f differs from pull request most recent head dcffa6e. Consider uploading reports for the commit dcffa6e to get more accurate results

@@            Coverage Diff             @@
##           master     #188      +/-   ##
==========================================
+ Coverage   56.73%   59.55%   +2.82%     
==========================================
  Files          35       38       +3     
  Lines        1641     1721      +80     
==========================================
+ Hits          931     1025      +94     
+ Misses        710      696      -14     
Impacted Files Coverage Δ
...embrane_rtc_engine/endpoints/webrtc/media_event.ex 5.35% <ø> (ø)
...ne_rtc_engine/endpoints/webrtc/variant_selector.ex 84.61% <ø> (+1.53%) ⬆️
...b/membrane_rtc_engine/endpoints/webrtc_endpoint.ex 0.00% <0.00%> (ø)
lib/membrane_rtc_engine/tees/filter_tee.ex 0.00% <0.00%> (ø)
lib/membrane_rtc_engine/track.ex 77.77% <ø> (ø)
lib/membrane_rtc_engine/utils.ex 12.12% <ø> (ø)
...rane_rtc_engine/endpoints/webrtc/track_receiver.ex 50.00% <11.11%> (-2.88%) ⬇️
...mbrane_rtc_engine/endpoints/webrtc/track_sender.ex 71.42% <37.50%> (+0.29%) ⬆️
...ne_rtc_engine/endpoints/hls/mobile_layout_maker.ex 60.00% <60.00%> (ø)
test/support/test_sink.ex 80.00% <62.50%> (+1.42%) ⬆️
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d5c4263...dcffa6e. Read the comment docs.

Comment on lines 43 to 48
new_buffers =
state
|> get_in([:buffers, state.update_queue])
|> then(&[buffer | &1])

state = put_in(state, [:buffers, state.update_queue], new_buffers)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new_buffers =
state
|> get_in([:buffers, state.update_queue])
|> then(&[buffer | &1])
state = put_in(state, [:buffers, state.update_queue], new_buffers)
state = update_in(state,[:buffers, state.update_queue],&[buffer | &1])

Comment on lines 54 to 66
buffers =
state
|> get_in([:buffers, state.update_queue])
|> Enum.reverse()

actions = [buffer: {:output, buffers}] ++ maybe_notify_end_of_stream(state)

new_buffers =
state
|> Map.get(:buffers)
|> Map.delete(state.update_queue)

{actions, %{state | buffers: new_buffers, update_queue: state.update_queue - 1}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
buffers =
state
|> get_in([:buffers, state.update_queue])
|> Enum.reverse()
actions = [buffer: {:output, buffers}] ++ maybe_notify_end_of_stream(state)
new_buffers =
state
|> Map.get(:buffers)
|> Map.delete(state.update_queue)
{actions, %{state | buffers: new_buffers, update_queue: state.update_queue - 1}}
{buffers,state} = pop_in([:buffers, state.update_queue])
buffers = Enum.reverse(buffers)
actions = [buffer: {:output, buffers}] ++ maybe_notify_end_of_stream(state)
{actions, %{state | update_queue: state.update_queue - 1}}

"""

@typedoc """
* `channels` - number of channels inside a frame. Default value is 1.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a frame is a term related to video and doesn't have much sense in the context of audio, but I am maybe wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same term is widely used in AudioRaw documentation.

Comment on lines 7 to 11
@typedoc """
To read more about config options go to module Membrane.HTTPAdaptiveStream.SinkBin and read options descriptions.
"""

alias Membrane.HTTPAdaptiveStream.{Manifest, Storage}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@typedoc """
To read more about config options go to module Membrane.HTTPAdaptiveStream.SinkBin and read options descriptions.
"""
alias Membrane.HTTPAdaptiveStream.{Manifest, Storage}
alias Membrane.HTTPAdaptiveStream.{Manifest, Storage}
@typedoc """
To read more about config options go to module Membrane.HTTPAdaptiveStream.SinkBin and read options descriptions.
"""


@type t() :: %__MODULE__{
manifest_name: String.t(),
manifest_module: (Path.t() -> module),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type doesn't match the default value, isn't there some error?

stream_beginning: nil,
video_layout_state: nil,
stream_ids: MapSet.new(),
video_layout_tracks_added: %{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this map and where do we put anything in it?

@@ -0,0 +1,73 @@
defmodule Membrane.RTC.Engine.Endpoint.HLS.StreamFormatUpdater do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outdated file name.

end

defp get_track_offset(%{stream_beginning: nil} = state),
do: {0, Map.put(state, :stream_beginning, System.monotonic_time())}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
do: {0, Map.put(state, :stream_beginning, System.monotonic_time())}
do: {0, %{state | stream_beginning: System.monotonic_time()})}

mix.exs Outdated
{:membrane_audio_mix_plugin, "~> 0.12.0", optional: true},
{:membrane_generator_plugin, "~> 0.8.0", optional: true},
{:membrane_realtimer_plugin, "~> 0.6.0", optional: true},
{:membrane_audio_filler_plugin, "~> 0.1.0"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this dependency optional?

Comment on lines 299 to 303
for output_file <- output_files do
output_path = Path.join(output_dir, output_file)
%{size: size} = File.stat!(output_path)
assert size > 0
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use this fragment in multiple tests could we move it to a function?

@Karolk99 Karolk99 requested a review from Rados13 February 13, 2023 14:25
@Karolk99 Karolk99 force-pushed the add-compositor-with-synchronization branch 4 times, most recently from e1fd1e0 to 2d2c779 Compare February 13, 2023 15:03
@Karolk99 Karolk99 force-pushed the add-compositor-with-synchronization branch from 2d2c779 to a7887b5 Compare February 13, 2023 15:25
@moduledoc """
Module representing mixer configuration for the HLS endpoint.
"""
if Code.ensure_loaded?(Membrane.RawAudio) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we for consistency add also check for RawVideo?

@@ -148,7 +148,6 @@ if Enum.all?(
tracks: %{},
stream_beginning: nil,
video_layout_state: nil,
stream_ids: MapSet.new(),
video_layout_tracks_added: %{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in our talk I think we should add a test for this whether we properly call functions from VideoLayoutMaker behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests added

@Karolk99 Karolk99 requested a review from Rados13 February 14, 2023 15:40
Copy link
Contributor

@mickel8 mickel8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really cool 👍 I had a couple of suggestions regarding the API

alias Membrane.HTTPAdaptiveStream.{Manifest, Storage}

@typedoc """
To read more about config options go to module Membrane.HTTPAdaptiveStream.SinkBin and read options descriptions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To read more about config options go to module Membrane.HTTPAdaptiveStream.SinkBin and read options descriptions.
To read more about config options go to module `Membrane.HTTPAdaptiveStream.SinkBin` and read options descriptions.

Comment on lines +4 to +30
Module representing function for updating video layout for the HLS stream.

1) Only main presenter
_ _ _ _
| |
| |
| |
| |
| |
- - - -
2) Main presenter and one side presenter
_ _ _ _
| |
| |
| |
- - |
| | |
- - - -

3) Main presenter and two side presenters
_ _ _ _
| |
| |
| |
- - - -
| | |
- - - -
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really cool docs 👍

@mickel8 mickel8 marked this pull request as ready for review February 16, 2023 15:54
default: SinkBinConfig,
hls_config: [
spec: HLSConfig.t(),
default: HLSConfig,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default: HLSConfig,
default: %HLSConfig{},

Base automatically changed from core-v0.11 to master February 16, 2023 16:23
@mickel8 mickel8 changed the base branch from master to core-v0.11 February 16, 2023 16:28
@mickel8 mickel8 merged commit 0512d7c into core-v0.11 Feb 16, 2023
@mickel8 mickel8 deleted the add-compositor-with-synchronization branch February 16, 2023 16:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants