Send a stream from Wowza Streaming Engine to a Wowza CDN HLS target using Wowza REST APIs

Wowza Streaming Engine™ media server software can broadcast a live stream to a target in the Wowza Video™ service. This workflow allows you to bypass transcoding in Wowza Video and just use the Wowza Video edge network to deliver the stream to viewers.

You can achieve this workflow programmatically: First, use the Wowza Video REST API to create the HLS target to deliver the final stream to viewers. Then, use the Wowza Streaming Engine REST API to configure a live application to send a single- or multi-bitrate stream to the Wowza Video HLS target.

This article explains how to create a Fastly stream target for a pull-based workflow. This requires that you configure your firewall to allow proper traffic flow and security.

Alternatively, you may configure your connection to Wowza CDN on Fastly for a push-based workflow. This requires that you use an Amazon account for S3 storage, but eliminates the need to configure your firewall.

To configure your stream target using a pull connection, see Send Apple HLS content to Amazon S3 using Wowza REST APIs.

Important: If you are using the provided Wowza Video player, you'll need to create a new livestream and update the player embed code on your website.

Before you start


You should be familiar with the following concepts:

  • API authentication methods. We use JSON web tokens for API authentication. See Authentication for more information.
  • Environment variables. We use environment variables for the API version and your JWT in the cURL API request examples in this topic to make it easier for you to copy, paste, and run commands in your Terminal or Command Prompt window. If you don't set environment variables for these values, you'll need to manually enter the correct values in the code samples throughout this tutorial. See Tools for testing the API for instructions.

You should be familiar with the following concepts:

  • Scaling Wowza Streaming Engine with Wowza CDN – Review the workflows for using Wowza CDN with Wowza Streaming Engine to determine which best fits your streaming needs: streaming directly to Wowza CDN, as described in this article, or sending a stream to Wowza Video for trancoding and delivery over Wowza CDN.

1. Create a Live HTTP Origin application


To send streams directly to Wowza CDN, you need to use a Live HTTP Origin application in Wowza Streaming Engine Complete the following steps to create one if you haven't already.

Note: Content delivery networks, including Wowza CDN, don't support adaptive bitrate streaming based on SMIL files. To send a set of adaptive bitrate renditions to a CDN endpoint, you must use the Transcoder feature to produce renditions with the same stream name prefix.

You can use the following sample request, making sure to:

  • Set appName to the name you would like to use for your application.

Sample request

curl -X POST 'http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/{appName}' \
-H 'Content-Type: application/json' \
-d '{
   "restURI": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/{appName}",
   "name": "appName",
   "appType": "LiveHTTPOrigin",
   "clientStreamReadAccess": "*",
   "clientStreamWriteAccess": "*",
   "description": "A Live HTTP Origin application for Fastly",
   "streamConfig": {
      "restURI": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/{appName}/streamconfiguration",
      "streamType": "live"
    }
  }
}'

2. Create a Wowza CDN on Fastly stream target in Wowza Video


A Wowza CDN on Fastly stream target is a destination that uses Wowza CDN to deliver the stream to players. 

You can use the following sample request, making sure to:

  • Set stream_target_name to the name you would like to use for your stream target.
  • Set custom_origin_URL to your Wowza Streaming Engine instances domain or IP address starting with http:// or https://. This will be the address for the location where you are running engine.
     
    Note: Your address must be a host address with no paths. For examples http://12.12.12.12, http://my.domain.com or https://my.domain.com
     
  • If your instance of Engine is protected by a firewall, you must configure the firewall to allow incoming connections from the following Wowza servers on the appropriate port (80 or 443). You'll need to add the following addresses to your firewall rules to allow Wowza Video to access Engine through your firewall using port forwarding:
     
    • 34.81.115.95
    • 34.159.18.6
    • 35.198.130.93
    • 35.202.71.195
    • 35.238.167.42
    • 130.211.240.176
     
    Note: September 13, 2022 — We'll soon be replacing the IP address above with the IP addresses listed here. To prepare, we recommend adding these addresses to your firewall rules so your integration continues to work seamlessly when the change occurs. When we've completed the transition to these new IP addresses, you should remove the old addresses from your rules. We expect the IP addresses below to remain static moving forward.
    • 129.153.100.158
    • 129.153.114.13
    • 129.154.207.194
    • 132.145.253.238
    • 138.3.255.30
    • 141.147.1.186
    • 146.56.156.1
    • 158.101.43.210
    • 193.123.241.42

    We'll add information to the release notes when the transition is complete so you know when to remove the old addresses.
    We also recommend you configure Engine to utilize port 443 with SSL to help secure your server. Port-forwarding is necessary for most non-host based firewalls.
  • Set region to the region where your Wowza Streaming Engine instance is located. For example: us, eu, asia, sa, or india.
  • Change any values unique to your broadcast, using the API reference documentation as a resource. See the Endpoint Reference button below.

