Jocloud-Cloud-Recording supports event notification service. You can configure an HTTP/HTTPS server to receive callbacks. When a recording event occurs, Jocloud-Cloud-Recording server notifies the callback server, and then the callback server sends an HTTP/HTTPS request to your server.
The callback function can be used when any of the following conditions is met:
callbackurl
of startrecord
to specify the HTTP/HTTPS server address to receive callback message when starting the recording task. After you finish the callback configuration, Cloud-Recording server sends an HTTP/HTTPS request when a recording event occurs. The content of the callback message is returned as a JSON object in the body of the POST request. Depending on the msgtype, the fields in the JSON object are different.
Content-type
is application/json
{
"msgid":"RECORD-ec0b460a0000b5794f66e14d5ab7d4ab9c166-17394cfdc6f",
"product":1,
"msgtype":2,
"notifytime":1595929517000,
"context":{
"msgname":"recordtask_m3u8_info",
"appid":123123,
"roomid":"abcabc",
"uid":[
"0"
],
"recordid":"ec0b460a0000b5794f66e14d5ab7d4ab9c166",
"filetype":"m3u8",
"duration":9000,
"fileaddress":"http://xxxxx.m3u8",
"starttime":1595929495000
}
}
Name | Type | Description |
---|---|---|
msgid | string | Notification ID, identifying the notification callback when the event occurs. |
product | int | Product ID 1: Cloud-Recording Value range: 1 |
msgtype | int | Cloud-Recording event type 1: Recording task status change event 2: Recording result event Value range: 1,2 |
notifytime | int | The Unix timestamp of the callback request, in milliseconds. |
msgtype
event type.Context is a JSON object that contains the specific content of the event.
msgtype
is 1 means recording task status change event, for example:
{
"msgid":"RECORD-ee0b460a0000a3994f66e14d5ab7d4b902923-17394cfdb7e",
"product":1,
"msgtype":1,
"notifytime":1595929516926,
"context":{
"msgname":"recordtask_status",
"appid":123123,
"roomid":"abcabc",
"uid":[
"0"
],
"recordid":"ee0b460a0000a3994f66e14d5ab7d4b902923",
"status":2
}
}
context fields:
Name | Type | Description |
---|---|---|
msgname | string | The name of the message, which is "recordtask_status" |
appid | int | The AppID used in your project |
roomid | string | ID of the room to be recorded |
uid | JSON Array | User ID Note: Mixed stream recording is "0" |
recordid | string | Recording ID returned after calling startrecord successfully |
status | int | Record task status 0: Init status 1: Task starting 2: Task stop |
endreason | int | Record task stop reason 1: Actively stop the task. 2: The stream has no data in some time and stop the task. 3: The channel has no stream for some time and stop the task. Note: This field is valid only when the recording task is stopped. |
msgtype
is 2 means recording result event, for example:
{
"msgid":"RECORD-ec0b460a0000b5794f66e14d5ab7d4ab9c166-17394cfdc6f",
"product":1,
"msgtype":2,
"notifytime":1595929517000,
"context":{
"msgname":"recordtask_m3u8_info",
"appid":123123,
"roomid":"abcabc",
"uid":[
"0"
],
"recordid":"ec0b460a0000b5794f66e14d5ab7d4ab9c166",
"filetype":"m3u8",
"duration":9000,
"fileaddress":"http://xxxxx.m3u8",
"starttime":1595929495000
}
}
context fields:
Name | Type | Description |
---|---|---|
msgname | string | The name of the message, which is "recordtask_m3u8_info" |
appid | int | The AppID used in your project |
roomid | string | ID of the room to be recorded |
uid | JSON Array | User ID Note: Mixed stream recording is "0" |
recordid | string | Recording ID returned after calling startrecord successfully |
filetype | string | Recording file format, currently only supports "m3u8" |
duration | unsigned int | The duration of the recording file, in milliseconds |
fileaddress | string | The link of recording file |
starttime | int | Timestamp of the earliest frame in the recording file, in milliseconds |
upload_status | int | Reason when m3u8 address is empty. 0: no ts files. 2: upload timeout error. >100: HTTP upload error code, such as: access denied, etc. For details, please refer to the status of the specific OSS vendor |
Note:
duration
is 0, starttime
is 0, and fileaddress
is empty. At this time, you can check upload_status
or the upstream status of anchor. msgtype
type of 2. startrecord
and stoprecord
are close, the callback event of recordtask_m3u8_info
may not be triggered.
- After sending the message, no response is received in 5 seconds.
- The HTTP status code received is not 200.