Connect a WebRTC stream to Wowza Streaming Cloud using the Wowza Streaming Cloud REST API

The Wowza Streaming Cloud™ service supports Web Real-Time Communication (WebRTC) streaming. This article describes how to use the Wowza Streaming Cloud REST API to create a transcoder and configure a WebRTC stream as the video source.

Create a transcoder


  1. Using the Wowza Streaming Cloud REST API, create a transcoder.
     
    Notes:
    • Wowza Streaming Cloud accepts WebRTC source streams through the transcoder workflow only. You can't configure WebRTC ingest directly through the live stream workflow.
    • Source authentication is not available for transcoders ingesting WebRTC streams.

    Transcoder parameters

    Parameter Data Type Description
    billing_mode string The billing mode for the stream. Use the default, pay_as_you_go.
    broadcast_location string Specify the region that's closest to where your stream originates. For a list of valid regions, see the API reference documentation.
    delivery_method string The method you're using to deliver the source stream to the transcoder. Use push so the WebRTC source pushes the stream to Wowza Streaming Cloud.

    WebRTC source streams can't connect to the transcoder using a delivery_method of pull.
    name string The name of the transcoder. Enter an alphanumeric string that is short (maximum 200 characters) and descriptive, for example, MyWebRTCTranscoder.
    protocol string The transport protocol you're using to send the encoded stream to the transcoder. Use webrtc.
    transcoder_type string Specify the default, transcoded. WebRTC source streams can’t connect to the transcoder if the transcoder_type is set to passthrough.

    Example request and response

    curl -X POST \
    -H "Content-Type: application/json" \
    -H "wsc-api-key: ${WSC_API_KEY}" \
    -H "wsc-access-key: ${WSC_ACCESS_KEY}" \
    -d '{    
      "transcoder": { 
        "billing_mode": "pay_as_you_go",      
        "broadcast_location": "us_west_california",      
        "delivery_method": "push",      
        "name": "MyWebRTCTranscoder",      
        "protocol": "webrtc",      
        "transcoder_type": "transcoded"
      } 
    }' "${WSC_HOST}/api/${WSC_VERSION}/transcoders"

    This request creates a transcoder with an id parameter, but no outputs or stream targets. The details of the transcoder's configuration are listed in the response, which should look something like this:

    { 
      "transcoder": { 
        "id": "tmd8ybp2", 
        "name": "MyWebRTCTranscoder", 
        "transcoder_type": "transcoded", 
        "billing_mode": "pay_as_you_go", 
        "broadcast_location": "us_west_california", 
        ... 
        "protocol": "webrtc", 
        "delivery_method": "push", 
        "source_port": 443, 
        "domain_name": "[hostname].entrypoint.cloud.wowza.com", 
        ...
        "outputs": []
      } 
    } 
  2. Complete the transcoder by adding output renditions and stream targets. For instructions, see one of the following articles, depending on whether you're creating an adaptive bitrate or passthrough transcoder:
     
    Note: WebRTC doesn’t support passthrough video or passthrough audio. Be sure to check that these options aren’t enabled when adding output renditions to the transcoder.

Test the connection


The Wowza Streaming Cloud documentation includes a downloadable example that shows how to publish a WebRTC stream to Wowza Streaming Cloud.

Notes:
  • The WebRTC example must be hosted on a webserver utilizing SSL encryption.
  • In order for the example to work properly, the transcoder stream_extension must be set to .json.
  1. Download the WebRTC HTML example.
  2. Extract the contents of the archive to any location on your computer.
  3. In your file system, navigate to the extracted content and copy the contents of the html folder to your web server.
  4. Open index.html in a web browser.
     
    Note: Be sure to give index.html access to your camera and microphone when requested.
  5. Use the transcoder information from the REST API response to configure the stream settings:
     
    • Host Server – Replace [wowza_subdomain].entrypoint.cloud.wowza.com with the domain_name.
    • Application Name – Replace webrtc with the application_name.
    • Stream Name – Replace myStream with the stream_name.
  6. Start the transcoder using the Wowza Streaming Cloud REST API.

    Start the transcoder:
    curl -X PUT \
    -H "wsc-api-key: ${WSC_API_KEY}" \
    -H "wsc-access-key: ${WSC_ACCESS_KEY}" \
    "${WSC_HOST}/api/${WSC_VERSION}/transcoders/[transcoder_id]/start"


    Alternatively, click Start Transcoder at the top of the transcoder detail page in the Wowza Streaming Cloud user interface.
  7. If you’re using the Wowza Streaming Cloud REST API to start the transcoder, fetch the state of the transcoder to make sure it’s started.

    Fetch the state of the transcoder:
    curl -X GET \
    -H "wsc-api-key: ${WSC_API_KEY}" \
    -H "wsc-access-key: ${WSC_ACCESS_KEY}" \
    "${WSC_HOST}/api/${WSC_VERSION}/transcoders/[transcoder_id]/state"
  8. On the index.html page, click Publish.
  9. Confirm that the stream is playing.
     
    1. Fetch a video thumbnail of the stream using the Wowza Streaming Cloud REST API.

      Fetch the thumbnail URL of a transcoder:
      curl -X GET \
      -H "wsc-api-key: ${WSC_API_KEY}" \
      -H "wsc-access-key: ${WSC_ACCESS_KEY}" \
      "${WSC_HOST}/api/${WSC_VERSION}/transcoders/[transcoder_id]/thumbnail_url"
    2. View the thumbnail URL in a browser.
    3. Alternatively, in the Wowza Streaming Cloud user interface, confirm that the transcoder is playing by looking at the Video Thumbnail in the Overview tab of the transcoder detail page.
  10. Use the Wowza Streaming Cloud REST API to stop the transcoder.

    Stop the transcoder:
    curl -X PUT \
    -H "wsc-api-key: ${WSC_API_KEY}" \
    -H "wsc-access-key: ${WSC_ACCESS_KEY}" \
    "${WSC_HOST}/api/${WSC_VERSION}/transcoders/[transcoder_id]/stop"


    Alternatively, click Stop Transcoder at the top of the transcoder detail page in the Wowza Streaming Cloud user interface.

More resources