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 Flowplayer, 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. 

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.

In the following sample request, you will replace appName with the name for your application.

Note: New Live HTTP Origin apps default httpRandomizeMediaName to true; if you're using an older app, make sure this property is set to true

Sample request

curl -X POST 'http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}' \
-H 'Content-Type: application/json' \
-d '{
   "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/(vhostName}/applications/{appName}",
   "name": "appName",
   "appType": "LiveHTTPOrigin",
   "clientStreamReadAccess": "*",
   "clientStreamWriteAccess": "*",
   "description": "A Live HTTP Origin application for Fastly",
   "streamConfig": {
      "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName)/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:

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.

Sample request

Endpoint Reference

  • 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:
     

    • 54.68.61.81
    • 44.225.129.35
    • 35.161.247.138
    • 13.125.58.224
    • 3.35.119.29
    • 43.200.156.236
    • 52.29.60.88
    • 3.123.121.43
    • 3.77.81.251

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.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${WV_JWT}" \
-d '{
   "stream_target_fastly": {
     "name": "{streamtargetName}",
     "custom_origin_url": "{customoriginURL}",
     "custom_origin_region": "{region}"
   } 
}' "${WV_HOST}/api/${WV_VERSION}/stream_targets/fastly"

Sample response

The response includes:

  • An 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": "customoriginURL"
        "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. 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