This repository has been archived by the owner on Sep 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RTC-258][RTC-259] Fix overflow in Tee tests. Fix RC in VAD Tee test. (…
- Loading branch information
Showing
3 changed files
with
82 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
defmodule Membrane.RTC.Engine.PreciseRealtimer do | ||
@moduledoc false | ||
|
||
use Membrane.Filter | ||
|
||
def_input_pad :input, demand_mode: :auto, accepted_format: _any | ||
def_output_pad :output, demand_mode: :auto, accepted_format: _any | ||
|
||
def_options timer_resolution: [ | ||
spec: Membrane.Time.t() | ||
] | ||
|
||
@impl true | ||
def handle_init(_ctx, opts) do | ||
{[], | ||
%{ | ||
tick_idx: 0, | ||
resolution: opts.timer_resolution, | ||
queue: Qex.new() | ||
}} | ||
end | ||
|
||
@impl true | ||
def handle_playing(_ctx, state) do | ||
{[start_timer: {:timer, state.resolution}], state} | ||
end | ||
|
||
@impl true | ||
def handle_process(:input, buffer, _ctx, state) do | ||
{[], %{state | queue: Qex.push(state.queue, {:buffer, {:output, buffer}})}} | ||
end | ||
|
||
@impl true | ||
def handle_end_of_stream(:input, _ctx, state) do | ||
{[], %{state | queue: Qex.push(state.queue, {:end_of_stream, :output})}} | ||
end | ||
|
||
@impl true | ||
def handle_tick(:timer, _ctx, %{tick_idx: tick_idx} = state) do | ||
current_ts = tick_idx * state.resolution | ||
state = %{state | tick_idx: tick_idx + 1} | ||
|
||
if Enum.empty?(state.queue) do | ||
{[], state} | ||
else | ||
{actions, buffered} = | ||
Enum.split_while(state.queue, fn | ||
{:buffer, {:output, buffer}} -> | ||
Membrane.Buffer.get_dts_or_pts(buffer) <= current_ts | ||
|
||
_other -> | ||
true | ||
end) | ||
|
||
{actions, %{state | queue: Qex.new(buffered)}} | ||
end | ||
end | ||
end |