Java 类org.webrtc.CameraVideoCapturer 实例源码

项目:quickblox-android    文件:VideoConversationFragment.java   
private void switchCamera(final MenuItem item) {
    if (cameraState == CameraState.DISABLED_FROM_USER) {
        return;
    }
    cameraToggle.setEnabled(false);
    conversationFragmentCallbackListener.onSwitchCamera(new CameraVideoCapturer.CameraSwitchHandler() {
        @Override
        public void onCameraSwitchDone(boolean b) {
            Log.d(TAG, "camera switched, bool = " + b);
            isCurrentCameraFront = b;
            updateSwitchCameraIcon(item);
            toggleCameraInternal();
        }

        @Override
        public void onCameraSwitchError(String s) {
            Log.d(TAG, "camera switch error " + s);
            Toaster.shortToast(getString(R.string.camera_swicth_failed) + s);
            cameraToggle.setEnabled(true);
        }
    });
}
项目:webrtc-android-codelab    文件:MainActivity.java   
private VideoCapturer getVideoCapturer(CameraVideoCapturer.CameraEventsHandler eventsHandler) {
    String[] cameraFacing = {"front", "back"};
    int[] cameraIndex = {0, 1};
    int[] cameraOrientation = {0, 90, 180, 270};
    for (String facing : cameraFacing) {
        for (int index : cameraIndex) {
            for (int orientation : cameraOrientation) {
                String name = "Camera " + index + ", Facing " + facing +
                        ", Orientation " + orientation;
                VideoCapturer capturer = VideoCapturerAndroid.create(name, eventsHandler);
                if (capturer != null) {
                    Log.d("Using camera: ", name);
                    return capturer;
                }
            }
        }
    }
    throw new RuntimeException("Failed to open capture");
}
项目:matrix-android-sdk    文件:MXWebRtcCall.java   
/**
 * Create the video capturer
 *
 * @param cameraName the selected camera name
 * @return the video capturer
 */
