在转推直播时,你可以在各个客户端实现采集时添加 SEI 信息,获取当前说话的用户信息。

前提条件

你已经集成了 RTC SDK,并实现音视频通话功能。

业务逻辑
  1. 通过 HTTP 请求启动合流转推任务。
  2. 通过 HTTP 请求将volumeIndicationMode参数设置为 true,开启音量指示功能。
    3.可选通过 HTTP 请求设置 volumeIndicationInterval 参数,设置音量回调间隔。
  3. binary 初始化,并设置音量指示回调间隔。
  4. 若当前说话用户列表发生变化,则会收到相应 SEI 信息。
示例代码
HTTP启动请求
{
    "AppId": "Your_AppId",
    "RoomId": "Your_RoomId",
    "UserId": "Your_UserId",
    "transcodeMeta": {
        "transcode": {
            "Url":  "rtmp://xxx.xxx"
        },
        "layout": {
            "canvas": {
                "Width": 544,
                "Height": 960,
                "Background": "#303342"
            },
            "Region": [
                {
                    "uid": "pl122",
                    "LocationX": 0,
                    "LocationY": 0,
                    "WidthProportion": 0.5,
                    "HeightProportion": 1,
                    "ZOrder": 0,
                    "Alpha": 1,
                    "RenderMode": 0
                },
                {
                    "uid": "pl123",
                    "LocationX": 0.5,
                    "LocationY": 0,
                    "WidthProportion": 0.5,
                    "HeightProportion": 1,
                    "ZOrder": 0,
                    "Alpha": 1,
                    "RenderMode": 0
                }
                
            ],
            "watermarks": [
            {
                    "image": {
                            "x": 10,
                            "y": 10,
                            "w": 64,
                            "h": 64,
                            "type": "",
                            "url": "http://xxx.xxx.jpg"
                    },
                    "text": {
                            "x": 10,
                            "y": 20,
                            "font": "",
                            "data": "#ts#localtime",
                            "size": 50,
                            "color": "Black",
                            "transparent": 234
                    }
            }]
        },
        "video": {
            "codec": "H264",
            "bitRate": 1200000,
            "fps": 15,
            "gop": 60,
            "width": 640,
            "height": 360,
            "noBFrame": false
        },
        "audio": {
            "codec": "AAC",
            "bitRate": 128000,
            "sampleRate": 44100,
            "channels": 2,
            "profile":"LC"
        },
        "control": {
            "audioOnly": false, 
            "autoLayout": false,
            "volumeIndicationInterval":2000, 
            "volumeIndicationMode":true, 
            "talkVolume":30 
        }
    }
}

json
说话状态的 SEI JSON
{
    // ... ...
    "canvas":{
        "Background":"#303342",
        "Height":1920,
        "Width":1088
    },
    "Region":[
        {
            "Alpha":1,
            "RenderMode":1,
            "uid":"1000001",
            "HeightProportion":1,
            "WidthProportion":1,
            "LocationX":0,
            "LocationY":0,
            "Zorder":0
        }
    ],
    "infos":[ // 数据,包括订阅中用户的说话情况
        {
            "uid":"1000001", 
            "talk": 1     //音量大小大于30, 说话
        }
    ],
    "msg":"",
    "ts":1620717210623
}

各参数定义,请参看数据结构。