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

Fix/segment duration module #268

Merged
merged 15 commits into from
May 26, 2023
2 changes: 1 addition & 1 deletion integration_test/test_videoroom/assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions integration_test/test_videoroom/mix.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ if Code.ensure_loaded?(Membrane.HTTPAdaptiveStream.Manifest) do
"""

alias Membrane.HTTPAdaptiveStream.{Manifest, Storage}
alias Membrane.HTTPAdaptiveStream.Manifest.SegmentDuration
alias Membrane.Time

@typedoc """
To read more about config options go to module `Membrane.HTTPAdaptiveStream.SinkBin` and read options descriptions.
* `segment_duration` - The segment duration range of the regular segments.
* `partial_segment_duration` - The segment duration range of the partial segments. If not set then the bin won't produce any partial segments.
* `segment_duration` - The target duration of the regular segments.
* `partial_segment_duration` - The target duration of the partial segments. If not set then the bin won't produce any partial segments.
"""
@type t() :: %__MODULE__{
manifest_name: String.t(),
Expand All @@ -23,8 +22,8 @@ if Code.ensure_loaded?(Membrane.HTTPAdaptiveStream.Manifest) do
hls_mode: :muxed_av | :separate_av,
header_naming_fun: (Manifest.Track.t(), counter :: non_neg_integer() -> String.t()),
segment_naming_fun: (Manifest.Track.t() -> String.t()),
segment_duration: SegmentDuration.t(),
partial_segment_duration: SegmentDuration.t() | nil
segment_duration: Membrane.Time.t(),
partial_segment_duration: Membrane.Time.t() | nil
}

defstruct manifest_name: "index",
Expand All @@ -36,7 +35,7 @@ if Code.ensure_loaded?(Membrane.HTTPAdaptiveStream.Manifest) do
hls_mode: :separate_av,
header_naming_fun: &Manifest.Track.default_header_naming_fun/2,
segment_naming_fun: &Manifest.Track.default_segment_naming_fun/1,
segment_duration: SegmentDuration.new(Time.seconds(4), Time.seconds(5)),
segment_duration: Time.seconds(5),
partial_segment_duration: nil

@spec default_storage(String.t()) :: any
Expand Down
2 changes: 1 addition & 1 deletion lib/membrane_rtc_engine/endpoints/hls_endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ if Enum.all?(
}

{frames_per_second, 1} = state.mixer_config.video.stream_format.framerate
seconds_number = Membrane.Time.as_seconds(state.hls_config.segment_duration.target)
seconds_number = Membrane.Time.as_seconds(state.hls_config.segment_duration)

[
child(:compositor, compositor)
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Membrane.RTC.Engine.MixProject do
[
app: :membrane_rtc_engine,
version: @version,
elixir: "~> 1.12",
elixir: "~> 1.14",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand Down Expand Up @@ -96,7 +96,7 @@ defmodule Membrane.RTC.Engine.MixProject do
{:membrane_h264_plugin, "~> 0.2.0", optional: true},
{:membrane_audio_filler_plugin, "~> 0.1.0", optional: true},
{:membrane_video_compositor_plugin, "~> 0.3.1", optional: true},
{:membrane_http_adaptive_stream_plugin, "~> 0.13.0", optional: true},
{:membrane_http_adaptive_stream_plugin, "~> 0.14.0", optional: true},

# Optional deps for RTSP endpoint
{:connection, "~> 1.1", optional: true},
Expand Down
4 changes: 2 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
"membrane_h264_ffmpeg_plugin": {:hex, :membrane_h264_ffmpeg_plugin, "0.26.2", "ec916f86f059ca32a626153cf19ab024990d4aeb86122235c6c75a18a9dd5f10", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_common_c, "~> 0.14.0", [hex: :membrane_common_c, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.11.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_h264_format, "~> 0.5.0", [hex: :membrane_h264_format, repo: "hexpm", optional: false]}, {:membrane_raw_video_format, "~> 0.3.0", [hex: :membrane_raw_video_format, repo: "hexpm", optional: false]}, {:ratio, "~> 2.4.0", [hex: :ratio, repo: "hexpm", optional: false]}, {:unifex, "~> 1.1", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "7a7e5511bc7f2de03e861d8c068e67d83c400986be4e2f6655f508de35f6bec9"},
"membrane_h264_format": {:hex, :membrane_h264_format, "0.5.0", "95c1cc00896dab6de322cee3be0c9b0b0840537b4cc49e82a34e901b4e4763f9", [:mix], [], "hexpm", "7b44e0b02d86b45d24699de3c970186dffbca6d51aca80bbed2f6a3fe5c9eba1"},
"membrane_h264_plugin": {:hex, :membrane_h264_plugin, "0.2.1", "d1643644afd45e45f5bd9b47e52fa02c6e17a6371d3045417096f6a2dea69a13", [:mix], [{:bunch, "~> 1.4", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.11.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_h264_format, "~> 0.5.0", [hex: :membrane_h264_format, repo: "hexpm", optional: false]}], "hexpm", "875f9ccbee6cada3181b7b54ee2e89a22816e6372dfa9ea190725dc7908a57fe"},
"membrane_http_adaptive_stream_plugin": {:hex, :membrane_http_adaptive_stream_plugin, "0.13.0", "19d8eb6cc148d8dae84683561d9dcc4889706463ca6fe596ba44538595efb415", [:mix], [{:bunch, "~> 1.5", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_cmaf_format, "~> 0.6.1", [hex: :membrane_cmaf_format, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.11.2", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_mp4_plugin, "~> 0.19.0", [hex: :membrane_mp4_plugin, repo: "hexpm", optional: false]}, {:membrane_tee_plugin, "~> 0.10.1", [hex: :membrane_tee_plugin, repo: "hexpm", optional: false]}], "hexpm", "4fc1c703c70bbabd014b955be56e5cb713f2232f30c512f1edb4b060f55d6b98"},
"membrane_http_adaptive_stream_plugin": {:hex, :membrane_http_adaptive_stream_plugin, "0.14.0", "431d053b772aa306dd452865fcc6593c8dfe58694d8e3e6fef2552f5f4f77c28", [:mix], [{:bunch, "~> 1.5", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_cmaf_format, "~> 0.6.1", [hex: :membrane_cmaf_format, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.11.3", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_mp4_plugin, "~> 0.21.0", [hex: :membrane_mp4_plugin, repo: "hexpm", optional: false]}, {:membrane_tee_plugin, "~> 0.10.1", [hex: :membrane_tee_plugin, repo: "hexpm", optional: false]}], "hexpm", "5c538065b1ee749146ea811c06805fb317c2c32f2966284683c56e6b8a13d2b8"},
"membrane_ice_plugin": {:hex, :membrane_ice_plugin, "0.15.1", "34190bc0be340e1c8978068874c05164517f66b33588750f4455569a47969c57", [:mix], [{:bunch, "~> 1.5", [hex: :bunch, repo: "hexpm", optional: false]}, {:ex_dtls, "~> 0.12.0", [hex: :ex_dtls, repo: "hexpm", optional: false]}, {:fake_turn, "~> 0.4.0", [hex: :fake_turn, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.11", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_funnel_plugin, "~> 0.7.0", [hex: :membrane_funnel_plugin, repo: "hexpm", optional: false]}, {:membrane_opentelemetry, "~> 0.1.0", [hex: :membrane_opentelemetry, repo: "hexpm", optional: false]}, {:membrane_rtp_format, "~> 0.6.0", [hex: :membrane_rtp_format, repo: "hexpm", optional: false]}, {:membrane_telemetry_metrics, "~> 0.1.0", [hex: :membrane_telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "11babf966882e83dd3423818b69cc4b4bdaea5ed62b5f8589df9c285e4a69a8d"},
"membrane_mp4_format": {:hex, :membrane_mp4_format, "0.7.0", "0cc33f21dc571b43b4d2db66a056e2b7eecdc7ada71a9e0e923ab7a1554f15f2", [:mix], [], "hexpm", "7653a20e7b0c048ea05ffad6df88249abf4c1b63772c14dee843acffcad6b038"},
"membrane_mp4_plugin": {:hex, :membrane_mp4_plugin, "0.19.0", "83ea8d0734d1be638c21c5e5a774c33c8ea6afcaa9cc2b77d6b13d38eb414de0", [:mix], [{:bunch, "~> 1.5", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_aac_format, "~> 0.7.0", [hex: :membrane_aac_format, repo: "hexpm", optional: false]}, {:membrane_cmaf_format, "~> 0.6.0", [hex: :membrane_cmaf_format, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.11.2", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_file_plugin, "~> 0.13.2", [hex: :membrane_file_plugin, repo: "hexpm", optional: false]}, {:membrane_h264_format, "~> 0.5.0", [hex: :membrane_h264_format, repo: "hexpm", optional: false]}, {:membrane_mp4_format, "~> 0.7.0", [hex: :membrane_mp4_format, repo: "hexpm", optional: false]}, {:membrane_opus_format, "~> 0.3.0", [hex: :membrane_opus_format, repo: "hexpm", optional: false]}], "hexpm", "19bc8663348a204dc1489493c571372775e52a1afecb869fc0fe7faa918917bc"},
"membrane_mp4_plugin": {:hex, :membrane_mp4_plugin, "0.21.0", "d20516cad6152e92ff55b340f3b98f0f26c7a62e1a97d1ce770d6298eb8019d1", [:mix], [{:bunch, "~> 1.5", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_aac_format, "~> 0.7.0", [hex: :membrane_aac_format, repo: "hexpm", optional: false]}, {:membrane_cmaf_format, "~> 0.6.0", [hex: :membrane_cmaf_format, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.11.2", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_file_plugin, "~> 0.13.2", [hex: :membrane_file_plugin, repo: "hexpm", optional: false]}, {:membrane_h264_format, "~> 0.5.0", [hex: :membrane_h264_format, repo: "hexpm", optional: false]}, {:membrane_mp4_format, "~> 0.7.0", [hex: :membrane_mp4_format, repo: "hexpm", optional: false]}, {:membrane_opus_format, "~> 0.3.0", [hex: :membrane_opus_format, repo: "hexpm", optional: false]}], "hexpm", "d63934b1c8c038668454985797025d4149be825850ecda178624b5dc71b85f78"},
"membrane_opentelemetry": {:hex, :membrane_opentelemetry, "0.1.0", "af774bc5b9bad3a822e9a26d8530819b0291b569a282c65a7dd51cc498e6e9cd", [:mix], [{:opentelemetry_api, "~> 1.0.0", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "2e4072a5f14eb95514701e242a7667a7178dfc6afd313d4643ec0726391c243b"},
"membrane_opus_format": {:hex, :membrane_opus_format, "0.3.0", "3804d9916058b7cfa2baa0131a644d8186198d64f52d592ae09e0942513cb4c2", [:mix], [], "hexpm", "8fc89c97be50de23ded15f2050fe603dcce732566fe6fdd15a2de01cb6b81afe"},
"membrane_opus_plugin": {:hex, :membrane_opus_plugin, "0.16.0", "f84b1644410848c336e8598415589c65e4f8a58c09559a3a7998470de4af4fe2", [:mix], [{:bunch, "~> 1.3", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_common_c, "~> 0.14.0", [hex: :membrane_common_c, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.11.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_opus_format, "~> 0.3.0", [hex: :membrane_opus_format, repo: "hexpm", optional: false]}, {:membrane_raw_audio_format, "~> 0.10.0", [hex: :membrane_raw_audio_format, repo: "hexpm", optional: false]}, {:unifex, "~> 1.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "f049376cc98c188b70674dea33f7e37224cbd2c39f803cd35393e7074f0c0cca"},
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion test/hls_reference/audio_mixer/index.m3u8
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,NAME="audio_default_name",GROUP-ID="audio_default_id",AUTOSELECT=YES,DEFAULT=YES,URI="g2QABWF1ZGlv.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=57536,CODECS="avc1.42e00a",AUDIO="audio_default_id"
#EXT-X-STREAM-INF:BANDWIDTH=48752,CODECS="avc1.42e00a",AUDIO="audio_default_id"
g2QABXZpZGVv.m3u8
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:5
#EXT-X-TARGETDURATION:9
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-DISCONTINUITY-SEQUENCE:0
#EXT-X-MAP:URI="video_header_g2gCZAAFdmlkZW9tAAAAEHRlc3QtdmlkZW8tdHJhY2s_part_0.mp4"
#EXTINF:4.15,
#EXTINF:8.316666666,
video_segment_0_g2gCZAAFdmlkZW9tAAAAEHRlc3QtdmlkZW8tdHJhY2s.m4s
#EXTINF:4.166666666,
video_segment_1_g2gCZAAFdmlkZW9tAAAAEHRlc3QtdmlkZW8tdHJhY2s.m4s
#EXTINF:1.683333334,
video_segment_2_g2gCZAAFdmlkZW9tAAAAEHRlc3QtdmlkZW8tdHJhY2s.m4s
video_segment_1_g2gCZAAFdmlkZW9tAAAAEHRlc3QtdmlkZW8tdHJhY2s.m4s
#EXT-X-ENDLIST
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion test/hls_reference/muxed-segments/index.m3u8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-STREAM-INF:BANDWIDTH=3231148,CODECS="avc1.42e00a"
#EXT-X-STREAM-INF:BANDWIDTH=3231858,CODECS="avc1.42e00a"
g2QABXZpZGVv.m3u8
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:5
#EXT-X-TARGETDURATION:9
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-DISCONTINUITY-SEQUENCE:0
#EXT-X-MAP:URI="video_header_g2gCZAAFdmlkZW9tAAAADXRlc3QtdHJhY2staWQ_part_0.mp4"
#EXTINF:4.15,
#EXTINF:8.316666666,
video_segment_0_g2gCZAAFdmlkZW9tAAAADXRlc3QtdHJhY2staWQ.m4s
#EXTINF:4.166666666,
video_segment_1_g2gCZAAFdmlkZW9tAAAADXRlc3QtdHJhY2staWQ.m4s
#EXTINF:1.683333334,
video_segment_2_g2gCZAAFdmlkZW9tAAAADXRlc3QtdHJhY2staWQ.m4s
video_segment_1_g2gCZAAFdmlkZW9tAAAADXRlc3QtdHJhY2staWQ.m4s
#EXT-X-ENDLIST
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion test/hls_reference/video_mixer/index.m3u8
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,NAME="audio_default_name",GROUP-ID="audio_default_id",AUTOSELECT=YES,DEFAULT=YES,URI="g2QABWF1ZGlv.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=3196078,CODECS="avc1.42e00a",AUDIO="audio_default_id"
#EXT-X-STREAM-INF:BANDWIDTH=3196806,CODECS="avc1.42e00a",AUDIO="audio_default_id"
g2QABXZpZGVv.m3u8
Binary file not shown.
Binary file not shown.
Binary file modified test/hls_reference/video_mixer/video_segment_2_g2QABXZpZGVv.m4s
Binary file not shown.
5 changes: 2 additions & 3 deletions test/membrane_rtc_engine/hls_endpoint_test.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
defmodule Membrane.RTC.HLSEndpointTest do
use ExUnit.Case

alias Membrane.HTTPAdaptiveStream.Manifest.SegmentDuration
alias Membrane.RTC.Engine
alias Membrane.RTC.Engine.Endpoint.HLS
alias Membrane.RTC.Engine.Message
Expand Down Expand Up @@ -414,7 +413,7 @@ defmodule Membrane.RTC.HLSEndpointTest do
hls_config: %HLSConfig{
mode: :vod,
target_window_duration: :infinity,
segment_duration: SegmentDuration.new(Membrane.Time.seconds(2), Membrane.Time.seconds(3))
segment_duration: Membrane.Time.seconds(3)
}
}
end
Expand Down Expand Up @@ -446,7 +445,7 @@ defmodule Membrane.RTC.HLSEndpointTest do
hls_mode: :muxed_av,
mode: :vod,
target_window_duration: :infinity,
segment_duration: SegmentDuration.new(Membrane.Time.seconds(2), Membrane.Time.seconds(3))
segment_duration: Membrane.Time.seconds(3)
}
}
end
Expand Down
7 changes: 1 addition & 6 deletions test/membrane_rtc_engine/rtsp_endpoint_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ defmodule Membrane.RTC.RTSPEndpointTest do
alias Membrane.RTC.Engine.Endpoint.{HLS, RTSP}
alias Membrane.RTC.Engine.Message

alias Membrane.HTTPAdaptiveStream.Manifest.SegmentDuration

setup do
options = [
id: "test_rtc"
Expand Down Expand Up @@ -181,10 +179,7 @@ defmodule Membrane.RTC.RTSPEndpointTest do
hls_config: %HLS.HLSConfig{
mode: :vod,
target_window_duration: :infinity,
segment_duration: %SegmentDuration{
min: Membrane.Time.seconds(2),
target: Membrane.Time.seconds(2)
}
segment_duration: Membrane.Time.seconds(2)
}
}

Expand Down