...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
package com.flashphoner.mixerlayout; // Import mixer layout interface import com.flashphoner.media.mixer.video.presentation.BoxPosition; import com.flashphoner.sdk.media.IVideoMixerLayout; // Import YUV frame description import com.flashphoner.sdk.media.YUVFrame; // Import Box class for picture operations import com.flashphoner.media.mixer.video.presentation.Box; // Uncomment this if using build 5.2.878-5.2.976 // import com.flashphoner.server.commons.rmi.data.impl.MixerConfig; // Import Java packages to use import java.awt.*; import java.util.ArrayList; public class SideBySideLayout implements IVideoMixerLayout { // Owner's stream name private static final String USERFOR = "user_for"; // Challenger's stream name private static final String USERAGAINST = "user_against"; /** * Function to compute layout, will be called by mixer before encoding output stream picture * This example computes grid layout * @param yuvFrames - incoming streams raw pictures array in YUV format * @param strings - incoming streams names array * @param canvasWidth - mixer output picture canwas width * @param canvasHeight - mixer output picture canwas heigth * @return array of pictures layouts */ @Override public Layout[] computeLayout(YUVFrame[] yuvFrames, String[] strings, int canvasWidth, int canvasHeight) { // This object represents mixer canvas Box mainBox = new Box(null, canvasWidth, canvasHeight); // Container to place CHALLENGER stream pictures Box userForContainer = new Box(mainBox, canvasWidth / 2, canvasHeight); userForContainer.setPosition(BoxPosition.LEFT); // Container to place OWNER stream pictures Box userAgainstContainer = new Box(mainBox, canvasWidth / 2, canvasHeight); userAgainstContainer.setPosition(BoxPosition.RIGHT); // Iterate through incoming stream pictures array for (int c = 0; c < yuvFrames.length; c++) { String name = strings[c]; Box container; // Chhose container depending on stream name if (name.contains(USERFOR)) { container = userForContainer; } else if (name.contains(USERAGAINST)) { container = userAgainstContainer; } else { // Wrong stream name continue; } // Fill the container by the stream picture Box frameBox = Box.computeBoxWithFrame(container, yuvFrames[c]); frameBox.fillParentNoScale(); } // Prepare an array to return layout calculated ArrayList<IVideoMixerLayout.Layout> layout = new ArrayList<>(); // Calculate mixer layout mainBox.computeLayout(layout); // Return the result return layout.toArray(new IVideoMixerLayout.Layout[layout.size()]); } /** * The function for internal use. * Uncomment this if using build 5.2.878-5.2.976 */ //@Override //public void setConfig(MixerConfig mixerConfig) { //} } |
A separate folder for custom Java libraries
Since build 5.2.1512, custom layout Java libraries (jar files) should be placed to the folder /usr/local/FlashphonerWebCallServer/lib/custom
Code Block | ||||
---|---|---|---|---|
| ||||
cp testlayout.jar /usr/local/FlashphonerWebCallServer/lib/custom |
This folder is keeped while updating WCS to a newer builds. A jar files do not need to be copied again after updating.
Mixer layout management while creating mixer
...