Streams Prefab¶
The Streams
prefab object defines data streams from your game for
your broadcast session. You can have multiple data streams for the same
Streams
object. You need to modify the size of the Ids
member
to have the number of data streams required for your application. Each
element of this array contains several properties that can be
modified:
- Id
- The name of the data stream. Make sure to use a unique name compared to the other streams used in your application.
- Framerate
The rate at which the On Submit Stream function will be executed. 0 is the default value.
0 means that the stream data is sent every frame (depending directly on the game framerate).
All other values use the formula: Min(value, Game Framerate).
For example, in a game running at 30 FPS:
- At value 10, the stream is sent at Min(10, 30) = 10 Frames per second.
- At value 100, the stream is sent at Min(100, 30) = 30 Frames per second.
- On Submit Stream (String)
This is the function that will be executed according to the framerate selected. The String parameter received will always be the stream name. In the methods called afterwards, you are free to use the best method to send your data:
- SubmitAnnotation(object streamID, string data)
- SubmitGameData(object streamID, string data)
- SubmitGameDataJSON(object streamID, object data)
- SubmitAnnotationJSON(object streamID, object data)
- SubmitNotificationJSON(object notificationID, object data)
Note
Notifications are mentioned here because they are one of the 3 strategies available to you in how you send your data. However, submitting notifications has been depricated in the
Streams
prefab and moved to theGenvidSession
prefab given that notifications are not sent over a stream.Warning
The submit functions suffixed with “JSON” only support JSON serializable objects.
Each method not ending with JSON requires:
- The stream name that will receive the data and
- Serialized data in byte[] or string
Each method ending with JSON requires:
- The stream name that will receive the data and
- JSON-serializable data
In the Unity cube sample, we use the Streams
prefab to submit data about
copyright, cube names, cube positions, cube colors, and camera info. The data
types above each have their respective streams and submission frequencies.
We recommend to follow this pattern of dedicated data streams for better
organisation and flexibility.
.. seealso:
:ref:`add data prefab`