Skip to content
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

V0.18 #53

Merged
merged 10 commits into from
Jan 23, 2024
Merged
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions lib/membrane_aac_fdk_plugin/encoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ defmodule Membrane.AAC.FDK.Encoder do
encapsulation: :ADTS
}

{[stream_format: {:output, out_format}], %{state | native: native}}
{[stream_format: {:output, out_format}],
Map.merge(state, %{
native: native,
input_stream_format: format
})}
end

@impl true
Expand All @@ -157,9 +161,8 @@ defmodule Membrane.AAC.FDK.Encoder do
{encoded_buffers, bytes_used, state} when bytes_used > 0 ->
<<_handled::binary-size(bytes_used), rest::binary>> = to_encode

if check_pts_integrity? and length(encoded_buffers) >= 2 and
Enum.at(encoded_buffers, 1).pts > input_pts do
Membrane.Logger.warning("PTS values are overlapping")
if check_pts_integrity? do
validate_pts_integrity(encoded_buffers, input_pts)
end

{[buffer: {:output, encoded_buffers}], %{state | queue: rest}}
Expand Down Expand Up @@ -270,4 +273,19 @@ defmodule Membrane.AAC.FDK.Encoder do
defp validate_bitrate_mode!(bitrate_mode) do
raise "Invalid bitrate_mode: #{inspect(bitrate_mode)}"
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
end