Sample request

Endpoint Reference

curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${WV_JWT}" \
-d '{
   "stream_target_fastly": {
     "name": "[stream_target_name]",
     "custom_origin_url": "[custom_origin_URL]",
     "custom_origin_region": "[region]"
   } 
}' "${WV_HOST}/api/${WV_VERSION}/stream_targets/fastly"

Sample response

The response includes:

  • A hls playback url you'll use to test the stream in step 3.
{
    "stream_target_fastly": {
        "id": "lwzgrj9r",
        "name": "My first Wowza CDN on Fastly target",
        "state": "activated",
        "stream_name": "ZmYxSXRrTERrUlk9",          
        "playback_urls": {
          "hls": [
            {
	      "name": "default",
              "url": "https://[subdomain].wowza.com/1/[stream_id]/[stream_name]/hls/live/playlist.m3u8"
            }
          ]
        },
        "token_auth_enabled": false,
        "token_auth_playlist_only": false,
        "geoblock_enabled": false,
        "geoblock_by_location": "disabled",
        "geoblock_ip_override": "disabled",
        "force_ssl_playback": false,
        "custom_origin_url": "[custom_origin_URL]"
        "custom_origin_region": "[region]"
        "created_at": "2021-07-22T16:38:21.000Z",
        "updated_at": "2021-07-22T16:38:21.000Z"
    }
}

You can use this stream target with any Live HTTP Origin applications added to the Wowza Streaming Engine instance specified.

3. Test the connection 


Streams sent directly to Wowza CDN targets for distributed delivery are first sent to the Wowza Streaming Engine Live HTTP Origin application and then played using a Wowza CDN playback URL provided by Wowza Video.

  1. Start the stream in the H.264 camera or encoder that's sending the stream to your live application in Wowza Streaming Engine.

    The application ingests the live stream and sends it to a Wowza CDN endpoint.
     
  2. (Optional) Verify that the stream is published by viewing the incoming streams for your application.

    You can use the following sample request, making sure to:
     
  3. Verify that the stream is playing by pasting the playback URL into an HLS player returned in step 2.
  4. Stop the stream in the source camera or encoder to end your test connection.

Next steps


Viewer data for Wowza CDN on Fastly stream targets is available in near-real time. Use the following resources to get viewer data:

Related API requests

  • GET /v2/servers/[serverName]/vhosts/[vhostName]/applications — Get a list of applications.
  • GET /v2/servers/[serverName]/vhosts/[vhostName]/applications/[appName] — View the details of an application.
  • GET /v2/servers/[serverName]/vhosts/[vhostName]/applications/[appName]/publishers — View a list of source streams (publishers) connected to an application.
  • GET /v2/servers/[serverName]/vhosts/[vhostName]/applications/[appName]/pushpublish/mapentries — View a list of stream targets (push publishing map entries):
  • GET /v2/servers/[serverName]/vhosts/[vhostName]/applications/[appName]/pushpublish/mapentries/[entryName] — View the details of a target (push publishing map entry) for an application on a local instance of Wowza Streaming Engine.
  • DELETE /v2/servers/[serverName]/vhosts/[vhostName]/applications/[appName]/pushpublish/mapentries/[entryName] — Delete a stream target (push publishing map entry).
  • PUT /v2/servers/[server_name]/vhosts/[vhostName]/applications/[appname]/pushpublish/mapentries/[entryname]/actions/enable — Enable a single stream target (push publishing map entry).

More resources