创建或更新录制规则
功能介绍
调用此接口创建或更新录制规则。
- 
    
若当前app在请求的location中无录制规则,则会创建新的录制规则
 - 
    
若当前app在请求的location中已有录制规则,则会更新原来的录制规则
 
接口约束
一个app在一个location最多创建一个录制规则。
URI
POST /v2/apps/{app_id}/record-rules
| 
        参数  | 
      
        是否必选  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|---|
| 
        app_id  | 
      
        是  | 
      
        String  | 
      
        应用id  | 
     
请求参数
| 
        参数  | 
      
        是否必选  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|---|
| 
        Content-Type  | 
      
        是  | 
      
        String  | 
      
        内容类型。取值application/json。  | 
     
| 
        X-Auth-Token  | 
      
        否  | 
      
        String  | 
      
        用户Token。使用Token鉴权方式时必选。通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。  | 
     
| 
        Authorization  | 
      
        否  | 
      
        String  | 
      
        使用AK/SK方式认证时必选,携带的鉴权信息。  | 
     
| 
        X-Sdk-Date  | 
      
        否  | 
      
        String  | 
      
        使用AK/SK方式认证时必选,请求的发生时间。  | 
     
| 
        X-Project-Id  | 
      
        否  | 
      
        String  | 
      
        使用AK/SK方式认证时必选,携带项目ID信息。  | 
     
| 
        参数  | 
      
        是否必选  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|---|
| 
        obs_addr  | 
      
        是  | 
      
        RecordObsFileAddr object  | 
      
        保存录制文件所在的桶信息  | 
     
| 
        record_formats  | 
      
        是  | 
      
        Array of strings  | 
      
        录制格式:支持HLS格式和MP4格式(HLS和MP4为大写)。 
  | 
     
| 
        hls_config  | 
      
        否  | 
      
        HLSRecordConfig object  | 
      
        HLS格式录制规则管理  | 
     
| 
        mp4_config  | 
      
        否  | 
      
        MP4RecordConfig object  | 
      
        MP4格式录制规则管理  | 
     
| 
        参数  | 
      
        是否必选  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|---|
| 
        location  | 
      
        是  | 
      
        String  | 
      
        OBS Bucket所在RegionID 
  | 
     
| 
        project_id  | 
      
        是  | 
      
        String  | 
      
        OBS Bucket所在Region的项目ID  | 
     
| 
        bucket  | 
      
        是  | 
      
        String  | 
      
        OBS的bucket名称  | 
     
| 
        object  | 
      
        否  | 
      
        String  | 
      
        OBS对象路径,遵守OBS Object定义。如果为空则保存到根目录  | 
     
| 
        参数  | 
      
        是否必选  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|---|
| 
        record_cycle  | 
      
        是  | 
      
        Integer  | 
      
        周期录制时长。 取值范围:[60,43200]或者0,如果为0则整个流录制为一个文件。 单位:秒。  | 
     
| 
        record_prefix  | 
      
        否  | 
      
        String  | 
      
        录制m3u8文件含路径和文件名的前缀 默认{app_id}/{record_format}/{stream}_{file_start_time}/{stream}_{file_start_time} 可自定义以下特殊变量: 
  | 
     
| 
        record_slice_duration  | 
      
        否  | 
      
        Integer  | 
      
        录制HLS时ts的切片时长,非必填。 取值范围:[2,60],缺省为10。 单位:秒。  | 
     
| 
        record_max_duration_to_merge_file  | 
      
        否  | 
      
        Integer  | 
      
        录制HLS文件拼接时长,如果流中断超过该时间,则生成新文件。 取值范围:[-1,300],缺省为0。 单位:秒。 
  | 
     
| 
        参数  | 
      
        是否必选  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|---|
| 
        record_cycle  | 
      
        是  | 
      
        Integer  | 
      
        周期录制时长。 取值范围:[60,10800]。 单位:秒。  | 
     
| 
        record_prefix  | 
      
        否  | 
      
        String  | 
      
        录制文件含路径和文件名的前缀。 默认{app_id}/{record_format}/{stream}_{file_start_time}/{stream}_{file_start_time} 可自定义以下特殊变量: 
  | 
     
| 
        record_max_duration_to_merge_file  | 
      
        否  | 
      
        Integer  | 
      
        录制MP4拼接时长,如果流中断超过该时间,则生成新文件。 取值范围:[0,300],缺省为0。 单位:秒。 如果为0表示流中断就生成新文件。  | 
     
响应参数
状态码:201
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        X-request-Id  | 
      
        String  | 
      
        此字段携带请求ID号,以便任务跟踪。  | 
     
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        rule_id  | 
      
        String  | 
      
        规则id,由服务端返回。创建或修改规则的时候不携带  | 
     
| 
        app_id  | 
      
        String  | 
      
        应用id  | 
     
