-
Notifications
You must be signed in to change notification settings - Fork 6
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
Pts integrity warn #59
Conversation
lib/membrane_opus/parser.ex
Outdated
defp validate_pts_integrity(true = _check_pts_integrity?, packets, input_pts) do | ||
cond do | ||
length(packets) >= 2 and Enum.at(packets, 1).pts > input_pts -> | ||
Membrane.Logger.warning("PTS values are overlapping") | ||
|
||
length(packets) >= 2 and Enum.at(packets, 1).pts < input_pts -> | ||
Membrane.Logger.warning("PTS values are not continous") | ||
|
||
true -> | ||
:ok | ||
end | ||
end |
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.
defp validate_pts_integrity(true = _check_pts_integrity?, packets, input_pts) do | |
cond do | |
length(packets) >= 2 and Enum.at(packets, 1).pts > input_pts -> | |
Membrane.Logger.warning("PTS values are overlapping") | |
length(packets) >= 2 and Enum.at(packets, 1).pts < input_pts -> | |
Membrane.Logger.warning("PTS values are not continous") | |
true -> | |
:ok | |
end | |
end | |
defp validate_pts_integrity(packets, input_pts) do | |
cond do | |
length(packets) < 2 or Enum.at(packets, 1).pts == input_pts -> | |
:ok | |
Enum.at(packets, 1).pts > input_pts -> | |
Membrane.Logger.warning("PTS values are overlapping") | |
:ok | |
Enum.at(packets, 1).pts < input_pts -> | |
Membrane.Logger.warning("PTS values are not continous") | |
:ok | |
end | |
end |
- I would avoid calling
length(packets)
two times, because this function has linear complexity - Move it to
Util
module, to stop reapeating yourself and delete this function fromEncoder
- IMO it would be prettier to remove flag from function args and wrap function call into an
if
statement, eg.if check_pts_integrity?, do: Util.validate..
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.
Bump version minor
lib/membrane_opus/util.ex
Outdated
@@ -66,4 +66,20 @@ defmodule Membrane.Opus.Util do | |||
_otherwise -> :error | |||
end | |||
end | |||
|
|||
@spec validate_pts_integrity(list(), any()) :: :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.
@spec validate_pts_integrity(list(), any()) :: :ok | |
@spec validate_pts_integrity([Membrane.Buffer.t()], integer()) :: :ok |
It is better, to be more specific in typespecs, when it is possible
No description provided.