From 8ea45861cfab0e1c545a0094521adbe287aefdf6 Mon Sep 17 00:00:00 2001 From: noarkhh Date: Mon, 6 Jul 2026 17:39:59 +0200 Subject: [PATCH 1/2] Add content_format option --- README.md | 2 +- lib/membrane_file/source.ex | 33 +++++++++++++------ mix.exs | 2 +- .../sink_source_integration_test.exs | 2 +- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 37bdcb5..3271d8b 100644 --- a/README.md +++ b/README.md @@ -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.18.0"} ] end ``` diff --git a/lib/membrane_file/source.ex b/lib/membrane_file/source.ex index 110e29f..11378f0 100644 --- a/lib/membrane_file/source.ex +++ b/lib/membrane_file/source.ex @@ -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 @@ -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 diff --git a/mix.exs b/mix.exs index 0a9c252..84983ae 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Membrane.File.Plugin.Mixfile do use Mix.Project - @version "0.17.4" + @version "0.18.0" @github_url "https://github.com/membraneframework/membrane_file_plugin" diff --git a/test/membrane_file/sink_source_integration_test.exs b/test/membrane_file/sink_source_integration_test.exs index 781c42d..7d781a9 100644 --- a/test/membrane_file/sink_source_integration_test.exs +++ b/test/membrane_file/sink_source_integration_test.exs @@ -120,7 +120,7 @@ defmodule Membrane.File.SinkSourceIntegrationTest do @impl true def handle_buffer(:input, buffer, _ctx, %{head_size: head_size, split?: true}) do - <> = buffer.payload + <> = buffer.payload actions = [ buffer: {:output, %Buffer{payload: head}}, From 05c10f95a24000fbfb92bf572ce8c359e307b529 Mon Sep 17 00:00:00 2001 From: noarkhh Date: Mon, 6 Jul 2026 18:03:18 +0200 Subject: [PATCH 2/2] Bump patch instead of minor --- README.md | 2 +- mix.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3271d8b..e1de7d2 100644 --- a/README.md +++ b/README.md @@ -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.18.0"} + {:membrane_file_plugin, "~> 0.17.5"} ] end ``` diff --git a/mix.exs b/mix.exs index 84983ae..cd77f36 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Membrane.File.Plugin.Mixfile do use Mix.Project - @version "0.18.0" + @version "0.17.5" @github_url "https://github.com/membraneframework/membrane_file_plugin"