Java Code Examples for com.qiniu.pili.droid.streaming.CameraStreamingSetting#CAMERA_FACING_ID

The following examples show how to use com.qiniu.pili.droid.streaming.CameraStreamingSetting#CAMERA_FACING_ID . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RTCStreamingActivity.java    From PLDroidRTCStreaming with Apache License 2.0 6 votes vote down vote up
public void onClickSwitchCamera(View v) {
    if (isPictureStreaming()) {
        return;
    }
    mCurrentCamFacingIndex = (mCurrentCamFacingIndex + 1) % CameraStreamingSetting.getNumberOfCameras();
    CameraStreamingSetting.CAMERA_FACING_ID facingId;
    if (mCurrentCamFacingIndex == CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK.ordinal()) {
        facingId = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK;
    } else if (mCurrentCamFacingIndex == CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT.ordinal()) {
        facingId = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT;
    } else {
        facingId = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD;
    }
    Log.i(TAG, "switchCamera:" + facingId);
    mRTCStreamingManager.switchCamera(facingId);
    mIsEncodingMirror = false;
    mIsPreviewMirror = false;
}
 
Example 2
Source File: AVStreamingActivity.java    From PLDroidMediaStreaming with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    mCurrentCamFacingIndex = (mCurrentCamFacingIndex + 1) % CameraStreamingSetting.getNumberOfCameras();
    CameraStreamingSetting.CAMERA_FACING_ID facingId;
    if (mCurrentCamFacingIndex == CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK.ordinal()) {
        facingId = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK;
    } else if (mCurrentCamFacingIndex == CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT.ordinal()) {
        facingId = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT;
    } else {
        facingId = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD;
    }
    Log.i(TAG, "switchCamera:" + facingId);
    mMediaStreamingManager.switchCamera(facingId);

    mIsEncodingMirror = mCameraConfig.mEncodingMirror;
    mIsPreviewMirror = facingId == CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT ? mCameraConfig.mPreviewMirror : false;
}
 
Example 3
Source File: QiniucloudPushPlatformView.java    From FlutterQiniucloudLivePlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 切换摄像头
 */
private void switchCamera(MethodCall call, final MethodChannel.Result result) {
    CameraStreamingSetting.CAMERA_FACING_ID id;
    if(cameraStreamingSetting.getCameraFacingId() == CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT){
        id = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK;
    }else{
        id = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT;
    }
    cameraStreamingSetting.setCameraFacingId(id);
    result.success(manager.switchCamera(id));
}
 
Example 4
Source File: ConferenceActivity.java    From PLDroidRTCStreaming with Apache License 2.0 5 votes vote down vote up
public void onClickSwitchCamera(View v) {
    mCurrentCamFacingIndex = (mCurrentCamFacingIndex + 1) % CameraStreamingSetting.getNumberOfCameras();
    CameraStreamingSetting.CAMERA_FACING_ID facingId;
    if (mCurrentCamFacingIndex == CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK.ordinal()) {
        facingId = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK;
    } else if (mCurrentCamFacingIndex == CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT.ordinal()) {
        facingId = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT;
    } else {
        facingId = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD;
    }
    Log.i(TAG, "switchCamera:" + facingId);
    mRTCConferenceManager.switchCamera(facingId);
}
 
Example 5
Source File: ConferenceActivity.java    From PLDroidRTCStreaming with Apache License 2.0 5 votes vote down vote up
private CameraStreamingSetting.CAMERA_FACING_ID chooseCameraFacingId() {
    if (CameraStreamingSetting.hasCameraFacing(CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD)) {
        return CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD;
    } else if (CameraStreamingSetting.hasCameraFacing(CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT)) {
        return CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT;
    } else {
        return CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK;
    }
}
 
Example 6
Source File: PKAnchorActivity.java    From PLDroidRTCStreaming with Apache License 2.0 5 votes vote down vote up
public void onClickSwitchCamera(View v) {
    mCurrentCamFacingIndex = (mCurrentCamFacingIndex + 1) % CameraStreamingSetting.getNumberOfCameras();
    CameraStreamingSetting.CAMERA_FACING_ID facingId;
    if (mCurrentCamFacingIndex == CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK.ordinal()) {
        facingId = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK;
    } else if (mCurrentCamFacingIndex == CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT.ordinal()) {
        facingId = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT;
    } else {
        facingId = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD;
    }
    Log.i(TAG, "switchCamera:" + facingId);
    mRTCStreamingManager.switchCamera(facingId);
}
 
Example 7
Source File: PKAnchorActivity.java    From PLDroidRTCStreaming with Apache License 2.0 5 votes vote down vote up
private CameraStreamingSetting.CAMERA_FACING_ID chooseCameraFacingId() {
    if (CameraStreamingSetting.hasCameraFacing(CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD)) {
        return CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD;
    } else if (CameraStreamingSetting.hasCameraFacing(CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT)) {
        return CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT;
    } else {
        return CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK;
    }
}
 
Example 8
Source File: RTCStreamingActivity.java    From PLDroidRTCStreaming with Apache License 2.0 5 votes vote down vote up
private CameraStreamingSetting.CAMERA_FACING_ID chooseCameraFacingId() {
    if (CameraStreamingSetting.hasCameraFacing(CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD)) {
        return CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD;
    } else if (CameraStreamingSetting.hasCameraFacing(CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT)) {
        return CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT;
    } else {
        return CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK;
    }
}
 
