com.aliyun.svideosdk.mixrecorder

## Interface AliyunIMixRecorder

-     public interface AliyunIMixRecorder

  The interface of mix recorder

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `addImage(EffectImage effctImage)` Deprecated. in v3.27.0 ，use `getPasterManager()` instead.
    `int` | `addPaster(EffectPaster effectPaster)` Deprecated. in v3.27.0 ，use `getPasterManager()` instead.
    `int` | `addPaster(EffectPaster effectPaster, float sx, float sy, float sw, float sh, float rotation, boolean flip)` Deprecated. in v3.27.0 ，use `getPasterManager()` instead. `setEffectView(float, float, float, float, EffectBase)` and this method can be used to add multiple effects.
    `int` | `applyAnimationFilter(EffectFilter effectFilter)` Applies an animated filter.
    `int` | `applyFilter(EffectFilter effectFilter)` Applies a filter.
    `int` | `cancelFinishing()` Cancels the composition process.
    `int` | `deleteLastPart()` Deletes the last clip.
    `int` | `finishRecording()` Stops recording and starts the composition process.
    `int` | `getBeautyLevel()` Gets the beauty level.
    `int` | `getCameraCount()` Gets the number of cameras.
    `AliyunIClipManager` | `getClipManager()` Gets the clip manager.
    `float` | `getCurrentExposureCompensationRatio()` Gets the current exposure level.
    `AliyunIRecordPasterManager` | `getPasterManager()` Get sticker manager interface
    `void` | `needFaceTrackInternal(boolean need)` Sets whether to enable facial recognition.
    `void` | `release()` Releases resources.
    `void` | `removeAnimationFilter(EffectFilter effctFilter)` Removes an animated filter.
    `int` | `removeFilter()` Added in v3.27.0 Remove a filter.
    `void` | `removeImage(EffectImage effctImage)` Deprecated. in v3.27.0 ，use `getPasterManager()` instead.
    `void` | `removePaster(EffectPaster effectPaster)` Deprecated. in v3.27.0 ，use `getPasterManager()` instead.
    `void` | `setBackgroundColor(int color)` Set the background color Added in v3.19.0
    `void` | `setBackgroundImage(Bitmap bitmap, int displayMode)` Set the background image with bitmap Added in v3.19.0
    `void` | `setBeautyLevel(int level)` Sets the beauty level.
    `void` | `setBeautyStatus(boolean on)` Deprecated. in v3.27.0, use`setBeautyLevel(int)` instead.
    `void` | `setCamera(CameraType camera)` Sets the camera type during preview.
    `void` | `setCameraCaptureDataMode(int captureDataMode)` Sets the data capture method during preview.
    `void` | `setCameraParam(CameraParam cameraParam)` Sets camera parameters during preview.
    `int` | `setDisplayView(SurfaceView previewView, SurfaceView playView)` Sets the `SurfaceView` during preview.
    `int` | `setEffectView(float xRatio, float yRatio, float widthRatio, float heightRatio, EffectBase effectBase)` Deprecated. in v3.27.0 ，use `getPasterManager()` instead.
    `int` | `setExposureCompensationRatio(float value)` Sets the exposure level.
    `void` | `setFaceDetectRotation(int rotation)` Sets the rotation angle of the gyro sensor when performing facial recognition.
    `int` | `setFaces(float[][] faces)` Sets the coordinate points to define faces.
    `void` | `setFaceTrackInternalMaxFaceCount(int maxFaceCount)` Sets the maximum number of faces that can be recognized at the same time.
    `int` | `setFaceTrackInternalModelPath(java.lang.String path)` Sets the path of facial recognition models.
    `void` | `setFocus(float xRatio, float yRatio)` Sets the focus point.
    `void` | `setFocusMode(int mode)` Sets the focus mode.
    `int` | `setGop(int gop)` Deprecated. in v3.27.0, use`setMixMediaInfo(AliyunMixMediaInfoParam, MediaInfo)` instead.
    `void` | `setIsAutoClearClipVideos(boolean isAutoClear)`
    `boolean` | `setLight(FlashType flashType)` Sets the flash mode.
    `void` | `setMixAudioAecType(MixAudioAecType type)` config audio source type of the output video Added in v3.23.0
    `void` | `setMixAudioSource(MixAudioSourceType type)` config audio source type of the output video Added in v3.18.0 see `MixAudioSourceType`
    `void` | `setMixAudioWeight(int originAudioWeight, int recorderAudioWeight)` Added in v3.19.0 set the audio volume when mix，Only take effect when `MixAudioSourceType.MIX`
    `void` | `setMixedBorderParam(AliyunMixBorderParam param)` Set mixed video border parameter Added in v3.21.0
    `int` | `setMixMediaInfo(AliyunMixMediaInfoParam inputMediaInfo, MediaInfo outputInfo)` Sets input and output information about the duet.
    `void` | `setOnAudioCallback(OnAudioCallBack callback)` Sets the callback that outputs audio data in 44.1 kHz 16-bit mono PCM format.
    `void` | `setOnChoosePictureSizeCallBack(OnChoosePictureSizeCallback callback)` Sets the callback that outputs the image resolution.
    `void` | `setOnFaceDetectInfoListener(OnFaceDetectInfoListener listener)` Sets the callback that outputs facial recognition data.
    `void` | `setOnFrameCallback(OnFrameCallback callback)` Sets the callback that outputs frame data during recording.
    `void` | `setOnRecordCallback(OnRecordCallback callback)` Sets the recording callback.
    `void` | `setOnTextureIdCallback(OnTextureIdCallback callback)` Sets the callback that outputs the texture on every frame.
    `int` | `setOutputPath(java.lang.String path)` Sets the output path.
    `int` | `setRate(float rate)` Sets the recording speed.
    `void` | `setRecordBorderParam(AliyunMixBorderParam param)` Set recorded video border parameter Added in v3.21.0
    `void` | `setRecordRotation(int rotation)` Sets the rotation angle of the gyro sensor during recording.
    `void` | `setRotation(int rotation)` Sets the rotation angle of the gyro sensor.
    `int` | `setVideoBitrate(int bitrate)` Deprecated. in v3.27.0, use`setMixMediaInfo(AliyunMixMediaInfoParam, MediaInfo)` instead.
    `void` | `setVideoQuality(VideoQuality quality)` Deprecated. in v3.27.0, use`setMixMediaInfo(AliyunMixMediaInfoParam, MediaInfo)` instead.
    `int` | `setZoom(float rate)` Sets the zoom level.
    `int` | `startPreview()` Starts preview.
    `int` | `startRecording()` Starts recording.
    `void` | `stopPreview()` Stops preview.
    `int` | `stopRecording()` Stops recording.
    `int` | `switchCamera()` Switches the camera.
    `FlashType` | `switchLight()` Switches the flash mode.
    `int` | `updateAnimationFilter(EffectFilter effectFilter)` update an animated filter.

