Skip to content

Commit 9b1a684

Browse files
committed
Add docs
1 parent ccc6ae3 commit 9b1a684

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/ex_webrtc/media/ogg_writer.ex

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ defmodule ExWebRTC.Media.OggWriter do
2929
@enforce_keys [:file, :page, :seg_count]
3030
defstruct @enforce_keys
3131

32+
@doc """
33+
Opens a new Ogg writer.
34+
35+
The writer MUST be closed with close/1,
36+
otherwise some of the data might not be written to a file.
37+
"""
3238
@spec open(
3339
Path.t(),
3440
sample_rate: non_neg_integer(),
@@ -47,6 +53,9 @@ defmodule ExWebRTC.Media.OggWriter do
4753
end
4854
end
4955

56+
@doc """
57+
Writes an Opus packet to the Ogg file.
58+
"""
5059
@spec write_packet(t(), binary()) :: {:ok, t()} | {:error, term()}
5160
def write_packet(_writer, packet) when byte_size(packet) > @max_page_len do
5261
# we dont handle packets that would have to span more than one page
@@ -72,6 +81,11 @@ defmodule ExWebRTC.Media.OggWriter do
7281
end
7382
end
7483

84+
@doc """
85+
Closes the writer.
86+
87+
This function MUST be called as it writes remaining, bufferd data to the Ogg file.
88+
"""
7589
@spec close(t()) :: :ok | {:error, term()}
7690
def close(%__MODULE__{file: file} = writer) do
7791
with {:ok, _writer} <- write_page(writer, true) do

0 commit comments

Comments
 (0)