| 
        obs_addr  | 
      
        RecordObsFileAddr object  | 
      
        保存录制文件所在的桶信息  | 
     
| 
        record_formats  | 
      
        Array of strings  | 
      
        录制格式:HLS格式或者MP4格式  | 
     
| 
        hls_config  | 
      
        HLSRecordConfig object  | 
      
        hls格式录制规则管理  | 
     
| 
        mp4_config  | 
      
        MP4RecordConfig object  | 
      
        mp4格式录制规则管理  | 
     
| 
        create_time  | 
      
        String  | 
      
        创建时间,形如“2006-01-02T15:04:05.075Z”,时区为:UTC  | 
     
| 
        update_time  | 
      
        String  | 
      
        更新时间,形如“2006-01-02T15:04:05.075Z”,时区为:UTC  | 
     
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        location  | 
      
        String  | 
      
        OBS Bucket所在RegionID 
  | 
     
| 
        project_id  | 
      
        String  | 
      
        OBS Bucket所在Region的项目ID  | 
     
| 
        bucket  | 
      
        String  | 
      
        OBS的bucket名称  | 
     
| 
        object  | 
      
        String  | 
      
        OBS对象路径,遵守OBS Object定义。如果为空则保存到根目录  | 
     
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        record_cycle  | 
      
        Integer  | 
      
        周期录制时长。 取值范围:[60,43200]或者0,如果为0则整个流录制为一个文件。 单位:秒。  | 
     
| 
        record_prefix  | 
      
        String  | 
      
        录制m3u8文件含路径和文件名的前缀 默认{app_id}/{record_format}/{stream}_{file_start_time}/{stream}_{file_start_time} 可自定义以下特殊变量: 
  | 
     
| 
        record_slice_duration  | 
      
        Integer  | 
      
        录制HLS时ts的切片时长,非必填。 取值范围:[2,60],缺省为10。 单位:秒。  | 
     
| 
        record_max_duration_to_merge_file  | 
      
        Integer  | 
      
        录制HLS文件拼接时长,如果流中断超过该时间,则生成新文件。 取值范围:[-1,300],缺省为0。 单位:秒。 
  | 
     
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        record_cycle  | 
      
        Integer  | 
      
        周期录制时长。 取值范围:[60,10800]。 单位:秒。  | 
     
| 
        record_prefix  | 
      
        String  | 
      
        录制文件含路径和文件名的前缀。 默认{app_id}/{record_format}/{stream}_{file_start_time}/{stream}_{file_start_time} 可自定义以下特殊变量: 
  | 
     
| 
        record_max_duration_to_merge_file  | 
      
        Integer  | 
      
        录制MP4拼接时长,如果流中断超过该时间,则生成新文件。 取值范围:[0,300],缺省为0。 单位:秒。 如果为0表示流中断就生成新文件。  | 
     
状态码:200
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        X-request-Id  | 
      
        String  | 
      
        此字段携带请求ID号,以便任务跟踪。  | 
     
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        rule_id  | 
      
        String  | 
      
        规则id,由服务端返回。创建或修改规则的时候不携带  | 
     
| 
        app_id  | 
      
        String  | 
      
        应用id  | 
     
| 
        obs_addr  | 
      
        RecordObsFileAddr object  | 
      
        保存录制文件所在的桶信息  | 
     
| 
        record_formats  | 
      
        Array of strings  | 
      
        录制格式:HLS格式或者MP4格式  | 
     
| 
        hls_config  | 
      
        HLSRecordConfig object  | 
      
        hls格式录制规则管理  | 
     
| 
        mp4_config  | 
      
        MP4RecordConfig object  | 
      
        mp4格式录制规则管理  | 
     
| 
        create_time  | 
      
        String  | 
      
        创建时间,形如“2006-01-02T15:04:05.075Z”,时区为:UTC  | 
     
| 
        update_time  | 
      
        String  | 
      
        更新时间,形如“2006-01-02T15:04:05.075Z”,时区为:UTC  | 
     
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        location  | 
      
        String  | 
      
        OBS Bucket所在RegionID 
  | 
     
| 
        project_id  | 
      
        String  | 
      
        OBS Bucket所在Region的项目ID  | 
     
| 
        bucket  | 
      
        String  | 
      
        OBS的bucket名称  | 
     
| 
        object  | 
      
        String  | 
      
        OBS对象路径,遵守OBS Object定义。如果为空则保存到根目录  | 
     
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        record_cycle  | 
      
        Integer  | 
      
        周期录制时长。 取值范围:[60,43200]或者0,如果为0则整个流录制为一个文件。 单位:秒。  | 
     
| 
        record_prefix  | 
      
        String  | 
      
        录制m3u8文件含路径和文件名的前缀 默认{app_id}/{record_format}/{stream}_{file_start_time}/{stream}_{file_start_time} 可自定义以下特殊变量: 
  | 
     
