Skip to main content

Stream Mixing

Stream mixing refers to the on-demand combination of multiple audio and video streams in a room, controlling the output parameters of the mixed stream.

Using the server API for stream mixing, you can configure the following:

  • Select anchor video streams for mixing, determining which anchors viewers can see or hear in the final output
  • Configure the layout of the live stream, i.e., the arrangement of multiple video feeds on the viewer's end
  • Manage the resolution of the mixed stream output
  • Control the effect and positioning of watermarks (text or images)

Request Method

POST: https://data center domain/rtc/mcu/config.json

Signature Rule: All requests to RC's server API require signature verification. See API Request Signature for details.

Request Body Parameters

The HTTP request body contains a JSON object with the following structure:

ParameterTypeDescription
sessionIdString(Required) The conversation ID for stream mixing configuration, obtainable via server callback. See Room Status Update Callback.
configObjectJSON-formatted data containing all layout-related parameters.
config.modeNumberStream mixing layout mode, controlling how multiple video feeds are arranged. Options:
  • 1: Custom layout. You can set the overall dimensions of the mixed video and the position/size of each participant's view.

    Note: Each sub-view's position/size must be specified in config.video.input.

  • 2: Floating layout (default)
  • 3: Adaptive layout
See [Understanding Stream Mixing Layouts].
config.versionNumberConfiguration version number, defaults to 1.
config.host_user_idStringThe user ID of the primary video stream publisher. Leave empty ("") when using custom layout (config.mode = 1).
  • For floating layout (config.mode = 2), this ID will be placed in the background.
  • For adaptive layout (config.mode = 3), this ID will be placed in the top-left corner.
config.host_stream_idStringThe stream ID of the primary video. Leave empty ("") when using custom layout (config.mode = 1).
  • For floating layout (config.mode = 2), this ID will be placed in the background.
  • For adaptive layout (config.mode = 3), this ID will be placed in the top-left corner.
Obtainable via Room Status Update Callback.
config.outputObjectSpecifies output parameters for the mixed stream, including video (video) and audio (audio) configurations. See config.output Object Details below.
config.customModeBool(Deprecated) Use inputFilterMode instead.
config.inputFilterModeNumberControls MCU stream mixing resources.
  • 0: Uses all audio/video streams from the current session.
  • 4: Uses only the stream IDs specified in config.input.video and config.input.audio.
