-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement basic functionalities #1
Conversation
b19c76f
to
f7febd7
Compare
d7ef045
to
58c1df0
Compare
5b507ea
to
b469dbf
Compare
def new(options \\ []) do | ||
metric = | ||
options | ||
|> Keyword.get(:pause_demand_boundary_unit, :buffers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as we spoke, the most appropriate unit seems to be time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will implement having boundary unit expressed in time
in the another PR
lib/membrane/timestamp_queue.ex
Outdated
Makes the queue not return any buffer in `pop_batch/3`, until a buffer or end of stream arrival | ||
from `pad_ref`. | ||
""" | ||
@spec wait_on_pad(t(), Pad.ref()) :: t() | ||
def wait_on_pad(%__MODULE__{} = timestamp_queue, pad_ref) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes the queue not return any buffer in `pop_batch/3`, until a buffer or end of stream arrival | |
from `pad_ref`. | |
""" | |
@spec wait_on_pad(t(), Pad.ref()) :: t() | |
def wait_on_pad(%__MODULE__{} = timestamp_queue, pad_ref) do | |
Registers an input pad in the queue without pushing anything on that pad. | |
Once a pad is registered, the `pop_batch/3` function won't return buffers | |
until a `buffer` or `end_of_stream` is available on the registered pad. | |
Pushing a buffer on an unregistered pad automatically registers it. | |
""" | |
@spec register_pad(t(), Pad.ref()) :: t() | |
def register_pad(%__MODULE__{} = timestamp_queue, pad_ref) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- After calling this function, stream formats and events still can occur in the returned batch
- Calling
push_stream_format
orpush_event
doesn't cause waiting on the pad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the suggestion
lib/membrane/timestamp_queue.ex
Outdated
@doc """ | ||
Creates and returnes new #{inspect(__MODULE__)}. | ||
|
||
Accepts `t:options()`. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this says nothing :P
@doc """ | |
Creates and returnes new #{inspect(__MODULE__)}. | |
Accepts `t:options()`. | |
""" |
lib/membrane/timestamp_queue.ex
Outdated
A queue, that accepts buffers, stream formats and events from various pads and sorts them based on | ||
their timestamps. | ||
""" | ||
@type t :: %__MODULE__{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should probably be opaque
lib/membrane/timestamp_queue.ex
Outdated
Buffer #{inspect(buffer, pretty: true)} from pad #{inspect(pad_ref)} has timestamp equal \ | ||
#{inspect(buffer_timestamp)}, but previous buffer pushed on queue from this pad had timestamp \ | ||
equal #{inspect(max_timestamp)}. Buffers from a single pad must have non-decreasing timestamps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to change the word timestamp to PTS
or DTS
, whichever we rely on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can refactor error message, but simply changing timestamp
to PTS
or DTS
will make this log untrue, since having buffers with monotonic DTS and non-monotonic PTS is totally ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having buffers with monotonic DTS and non-monotonic PTS is totally ok
If the queue relies on PTS and they are not monotonic, the queue can't handle this case no matter what DTS are, so I think the log would be true. Such a situation would probably mean a bug anyway - I believe PTS and DTS should either be always set or never set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If buffers from a specific pad contain DTS, queue will look only at DTS and won't look at PTS at all
lib/membrane/timestamp_queue.ex
Outdated
Pops as many buffers from the queue, as it is possible. | ||
|
||
Returns suggested actions list, list of popped buffers and the updated queue. | ||
|
||
If the amount of buffers associated with any pad in the queue falls below the | ||
`pause_demand_boundary`, the suggested actions list contains `t:Action.resume_auto_demand()` | ||
actions, otherwise it is an empty list. | ||
|
||
If the queue cannot return any buffer, empty list is returned. Note, that queue doesn't have to be | ||
empty to be unable to return a buffer - sometimes queue must keep up to 1 buffer for each pad, | ||
to be able to work correctly. | ||
|
||
To be able to maintain proper order of buffers from varius pads, queue won't return next buffer, | ||
if the next buffer that should be returned: | ||
- is the only buffer from a certain pad | ||
- and that certain pad has not received the end of stream yet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's my try, correct me if I'm wrong:
Pops as many buffers from the queue, as it is possible. | |
Returns suggested actions list, list of popped buffers and the updated queue. | |
If the amount of buffers associated with any pad in the queue falls below the | |
`pause_demand_boundary`, the suggested actions list contains `t:Action.resume_auto_demand()` | |
actions, otherwise it is an empty list. | |
If the queue cannot return any buffer, empty list is returned. Note, that queue doesn't have to be | |
empty to be unable to return a buffer - sometimes queue must keep up to 1 buffer for each pad, | |
to be able to work correctly. | |
To be able to maintain proper order of buffers from varius pads, queue won't return next buffer, | |
if the next buffer that should be returned: | |
- is the only buffer from a certain pad | |
- and that certain pad has not received the end of stream yet | |
Pops items from the queue while they are available. | |
An item that is not a buffer is always considered available. A buffer is | |
available when the following conditions are met: | |
- There is another buffer or `end_of_stream` enqueued on the pad | |
- On each other pad there is either `end_of_stream` or a buffer with a lower timestamp. | |
The returned value is a suggested actions list, a list of popped buffers and the updated queue. | |
If the amount of buffers associated with any pad in the queue falls below the | |
`pause_demand_boundary`, the suggested actions list contains `t:Action.resume_auto_demand()` | |
actions, otherwise it is an empty list. |
lib/membrane/timestamp_queue.ex
Outdated
timestamp_field = if pad_queue.use_pts?, do: "pts", else: "dts" | ||
max_timestamp = pad_queue.max_timestamp_on_qex | ||
|
||
if is_integer(max_timestamp) and max_timestamp > buffer_timestamp do | ||
raise """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timestamp_field = if pad_queue.use_pts?, do: "pts", else: "dts" | |
max_timestamp = pad_queue.max_timestamp_on_qex | |
if is_integer(max_timestamp) and max_timestamp > buffer_timestamp do | |
raise """ | |
max_timestamp = pad_queue.max_timestamp_on_qex | |
if is_integer(max_timestamp) and max_timestamp > buffer_timestamp do | |
timestamp_field = if pad_queue.use_pts?, do: "pts", else: "dts" | |
raise """ |
000fa9f
to
1ac231e
Compare
Continuation of membraneframework/membrane_core#756
Relates to membraneframework/membrane_core#734