![Live Streaming from Unity - Broadcasting from a Meta Quest (Part 8)](https://assets.community.aws/a/2daRex7ipHX74alG96LGdepQtvJ/unit.webp)
Live Streaming from Unity - Broadcasting from a Meta Quest (Part 8)
In this post, we'll broadcast directly from a Meta Quest to Amazon IVS!
Todd Sharp
Amazon Employee
Published Mar 13, 2024
We've already seen how to broadcast from a game built in Unity directly to a real-time live stream with Amazon Interactive Video Service (Amazon IVS). If you need a refresher, or you missed any of the previous posts, be sure to check them out to learn how to create an Amazon IVS stage, generate participant tokens, and broadcast from a Unity camera. In this post, we'll see that broadcasting from a VR game built for the Meta Quest is just as straightforward as it is from a non-VR game.
For this demo, we'll use the Unity First Hand demo app. Follow the instructions in that repo to get the game downloaded and setup in Unity, and once you've got the project open we'll add a new camera that will be used for the live stream. In the project explorer (Hierarchy view) add a camera as a child to
CenterEyeAnchor
called WebRTCPublishCamera
.![WebRTCPublishCamera WebRTCPublishCamera](https://assets.community.aws/a/2daRs4GlOKY6EB0RKf5mkalwjyz/1-pn.webp)
Next, add a script to
WebRTCPublishCamera
called WebRTCPublish
. This script is exactly the same as we have previously used, so I'll post it in its entirety below. We've got a few classes to model stage token requests. Those requests are posted to a service which returns a stage token (see the
simple-ivs-token-service
script for an example implementation). We establish a peerConnection
, get a remote SDP, and wire the camera up to the peerConnection
as a MediaTrack
. That's it! At this point we're ready to test it out. Launch the First Hand demo on a Meta Quest device, and check the output via your own custom web based interface (or the CodePen that we used before).
In this post, we used the techniques that we've learned in this series to broadcast a real-time stream to Amazon IVS from a Meta Quest VR headset. We could add a button that the player has to press to start the stream, integrate viewer chat (see part 4), spawn dynamic game elements (part 5) and much more - the possibilities are exciting and endless. In the next post, we'll wrap up this series with a look at using the techniques we've learned so far to broadcast a game directly to Twitch instead of an Amazon IVS stage.
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.