@@ -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
0 commit comments