Unreal Engine 4 Genvid Blueprint

Preparing your game

To simplify integrating the Genvid SDK into your Unreal project, you can now create some Blueprint Classes directly from the editor.

These five classes will help you integrate the video, audio, streams, events, and commands:

  • GenvidAudio
  • GenvidVideo
  • GenvidStreams
  • GenvidEvents
  • GenvidCommands

The GenvidSession class manages these five classes, while the GenvidSessionManager class manages the GenvidSession.

The following diagram summarizes the relationships between these Blueprints. See Genvid Module Design for a more detailed version.

../../_images/GenvidModuleV2_Small.png

Fig. 6 Blueprint Diagram

Note

We designed the Genvid Module to potentially handle multiple sessions in the future. For now, a GenvidSessionManager instance may only contain a single GenvidSession based on the current Genvid SDK design.

You create your own Blueprint assets based on each one’s matching C++ class:

GenvidSessionManager

After you create all your Blueprint assets, set the session class you want to use in GenvidSessionManager.

../../_images/BP_GenvidSessionManager_Details.png

Fig. 7 GenvidSessionManager Blueprint Details

Caution

Make sure you have only one GenvidSessionManager instance. Select the way that works best for your implementation. For example, you can declare it in a class derived from UGameInstance.

GenvidSession

Next, select the GenvidSession Blueprint and set the child classes that you want to use for the session.

../../_images/BP_GenvidSession_Details.png

Fig. 8 GenvidSession Blueprint Details

GenvidVideo

After setting up the session, open the Genvid Video Blueprint. In the Details panel, set the video Stream Name, the Video Mode, and a Video Source (if required by your selected video mode).

Note

The Automatic video mode captures the rendered window’s swapchain and sends it to the Genvid SDK.

The Texture video mode lets you set any object derived from a UTexture class.

../../_images/BP_GenvidVideo_Details.png

Fig. 9 Genvid Video Blueprint Details

GenvidAudio

Open the Genvid Audio Blueprint. In the Details panel, set the audio Stream Name, the Audio Format, and the Audio Mode.

../../_images/BP_GenvidAudio_Details.png

Fig. 10 GenvidAudio Blueprints Details

Note

The Audio Format setting selects the sound quality sent to the Genvid SDK.

The Audio Mode setting selects which type of capture you want to use. For now, only WASAPI is available, which captures all the audio generated by the game machine.

GenvidStreams

Open the Genvid Streams Blueprint. You create the stream(s) you need in the Event Graph panel.

Use the GenvidStream structure to create a stream. Type Make GenvidStream in the All Possible Actions context menu to add it to the Event Graph.

../../_images/BP_GenvidStreams_MakeGenvid_Menu.png

Fig. 11 Make GenvidStream

Select Name, Framerate, and the stream events you want.

Caution

You need to explicitly call the MatchHasStarted and MatchHasEnded functions from UGenvidSessionManager to trigger Stream (Match Started) and Stream (Match Ended).

../../_images/BP_GenvidStreams_MakeGenvidStream_PinOptions.png

Fig. 12 GenvidStream Pin Options

For each stream event you select:

  1. Add a custom event.
  2. Add a node to the function you want to call from your custom event.
  3. Add the stream to the Streams variable.
../../_images/Blueprint_Construct_GenvidStreams.gif

Fig. 13 Create Stream example

Note

The Framerate property is only available for the event Stream (Tick).

Set the Framerate property to 0 to call the event only one time.

Caution

If you select a stream event in the GenvidStream Pin Options but you don’t link a custom event to it, the Blueprint won’t compile. Uncheck the stream event to fix that.

GenvidEvents

Open the Genvid Events Blueprint. You can create any events you need in the Event Graph panel.

Use the GenvidEvent structure to create an event.

Type Make GenvidEvent in the All Actions for this Blueprint contextual menu to add it to the Event Graph.

../../_images/BP_GenvidEvents_MakeGenvidEvent_Menu.png

Fig. 14 Make GenvidEvent

For each event you create:
  1. Set the event Name.
  2. Activate the Client/Server mode checking the box Replicated.
  3. Link a custom event to the Delegate pin.
  4. Add a node to the function you want to call from your custom event.
  5. Add the event to the Events variable.
../../_images/Blueprint_Construct_GenvidEvents.gif

Fig. 15 Create Event example

Remember to implement your created events and commands in your website. You can find examples on the event generation page. The web.js file in our Web Sample also illustrates this in more detail.

GenvidCommands

Open the Genvid Commands Blueprint. You can create the command(s) you need in the Event Graph panel.

Use the GenvidCommand structure to create a command.

Type Make GenvidCommand in the All Actions for this Blueprint context menu to add it to the Event Graph.

../../_images/BP_GenvidCommands_MakeGenvidCommand_Menu.png

Fig. 16 Make GenvidCommand

For each command you create:
  1. Set the command Name.
  2. Activate the Client/Server mode checking the box Replicated.
  3. Link a custom event to the Delegate pin.
  4. Add a node to the function you want to call from your custom event.
  5. Add the command to the Commands variable.
../../_images/Blueprint_Construct_GenvidCommands.gif

Fig. 17 Create Command example

Remember to implement your created commands in your website. You can find examples on the sendCommands page. The web-admin.js file in our Web Sample also illustrates this in more detail.

Note

The replicated option in GenvidEvents and GenvidCommands allow you to call the delegate directly from the server. It’s useful if you want to use Remote Procedure Calls.

Starting Genvid Module

Instantiation

The first thing to do is instantiate the GenvidSessionManager.

One way to do this is:

  1. Declare it in a UGameInstance-based class.
  2. Call the Initialize() function when the application starts.
  3. Call the Terminate() function when the application stops.
../../_images/GenvidSessionManager_Initialize_Terminate.png

Fig. 18 Initialize and Terminate the GenvidSessionManager

Note

This implementation is one example of how to instantiate and terminate the GenvidSessionManager. You can select the best way based on your implementation.

Once you initialize GenvidSessionManager, add a new Blueprint class based on APlayerController.

Click on Add Component and select the class you want to use in your Genvid Session:

../../_images/PlayerController_AddComponent.png

Fig. 19 PlayerController - Add Component

Note

Ensure you have set your PlayerController class in your GameMode class Classes section.

Your Genvid Module is now ready.

See the Unreal Engine 4 Genvid Client/Server section for information on adapting your present code.

Class Diagram

../../_images/GenvidModuleV2_Full.png

Fig. 20 Genvid Module Design