config.inputObjectSpecifies input configurations for participant streams, including video (video) and audio (audio) arrays. See config.input Object Details below.
config.waterMarkObjectConfigures watermarks for the mixed stream, supporting image/text/timestamp watermarks on the entire canvas or individual streams. See config.waterMark Object Details.
  • config.output Object Details: Describes video/audio output parameters.

    ParameterTypeDescription
    videoObjectConfigures the mixed video output, including standard stream (normal), small stream (tiny), cropping mode, background color, and background image settings.
    video.normalObjectStandard video stream (HD) output configuration.
    video.normal.widthNumberWidth of the standard mixed video output.
    video.normal.heightNumberHeight of the standard mixed video output.
    video.normal.fpsNumberFrame rate of the standard mixed video output.
    video.normal.bitrateNumberBitrate of the standard mixed video output (kbps). Recommended values:
    • 640X360: 800
    • 480X480: 800
    • 640X480: 900
    • 1280X720: 2500
    • 1920X1080: 4000
    video.tinyObject(Optional) Small video stream output configuration. Defaults to 180x320 if unspecified.
    video.tiny.widthNumberWidth of the small mixed video output.
    video.tiny.heightNumberHeight of the small mixed video output.
    video.tiny.fpsNumberFrame rate of the small mixed video output.
    video.tiny.bitrateNumberBitrate of the small mixed video output (kbps).
    video.exparamsObjectAdditional video output settings, including cropping mode (renderMode).
    video.exparams.renderModeNumber1: Crop; 2: No crop.
    video.backgroundColorStringBackground color (e.g., "0xf1a2c3"). Retains last setting if unspecified.
    video.backgroundPictureObjectBackground image configuration. See video.backgroundPicture Object Details.
    audioObjectAudio output configuration, including bitrate (bitrate).
    audio.bitrateNumberAudio bitrate (kbps).
    • video.backgroundPicture Object Details: Background image settings.

      ParameterTypeDescription
      enableStringEnable/disable background image. off disables; on or unspecified enables.
      fillModeStringImage fill mode. 1: Crop proportionally. 2: Compress proportionally without cropping.
      pictureArray of ObjectsBackground image settings array.
      picture[i].uriStringImage URL (PNG format only; JPG conversions to PNG are invalid).
      picture[i].xNumberX-coordinate (0.0-1.0) relative to canvas width.
      picture[i].yNumberY-coordinate (0.0-1.0) relative to canvas height.
      picture[i].wNumberDisplay width (0.0-1.0), where 1 = full canvas width.
      picture[i].hNumberDisplay height (0.0-1.0), where 1 = full canvas height. Images scale proportionally. Example: For a 500x500 PNG with w=0.5, h=0.2 on a 640x480 canvas, the display area is 320x96 pixels, showing a 96x96 watermark.
  • config.input Object Details: Specifies input streams and custom layout coordinates.

    ParameterTypeDescription
    videoArray of objectsArray of video streams to mix, including base info and (for custom layout) view coordinates.
    video[i].user_idString(Required) Publisher's user ID. Must be valid.
    video[i].stream_idString(Required) Publisher's stream ID. Must be valid.

    Obtainable via Room Status Update Callback. Corresponds to msid where mediaType = 1.
    video[i].xNumberX-offset of sub-view's top-left corner (pixels). Cannot exceed canvas width.

    Required only for custom layout (config.mode = 1).
    video[i].yNumberY-offset of sub-view's top-left corner (pixels). Cannot exceed canvas height.

    Required only for custom layout (config.mode = 1).
    video[i].widthNumberSub-view width (pixels). x + width ≤ canvas width.

    Required only for custom layout (config.mode = 1).
    video[i].heightNumberSub-view height (pixels). y + height ≤ canvas height.

    Required only for custom layout (config.mode = 1).
    audioArray of objectsArray of audio streams to mix.
    audio[i].user_idStringPublisher's user ID.
    audio[i].stream_idStringAudio stream ID.

    Obtainable via Room Status Update Callback. Corresponds to msid where mediaType = 0.
  • config.waterMark Object Details: Watermark configurations for pre/post-mixing.

    ParameterTypeDescription
    waterMark.enableBoolWatermark toggle.
    waterMark.mixScreenObjectWatermark settings for the entire mixed canvas.
    waterMark.mixScreen.timestampObjectTimestamp watermark for the mixed canvas. See Timestamp Watermark Details.
    waterMark.mixScreen.textArray of ObjectsText watermark for the mixed canvas. See Text Watermark Details.
    waterMark.mixScreen.pictureArray of ObjectsImage watermark for the mixed canvas. See Image Watermark Details.
    waterMark.singleScreenArray of ObjectsPer-stream watermark configurations.
    waterMark.singleScreen[i].steamIdStringStream ID.

    Obtainable via Room Status Update Callback. Corresponds to msid where mediaType = 1.
    waterMark.singleScreen[i].timestampObjectTimestamp watermark for a single stream. See Timestamp Watermark Details.
    waterMark.singleScreen[i].textArray of ObjectsText watermark for a single stream. See Text Watermark Details.
    waterMark.singleScreen[i].pictureArray of ObjectsImage watermark for a single stream. See Image Watermark Details.
    • Timestamp Watermark Details: timestamp object parameters.

      ParameterTypeDescription
      timestampObjectTimestamp watermark configuration.
      timestamp.timezoneNumberTimezone offset.
      timestamp.fontSizeNumberFont size (pixels).
      timestamp.colorStringFont color: black or white.
      timestamp.alphaNumberOpacity (0.0-1.0).
      timestamp.xNumberX-coordinate (0.0-1.0), where 1 = full width.
      timestamp.yNumberY-coordinate (0.0-1.0), where 1 = full height.
    • Text Watermark Details: text array parameters.

      ParameterTypeDescription
      textArray of ObjectsText watermark configuration.
      text[i].contentStringText content.
      text[i].fontSizeNumberFont size (pixels).
      text[i].colorStringFont color: black or white.
      text[i].alphaNumberOpacity (0.0-1.0).
      text[i].xNumberX-coordinate (0.0-1.0).
      text[i].yNumberY-coordinate (0.0-1.0).
    • Image Watermark Details: picture array parameters.

      ParameterTypeDescription
      pictureArray of ObjectsImage watermark configuration.
      picture[i].uriStringImage URL (PNG format only; JPG conversions to PNG are invalid).
      picture[i].xNumberX-coordinate (0.0-1.0).
      picture[i].yNumberY-coordinate (0.0-1.0).
      picture[i].wNumberDisplay width (0.0-1.0), where 1 = full width.
      picture[i].hNumberDisplay height (0.0-1.0), where 1 = full height. Images scale proportionally. Example: For a 500x500 PNG with w=0.5, h=0.2 on a 640x480 canvas, the display area is 320x96 pixels, showing a 96x96 watermark.

