Hardware-accelerated video streaming surface.
Uses VideoToolbox (iOS) / MediaCodec (Android) for zero-copy GPU texture rendering. Decoded frames become GPU textures directly — no CPU bitmap copy.
Architecture:
H264/H265 stream → Hardware Decoder → GPU Texture → RendererExample
# Start a video stream from URL
{:ok, stream} = Dala.Media.Video.start_stream(socket, "https://example.com/video.mp4")
# Control playback
Dala.Media.Video.play(stream)
Dala.Media.Video.pause(stream)
Dala.Media.Video.seek(stream, 5000) # milliseconds
# Events arrive as handle_info:
# {:video, :frame_ready, %{texture_id: id, pts: timestamp}}
# {:video, :ended, %{}}
# {:video, :error, %{reason: reason}}
Summary
Functions
Returns a specification to start this module under a supervisor.
Get the GPU texture ID for the current frame (for compositing).
Get stream duration in milliseconds.
Pause playback (keeps decoder and texture alive).
Resume or start playback.
Get current playback position in milliseconds.
Start decoding a stream but don't render yet (for buffering).
Seek to a position in milliseconds.
Set whether the stream should loop.
Set volume (0.0 to 1.0).
Start a stream from a camera feed (uses existing camera preview).
Start a video stream from a URL or local path.
Get current state.
Stop playback and release all resources.
Types
@type stream_ref() :: pid()
@type texture_id() :: non_neg_integer()
@type timestamp_ms() :: non_neg_integer()
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec current_texture(stream_ref()) :: texture_id() | nil
Get the GPU texture ID for the current frame (for compositing).
@spec duration(stream_ref()) :: timestamp_ms() | :unknown
Get stream duration in milliseconds.
@spec pause(stream_ref()) :: :ok
Pause playback (keeps decoder and texture alive).
@spec play(stream_ref()) :: :ok
Resume or start playback.
@spec position(stream_ref()) :: timestamp_ms()
Get current playback position in milliseconds.
@spec prepare_stream(Dala.Socket.t(), String.t(), keyword()) :: {:ok, stream_ref()} | {:error, term()}
Start decoding a stream but don't render yet (for buffering).
@spec seek(stream_ref(), timestamp_ms()) :: :ok
Seek to a position in milliseconds.
@spec set_loop(stream_ref(), boolean()) :: :ok
Set whether the stream should loop.
@spec set_volume(stream_ref(), float()) :: :ok
Set volume (0.0 to 1.0).
@spec start_camera_stream( Dala.Socket.t(), keyword() ) :: {:ok, stream_ref()} | {:error, term()}
Start a stream from a camera feed (uses existing camera preview).
@spec start_stream(Dala.Socket.t(), String.t(), keyword()) :: {:ok, stream_ref()} | {:error, term()}
Start a video stream from a URL or local path.
@spec state(stream_ref()) :: atom()
Get current state.
@spec stop(stream_ref()) :: :ok
Stop playback and release all resources.