Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The package can be installed by adding `membrane_file_plugin` to your list of de
```elixir
def deps do
[
{:membrane_file_plugin, "~> 0.17.4"}
{:membrane_file_plugin, "~> 0.17.5"}
]
end
```
Expand Down
33 changes: 23 additions & 10 deletions lib/membrane_file/source.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,49 @@ defmodule Membrane.File.Source do
The source working in `seekable?: true` mode won't send any data before that event is received.
For more information about how to steer reading in `seekable?: true` mode, see: `Membrane.File.SeekSourceEvent`.
"""
],
content_format: [
spec: module() | nil,
default: nil,
description: """
Value from this option will be inserted into the `:content_format` field of emitted `Membrane.RemoteStream`
stream format.
"""
]

def_output_pad :output, accepted_format: %RemoteStream{type: :bytestream}, flow_control: :manual

@impl true
def handle_init(_ctx, %__MODULE__{location: :stdin, chunk_size: size, seekable?: seekable?}) do
if seekable? do
def handle_init(_ctx, %__MODULE__{location: :stdin} = opts) do
if opts.seekable? do
raise "Cannot seek when reading from :stdin"
else
{[],
%{
location: :stdin,
chunk_size: size,
chunk_size: opts.chunk_size,
should_send_eos: true,
size_to_read: :infinity,
seekable?: false
seekable?: false,
content_format: opts.content_format
}}
end
end

@impl true
def handle_init(_ctx, %__MODULE__{location: location, chunk_size: size, seekable?: seekable?})
def handle_init(_ctx, %__MODULE__{location: location} = opts)
when is_binary(location) do
size_to_read = if seekable?, do: 0, else: :infinity
size_to_read = if opts.seekable?, do: 0, else: :infinity

{[],
%{
location: Path.expand(location),
chunk_size: size,
chunk_size: opts.chunk_size,
fd: nil,
should_send_eos?: not seekable?,
should_send_eos?: not opts.seekable?,
size_to_read: size_to_read,
seekable?: seekable?
seekable?: opts.seekable?,
content_format: opts.content_format
}}
end

Expand All @@ -89,7 +99,10 @@ defmodule Membrane.File.Source do

@impl true
def handle_playing(_ctx, state) do
{[stream_format: {:output, %RemoteStream{type: :bytestream}}], state}
{[
stream_format:
{:output, %RemoteStream{type: :bytestream, content_format: state.content_format}}
], state}
end

@impl true
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Membrane.File.Plugin.Mixfile do
use Mix.Project

@version "0.17.4"
@version "0.17.5"

@github_url "https://github.com/membraneframework/membrane_file_plugin"

Expand Down
2 changes: 1 addition & 1 deletion test/membrane_file/sink_source_integration_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ defmodule Membrane.File.SinkSourceIntegrationTest do

@impl true
def handle_buffer(:input, buffer, _ctx, %{head_size: head_size, split?: true}) do
<<head::binary-size(head_size), tail::binary>> = buffer.payload
<<head::binary-size(^head_size), tail::binary>> = buffer.payload

actions = [
buffer: {:output, %Buffer{payload: head}},
Expand Down
Loading