Push/Pull URL

Last updated: 2021-09-13 17:08:38

    Prerequisites

    Manually generating live streaming URLs

    1. Log in to the CSS console.
    2. Go to CSS Toolkit > Address Generator**, and do the following:
      1. Select a domain type.
      2. Select the domain name you have added in Domain Management.
      3. Enter a custom AppName value (live by default). AppName is used to differentiate the paths of applications under the same domain name.
      4. Enter a custom StreamName value.
      5. Select an expiration time for the address.
    3. Click Generate Address to generate your publishing/playback address.
    Note:

    • AppName is a custom value and can contain only letters, numbers, and special characters.
    • Here is another way to generate publishing addresses: In Domain Management, find the publishing domain name you want use to generate a publishing address, click Manage, select Push Configuration, enter an expiration time for the address and a custom StreamName value, and click Generate Push Address.

    How to view the sample code of publishing addresses?

    Go to Domain Management** of the CSS console, find the publishing domain name you created, click Manage, and select Push Configuration. Scroll down and you will find Push Address Sample Code (for PHP and Java). The code demonstrates how to generate a hotlink protection address. For detailed directions, see Push Configuration.

    Automatically splicing publishing URLs

    If you run a large number of live streaming rooms, it is impossible to manually generate a publishing and playback URL for each host. In such cases, you can use the server to automatically splice the URLs. Any URL that meets Tencent Cloud standards can be used for publishing. A standard publishing URL consists of four parts, as shown below:

    • Domain
      Domain name for publishing, which can be the default publishing domain name provided by Tencent Cloud CSS or a publishing domain name that you have added and created a CNAME record for
    • AppName
      Application name, which is a custom value and live by default
    • StreamName (stream ID)
      Custom stream name, which is the unique ID of a live stream. We recommend that you use a random numeric or alphanumeric string for this parameter.
    • Authentication key (optional)
      An authentication key consists of txSecret and txTime: txSecret=Md5(key+StreamName+hex(time))&txTime=hex(time).
      If publishing authentication is enabled, the URL used for publishing must contain an authentication key. If publishing authentication is disabled, the publishing URL ends before “?”.
      • txTime (URL expiration time)
        The time when the URL expires, in the format of hexadecimal Unix timestamp
        Note:

        For example, 5867D600 means that the URL expires at 00:00:00, January 1, 2017. The validity period should neither be too short nor too long. Most of our clients set txTime to a point 24 hours or longer from the current time. If the validity period is too short, if a host is disconnected during a live stream, he or she may be unable to resume publishing due to the expiration of the publishing URL.

      • txSecret (hotlink protection signature)
        txSecret can prevent attackers from forging your backend to generate publishing URLs. For the calculation method, see Best Practice > Hotlink Protection URL Calculation.

    Automatically splicing playback URLs

    A playback URL consists of a playback protocol prefix, domain name (domain), application name (AppName), stream name (StreamName), playback protocol suffix, authentication key, and other custom parameters. Below are a few examples.

    webrtc://domain/AppName/StreamName?txSecret=Md5(key+StreamName+hex(time))&txTime=hex(time)
    http://domain/AppName/StreamName.flv?txSecret=Md5(key+StreamName+hex(time))&txTime=hex(time)
    rtmp://domain/AppName/StreamName?txSecret=Md5(key+StreamName+hex(time))&txTime=hex(time)
    http://domain/AppName/StreamName.m3u8?txSecret=Md5(key+StreamName+hex(time))&txTime=hex(time)
    
    • *Playback protocol prefix *
      Playback ProtocolPlayback PrefixNotes
      WebRTC webrtc:// Strongly recommended; best instant streaming performance; ultra-high concurrency
      HTTP-FLV http:// or https:// Recommended, excellent instant streaming performance; high concurrency
      RTMP rtmp:// Not recommend; poor instant streaming performance; unable to handle high concurrency
      HLS (M3U8) http:// or https:// Recommended for mobile and desktop Safari
    • Domain
      Domain name for playback, which must be a domain you have added and created a CNAME record for
    • AppName
      Application name, which is a custom value (live by default) that identifies the storage path of a live streaming media file
    • StreamName (stream name)
      Custom stream name, which is the unique ID of a live stream. We recommend that you use a random numeric or alphanumeric string for this parameter.
    • Authentication key (optional)
      An authentication key consists of txSecret and txTime: txSecret=Md5(key+StreamName+hex(time))&txTime=hex(time).
      If playback authentication is enabled, the URL used for playback must contain an authentication key. If it is disabled, the playback URL ends before “?”.
      • txTime (address expiration time): the time when the URL expires, in the format of hexadecimal Unix timestamp
      • txSecret (hotlink protection signature): a signature that prevents attackers from forging your backend to generate playback URLs. For the calculation method, see Best Practice > Hotlink Protection URL Calculation.