To meet the requirements of different scenarios, a production studio allows you to use typical layouts such as the single-image layout, picture-in-picture (PIP) layout, and four-image layout. The production studio service also allows you to create a custom layout based on your business scenario.

How to customize a layout

  1. Specify the number of video layers in the layout, video sources to be referenced by the layout and their location IDs, and overlay sequence of the video layers.
  2. Specify the position, coordinates, and normalized width or height of each video layer.
  3. Specify the number of audio streams to be mixed, audio sources to be referenced by the layout and their location IDs, and mix sequence of the audio streams.
  4. Specify the multiples of the original volume at which each audio stream is played and the input audio channel of each audio stream.

Parameters for customizing a sample PIP layout

For more information about the valid values of the parameters, see AddCasterLayout.

Parameter Example Description
Action AddCasterLayout The operation that you want to perform.
CasterId LIVEPRODUCER_POST-cn-v0h1557**** The ID of the production studio.
BlendList.1 RV01 The location ID of the lower-layer video source.
BlendList.2 RV02 The location ID of the upper-layer video source.
MixList.1 RV01 The location ID of the video source.
VideoLayer.1.HeightNormalized 1.0 The normalized height of the video layer. The width of the video layer is proportionally scaled based on this parameter.
VideoLayer.1.PositionNormalized.1 1.0 The normalized x-axis value of the video layer.
VideoLayer.1.PositionNormalized.2 1.0 The normalized y-axis value of the video layer.
VideoLayer.1.PositionRefer topLeft The reference origin of the coordinates of the video layer in the layout. In this example, the origin is the upper-left corner of the playback window.
VideoLayer.2.HeightNormalized 0.3 The normalized height of the video layer. The width of the video layer is proportionally scaled based on this parameter.
VideoLayer.2.PositionNormalized.1 0.2 The normalized x-axis value of the video layer.
VideoLayer.2.PositionNormalized.2 0.2 The normalized y-axis value of the video layer.
VideoLayer.2.PositionRefer topLeft The reference origin of the coordinates of the video layer in the layout. In this example, the origin is the upper-left corner of the playback window.
AudioLayer.1.ValidChannel leftChannel The audio input channel. In this example, the left channel is used.
AudioLayer.1.VolumeRate 1.0 The multiple of the original volume at which the audio stream is played. A value of 1.0 indicates the original volume.
Note A.n indicates the Nth parameter in the A list. A.n.B indicates the B parameter of the Nth struct element in the A list.

Sample code

public AddCasterLayoutResponse addCasterLayoutSample() {
        /* Set BlendList. */
        ArrayList<String> blendList = new ArrayList<String>();
        blendList.add("RV01");
        blendList.add("RV02");
        /* Set VideoLayers. */
        ArrayList<VideoLayer> videoLayers = new ArrayList<VideoLayer>();
        VideoLayer videoLayerRv01 = new VideoLayer();
        ArrayList<Float> positionNormalizedRv01 = new ArrayList<Float>();
        positionNormalizedRv01.add(0f);
        positionNormalizedRv01.add(0f);
        videoLayerRv01.setHeightNormalized(1f);  // Set the normalized height of the video layer.
        videoLayerRv01.setPositionNormalizeds(positionNormalizedRv01); // Set the normalized coordinates of the video layer.
        videoLayerRv01.setPositionRefer("topLeft"); // Set the reference origin of the coordinates of the video layer.
        videoLayers.add(videoLayerRv01);
        VideoLayer videoLayerRv02 = new VideoLayer();
        ArrayList<Float> positionNormalizedRv02 = new ArrayList<Float>();
        positionNormalizedRv02.add(0.2f);
        positionNormalizedRv02.add(0.2f);
        videoLayerRv02.setHeightNormalized(0.3f);  // Set the normalized height of the video layer.
        videoLayerRv02.setPositionNormalizeds(positionNormalizedRv02); // Set the normalized coordinates of the video layer.
        videoLayerRv02.setPositionRefer("topLeft"); // Set the reference origin of the coordinates of the video layer.
        videoLayers.add(videoLayerRv02);
        /* Set MixList. */
        ArrayList<String> mixList = new ArrayList<String>();
        mixList.add("RV01");
        /* Set AudioLayers. */
        ArrayList<AudioLayer> audioLayers = new ArrayList<AudioLayer>();
        AudioLayer audioLayer = new AudioLayer();
        audioLayer.setVolumeRate(1f); // Set the multiple of the original volume at which the audio stream is played.
        audioLayer.setValidChannel("leftChannel"); // Set the audio input channel.
        audioLayers.add(audioLayer);

        AddCasterLayoutRequest addCasterLayoutRequest = new AddCasterLayoutRequest();
        addCasterLayoutRequest.setCasterId("LIVEPRODUCER_POST-cn-v0h1557****"); // Set the ID of the production studio.
        addCasterLayoutRequest.setBlendLists(blendList); // Set BlendList.
        addCasterLayoutRequest.setMixLists(mixList);  // Set MixList.
        addCasterLayoutRequest.setVideoLayers(videoLayers); // Set VideoLayers.
        addCasterLayoutRequest.setAudioLayers(audioLayers); // Set AudioLayers.
        AddCasterLayoutResponse addCasterLayoutResponse = null;
        try {
            addCasterLayoutResponse = LiveClient.getClient().getAcsResponse(addCasterLayoutRequest);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return addCasterLayoutResponse;
    }