tencent cloud

Feedback

Publishing/Playback URL

Last updated: 2024-01-13 15:49:41

    Prerequisites

    You have signed up for a Tencent Cloud account and activated the CSS service.
    You have applied for a domain name at Tencent Cloud Domain Service.
    You have added publishing/playback domain names in the CSS console > Domain Management. For detailed directions, please see Adding Domain Name.
    You have configured CNAME for your domain names.

    Generating live streaming URLs in the console

    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.
    6. 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.

    Viewing the sample code of publishing URLs

    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.

    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.

    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)
    Prefix
    Playback Protocol
    Playback Prefix
    Notes
    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://
    We recommend HLS for mobile clients and for the Safari browser on macOS.
    DomainDomain 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 does not need to contain "?" and the content following it.
    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.

    Splicing URLs for RTC-based mic connect/host competition

    You need to splice publishing and playback URLs for RTC-based mic connect and host competition.
    
    Publishing URL
    You need to splice a publishing URL by yourself in your project code. The format is as shown below.
    trtc://cloud.tencent.com/push/streamid?sdkappid=1400188888&userId=A&usersig=xxxxx
    The table below lists the key fields in a publishing URL and their meanings.
    Field
    Description
    trtc://
    Prefix of a publishing URL for interactive live streaming
    cloud.tencent.com
    Dedicated domain name for interactive live streaming, which you must not modify
    push
    Identifier, which indicates publishing
    streamid
    Stream ID, which is a custom value specified by yourself
    sdkappid
    The `SDKAppID` generated in “Activate TRTC”
    userId
    User ID of the host, which is a custom value specified by yourself
    usersig
    User signature calculated from the key obtained in “Activate TRTC”
    
    Playback URL
    You need to splice a playback URL by yourself in your project code. The format is as shown below.
    trtc://cloud.tencent.com/play/streamid?sdkappid=1400188888&userId=A&usersig=xxxxx
    The table below lists the key fields in a playback URL and their meanings.
    Field
    Description
    trtc://
    Prefix of a playback URL for interactive live streaming
    cloud.tencent.com
    Dedicated domain name for interactive live streaming, which you must not modify
    play
    Identifier, which indicates playback
    streamid
    Stream ID, which is a custom value specified by yourself
    sdkappid
    The `SDKAppID` generated in “Activate TRTC”
    userId
    User ID of the host, which is a custom value specified by yourself
    usersig
    User signature calculated from the key obtained in “Activate TRTC”
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support