Genvid Streams¶
The GenvidStreams
prefab object defines a data stream from your game for
your broadcast session. You can have multiple data streams for the same
GenvidStreams
object. You need to modify the size of the Ids
to have the number of data stream 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)
- SubmitNotification(object notificationID, string data)
- SubmitAnnotationJSON(object streamID, object data)
- SubmitGameDataJSON(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, they are not sent over a stream. In that sense, they are very different from game data or annotations.
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
For example, this is how we performed the submit data for the sample:
public void SubmitGameData(string streamId) { ProjView = m_sceneCamera[m_currentActiveCamera].projectionMatrix * m_sceneCamera[m_currentActiveCamera].worldToCameraMatrix; if (GenvidSessionManager.IsInitialized) { //Getting the cube information and send it into the game data stream var cubeDataArray = from c in m_Cubes select c.InfoData; CubesGameData gameData = new CubesGameData() { cubes = cubeDataArray.ToArray(), MatProjView = Mat4ToArray(ProjView), camera = m_cameraCounter, scene = m_changeSceneCounter, }; GenvidSessionManager.Instance.Session.Streams.SubmitGameData(streamId, gameData); } }