How to upgrade from 1.3.0 to 1.4.0¶
Upgrade secrets using vault¶
We have begun supporting secrets. Although still in beta, we are currently using it to store the disco and command secrets. This section explains how to update your project to use it.
Edit the secrets in config¶
Change the secrets in stream.hcl to have something more secure.
secrets {
disco {
GENVID_DISCO_SECRET = "secrettochange"
}
command {
GENVID_COMMAND_SECRET = "anothersecret"
}
}
Change the templates¶
Add vault policies in order to access the password in vault
task "web" {
...
// Add vault policy
vault {
policies = ["genvid"]
}
env {
WWWROOT = "{{key `local/website/root` | js}}"
// Get access to disco secret from vault and assign the environment variable
# {{with secret `secret/disco` }}
GENVID_DISCO_SECRET = "{{ .Data.GENVID_DISCO_SECRET }}"
# {{end}}
// Get access to command secret from vault and assign the environment variable
# {{with secret `secret/command` }}
GENVID_COMMAND_SECRET = "{{ .Data.GENVID_COMMAND_SECRET }}"
# {{end}}
PORT = "${NOMAD_PORT_web}"
}
...
}
Change the static binding¶
We are now using an environment variable to set the static binding of ports. In the web nomad template a change is needed in order to use the environment variable.
port "web" {
// {{- if (key_or_default `genvid/static_binding` `false` | parseBool)}}
static = 3000
// {{- end}}
}
Becomes
port "web" {
{{- if (env "GENVID_STATIC_BINDING" | parseBool)}}
static = 3000
{{- end}}
}
Unity SDK upgrade¶
We are now using a C# wrapper for all the calls related to the Genvid SDK instead of using the GenvidPlugin and a C# script to do the communication.
First, GenvidPlugin is now used only for video capture. You will need to use DLL import to access this dll. Also, you will need to perform the video capture via a loop inside your code (we used to handle it with a script, now you need to add it to your code).
DLL import:
[DllImport("GenvidPlugin", EntryPoint = "getVideoInitStatus")]
[return: MarshalAs(UnmanagedType.I4)]
private static extern GenvidSDK.Status GetVideoInitStatus();
[DllImport("GenvidPlugin", EntryPoint = "getVideoSubmitDataStatus")]
[return: MarshalAs(UnmanagedType.I4)]
private static extern GenvidSDK.Status GetVideoSubmitDataStatus();
[DllImport("GenvidPlugin", EntryPoint = "setupVideoChannel")]
public static extern void SetupVideoChannel(string streamID);
[DllImport("GenvidPlugin", EntryPoint = "cleanUp")]
public static extern void CleanUp();
[DllImport("GenvidPlugin")]
public static extern IntPtr GetRenderEventFunc();
Video capture:
private IEnumerator CallPluginAtEndOfFrames()
{
// GetRenderEventFunc param
System.IntPtr renderingFunction = GetRenderEventFunc();
var waitForEndOfFrame = new WaitForEndOfFrame();
GenvidSDK.Status status = GenvidSDK.Status.Success;
while (true)
{
// Wait until all frame rendering is done
yield return waitForEndOfFrame;
if (m_quitProcess == false)
{
if (m_processComplete)
{
GL.IssuePluginEvent(renderingFunction, 0);
m_processComplete = false;
status = GetVideoInitStatus();
if (status != GenvidSDK.Status.Success)
{
Debug.LogError("Error while starting the video stream : " + GenvidSDK.StatusToString(status));
}
status = GenvidSDK.Status.ConnectionInProgress;
}
else
{
GL.IssuePluginEvent(renderingFunction, 1);
status = GetVideoSubmitDataStatus();
if (status != GenvidSDK.Status.Success)
{
Debug.LogError("Error while sending video data : " + GenvidSDK.StatusToString(status));
}
}
}
else
{
m_coRoutineEnd = true;
break;
}
}
}
Second, all the calls related to the Genvid SDK are now going through
the GenvidSDKCSharp.dll
. You need to add this dll to your project
to be able to use it properly. We also reduced the length of the calls
to the GenvidSDK, so now you only need to write:
GenvidSDK.Initialize()
In short, most of the calls no longer
require to write Genvid twice.
The GenvidSDKCSharp project is available with the sample so feel free to open it to observe the changes. Overall, the GenvidSDKCSharp DLL simplifies the integration process and allow us to support other C# applications. Also, feel free to read the Unity Sample Integration section which was updated with the new changes and more details for each step.