Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetOSD #77

Merged
merged 7 commits into from
Aug 5, 2024
Merged
Changes from 1 commit
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
72 changes: 55 additions & 17 deletions lib/media/ver10/set_osd.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,64 @@ defmodule Onvif.Media.Ver10.SetOSD do
),
element(:"tt:Pos", %{x: osd.position.pos.x, y: osd.position.pos.y})
]),
element(:"tt:TextString", [
element(:"tt:IsPersistentText", osd.text_string.is_persistent_text),
element(
:"tt:Type",
Keyword.fetch!(
Ecto.Enum.mappings(osd.text_string.__struct__, :type),
osd.text_string.type
)
),
element(:"tt:DateFormat", osd.text_string.date_format),
element(:"tt:TimeFormat", osd.text_string.time_format),
element(:"tt:FontSize", osd.text_string.font_size),
font_color_element(osd.text_string.font_color),
background_color_element(osd.text_string.background_color),
element(:"tt:PlainText", osd.text_string.plain_text)
]),
image_element(osd.image)
gen_element_type(osd.type, osd)
])
])
])
|> IO.inspect()
paoloo marked this conversation as resolved.
Show resolved Hide resolved
paoloo marked this conversation as resolved.
Show resolved Hide resolved
end

defp gen_element_type(:text, osd) do
element(:"tt:TextString", [
element_is_persistent_text(osd.text_string.is_persistent_text),
element(
:"tt:Type",
Keyword.fetch!(
Ecto.Enum.mappings(osd.text_string.__struct__, :type),
osd.text_string.type
)
),
element_date_format(osd.text_string.date_format),
element_time_format(osd.text_string.time_format),
paoloo marked this conversation as resolved.
Show resolved Hide resolved
element_font_size(osd.text_string.font_size),
font_color_element(osd.text_string.font_color),
background_color_element(osd.text_string.background_color),
element_plain_text(osd.text_string.plain_text)
])
end

defp gen_element_type(:image, osd) do
image_element(osd.image)
end

defp element_is_persistent_text(nil), do: []

defp element_is_persistent_text(is_persistent_text) do
element(:"tt:IsPersistentText", is_persistent_text)
end

defp element_date_format(nil), do: []

defp element_date_format(date_format) do
element(:"tt:DateFormat", date_format)
end

defp element_time_format(nil), do: []

defp element_time_format(time_format) do
element(:"tt:TimeFormat", time_format)
end

defp element_font_size(nil), do: []

defp element_font_size(font_size) do
element(:"tt:FontSize", font_size)
end

defp element_plain_text(nil), do: []

defp element_plain_text(plain_text) do
element(:"tt:PlainText", plain_text)
end

defp font_color_element(nil), do: []
Expand Down