The Client API
VideoServiceClient is the only type your application needs. This page covers hosting the service,
every client method, status notifications, and the playback states.
Table of Contents
Creating and Starting the Client
Hosting the Service
VideoService runs inside your application's service manager. The application must start it before
creating any client:
AhsokaRuntime.StartLocalServiceManager();
That hosts every AutoStart service in the package's service list, including VideoService. When
the video service is constructed it reads the packaged player list and, if any GMSL or analog player
is configured, starts the camera bring-up in the background.
Warning
Skipping StartLocalServiceManager() is the most common way to hang a video application. Nothing
hosts the service, the client connects optimistically anyway, and the first request blocks
forever with nothing in the log.
The service is found because AhsokaStartup.g.cs — generated into your project by the Toolkit's SDK
step — registers AhsokaExtensionsVideoPlayerRegistrar in a module initializer before any of your
code runs. If you remove the extension or regenerate without it, VideoService is no longer
registered.
Creating and Starting the Client
var client = new VideoServiceClient(); // uses the package's VideoService entry
client.NotificationReceived += OnVideoNotification;
client.Start();
| Constructor | Use |
|---|---|
VideoServiceClient() |
Connects using the VideoService configuration from the package |
VideoServiceClient(ServiceConfiguration config) |
Connects using an explicit configuration |
The service can report itself started a moment before its request handler is ready. The demos guard the first request with a short retry:
VideoPlayerInfo players = null;
for (int attempt = 0; attempt < 10 && players == null; attempt++)
{
if (attempt > 0)
Thread.Sleep(25);
players = client.GetVideoPlayers();
}
Methods
Every method is a synchronous request/response.
| Method | Argument | Returns | Use |
|---|---|---|---|
GetVideoPlayers() |
— | VideoPlayerInfo |
Every configured player, as packaged |
PlayVideo(request) |
VideoPlaybackRequest |
VideoStatus |
Start a player |
StopVideo(player) |
VideoPlayer |
VideoStatus |
Stop a player. Only VideoPlayerID is read. |
RequestVideoStatus(player) |
VideoPlayer |
VideoStatus |
One-shot current status. Only VideoPlayerID is read. |
GetVcicStatus() |
— | VcicStatus |
VCIC host network and camera presence. See VCIC Cameras. |
PauseVideo(player) |
VideoPlayer |
VideoStatus |
Pause a playing File player. Ignored for live inputs. |
ResumeVideo(player) |
VideoPlayer |
VideoStatus |
Resume a paused File player. Ignored for live inputs. |
PositionVideo(position) |
VideoPosition |
VideoStatus |
PositionInMs = 0 restarts a File player; other positions are not supported yet. Ignored for live inputs. |
StopVideo, RequestVideoStatus, PauseVideo and ResumeVideo take a VideoPlayer, but you do
not need the configured object — new VideoPlayer { VideoPlayerID = id } is enough. Passing an
entry from GetVideoPlayers() works just as well.
The transport calls act on File players only — see
Pause, Resume and Restart. For GMSL, Analog and VCIC
the service logs 'Pause' ignored — not supported for 'GMSL' (and so on) at low severity and returns
the current status without touching the pipeline. A PositionVideo other than 0 on a File player
is logged and ignored the same way, as are a pause of a File player that is not playing, a resume of
one that is not paused, and a restart of one that has ended.
VideoPlaybackRequest
| Member | Meaning |
|---|---|
VideoPlayerID |
The player to start |
StatusUpdateInMs |
How often to send StatusUpdated while playing or paused. 0 sends none, apart from the one sent when a player ends on its own. Positive values below 1000 are raised to 1000 (and logged), so a small interval cannot flood the notification channel. |
RenderWidth, RenderHeight |
VCIC and File. A per-play render size; when both are greater than 0 they override the player's configured size for this play. For VCIC the width also chooses the stream tier — see Render Size and Stream Quality. |
VideoURL |
Normally empty — players use their configured VideoSource. For GMSL/analog, a value here replaces the capture node for this one play. For File, it names the file to play, overriding any configured path — see Choosing the File. |
Status and Notifications
Every call returns a VideoStatus, and notifications carry the same type:
| Member | Meaning |
|---|---|
VideoPlayerID |
The player this status describes |
VideoState |
A PlaybackState |
TotalTimeInMs, PositionInMs |
Timeline values. A File player reports the file's duration and position; always 0 for live feeds on the device. |
To receive StatusUpdated, subscribe to the client's NotificationReceived event and set
StatusUpdateInMs on the play request:
void OnVideoNotification(object sender, AhsokaClientBase<VideoMessageTypes.Ids>.AhsokaNotificationArgs e)
{
if (e.NotificationObject is not VideoStatus status)
return;
Console.WriteLine($"Player {status.VideoPlayerID}: {status.VideoState}");
}
Notifications for every player arrive on the same event; use VideoPlayerID to tell them apart. On
the device they are driven by the native helper's periodic report and by the end of a stream, so
treat them as "state may have changed" rather than as a precise clock.
A player that ends on its own sends one StatusUpdated whatever StatusUpdateInMs is: Stopped when
a file reaches its end, Unavailable when its pipeline fails or its helper exits unexpectedly.
Playback States
| State | Meaning on the device |
|---|---|
Ready |
Configured, never played |
Playing |
The pipeline process was launched and has not exited |
Unavailable |
The play was refused — no camera on the port, no VCIC answer, a file that is missing or not supported, no pipeline for this input or platform, or the native helper is missing — or the pipeline failed after starting. The log says which. |
Stopped |
StopVideo was called, or a file reached its end |
Paused |
A File player after PauseVideo. Never reported for live inputs. |
stateDiagram-v2
[*] --> Ready
Ready --> Playing: PlayVideo
Ready --> Unavailable: PlayVideo (camera / file / helper missing)
Unavailable --> Playing: PlayVideo (camera now present)
Playing --> Paused: PauseVideo (File)
Paused --> Playing: ResumeVideo, or PlayVideo to start over (File)
Playing --> Stopped: StopVideo or end of file
Playing --> Unavailable: pipeline error or helper exit
Paused --> Stopped: StopVideo
Stopped --> Playing: PlayVideo
Stopped --> Unavailable: PlayVideo (camera gone)
Unavailable is not sticky — a later PlayVideo tries again.
Threading
| Call | Can block for |
|---|---|
PlayVideo (first GMSL/analog play) |
Up to 30 s, waiting for the boot-time bring-up |
PlayVideo (VCIC) |
Up to 10 s for the camera network, plus the SOME/IP subscribe |
StopVideo (VCIC, File) |
Up to 3 s, waiting for the decoder to drain — normally well under a second |
PositionVideo (File, restart) |
About a second, while the old player drains and a fresh one starts |
GetVcicStatus |
About half a second when cameras are missing |
Make these calls from a background task, not from a touch or render handler. Both demos run every
PlayVideo loop inside Task.Run.
Edge Cases
- An unknown
VideoPlayerIDis not an error.PlayVideoreturns a status withVideoState = PlayingandVideoPlayerID = 0;StopVideoreturnsStopped. Check that the returnedVideoPlayerIDmatches the one you asked for if the id comes from user input. - Playing a player that is already playing does nothing and returns its current status. To change a render size or a file, stop and play again.
RequestVideoStatusreports the player's live state, so a file that has ended, been paused or whose player exited reports that. A File player's position and duration are the ones its player last reported. An unknownVideoPlayerIDreturns an empty status.- A file's end and your own
StopVideoboth leave the playerStopped. An application that repeats a file onStoppedmust clear its own flag before stopping — see Repeating a File.