Example 9
Source File: PKViceAnchorActivity.java    From PLDroidRTCStreaming with Apache License 2.0 5 votes vote down vote up
public void onClickSwitchCamera(View v) {
    mCurrentCamFacingIndex = (mCurrentCamFacingIndex + 1) % CameraStreamingSetting.getNumberOfCameras();
    CameraStreamingSetting.CAMERA_FACING_ID facingId;
    if (mCurrentCamFacingIndex == CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK.ordinal()) {
        facingId = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK;
    } else if (mCurrentCamFacingIndex == CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT.ordinal()) {
        facingId = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT;
    } else {
        facingId = CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD;
    }
    Log.i(TAG, "switchCamera:" + facingId);
    mRTCStreamingManager.switchCamera(facingId);
}
 
Example 10
Source File: PKViceAnchorActivity.java    From PLDroidRTCStreaming with Apache License 2.0 5 votes vote down vote up
private CameraStreamingSetting.CAMERA_FACING_ID chooseCameraFacingId() {
    if (CameraStreamingSetting.hasCameraFacing(CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD)) {
        return CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_3RD;
    } else if (CameraStreamingSetting.hasCameraFacing(CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT)) {
        return CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT;
    } else {
        return CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_BACK;
    }
}
 
Example 11
Source File: PKViceAnchorActivity.java    From PLDroidRTCStreaming with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_pk_vice_anchor);

    /**
     * Step 1: find & init views
     */
    GLSurfaceView cameraPreviewFrameView = (GLSurfaceView) findViewById(R.id.cameraPreview_surfaceView);

    boolean isSwCodec = getIntent().getBooleanExtra("swcodec", true);
    mRoomName = getIntent().getStringExtra("roomName");
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    boolean isBeautyEnabled = getIntent().getBooleanExtra("beauty", false);
    boolean isDebugModeEnabled = getIntent().getBooleanExtra("debugMode", false);

    mControlButton = (Button) findViewById(R.id.ControlButton);
    mMuteCheckBox = (CheckBox) findViewById(R.id.MuteCheckBox);
    mMuteCheckBox.setOnClickListener(mMuteButtonClickListener);
    mControlButton.setText("开始连麦");

    CameraStreamingSetting.CAMERA_FACING_ID facingId = chooseCameraFacingId();
    mCurrentCamFacingIndex = facingId.ordinal();

    /**
     * Step 2: config camera & microphone settings
     */
    CameraStreamingSetting cameraStreamingSetting = new CameraStreamingSetting();
    cameraStreamingSetting.setCameraFacingId(facingId)
            .setContinuousFocusModeEnabled(true)
            .setRecordingHint(false)
            .setResetTouchFocusDelayInMs(3000)
            .setFocusMode(CameraStreamingSetting.FOCUS_MODE_CONTINUOUS_PICTURE)
            .setCameraPrvSizeLevel(CameraStreamingSetting.PREVIEW_SIZE_LEVEL.MEDIUM)
            .setCameraPrvSizeRatio(CameraStreamingSetting.PREVIEW_SIZE_RATIO.RATIO_4_3);

    if (isBeautyEnabled) {
        cameraStreamingSetting.setBuiltInFaceBeautyEnabled(true); // Using sdk built in face beauty algorithm
        cameraStreamingSetting.setFaceBeautySetting(new CameraStreamingSetting.FaceBeautySetting(0.8f, 0.8f, 0.6f)); // sdk built in face beauty settings
        cameraStreamingSetting.setVideoFilter(CameraStreamingSetting.VIDEO_FILTER_TYPE.VIDEO_FILTER_BEAUTY); // set the beauty on/off
    }

    /**
     * Step 3: create streaming manager and set listeners
     */
    AVCodecType codecType = isSwCodec ? AVCodecType.SW_VIDEO_WITH_SW_AUDIO_CODEC : AVCodecType.HW_VIDEO_YUV_AS_INPUT_WITH_HW_AUDIO_CODEC;
    mRTCStreamingManager = new RTCMediaStreamingManager(getApplicationContext(), cameraPreviewFrameView, codecType);
    mRTCStreamingManager.setConferenceStateListener(mRTCStreamingStateChangedListener);
    mRTCStreamingManager.setRemoteWindowEventListener(mRTCRemoteWindowEventListener);
    mRTCStreamingManager.setStreamingSessionListener(mStreamingSessionListener);
    mRTCStreamingManager.setDebugLoggingEnabled(isDebugModeEnabled);

    /**
     * Step 4: set conference options
     */
    RTCConferenceOptions options = new RTCConferenceOptions();
    // RATIO_4_3 & VIDEO_ENCODING_SIZE_HEIGHT_240 means the output size is 640 x 480
    options.setVideoEncodingSizeRatio(RTCConferenceOptions.VIDEO_ENCODING_SIZE_RATIO.RATIO_4_3);
    options.setVideoEncodingSizeLevel(RTCConferenceOptions.VIDEO_ENCODING_SIZE_HEIGHT_480);
    options.setVideoEncodingOrientation(RTCConferenceOptions.VIDEO_ENCODING_ORIENTATION.LAND);
    options.setVideoBitrateRange(300 * 1024, 800 * 1024);
    // 15 fps is enough
    options.setVideoEncodingFps(15);
    mRTCStreamingManager.setConferenceOptions(options);

    /**
     * Step 5: create the remote windows
     */
    RTCVideoWindow windowA = new RTCVideoWindow((RTCSurfaceView) findViewById(R.id.RemoteGLSurfaceViewA));

    /**
     * Step 6: add the remote windows
     */
    mRTCStreamingManager.addRemoteWindow(windowA);

    /**
     * Step 7: do prepare
     */
    mRTCStreamingManager.prepare(cameraStreamingSetting, null, null, null);

    mProgressDialog = new ProgressDialog(this);
}