Skip to content
Merged
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 @@ -17,7 +17,7 @@ The package can be installed by adding `membrane_transcoder_plugin` to your list
```elixir
def deps do
[
{:membrane_transcoder_plugin, "~> 0.3.1"}
{:membrane_transcoder_plugin, "~> 0.3.2"}
]
end
```
Expand Down
29 changes: 23 additions & 6 deletions lib/transcoder/audio.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,30 @@ defmodule Membrane.Transcoder.Audio do

@type audio_stream_format :: AAC.t() | Opus.t() | Membrane.MPEGAudio.t() | RawAudio.t()

defguardp is_raw_audio_format(format)
when is_struct(format) and format.__struct__ == RawAudio

defguardp is_aac_format(format)
when is_struct(format) and format.__struct__ == AAC

defguardp is_opus_format(format)
when is_struct(format) and
(format.__struct__ == Opus or
(format.__struct__ == RemoteStream and
format.content_format == Opus and
format.type == :packetized))

defguardp is_mpeg_audio_format(format)
when is_struct(format) and
(format.__struct__ == MPEGAudio or
(format.__struct__ == RemoteStream and
format.content_format == MPEGAudio))

defguard is_audio_format(format)
when is_struct(format) and
(format.__struct__ in [AAC, Opus, MPEGAudio, RawAudio] or
(format.__struct__ == RemoteStream and
format.content_format == Opus and
format.type == :packetized) or
(format.__struct__ == RemoteStream and format.content_format == MPEGAudio))
when is_raw_audio_format(format) or
is_aac_format(format) or
is_opus_format(format) or
is_mpeg_audio_format(format)

defguard is_opus_compliant(format)
when is_map_key(format, :content_type) and format.content_type == :s16le and
Expand Down
38 changes: 34 additions & 4 deletions lib/transcoder/video.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,26 @@ defmodule Membrane.Transcoder.Video do

@type video_stream_format :: VP8.t() | VP9.t() | H264.t() | H265.t() | RawVideo.t()

defguardp is_raw_video_format(format)
when is_struct(format) and format.__struct__ == RawVideo

defguardp is_h26x_format(format)
when is_struct(format) and
(format.__struct__ in [H264, H265] or
(format.__struct__ == RemoteStream and
format.content_format in [H264, H265]))

defguardp is_vpx_format(format)
when is_struct(format) and
(format.__struct__ in [VP8, VP9] or
(format.__struct__ == RemoteStream and
format.content_format in [VP8, VP9] and
format.type == :packetized))

defguard is_video_format(format)
when is_struct(format) and
(format.__struct__ in [VP8, VP9, H264, H265, RawVideo] or
(format.__struct__ == RemoteStream and format.content_format in [VP8, VP9] and
format.type == :packetized))
when is_h26x_format(format) or
is_vpx_format(format) or
is_raw_video_format(format)

@spec plug_video_transcoding(
ChildrenSpec.builder(),
Expand All @@ -24,6 +39,21 @@ defmodule Membrane.Transcoder.Video do
do_plug_video_transcoding(builder, input_format, output_format, transcoding_policy)
end

defp do_plug_video_transcoding(
builder,
%RemoteStream{content_format: h26x},
output_format,
transcoding_policy
)
when h26x in [H264, H265] do
do_plug_video_transcoding(
builder,
struct!(h26x),
output_format,
transcoding_policy
)
end

defp do_plug_video_transcoding(builder, %H264{}, %H264{} = output_format, transcoding_policy)
when transcoding_policy in [:if_needed, :never] do
builder
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.Transcoder.Plugin.Mixfile do
use Mix.Project

@version "0.3.1"
@version "0.3.2"
@github_url "https://github.com/membraneframework/membrane_transcoder_plugin"

def project do
Expand Down