
# 设备码流配置
#### 功能介绍
设备码流配置，目前仅支持好望设备
#### URI
POST /v1/{user_id}/devices/{device_id}/channels/{channel_id}/stream-detail
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述                                                                                                                                                              |
|:---|:---|:---|:---|
| channel_id | 是    | String | 通道ID：目前只支持好望设备，取值范围\[-1,999\]                                                                                                                                   |
| device_id  | 是    | String | 设备ID： 好望设备：大小写字母、数字组成，长度范围\[8,32\]，可在设备外壳或者设备web页面上获取                                                            |
| user_id    | 是    | String | 用户ID：由数字组成，长度范围\[15,25\]，获取方式参考[获取user ID与下载AK/SK](https://support.huaweicloud.com/api-ivm/ivm_03_0005.html#ZH-CN_TOPIC_0000001710465704__section1213543912215) |
   
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                    |
|:---|:---|:---|:---|
| Access-Token | 是    | String | 用户认证AccessToken：从[获取用户北向接口认证AccessToken](https://support.huaweicloud.com/api-ivm/ivm_03_0002.html)中获取 |
   
表3请求Body参数 
| 参数                       | 是否必选 | 参数类型                                                                                               | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
|:---|:---|:---|:---|
| stream_num               | 是    | Integer                                                                                            | 开启码流数                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| max_frame_rate           | 是    | Integer                                                                                            | 全帧率，最大帧率，取值为设备码流能力列表包含的全帧率                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| stream_info              | 是    | Array of [SetStreamDetailInfo] objects | 各码流信息                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| corridor_mode_open       | 否    | Boolean                                                                                            | 走廊模式是否开启：枚举类型 枚举值： - **false**关闭  - **true**开启                                                                                                                                                                                                      |
| mirror_mode              | 否    | Integer                                                                                            | 镜像模式：枚举类型 枚举值： - 0 不开启镜像  - 1 水平镜像  - 2 垂直镜像  - 3 水平垂直镜像   |
| variable_bit_rate_open   | 否    | Boolean                                                                                            | 动态码率是否开启：枚举类型 枚举值： - **false**关闭  - **true**开启                                                                                                                                                                                                             |
| variable_bit_rate        | 否    | Integer                                                                                            | 动态码率值正整数                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| variable_frame_rate_open | 否    | Boolean                                                                                            | 动态帧率是否开启：枚举类型 枚举值： - **false**关闭  - **true**开启                                                                                                                                                                                                      |
| variable_frame_rate      | 否    | Integer                                                                                            | 动态帧率值正整数                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
   
 表4SetStreamDetailInfo 
| 参数                          | 是否必选 | 参数类型    | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
|:---|:---|:---|:---|
| stream_type                 | 是    | Integer | 码流类型：枚举类型 枚举值： - **0** 主码流，  - **1** 子码流1  - **2** 子码流2                                                                                                                                                                                                                                                                                                                                     |
| encode_type                 | 是    | Integer | 编码类型：枚举类型 枚举值： - **H.264**  - **H.265**                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| resolution                  | 否    | String  | 分辨率                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| frame_rate                  | 否    | Integer | 帧率                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| bit_rate_type               | 否    | Integer | 码率类型(H264/H265生效)：枚举类型 枚举值： - 0 定码率  - 1 变码率                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| bit_rate                    | 否    | Integer | (定码率)码率值/(变码率)：取值范围\[512, 16384\]\*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| intelligence_encoding_open  | 否    | Boolean | 智能编码是否开启(H264/H265生效)：枚举类型 枚举值： - **false**关闭  - **true**开启                                                                                                                                                                                                                                                                                                                                                                                                                             |
| intelligence_encoding_level | 否    | Integer | 智能编码级别(H264/H265生效)：取值范围\[1, 5\]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| slice_encoding_open         | 否    | Boolean | 多Slice编码是否开启(H264/H265生效)：枚举类型 枚举值： - **false**关闭  - **true**开启                                                                                                                                                                                                                                                                                                                                                                                                                             |
| layered_encoding_open       | 否    | Boolean | 分层编码是否开启(H264/H265生效)：枚举类型 枚举值： - **false**关闭  - **true**开启                                                                                                                                                                                                                                                                                                                                                                                                                               |
| profile                     | 否    | Integer | 编码质量(H264/H265生效)：枚举类型 H264枚举值： - **2** Base profile,  - **1** Main profile  - **0** High profile;   H265枚举值： - **0** Main profile                                                              |
| i_frame_interval            | 否    | Integer | I帧间隔(H264/H265生效)：取值范围\[1, 500\]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| jpeg_quality                | 否    | Integer | Jpeg图像质量(MJPEG生效)：取值范围\[1, 99\]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| bit_rate_mode               | 否    | Integer | 定码率类型：枚举类型 枚举值： - **1** 帧率优先  - **2** 图像质量优先                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| pic_quality                 | 否    | Integer | 变码率图像质量：枚举类型 枚举值： - **1** 最好  - **2** 次好  - **3** 较好  - **4** 一般  - **5** 较差  - **6** 差   |
   
#### 响应参数
**状态码： 200**
表5响应Body参数 
| 参数         | 参数类型   | 描述   |
|:---|:---|:---|
| device_id  | String | 设备ID |
| channel_id | String | 通道ID |
   
#### 请求示例
码流设置
```
POST/v1/2562572829***/devices/952352LWXT***/channels/0/stream-detail
{
    "stream_num": 2,
    "stream_info": [
        {
            "stream_type": 0,
            "encode_type": "H.264",
            "resolution": "2560*1440",
            "definition": "2K",
            "frame_rate": 25,
            "bit_rate_type": 0,
            "bit_rate": 6144,
            "intelligence_encoding_open": false,
            "intelligence_encoding_level": 0,
            "slice_encoding_open": false,
            "layered_encoding_open": false,
            "profile": 0,
            "i_frame_interval": 0,
            "jpeg_quality": 0,
            "bit_rate_mode": 0,
            "pic_quality": 0
        },
        {
            "stream_type": 1,
            "encode_type": "H.264",
            "resolution": "1920*1080",
            "definition": "1080P",
            "frame_rate": 25,
            "bit_rate_type": 0,
            "bit_rate": 1024,
            "intelligence_encoding_open": false,
            "intelligence_encoding_level": 0,
            "slice_encoding_open": false,
            "layered_encoding_open": false,
            "profile": 0,
            "i_frame_interval": 0,
            "jpeg_quality": 0,
            "bit_rate_mode": 0,
            "pic_quality": 0
        }
    ],
    "max_frame_rate": 20,
    "corridor_mode_open": false,
    "mirror_mode": 0,
    "variable_bit_rate_open": false,
    "variable_bit_rate": 0,
    "variable_frame_rate_open": false,
    "variable_frame_rate": 0
}
```
#### 响应示例
**状态码： 200**
OK
```
{
  "device_id" : "952352LWXT***",
  "channel_id" : "0"
}
```
#### 状态码
请参见[状态码](https://support.huaweicloud.com/api-ivm/ivm_03_0136.html)
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-ivm/ivm_03_0137.html)