JSON Example

{
"sessionId":"aaa",
"config":{
"version": 2,
"mode": 1/2/3, // 1: Custom, 2: Floating (default), 3: Adaptive
"host_user_id": "001",
"host_stream_id":"111_RongCloudRTC", // Primary stream for layout
"output": {
"video": {
"normal": {
"width": 360,
"height": 640,
"fps": 25,
"bitrate": 800, //kbps
},
"exparams": {
"renderMode":1 //1: Crop, 2: No crop
},
"backgroundColor":"0xf1a2c3", // Retains last setting if unspecified
"backgroundPicture" : { // Retains last setting if unspecified
"enable":"on", // off: Disable, on/unspecified: Enable
"fillMode" : 1, // 1: Crop proportionally, 2: Compress proportionally
"picture" : [
{
"uri" : "http://aaa.png", // PNG URL
"x" : 0.0, // X-coordinate
"y" : 0.0, // Y-coordinate
"w" : 1.0, // Width (0.0-1.0)
"h" : 1.0 // Height (0.0-1.0)
},
{
"uri" : "http://bbb.png",
"x" : 0.5,
"y" : 0.5,
"w" : 0.5,
"h" : 0.5
}
]
}
},
"audio": {
"bitrate": 200, //kbps
}
},
"inputFilterMode":4,
"input": {
"video": [
{
"user_id": "111",
"stream_id":"111_RongCloudRTC", // "RongCloudRTC" indicates standard camera stream
"x":0,
"y":0,
"width":180,
"height":320
},
{
"user_id": "2222",
"stream_id":"2222_screenshare",
"x":180,
"y":320,
"width":180,
"height":320
}
],
"audio":[
{
"user_id":"111",
"stream_id":"111_RongCloudRTC"
},
{
"user_id":"2222",
"stream_id":"2222_RongCloudRTC"
}
]
},
"waterMark": {
"enable":"on", // off: Disable, on/unspecified: Enable
"mixScreen": {
"timestamp": {
"fontSize": 30,
"timezone": 8,
"x": 0.1,
"y": 0.1,
"alpha": 0.8,
"color": "black"
},
"text": [{
"alpha": 1,
"color": "white",
"x": 0.1,
"y": 0.2,
"content": "abcde",
"fontSize": 30
},
{
"alpha": 0.2,
"color": "black",
"x": 0.3,
"y": 0.5,
"content": "hello, world",
"fontSize": 20
}
],
"picture": [{
"uri": "https://aaa",
"w": 0.1,
"h": 0.1,
"x": 0.1,
"y": 0.2
},
{
"uri": "https://ccc",
"w": 0.6,
"h": 0.6,
"x": 0.2,
"y": 0.2
}
]
},
"singleScreen": [{
"streamId": "stream1_RongCloudRTC",
"timestamp": {
"alpha": 0.8,
"color": "black",
"fontSize": 30,
"timezone": 8,
"x": 0.1,
"y": 0.1
}
},
{
"streamId": "stream2_RongCloudRTC",
"picture": [{
"uri": "https://ccc",
"w": 0.1,
"h": 0.1,
"x": 0.2,
"y": 0.3
}]
}
]
}
}
}

Response

The HTTP response body contains a JSON object with the following structure:

  • code: Business status code. 200 indicates success.
 {
"code":404,
"errorMessage": "Not a valid API"
}