Skip to content

Commit da7f139

Browse files
authored
Add content_format option (#60)
* Add content_format option * Bump patch instead of minor
1 parent cca8cb8 commit da7f139

4 files changed

Lines changed: 26 additions & 13 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The package can be installed by adding `membrane_file_plugin` to your list of de
1515
```elixir
1616
def deps do
1717
[
18-
{:membrane_file_plugin, "~> 0.17.4"}
18+
{:membrane_file_plugin, "~> 0.17.5"}
1919
]
2020
end
2121
```

lib/membrane_file/source.ex

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,49 @@ defmodule Membrane.File.Source do
3434
The source working in `seekable?: true` mode won't send any data before that event is received.
3535
For more information about how to steer reading in `seekable?: true` mode, see: `Membrane.File.SeekSourceEvent`.
3636
"""
37+
],
38+
content_format: [
39+
spec: module() | nil,
40+
default: nil,
41+
description: """
42+
Value from this option will be inserted into the `:content_format` field of emitted `Membrane.RemoteStream`
43+
stream format.
44+
"""
3745
]
3846

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

4149
@impl true
42-
def handle_init(_ctx, %__MODULE__{location: :stdin, chunk_size: size, seekable?: seekable?}) do
43-
if seekable? do
50+
def handle_init(_ctx, %__MODULE__{location: :stdin} = opts) do
51+
if opts.seekable? do
4452
raise "Cannot seek when reading from :stdin"
4553
else
4654
{[],
4755
%{
4856
location: :stdin,
49-
chunk_size: size,
57+
chunk_size: opts.chunk_size,
5058
should_send_eos: true,
5159
size_to_read: :infinity,
52-
seekable?: false
60+
seekable?: false,
61+
content_format: opts.content_format
5362
}}
5463
end
5564
end
5665

5766
@impl true
58-
def handle_init(_ctx, %__MODULE__{location: location, chunk_size: size, seekable?: seekable?})
67+
def handle_init(_ctx, %__MODULE__{location: location} = opts)
5968
when is_binary(location) do
60-
size_to_read = if seekable?, do: 0, else: :infinity
69+
size_to_read = if opts.seekable?, do: 0, else: :infinity
6170

6271
{[],
6372
%{
6473
location: Path.expand(location),
65-
chunk_size: size,
74+
chunk_size: opts.chunk_size,
6675
fd: nil,
67-
should_send_eos?: not seekable?,
76+
should_send_eos?: not opts.seekable?,
6877
size_to_read: size_to_read,
69-
seekable?: seekable?
78+
seekable?: opts.seekable?,
79+
content_format: opts.content_format
7080
}}
7181
end
7282

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

90100
@impl true
91101
def handle_playing(_ctx, state) do
92-
{[stream_format: {:output, %RemoteStream{type: :bytestream}}], state}
102+
{[
103+
stream_format:
104+
{:output, %RemoteStream{type: :bytestream, content_format: state.content_format}}
105+
], state}
93106
end
94107

95108
@impl true

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Membrane.File.Plugin.Mixfile do
22
use Mix.Project
33

4-
@version "0.17.4"
4+
@version "0.17.5"
55

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

test/membrane_file/sink_source_integration_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ defmodule Membrane.File.SinkSourceIntegrationTest do
120120

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

125125
actions = [
126126
buffer: {:output, %Buffer{payload: head}},

0 commit comments

Comments
 (0)