- - ### Method Detail

    - #### getClipManager

          AliyunIClipManager getClipManager()

      Gets the clip manager.
      Returns:
        The clip manager.
      See Also:
        `AliyunIClipManager`

    - #### setOutputPath

          int setOutputPath(java.lang.String path)

      Sets the output path.
      Parameters:
        `path` -

    - #### setVideoQuality

          @Deprecated
          void setVideoQuality(VideoQuality quality)

      Deprecated. in v3.27.0, use`setMixMediaInfo(AliyunMixMediaInfoParam, MediaInfo)` instead.
      Sets the video quality. This setting affects the video bitrate.
      Parameters:
        `quality` - The quality of the video.
      See Also:
        `VideoQuality`

    - #### setGop

          @Deprecated
          int setGop(int gop)

      Deprecated. in v3.27.0, use`setMixMediaInfo(AliyunMixMediaInfoParam, MediaInfo)` instead.
      Sets the GOP size in frames, that is, the number of frames between two I-frames. In hardware encoders, the GOP is measured in seconds, that is, the time interval between two I-frames. The acutal GOP is calculated by dividing the GOP size in frames by the frame rate and rounding the result down to the nearest integer. For example, if the frame rate is set to 25 FPS and this method sets the GOP size to 125 frames. The acutal GOP is 5 seconds, that is, one I-frame per 5 seconds. If the GOP size in frames is smaller than the frame rate value, the acutal GOP is 1.
      Parameters:
        `gop` - Valid values: [0, 9,000] When this parameter is set to 0, full I-frames may be possible depending on the device type.
      Returns:
        `AliyunErrorCode.OK` if the invocation is successful. `AliyunErrorCode.ERROR_INVALID_ARGUMENTS` if the GOP parameter is invalid.

    - #### setVideoBitrate

          @Deprecated
          int setVideoBitrate(int bitrate)

      Deprecated. in v3.27.0, use`setMixMediaInfo(AliyunMixMediaInfoParam, MediaInfo)` instead.
      Sets the video bitrate. Valid values: [200, 20,000]. Unit: kbit/s. If the bitrate exceeds the recommended maximum value, the bitrate specified in the input parameter may not take effect in some hardware encoders. For example, for a resolution of 1280 x 720 pixels, a bitrate of 4 Mbit/s should be enough. If the bitrate is set to 10 Mbit/s, the acutal bitrate may still be 4 Mbit/s depending on the encoder.
      Parameters:
        `bitrate` -
      Returns:
        0 if the invocation is successful or an error code if the invocation fails. `AliyunErrorCode.ERROR_INVALID_ARGUMENTS` if the specified bitrate is invalid.

    - #### setCamera

          void setCamera(CameraType camera)

      Sets the camera type during preview. This setting only takes effect when the preview is started for the first time. Use `switchCamera()` to switch cameras.
      Parameters:
        `camera` -
      See Also:
        `CameraType.BACK`, `CameraType.FRONT`

    - #### setDisplayView

          int setDisplayView(SurfaceView previewView,
                             SurfaceView playView)

      Sets the `SurfaceView` during preview.
      Parameters:
        `previewView` - The preview of the camera.
        `playView` - The view of the duet.
      Returns:
        `AliyunErrorCode.OK` if the invocation is successful or an error code if the invocation fails.

    - #### setCameraCaptureDataMode

          void setCameraCaptureDataMode(int captureDataMode)

      Sets the data capture method during preview.
      Parameters:
        `captureDataMode` -
      See Also:
        `CameraCaptureDataMode`

    - #### startPreview

          int startPreview()

      Starts preview. It is recommended to call this method in `Activity.onResume()`.

    - #### stopPreview

          void stopPreview()

      Stops preview. It is recommended to call this method in `Activity.onPause()`.

    - #### addPaster

          @Deprecated
          int addPaster(EffectPaster effectPaster)

      Deprecated. in v3.27.0 ，use `getPasterManager()` instead.
      Adds a face sticker. Face stickers are different from other stickers in that `setRotation(int)` must be invoked to add face stickers. For details about calculating the rotation parameter, see the demo. Use this method to add face stickers only. To add other stickers, call `addPaster(EffectPaster, float, float, float, float, float, boolean)`.
      Parameters:
        `effectPaster` -
      Returns:
        0 if the invocation is successful or an error code if the invocation fails.
      See Also:
        `EffectPaster`

    - #### addPaster

          @Deprecated
          int addPaster(EffectPaster effectPaster,
                                    float sx,
                                    float sy,
                                    float sw,
                                    float sh,
                                    float rotation,
                                    boolean flip)

      Deprecated. in v3.27.0 ，use `getPasterManager()` instead. `setEffectView(float, float, float, float, EffectBase)` and this method can be used to add multiple effects.
      Adds a normal sticker.
      Parameters:
        `effectPaster` -
        `sx` - The x coordinate of the sticker relative to the video resolution.
        `sy` - The x coordinate of the sticker relative to the video resolution.
        `sw` - The width of the sticker relative to the video resolution.
        `sh` - The height of the sticker relative to the video resolution.
        `rotation` - The rotation angle of the sticker.
        `flip` - Whether to flip the sticker.
      Returns:
        0 if the invocation is successful or an error code if the invocation fails.
      See Also:
        `setEffectView(float, float, float, float, EffectBase)`

    - #### removePaster

          @Deprecated
          void removePaster(EffectPaster effectPaster)

      Deprecated. in v3.27.0 ，use `getPasterManager()` instead.
      Removes a sticker.
      Parameters:
        `effectPaster` -

    - #### addImage

          @Deprecated
          int addImage(EffectImage effctImage)

      Deprecated. in v3.27.0 ，use `getPasterManager()` instead.
      Adds a watermark image. To add a text watermark, use bitmap tools to convert texts into images.
      Parameters:
        `effctImage` -
      Returns:
        0 if the invocation is successful or an error code if the invocation fails.

    - #### removeImage

          @Deprecated
          void removeImage(EffectImage effctImage)

      Deprecated. in v3.27.0 ，use `getPasterManager()` instead.
      Removes a watermark image.
      Parameters:
        `effctImage` -

    - #### getPasterManager

          AliyunIRecordPasterManager getPasterManager()

      Get sticker manager interface

      Added in v3.27.0

      See Also:
        `AliyunIRecordPasterManager`

    - #### applyFilter

          int applyFilter(EffectFilter effectFilter)

      Applies a filter.
      Parameters:
        `effectFilter` - null indicates remove all filters.
      Returns:
        0 if the invocation is successful or an error code if the invocation fails.

    - #### removeFilter

          int removeFilter()

      Added in v3.27.0 Remove a filter.

      Returns:
        0 if the invocation is successful or an error code if the invocation fails.

    - #### applyAnimationFilter

          int applyAnimationFilter(EffectFilter effectFilter)

      Applies an animated filter. Call `EffectBase.setPath(String)` and use the path of the filter as the input parameter. Alternatively, call `EffectFilter.Builder` to create the filter object.
      Parameters:
        `effectFilter` -
      Returns:
        0 if the invocation is successful or an error code if the invocation fails.

    - #### updateAnimationFilter

          int updateAnimationFilter(EffectFilter effectFilter)

      update an animated filter. Call `EffectBase.setPath(String)` and use the path of the filter as the input parameter. Alternatively, call `EffectFilter.Builder` to create the filter object.
      Parameters:
        `effectFilter` -
      Returns:
        0 if the invocation is successful or an error code if the invocation fails.

    - #### removeAnimationFilter

          void removeAnimationFilter(EffectFilter effctFilter)

      Removes an animated filter.
      Parameters:
        `effctFilter` -

    - #### getCameraCount

          int getCameraCount()

      Gets the number of cameras.
      Returns:
        The number of cameras.

    - #### setCameraParam

          void setCameraParam(CameraParam cameraParam)

      Sets camera parameters during preview.
      Parameters:
        `cameraParam` -
      See Also:
        `CameraParam`

    - #### switchCamera

          int switchCamera()

      Switches the camera.
      Returns:
        The id of the camera that is in use.

    - #### switchLight

          FlashType switchLight()

      Switches the flash mode.
      Returns:
        The current flash mode.
      See Also:
        `FlashType.AUTO`, `FlashType.OFF`, `FlashType.ON`

    - #### setLight

          boolean setLight(FlashType flashType)

      Sets the flash mode.
      Parameters:
        `flashType` -
      Returns:
        true if the invocation is successful or false if the invocation fails.

    - #### setZoom

          int setZoom(float rate)

      Sets the zoom level.
      Parameters:
        `rate` -

    - #### setExposureCompensationRatio

          int setExposureCompensationRatio(float value)

      Sets the exposure level.
      Parameters:
        `value` -

    - #### setFocusMode

          void setFocusMode(int mode)

      Sets the focus mode.
      Parameters:
        `mode` -
      See Also:
        `CameraParam.FOCUS_MODE_CONTINUE`, `CameraParam.FOCUS_MODE_AUTO`

    - #### setRate

          int setRate(float rate)

      Sets the recording speed.
      Parameters:
        `rate` - Valid values: [0.5, 2.0]

    - #### setFocus

          void setFocus(float xRatio,
                        float yRatio)

      Sets the focus point. This setting only takes effect when the input parameter of `setFocusMode(int)` is set to `CameraParam.FOCUS_MODE_AUTO`.
      Parameters:
        `xRatio` - The x coordinate of the focus point relative to the surface view.
        `yRatio` - The y coordinate of the focus point relative to the surface view.

    - #### getBeautyLevel

          int getBeautyLevel()

      Gets the beauty level.
      Returns:
        The current beauty level.

    - #### setBeautyLevel

          void setBeautyLevel(int level)

      Sets the beauty level.
      Parameters:
        `level` - Valid values: [0, 100]. A value of 0 indicates disable beauty mode.

    - #### setBeautyStatus

          @Deprecated
          void setBeautyStatus(boolean on)

      Deprecated. in v3.27.0, use`setBeautyLevel(int)` instead.
      Enables or disables beauty mode.
      Parameters:
        `on` - A value of true indicates enable beauty mode. A value of false indicates disable beauty mode.

    - #### startRecording

          int startRecording()

      Starts recording.

    - #### stopRecording

          int stopRecording()

      Stops recording.

    - #### finishRecording

          int finishRecording()

      Stops recording and starts the composition process.

    - #### setMixAudioSource

          void setMixAudioSource(MixAudioSourceType type)

      config audio source type of the output video Added in v3.18.0 see `MixAudioSourceType`
      Parameters:
        `type` - audio source type

    - #### setMixAudioAecType

          void setMixAudioAecType(MixAudioAecType type)

      config audio source type of the output video Added in v3.23.0
      Parameters:
        `type` - aec type, default none see `MixAudioAecType`

    - #### setMixAudioWeight

          void setMixAudioWeight(int originAudioWeight,
                                 int recorderAudioWeight)

      Added in v3.19.0 set the audio volume when mix，Only take effect when `MixAudioSourceType.MIX`
      Parameters:
        `originAudioWeight` - [0~100]
        `recorderAudioWeight` - [0~100]

    - #### setEffectView

          @Deprecated
          int setEffectView(float xRatio,
                                        float yRatio,
                                        float widthRatio,
                                        float heightRatio,
                                        EffectBase effectBase)

      Deprecated. in v3.27.0 ，use `getPasterManager()` instead.
      Sets sticker parameters, such as the position and size of the sticker.
      Parameters:
        `xRatio` - The x coordinate of the sticker relative to the video resolution.
        `widthRatio` - The width of the sticker relative to the video resolution.
        `heightRatio` - The height of the sticker relative to the video resolution.
        `effectBase` - The sticker.

    - #### setOnRecordCallback

          void setOnRecordCallback(OnRecordCallback callback)

      Sets the recording callback.
      Parameters:
        `callback` -
      See Also:
        `OnRecordCallback`

    - #### setOnFrameCallback

          void setOnFrameCallback(OnFrameCallback callback)

      Sets the callback that outputs frame data during recording.
      Parameters:
        `callback` -
      See Also:
        `OnFrameCallback`

    - #### setOnChoosePictureSizeCallBack

          void setOnChoosePictureSizeCallBack(OnChoosePictureSizeCallback callback)

      Sets the callback that outputs the image resolution.
      Parameters:
        `callback` -

    - #### setOnAudioCallback

          void setOnAudioCallback(OnAudioCallBack callback)

      Sets the callback that outputs audio data in 44.1 kHz 16-bit mono PCM format.
      Parameters:
        `callback` -

    - #### setFaces

          int setFaces(float[][] faces)

      Sets the coordinate points to define faces. Each element of the 2D array indicates the six features of a face.
      Parameters:
        `faces` - Represented by a 2D array of size N*6. point[i][0] => LEFT_EYE_X point[i][1] => LEFT_EYE_Y point[i][2] => RIGHT_EYE_X point[i][3] => RIGHT_EYE_Y point[i][4] => MOUTH_X point[i][5] => MOUTH_Y The above example defines the six features of face i.
      Returns:

    - #### setRotation

          void setRotation(int rotation)

      Sets the rotation angle of the gyro sensor. If the original angle is not one of the following values: 0, 90, 180, and 270, use the following method to determine the rotation angle.

               private int getSensorRotation() {
                    int orientation = orientationDetector.getOrientation();
                    int rotation = 90;
                    if (orientation >= 45 && orientation < 135) {
                        rotation = 180;
                    }
                    if (orientation >= 135 && orientation < 225) {
                        rotation = 270;
                    }
                    if (orientation >= 225 && orientation < 315) {
                        rotation = 0;
                    }
                    if (mCameraType == CameraType.FRONT) {
                        if (rotation != 0) {
                            rotation = 360 - rotation;
                        }
                    }
                    return rotation;
                }

      Parameters:
        `rotation` - Do not use this method to control the angle when performing facial recognition or recording.
      See Also:
        `setFaceDetectRotation(int)`, `setRecordRotation(int)`

    - #### setFaceDetectRotation

          void setFaceDetectRotation(int rotation)

      Sets the rotation angle of the gyro sensor when performing facial recognition. Do not use this method together with setRotation.
      See Also:
        `setRecordRotation(int)`, `setRotation(int)`

    - #### setRecordRotation

          void setRecordRotation(int rotation)

      Sets the rotation angle of the gyro sensor during recording. Do not use this method together with setRotation. Use the following method to determine the rotation angle.

                if (rotation == 90 || rotation == 270) {
                    rotation = (rotation + 90) % 360;
                    if (mAliyunCamera.getCameraInfo().facing == CameraInfo.CAMERA_FACING_BACK) {
                        rotation += 180;
                        rotation %= 360;
                    }
                } else if (rotation == 0 || rotation == 180) {
                    rotation = (rotation + 270) % 360;
                }

      See Also:
        `setRotation(int)`, `setFaceDetectRotation(int)`

    - #### setOnTextureIdCallback

          void setOnTextureIdCallback(OnTextureIdCallback callback)

      Sets the callback that outputs the texture on every frame.
      Parameters:
        `callback` -
      See Also:
        `OnTextureIdCallback`

    - #### setOnFaceDetectInfoListener

          void setOnFaceDetectInfoListener(OnFaceDetectInfoListener listener)

      Sets the callback that outputs facial recognition data. `OnFaceDetectInfoListener.onFaceInfoChange(FaceDetectInfo)` is invoked when changes in facial recognition data are detected.
      Parameters:
        `listener` -

    - #### getCurrentExposureCompensationRatio

          float getCurrentExposureCompensationRatio()

      Gets the current exposure level.
      Returns:
        The current exposure level.

    - #### needFaceTrackInternal

          void needFaceTrackInternal(boolean need)

      Sets whether to enable facial recognition.
      Parameters:
        `need` -

    - #### setFaceTrackInternalModelPath

          int setFaceTrackInternalModelPath(java.lang.String path)

      Sets the path of facial recognition models. The path of facial recognition models is required as the input parameter.
      Parameters:
        `path` -
      Returns:
        `AliyunErrorCode.OK` if the invocation is successful. `AliyunErrorCode.ERROR_INVALID_ARGUMENTS` if the invocation fails, the path is invalid, or the model files are damaged.

    - #### setFaceTrackInternalMaxFaceCount

          void setFaceTrackInternalMaxFaceCount(int maxFaceCount)

      Sets the maximum number of faces that can be recognized at the same time. Maximum value: 3.
      Parameters:
        `maxFaceCount` -

    - #### setMixMediaInfo

          int setMixMediaInfo(AliyunMixMediaInfoParam inputMediaInfo,
                              MediaInfo outputInfo)

      Sets input and output information about the duet.
      Returns:

    - #### deleteLastPart

          int deleteLastPart()

      Deletes the last clip.
      Returns:

    - #### cancelFinishing

          int cancelFinishing()

      Cancels the composition process.
      Returns:

    - #### release

          void release()

      Releases resources.

    - #### setBackgroundColor

          void setBackgroundColor(int color)

      Set the background color Added in v3.19.0
      Parameters:
        `color` -

    - #### setBackgroundImage

          void setBackgroundImage(Bitmap bitmap,
                                  int displayMode)

      Set the background image with bitmap Added in v3.19.0
      Parameters:
        `bitmap` -
        `displayMode` - 0：crop 1：fill 2：exact fit

    - #### setRecordBorderParam

          void setRecordBorderParam(AliyunMixBorderParam param)

      Set recorded video border parameter Added in v3.21.0
      Parameters:
        `param` - record video border parameter `AliyunMixBorderParam`

    - #### setMixedBorderParam

          void setMixedBorderParam(AliyunMixBorderParam param)

      Set mixed video border parameter Added in v3.21.0
      Parameters:
        `param` - record video border parameter `AliyunMixBorderParam`

    - #### setIsAutoClearClipVideos

          void setIsAutoClearClipVideos(boolean isAutoClear)