Skip to content

Latest commit

 

History

History
89 lines (53 loc) · 3.45 KB

README.md

File metadata and controls

89 lines (53 loc) · 3.45 KB

LiveSwitch HLS Demo

code quality license

The LiveSwitch HLS Demo listens for new connections using LiveSwitch Cloud webhooks and converts them into a near-real-time HLS stream using lsconnect and ffmpeg.

The LiveSwitch HLS Demo was built using Node.js and TypeScript. It is provided as a Visual Studio solution, but Visual Studio is not required.

Requirements

  1. lsconnect
  2. ffmpeg
  3. Node.js
  4. ngrok (optional)

Getting Started

Create a LiveSwitch Cloud application if you haven't already.

LiveSwitch Server customers can use this demo as well. Simply update gatewayUrl in app.ts to point to your LiveSwitch Gateway.

Update applicationId and sharedSecret in app.ts to your LiveSwitch application ID and shared secret.

First, make sure "express" is installed. In a terminal, browse to src/FM.LiveSwitch.Hls and type:

npm install

Create the 'hls' directory under 'static' -> .\src\FM.LiveSwitch.Hls\static\hls

In a terminal, browse to src/FM.LiveSwitch.Hls and type:

node app.js

The web server is now listening for inbound webhooks.

Use ngrok in a separate terminal to create a secure tunnel to port 3000:

ngrok http 3000

Using ngrok is not required, but avoids the need to configure firewalls to allow inbound requests.

Finally, add a channel-level webhook for the Connection Connected event to your LiveSwitch Cloud application pointing to your ngrok URL.

Live Recording from Web Browser

In your node terminal window, you should see a URL with your application ID and shared secret:

Browse to: https://demo.liveswitch.io/#application=...&sharedsecret=...&mode=1

If you see <YOUR_APPLICATION_ID_GOES_HERE> or <YOUR_SHARED_SECRET_GOES_HERE> in the URL, you missed a step from the previous section.

Open a web browser and navigate to the URL. You should see the standard LiveSwitch demo app. Join any channel, and you should see a few things happen:

  1. The ngrok terminal should show that an inbound POST request has been forwarded to port 3000.
  2. The node terminal should show logs indicating that a webhook event has been received and is being processed by lsconnect and ffmpeg.
  3. The file system should show HLS output under src/FM.LiveSwitch.Hls/static/hls.

Open a new browser tab and navigate to http://localhost:3000. You should see a list of live recordings, including the one that is currently active!

Live Recording from Test Unity Application

Download the Unity Liveswitch Sender app from here.

Run it and it will start sending audio/video data.

Troubleshooting

If you are using macOS or Linux, you may need to set the executable bit on lsconnect:

chmod +x lsconnect
chmod +x lsconnect-macos

Contact

To learn more, visit frozenmountain.com or liveswitch.io.

For inquiries, contact [email protected].

All contents copyright © Frozen Mountain Software.