Push Configuration

Last updated: 2021-12-08 14:34:40

    To protect the information security of live streaming, push authentication is enabled for CSS push domain names by default. You can use the push address generator on the push address details page to generate a push URL. Then, you can use the URL to push the stream (upload the live streaming video) to the CSS platform.

    Note

    • CSS provides a test domain name xxxx.tlivepush.com. You can use it to test live push, but you’re not advised to use it as the push domain name for business purposes.
    • CSS can only generate push URLs in RTMP format.
    • The generated push URL is valid before the set expiration time. You can generate a new URL after the old one expires.

    Prerequisites

    You have activated the CSS service and completed identity verification.

    Authentication Configuration

    1. Go to Domain Management, click the target push domain name or click Manage to enter the domain details page.
    2. Click Push Configuration, and click Edit in the Authentication Configuration section.
    3. On the Authentication Configuration page, toggle to enable or disable push configuration.
    4. Enter the primary key and backup key, and click Save.
      Note:

      Primary key is required and backup key is optional. Entering both allows you to switch keys when one key is disclosed.

    Push Address Generator

    Directions

    1. Go to Domain Management, and click the target domain name or click Manage on its right to enter its details page.
    2. Select Push Configuration > Push Address Generator and configure as follows:
      1. Select an expiration time, such as 2021-06-30 19:26:02.
      2. Enter a custom StreamName, such as liveteststream.
      3. Click Generate Push Address to generate an RTMP push URL containing the StreamName.
    3. If playback authentication is not enabled for your push domain name, you can view two types (RTMP and UDP) of playback URLs under the domain name in Push Configuration > Push URL. Splice the StreamName in the playback URL to the desired push URL, and then you can use the playback URL to play back the stream corresponding to the push URL.

    Notes on Push URL

    RTMP push URL format:

    rtmp://domain/AppName/StreamName?txSecret=Md5(key+StreamName+hex(time))&txTime=hex(time)
    

    Where:

    • domain: push domain name
    • AppName: live streaming application name, which is live by default and customizable
    • StreamName: custom stream name used to identify a live stream
    • txSecret: authentication string generated after push authentication is enabled
    • txTime: expiration timestamp set for a push URL configured in the console
    Note:

    If you have enabled authentication for the domain name, the actual URL expiration time will be txTime plus the key validity period.

    Sample Code of Push URL

    Sample code for generating a push URL in PHP and Java is provided for your reference, which can be viewed by performing the following steps:

    1. Go to Domain Management.
    2. Select a push domain name or click Manage on the right to enter its details page.
    3. Select Push Configuration and scroll down to find Push Address Sample Code.
    4. Click the tab to view the PHP/Java sample code accordingly as shown below:
      /**
      * Get the push URL
      * If you do not pass in the authentication key and URL expiration time, a URL without hotlink protection will be returned.
      * @param domain   Your push domain name
      *        streamName   Unique stream name to identify its push URLs
      *        key   Authentication key
      *        time   URL expiration time in seconds (example: 2016-11-12 12:00:00)
      * @return String url
      */
      function getPushUrl($domain, $streamName, $key = null, $time = null){
      if($key && $time){
       $txTime = strtoupper(base_convert(strtotime($time),10,16));
       //txSecret = MD5( KEY + streamName + txTime )
       $txSecret = md5($key.$streamName.$txTime);
       $ext_str = "?".http_build_query(array(
                  "txSecret"=> $txSecret,
                  "txTime"=> $txTime
       ));
      }
      return "rtmp://".$domain."/live/".$streamName . (isset($ext_str) ? $ext_str : "");
      }
      echo getPushUrl("123.test.com","123456","69e0daf7234b01f257a7adb9f807ae9f","2016-09-11 20:08:07");
      

    Operations

    After the push URL is generated, you can use it based on business scenarios. For specific operations, see Live Push.