private CameraVideoCapturer createVideoCapturer(String cameraName) {
    CameraVideoCapturer cameraVideoCapturer = null;

    CameraEnumerator camerasEnumerator = getCameraEnumerator(mContext);
    final String[] deviceNames = camerasEnumerator.getDeviceNames();


    if ((null != deviceNames) && (deviceNames.length > 0)) {
        for (String name : deviceNames) {
            if (name.equals(cameraName)) {
                cameraVideoCapturer = camerasEnumerator.createCapturer(name, null);
                if (null != cameraVideoCapturer) {
                    break;
                }
            }
        }

        if (null == cameraVideoCapturer) {
            cameraVideoCapturer = camerasEnumerator.createCapturer(deviceNames[0], null);
        }
    }

    return cameraVideoCapturer;
}
项目:nc-android-webrtcpeer    文件:PeerConnectionClient.java   
private void switchCameraInternal() {
    if (videoCapturer instanceof CameraVideoCapturer) {
        if (!videoCallEnabled || isError || videoCapturer == null) {
            Log.e(TAG, "Failed to switch camera. Video: " + videoCallEnabled + ". Error : " + isError);
            return; // No video is sent or only one camera is available or error happened.
        }
        Log.d(TAG, "Switch camera");
        CameraVideoCapturer cameraVideoCapturer = (CameraVideoCapturer) videoCapturer;
        cameraVideoCapturer.switchCamera(null);
    } else {
        Log.d(TAG, "Will not switch camera, video caputurer is not a camera");
    }
}
项目:AppRTC-Android    文件:PeerConnectionClient.java   
private void switchCameraInternal() {
  if (videoCapturer instanceof CameraVideoCapturer) {
    if (!videoCallEnabled || isError || videoCapturer == null) {
      Log.e(TAG, "Failed to switch camera. Video: " + videoCallEnabled + ". Error : " + isError);
      return; // No video is sent or only one camera is available or error happened.
    }
    Log.d(TAG, "Switch camera");
    CameraVideoCapturer cameraVideoCapturer = (CameraVideoCapturer) videoCapturer;
    cameraVideoCapturer.switchCamera(null);
  } else {
    Log.d(TAG, "Will not switch camera, video caputurer is not a camera");
  }
}
项目:AndroidRTC    文件:PeerConnectionClient.java   
private void switchCameraInternal() {
    if (videoCapturer instanceof CameraVideoCapturer) {
        if (!videoCallEnabled || isError || videoCapturer == null) {
            Log.e(TAG, "Failed to switch camera. Video: " + videoCallEnabled + ". Error : " + isError);
            return; // No video is sent or only one camera is available or error happened.
        }
        Log.d(TAG, "Switch camera");
        CameraVideoCapturer cameraVideoCapturer = (CameraVideoCapturer) videoCapturer;
        cameraVideoCapturer.switchCamera(null);
    } else {
        Log.d(TAG, "Will not switch camera, video caputurer is not a camera");
    }
}
项目:voip_android    文件:PeerConnectionClient.java   
private void switchCameraInternal() {
    if (videoCapturer instanceof CameraVideoCapturer) {
        if (!videoCallEnabled || isError || videoCapturer == null) {
            Log.e(TAG, "Failed to switch camera. Video: " + videoCallEnabled + ". Error : " + isError);
            return; // No video is sent or only one camera is available or error happened.
        }
        Log.d(TAG, "Switch camera");
        CameraVideoCapturer cameraVideoCapturer = (CameraVideoCapturer) videoCapturer;
        cameraVideoCapturer.switchCamera(null);
    } else {
        Log.d(TAG, "Will not switch camera, video caputurer is not a camera");
    }
}
项目:q-municate-android    文件:ConversationCallFragment.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    QBRTCSession currentSession = ((CallActivity) getActivity()).getCurrentSession();
    if (currentSession == null) {
        return super.onOptionsItemSelected(item);
    }

    final QBMediaStreamManager mediaStreamManager = currentSession.getMediaStreamManager();
    if (mediaStreamManager == null) {
        return super.onOptionsItemSelected(item);
    }

    switch (item.getItemId()) {
        case R.id.switch_camera_toggle:
            mediaStreamManager.switchCameraInput(new CameraVideoCapturer.CameraSwitchHandler() {
                @Override
                public void onCameraSwitchDone(boolean b) {
                    isFrontCameraSelected = b;
                    toggleCameraInternal();
                }
                @Override
                public void onCameraSwitchError(String s) {

                }
            });
            break;
        case R.id.switch_speaker_toggle:
            toggleAudioOutput();
            break;
        default:
            return super.onOptionsItemSelected(item);
    }

    getActivity().invalidateOptionsMenu();
    return super.onOptionsItemSelected(item);
}
项目:restcomm-android-sdk    文件:PeerConnectionClient.java   
private void switchCameraInternal() {
  if (videoCapturer instanceof CameraVideoCapturer) {
    if (!videoCallEnabled || isError) {
      Log.e(TAG, "Failed to switch camera. Video: " + videoCallEnabled + ". Error : " + isError);
      return; // No video is sent or only one camera is available or error happened.
    }
    Log.d(TAG, "Switch camera");
    CameraVideoCapturer cameraVideoCapturer = (CameraVideoCapturer) videoCapturer;
    cameraVideoCapturer.switchCamera(null);
  } else {
    Log.d(TAG, "Will not switch camera, video caputurer is not a camera");
  }
}
项目:quickblox-android    文件:CallActivity.java   
@Override
public void onSwitchCamera(CameraVideoCapturer.CameraSwitchHandler cameraSwitchHandler) {
    ((QBRTCCameraVideoCapturer)(currentSession.getMediaStreamManager().getVideoCapturer()))
            .switchCamera(cameraSwitchHandler);
}
项目:VideoCRE    文件:VideoSource.java   
public void switchCamera() {
    if (mVideoCapturer instanceof CameraVideoCapturer) {
        ((CameraVideoCapturer) mVideoCapturer).switchCamera(null);
    }
}
项目:quickblox-android    文件:ConversationFragmentCallbackListener.java   
void onSwitchCamera(CameraVideoCapturer.CameraSwitchHandler cameraSwitchHandler);