Field name | Value |
Content-Type | application/json |
Sign | Signature value |
SdkAppId | sdk application id |
Field Name | Type | Description |
EventGroupId | Number | Event group ID, fixed at 3 for cloud recording |
EventType | Number | Event type for callback notification |
CallbackTs | Number | The Unix timestamp (in milliseconds) when the event callback server sends a callback request to your server |
EventInfo | JSON Object | The event information |
Field Name | Type | Description |
EVENT_TYPE_CLOUD_RECORDING_RECORDER_START | The cloud recording module starts. | |
EVENT_TYPE_CLOUD_RECORDING_RECORDER_STOP | The cloud recording module exits. | |
EVENT_TYPE_CLOUD_RECORDING_UPLOAD_START | The cloud recording file upload task starts, and it is called back only when COS is chosen. | |
EVENT_TYPE_CLOUD_RECORDING_FILE_INFO | Cloud recording: Generating the M3U8 index file. After the first successful generation and upload, it is called back only when COS is chosen through API recording. | |
EVENT_TYPE_CLOUD_RECORDING_UPLOAD_STOP | The cloud recording file upload is complete. It is called back only when COS is chosen. | |
EVENT_TYPE_CLOUD_RECORDING_FAILOVER | Cloud recording migration occurs. It is triggered when the existing recording task is migrated to a new load. | |
EVENT_TYPE_CLOUD_RECORDING_FILE_SLICE | Cloud recording: Generating the M3U8 index file (generating the first ts slice). After generation, it is called back only when COS is chosen through API recording. | |
EVENT_TYPE_CLOUD_RECORDING_DOWNLOAD_IMAGE_ERROR | An error occurs when the cloud recording attempts to download and decode the image file. | |
EVENT_TYPE_CLOUD_RECORDING_MP4_STOP | The MP4 recording task of cloud recording stops, and it is called back only when COS is chosen via API recording (when automatic recording is turned on in the console and the authorized VOD COS is selected as storage, please pay attention to event 311). | |
EVENT_TYPE_CLOUD_RECORDING_VOD_COMMIT | The cloud recording VOD recording task has completed the upload of media resources, and it is called back when you select Video on Demand and automatically recording to COS via the console (after file recording ends, the VOD index information is carried. Please subscribe to this type of callback event). | |
EVENT_TYPE_CLOUD_RECORDING_VOD_STOP | The cloud recording VOD task stops, and it is called back only when VOD is chosen. |
Field Name | Type | Description |
RoomId | String/Number | The room name, consistent with the room ID type on the client side |
EventTs | Number | The Unix timestamp of when the event occurred, in seconds (this field is not recommended. Instead, EventMsTs is recommended) |
EventMsTs | Number | The Unix timestamp of when the event occurred, in milliseconds |
UserId | String | The user ID of the recording robot |
TaskId | String | The recording ID, which is a unique ID of a single cloud recording task |
Payload | JsonObject | Defined based on various event types |
Field Name | Type | Description |
Status | Number | 0: Indicates that the recording module successfully starts. 1: Indicates that the recording module fails to start. |
{"EventGroupId": 3,"EventType": 301,"CallbackTs": 1622186275913,"EventInfo": {"RoomId": "xx","EventTs": "1622186275","EventMsTs": 1622186275757,"UserId": "xx","TaskId": "xx","Payload": {"Status": 0}}}
Field Name | Type | Description |
LeaveCode | Number | 0: The invocation of recording module normally stops and exits. 1: The customer kicks out the recording robot from the room. 2: The customer disbands the room. 3: The server kicks out the recording robot from the room. 4: The server disbands the room. 99: There is no other user flow in the room except for the recording robot, which will exit after a specified time. 100: Exit from the room due to timeout. 101: Repeated entry of the same user into the same room causes the robot to exit. |
{"EventGroupId": 3,"EventType": 302,"CallbackTs": 1622186354806,"EventInfo": {"RoomId": "xx","EventTs": "1622186354","EventMsTs": 1622186275757,"UserId": "xx","TaskId": "xx","Payload": {"LeaveCode": 0}}}
Field Name | Type | Description |
Status | Number | 0: Indicates that the upload module normally starts.
1: Indicates that the upload module fails to be initiated. |
Field Name | Type | Description |
FileList | String | The generated M3U8 filename |
Field Name | Type | Description |
LeaveCode | Number | 0: Indicates that this recording upload task has been completed, and all files have been uploaded to the specified third-party cloud storage.
1: Indicates that this recording upload task has been completed, but at least one file is lingering on the server or backup storage.
2: Indicates that files lingering on the server or backup storage have been restored and uploaded to the designated third-party cloud storage. Note: 305 indicates the event that the HLS file upload is complete. |
Field Name | Type | Description |
Status | Number | 0: Indicates that this migration is completed. |
{"EventGroupId": 3,"EventType": 306,"CallbackTs": 1622191989674,"EventInfo": {"RoomId": "20015","EventTs": 1622191989,"EventMsTs": 1622186275757,"UserId": "xx","TaskId": "xx","Payload": {"Status": 0}}}
Field Name | Type | Description |
FileName | String | M3U8 filename |
UserId | String | The user ID corresponding to the recorded file |
TrackType | String | Audio/Video types: audio/video/audio_video |
BeginTimeStamp | String | The Unix timestamp of the server when the recording starts (in milliseconds) |
Field Name | Type | Description |
Url | String | The URL of the failed download |
{"EventGroupId": 3,"EventType": 309,"CallbackTs": 1622191989674,"EventInfo": {"RoomId": "20015","EventTs": 1622191989,"EventMsTs": 1622186275757,"UserId": "xx","TaskId": "xx","Payload": {"Url": "http://xx"}}}
Field Name | Type | Description |
Status | Number | 0: Indicates that the MP4 recording task has exited normally, and all files have been uploaded to the designated third-party cloud storage. 1: Indicates that this MP4 recording task has exited normally, but at least one file lingers on the server or backup storage.
2: Indicates that this MP4 recording task exits abnormally (the possible reason is the failure of extracting HLS files from COS). |
FileList | Array | All generated MP4 file names |
FileMessage | Array | All generated MP4 file information |
FileName | String | MP4 file name |
UserId | String | The user ID corresponding to the MP4 file (this field is empty when the recording mode is set to mixed streaming mode) |
TrackType | String | audio for audio / video for pure video / audio_video for audio and video |
MediaId | String | The primary and auxiliary stream tag. main indicates the primary stream (camera), aux indicates the auxiliary streams (screen sharing), and mix indicates mixed stream recording. |
StartTimeStamp | Number | The Unix timestamp at the beginning of the MP4 file (in milliseconds) |
EndTimeStamp | Number | The UNIX timestamp at the end of the MP4 file (in milliseconds) |
{"EventGroupId": 3,"EventType": 310,"CallbackTs": 1622191965320,"EventInfo": {"RoomId": "20015","EventTs": 1622191989,"EventMsTs": 1622186275757,"UserId": "xx","TaskId": "xx","Payload": {"Status": 0,"FileList": ["xxxx1.mp4", "xxxx2.mp4"],"FileMessage": [{"FileName": "xxxx1.mp4","UserId": "xxxx","TrackType": "audio_video","MediaId": "main","StartTimeStamp": 1622186279145,"EndTimeStamp": 1622186282145},{"FileName": "xxxx2.mp4","UserId": "xxxx","TrackType": "audio_video","MediaId": "main","StartTimeStamp": 1622186279153,"EndTimeStamp": 1622186282153}]}}}
Field Name | Type | Description |
Status | Number | 0: Indicates that the recorded file has been successfully uploaded to the VOD platform. 1: Indicates that the recorded file lingers on the server or backup storage. 2: Indicates that the upload and VOD task for this recorded file to is abnormal. |
UserId | String | The user ID corresponding to this recorded file (this field is empty when the recording mode is set to mixed stream mode) |
TrackType | String | audio for audio / video for pure video / audio_video for audio and video |
MediaId | String | The primary and auxiliary stream tag. main indicates the primary stream (camera), aux indicates the auxiliary stream (screen sharing), and mix indicates mixed stream recording. |
FileId | String | The unique ID of this recorded file in the VOD platform |
VideoUrl | String | The playback address of this recorded file on the VOD platform |
CacheFile | String | The filename corresponding to this MP4/HLS recording file |
StartTimeStamp | Number | The Unix timestamp of the beginning of this recorded file (in milliseconds) |
EndTimeStamp | Number | The Unix timestamp of the end of this recorded file (in milliseconds) |
Errmsg | String | Corresponding error message when the status is not 0 |
{"EventGroupId": 3,"EventType": 311,"CallbackTs": 1622191965320,"EventInfo": {"RoomId": "20015","EventTs": 1622191965,"EventMsTs": 1622186275757,"UserId": "xx","TaskId": "xx","Payload": {"Status": 0,"TencentVod": {"UserId": "xx","TrackType": "audio_video","MediaId": "main","FileId": "xxxx","VideoUrl": "http://xxxx","CacheFile": "xxxx.mp4","StartTimeStamp": 1622186279153,"EndTimeStamp": 1622186282153}}}}
{"EventGroupId": 3,"EventType": 311,"CallbackTs": 1622191965320,"EventInfo": {"RoomId": "20015","EventTs": 1622191965,"EventMsTs": 1622186275757,"UserId": "xx","TaskId": "xx","Payload": {"Status": 1,"Errmsg": "xxx","TencentVod": {"UserId": "123","TrackType": "audio_video","CacheFile": "xxx.mp4"}}}}
Field Name | Type | Description |
Status | Number | 0: Indicates that this VOD upload task has exited normally. 1: Indicates that this VOD upload task exits abnormally. |
{"EventGroupId": 3,"EventType": 312,"CallbackTs": 1622191965320,"EventInfo": {"RoomId": "20015","EventTs": 1622191965,"EventMsTs": 1622186275757,"UserId": "xx","TaskId": "xx","Payload": {"Status": 0}}}
// In the signature Sign calculation formula, key is the encryption key used for calculating the signature Sign.Sign = base64(hmacsha256(key, body))
body="{\\n\\t\\"EventGroupId\\":\\t1,\\n\\t\\"EventType\\":\\t103,\\n\\t\\"CallbackTs\\":\\t1615554923704,\\n\\t\\"EventInfo\\":\\t{\\n\\t\\t\\"RoomId\\":\\t12345,\\n\\t\\t\\"EventTs\\":\\t1608441737,\\n\\t\\t\\"UserId\\":\\t\\"test\\",\\n\\t\\t\\"UniqueId\\":\\t1615554922656,\\n\\t\\t\\"Role\\":\\t20,\\n\\t\\t\\"Reason\\":\\t1\\n\\t}\\n}"
import javax.crypto.Mac;import javax.crypto.spec.SecretKeySpec;import java.util.Base64;//# Function: Third-party callback sign verification//# Parameters://# key: The key configured in the console//# body: The body returned in Tencent Cloud callback//# sign: Signature value of sign returned in Tencent Cloud callback//# Returned values://# Status: OK indicates successful verification, and FAIL indicates verification failure. For specific reasons, see Info.//# Info: Success/Failure messagepublic class checkSign {public static String secureFinalSign(String key, String entityBody) throws Exception {Mac hmacSha256 = Mac.getInstance("HmacSHA256");SecretKeySpec secret_key = new SecretKeySpec(key.getBytes(), "HmacSHA256");hmacSha256.initialize(secret_key);return Base64.getEncoder().encodeToString(hmacSha256.doFinal(body.getBytes()));}public static void main(String[] args) throws Exception {String key = "123654";String body = "{\\n" + "\\t\\"EventGroupId\\":\\t2,\\n" + "\\t\\"EventType\\":\\t204,\\n" + "\\t\\"CallbackTs\\":\\t1664209748188,\\n" + "\\t\\"EventInfo\\":\\t{\\n" + "\\t\\t\\"RoomId\\":\\t8489,\\n" + "\\t\\t\\"EventTs\\":\\t1664209748,\\n" + "\\t\\t\\"EventMsTs\\":\\t1664209748180,\\n" + "\\t\\t\\"UserId\\":\\t\\"user_85034614\\",\\n" + "\\t\\t\\"Reason\\":\\t0\\n" + "\\t}\\n" + "}";String Sign = "kkoFeO3Oh2ZHnjtg8tEAQhtXK16/KI05W3BQff8IvGA=";String resultSign = obtainResultSignature(key, body);if (resultSign.equals(Sign)) {System.out.println("{'Status': 'OK', 'Info': 'Verification passed'}");} else {System.out.println("{'Status': 'FAIL', 'Info': 'Verification failed'}");}}}
# -*- coding: utf8 -*-import hmacimport base64from hashlib import sha256# Function: Third-party callback sign verification# Parameters:# key: The key configured in the console# body: The body returned in Tencent Cloud callback# Sign: The signature value sign returned in Tencent Cloud's callback# Returned values:# Status: OK indicates successful verification, and FAIL indicates verification failure. For specific reasons, see Info.# Info: Success/Failure Informationdef checkSign(key, body, sign):temp_dict = {}computSign = base64.b64encode(hmac.new(key.encode('utf-8'), body.encode('utf-8'), digestmod=sha256).digest()).decode('utf-8')print(computSign)if computSign equals sign:temp_dict['Status'] = 'OK'temp_dict['Info'] = 'Verification passed'return temp_dictelse:temp_dict['Status'] = 'FAIL'temp_dict['Info'] = 'Verification failed'return temp_dictif __name__ == '__main__':key = '123654'body = "{\\n" + "\\t\\"EventGroupId\\":\\t2,\\n" + "\\t\\"EventType\\":\\t204,\\n" + "\\t\\"CallbackTs\\":\\t1664209748188,\\n" + "\\t\\"EventInfo\\":\\t{\\n" + "\\t\\t\\"RoomId\\":\\t8489,\\n" + "\\t\\t\\"EventTs\\":\\t1664209748,\\n" + "\\t\\t\\"EventMsTs\\":\\t1664209748180,\\n" + "\\t\\t\\"UserId\\":\\t\\"user_85034614\\",\\n" + "\\t\\t\\"Reason\\":\\t0\\n" + "\\t}\\n" + "}"`sign` = 'kkoFeO3Oh2ZHnjtg8tEAQhtXK16/KI05W3BQff8IvGA='result = verifySignature(key, body, sign)print(result)
<?phpclass TlsEventSig {private $key = false;private $body = false;public function __construct( $key, $body ) {$this->key = $key;$this->body = $body;}private function __hmacsha256() {$hash = hash_hmac( 'sha256', $this->body, $this->key, true );return base64_encode( $hash);}public function genEventSig() {return $this->__hmacsha256();}}$key="789";$data="{\\n\\t\\"EventGroupId\\":\\t1,\\n\\t\\"EventType\\":\\t101,\\n\\t\\"CallbackTs\\":\\t1608086882372,\\n\\t\\"EventInfo\\":\\t{\\n\\t\\t\\"RoomId\\":\\t20222,\\n\\t\\t\\"EventTs\\":\\t1608086882,\\n\\t\\t\\"UserId\\":\\t\\"222222_phone\\"\\n\\t}\\n}";$api = new TlsEventSig($key, $data);echo $api->genEventSig();
package mainimport "fmt"import ("crypto/hmac""crypto/sha256""encoding/base64")func main () {var data = "{\\n\\t\\"EventGroupId\\":\\t1,\\n\\t\\"EventType\\":\\t101,\\n\\t\\"CallbackTs\\":\\t1608086882372,\\n\\t\\"EventInfo\\":\\t{\\n\\t\\t\\"RoomId\\":\\t20222,\\n\\t\\t\\"EventTs\\":\\t1608086882,\\n\\t\\t\\"UserId\\":\\t\\"222222_phone\\"\\n\\t}\\n}"var key = "789"//JSRUN engine 2.0, supporting up to 30 types of languages for online running, with full simulation of online interaction for input and output.fmt.Println(hmacsha256(data,key))}func hmacsha256(data string, key string) string {h := hmac.New(sha256.New, []byte(key))h.Write([]byte(data))return base64.StdEncoding.EncodeToString(h.Sum(nil))}
Was this page helpful?