View Source Jellyfish.Room (Jellyfish Server SDK v0.2.0)

Utilities for manipulating the rooms.

Examples

iex> client = Jellyfish.Client.new()
iex> assert {:ok, %Jellyfish.Room{
...>    components: [],
...>    config: %{max_peers: 10, video_codec: nil},
...>    peers: []
...>  } = room, _jellyfish_address} = Jellyfish.Room.create(client, max_peers: 10)
iex> room == %Jellyfish.Room{
...>    id: room.id,
...>    components: [],
...>    config: %{max_peers: 10, video_codec: nil},
...>    peers: []}
true
iex> assert {:ok,%Jellyfish.Peer{
...>    status: :disconnected,
...>    type: Jellyfish.Peer.WebRTC
...> } = peer, _peer_token} = Jellyfish.Room.add_peer(client, room.id, Jellyfish.Peer.WebRTC)
iex> %Jellyfish.Peer{
...>    id: peer.id,
...>    status: :disconnected,
...>    type: Jellyfish.Peer.WebRTC} == peer
true
iex> :ok = Jellyfish.Room.delete(client, room.id)
:ok

Summary

Types

Id of the room, unique within Jellyfish instance.

Type describing room options.

Peer token, created by Jellyfish. Required by client application to open connection to Jellyfish.

t()

Stores information about the room.

Functions

Adds a component to the room with room_id.

Adds a peer to the room with room_id.

Creates a new room.

Deletes the room with room_id.

Deletes the component with component_id from the room with room_id.

Deletes the peer with peer_id from the room with room_id.

Gets metadata of the room with room_id.

Lists metadata of all of the rooms.

Types

@type id() :: String.t()

Id of the room, unique within Jellyfish instance.

@type options() :: [
  max_peers: non_neg_integer() | nil,
  video_codec: :h264 | :vp8 | nil
]

Type describing room options.

  • :max_peers - maximum number of peers present in a room simultaneously. If set to nil or unspecified, the number of peers is unlimited.
  • :video_codec - enforces specific video codec for each peer in the room. If set to nil or unspecified, any codec will be accepted. To use HLS component video codec has to be :h264.
@type peer_token() :: String.t()

Peer token, created by Jellyfish. Required by client application to open connection to Jellyfish.

@type t() :: %Jellyfish.Room{
  components: [Jellyfish.Component.t()],
  config: map(),
  id: id(),
  peers: [Jellyfish.Peer.t()]
}

Stores information about the room.

Functions

Link to this function

add_component(client, room_id, component)

View Source
@spec add_component(
  Jellyfish.Client.t(),
  id(),
  Jellyfish.Component.options() | Jellyfish.Component.type()
) :: {:ok, Jellyfish.Component.t()} | {:error, atom() | String.t()}

Adds a component to the room with room_id.

Link to this function

add_peer(client, room_id, peer)

View Source
@spec add_peer(
  Jellyfish.Client.t(),
  id(),
  Jellyfish.Peer.options() | Jellyfish.Peer.type()
) ::
  {:ok, Jellyfish.Peer.t(), peer_token()} | {:error, atom() | String.t()}

Adds a peer to the room with room_id.

Link to this function

create(client, opts \\ [])

View Source
@spec create(Jellyfish.Client.t(), options()) ::
  {:ok, t(), String.t()} | {:error, atom() | String.t()}

Creates a new room.

Returns an address of Jellyfish where the room was created. When running Jellyfish in a cluster, this address might be different than the one used in the initial call. Therefore, it is important to call Jellyfish.Client.update_address/2 before subsequent operations like adding peers or components.

@spec delete(Jellyfish.Client.t(), id()) :: :ok | {:error, atom() | String.t()}

Deletes the room with room_id.

Link to this function

delete_component(client, room_id, component_id)

View Source
@spec delete_component(Jellyfish.Client.t(), id(), Jellyfish.Component.id()) ::
  :ok | {:error, atom() | String.t()}

Deletes the component with component_id from the room with room_id.

Link to this function

delete_peer(client, room_id, peer_id)

View Source
@spec delete_peer(Jellyfish.Client.t(), id(), Jellyfish.Peer.id()) ::
  :ok | {:error, atom() | String.t()}

Deletes the peer with peer_id from the room with room_id.

@spec get(Jellyfish.Client.t(), id()) :: {:ok, t()} | {:error, atom() | String.t()}

Gets metadata of the room with room_id.

@spec get_all(Jellyfish.Client.t()) :: {:ok, [t()]} | {:error, atom() | String.t()}

Lists metadata of all of the rooms.