Skip to content

Commit

Permalink
add end of seek event
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-hek committed Jun 27, 2024
1 parent 1a1d3f9 commit 349b0b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 10 additions & 0 deletions lib/membrane_file/end_of_seek_event.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
defmodule Membrane.File.EndOfSeekEvent do
@moduledoc """
An event sent by the `Membrane.File.Source` with `seekable?: true` option,
after it sent all the data requested by `Membrane.File.SeekSourceEvent` or
whole file was read.
"""
@derive Membrane.EventProtocol

defstruct []
end
9 changes: 5 additions & 4 deletions lib/membrane_file/source.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ defmodule Membrane.File.Source do
use Membrane.Source

alias Membrane.{Buffer, RemoteStream}
alias Membrane.File.NewSeekEvent
alias Membrane.File.SeekSourceEvent
alias Membrane.File.{EndOfSeekEvent, NewSeekEvent, SeekSourceEvent}

@common_file Membrane.File.CommonFileBehaviour.get_impl()

Expand Down Expand Up @@ -185,8 +184,10 @@ defmodule Membrane.File.Source do
actions =
buffer_actions ++
cond do
state.should_send_eos? and (state.size_to_read == 0 or supplied_size < to_supply_size) ->
[end_of_stream: :output]
state.size_to_read == 0 or supplied_size < to_supply_size ->
eos = if state.should_send_eos?, do: [end_of_stream: :output], else: []
end_of_seek = if state.seekable?, do: [event: {:output, %EndOfSeekEvent{}}], else: []
end_of_seek ++ eos

to_supply_size == supplied_size ->
redemand
Expand Down

0 comments on commit 349b0b3

Please sign in to comment.