| 
        record_slice_duration  | 
      
        Integer  | 
      
        录制HLS时ts的切片时长,非必填。 取值范围:[2,60],缺省为10。 单位:秒。  | 
     
| 
        record_max_duration_to_merge_file  | 
      
        Integer  | 
      
        录制HLS文件拼接时长,如果流中断超过该时间,则生成新文件。 取值范围:[-1,300],缺省为0。 单位:秒。 
  | 
     
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        record_cycle  | 
      
        Integer  | 
      
        周期录制时长。 取值范围:[60,10800]。 单位:秒。  | 
     
| 
        record_prefix  | 
      
        String  | 
      
        录制文件含路径和文件名的前缀。 默认{app_id}/{record_format}/{stream}_{file_start_time}/{stream}_{file_start_time} 可自定义以下特殊变量: 
  | 
     
| 
        record_max_duration_to_merge_file  | 
      
        Integer  | 
      
        录制MP4拼接时长,如果流中断超过该时间,则生成新文件。 取值范围:[0,300],缺省为0。 单位:秒。 如果为0表示流中断就生成新文件。  | 
     
状态码:400
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        X-request-Id  | 
      
        String  | 
      
        此字段携带请求ID号,以便任务跟踪。  | 
     
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        错误码  | 
     
| 
        error_msg  | 
      
        String  | 
      
        错误描述  | 
     
状态码:404
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        X-request-Id  | 
      
        String  | 
      
        此字段携带请求ID号,以便任务跟踪。  | 
     
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        错误码  | 
     
| 
        error_msg  | 
      
        String  | 
      
        错误描述  | 
     
状态码:500
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        X-request-Id  | 
      
        String  | 
      
        此字段携带请求ID号,以便任务跟踪。  | 
     
| 
        参数  | 
      
        参数类型  | 
      
        描述  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        错误码  | 
     
| 
        error_msg  | 
      
        String  | 
      
        错误描述  | 
     
请求示例
创建或更新一个录制规则,区域为北京四,录制文件将被保存在名为obsName的桶上,录制文件格式为MP4,录制周期为60秒
POST https://rtc-api.myhuaweicloud.com/v2/apps/{app_id}/record-rules
{
  "obs_addr" : {
    "bucket" : "obsName",
    "location" : "cn-north-4",
    "object" : "Record/",
    "project_id" : "ad7456ce8ef89adf567"
  },
  "record_formats" : [ "MP4" ],
  "mp4_config" : {
    "record_cycle" : 60,
    "record_max_duration_to_merge_file" : 0
  }
}
 响应示例
状态码:201
创建配置成功
{
  "app_id" : "123456abc",
  "rule_id" : "456789abc",
  "create_time" : "2006-01-02T15:04:05.075Z",
  "obs_addr" : {
    "bucket" : "obsName",
    "location" : "cn-north-4",
    "object" : "Record/",
    "project_id" : "ad7456ce8ef89adf567"
  },
  "record_formats" : [ "MP4" ],
  "mp4_config" : {
    "record_cycle" : 60,
    "record_max_duration_to_merge_file" : 0
  },
  "update_time" : "2006-01-02T15:04:05.075Z"
}
  状态码:200
更新配置成功
{
  "app_id" : "123456abc",
  "rule_id" : "456789abc",
  "create_time" : "2006-01-02T15:04:05.075Z",
  "obs_addr" : {
    "bucket" : "obsName",
    "location" : "cn-north-4",
    "object" : "Record/",
    "project_id" : "ad7456ce8ef89adf567"
  },
  "record_formats" : [ "MP4" ],
  "mp4_config" : {
    "record_cycle" : 60,
    "record_max_duration_to_merge_file" : 0
  },
  "update_time" : "2006-01-02T15:04:05.075Z"
}
  状态码:400
配置失败,语义有误,当前请求无法被服务器理解,或参数有误
{
  "error_code" : "RTC.00001003",
  "error_msg" : "InvalidParameterValue"
}
  状态码:404
配置失败,应用不存在
{
  "error_code" : "RTC.00001003",
  "error_msg" : "InvalidParameterValue"
}
  状态码:500
配置失败,服务器端错误
{
  "error_code" : "RTC.00002xxx",
  "error_msg" : "InternalError"
}
 状态码
| 
        状态码  | 
      
        描述  | 
     
|---|---|
| 
        201  | 
      
        创建配置成功  | 
     
| 
        200  | 
      
        更新配置成功  | 
     
| 
        400  | 
      
        配置失败,语义有误,当前请求无法被服务器理解,或参数有误  | 
     
| 
        404  | 
      
        配置失败,应用不存在  | 
     
| 
        500  | 
      
        配置失败,服务器端错误  | 
     
错误码
请参见错误码。