Java 类org.webrtc.CameraEnumerationAndroid 实例源码

项目:webrtcpeer-android    文件:MediaResourceManager.java   
boolean hasCameraPosition(NBMMediaConfiguration.NBMCameraPosition position){
    boolean retMe = false;

    String backName = CameraEnumerationAndroid.getNameOfBackFacingDevice();
    String frontName = CameraEnumerationAndroid.getNameOfFrontFacingDevice();

    if (position == NBMMediaConfiguration.NBMCameraPosition.ANY &&
            (backName != null || frontName != null)){
        retMe = true;
    } else if (position == NBMMediaConfiguration.NBMCameraPosition.BACK &&
            backName != null){
        retMe = true;

    } else if (position == NBMMediaConfiguration.NBMCameraPosition.FRONT &&
            frontName != null){
        retMe = true;
    }

    return retMe;
}
项目:webrtc-android    文件:PeerConnectionClient.java   
public void createPeerConnection(
            final EglBase.Context renderEGLContext,
            final VideoRenderer.Callbacks localRender,
            final VideoRenderer.Callbacks remoteRender,
            final PeerConnectionEvents events,
            final PeerConnectionParameters peerConnectionParameters) {
        this.peerConnectionParameters = peerConnectionParameters;
        this.events = events;
        videoCallEnabled = peerConnectionParameters.videoCallEnabled;
//
//      PeerConnectionFactory.initializeAndroidGlobals(, true, true,
//              false);
//      factory = new PeerConnectionFactory();

//      if (peerConnectionParameters == null) {
//          Log.e(TAG, "Creating peer connection without initializing factory.");
//          return;
//      }
        this.localRender = localRender;
        this.remoteRender = remoteRender;

        executor.execute(new Runnable() {
            @Override
            public void run() {
                createMediaConstraintsInternal();
//              createPeerConnectionInternal(renderEGLContext, iceServers);
                if(mediaStream == null) {
                    mediaStream = factory.createLocalMediaStream("ARDAMS");
                    if (videoCallEnabled) {
                        String cameraDeviceName = CameraEnumerationAndroid.getDeviceName(0);
                        String frontCameraDeviceName =
                                CameraEnumerationAndroid.getNameOfFrontFacingDevice();
                        if (numberOfCameras > 1 && frontCameraDeviceName != null) {
                            cameraDeviceName = frontCameraDeviceName;
                        }
                        Log.d(TAG, "Opening camera: " + cameraDeviceName);
                        videoCapturer = VideoCapturerAndroid.create(cameraDeviceName, null,
                                peerConnectionParameters.captureToTexture ? renderEGLContext : null);
                        if (videoCapturer == null) {
                            reportError("Failed to open camera");
                            return;
                        }
                        mediaStream.addTrack(createVideoTrack(videoCapturer));
                    }

                    mediaStream.addTrack(factory.createAudioTrack(
                            AUDIO_TRACK_ID,
                            factory.createAudioSource(audioConstraints)));
                }
                try {
                    manager = new Manager(new URI(mHost));
                    client = manager.socket("/");
                } catch (URISyntaxException e) {
                    e.printStackTrace();
                }
                client
                        .on(INIT_MESSAGE, messageHandler.onInitMessage)
                        .on(TEXT_MESSAGE, messageHandler.onTextMessage)
//                      .on(INVITE_MESSAGE, messageHandler.onInviteMessage)
//                      .on(READY_MESSAGE, messageHandler.onReadyMessage)
//                      .on(OFFER_MESSAGE, messageHandler.onOfferMessage)
//                      .on(ANSWER_MESSAGE, messageHandler.onAnswerMessage)
//                      .on(ICE_CANDIDATE_MESSAGE, messageHandler.onCandidateMessage)
                        .on(RTC_MESSAGE, messageHandler.onRtcMessage)
                        .on(LEAVE_MESSAGE, messageHandler.onLeaveMessage)
                        .on(AVAILABLE_USERS_MESSAGE, messageHandler.onAvailablePeersMessage)
                        .on(PRESENCE_MESSAGE, messageHandler.onPresenceMessage);
                client.connect();
            }
        });

    }
项目:webrtc-android    文件:WebRtcClient.java   
private VideoCapturer getVideoCapturer() {
    String frontCameraDeviceName = CameraEnumerationAndroid.getDeviceName(0);
    return VideoCapturerAndroid.create(frontCameraDeviceName);
}
项目:webrtc-android    文件:WebRtcClient.java   
private VideoCapturer getVideoCapturer() {
    String frontCameraDeviceName = CameraEnumerationAndroid.getDeviceName(0);
    return VideoCapturerAndroid.create(frontCameraDeviceName);
}
项目:webrtcpeer-android    文件:MediaResourceManager.java   
void createLocalMediaStream(Object renderEGLContext,final VideoRenderer.Callbacks localRender) {
    if (factory == null) {
        Log.e(TAG, "Peerconnection factory is not created");
        return;
    }
    this.localRender = localRender;
    if (videoCallEnabled) {
        factory.setVideoHwAccelerationOptions(renderEGLContext, renderEGLContext);
    }

    // Set default WebRTC tracing and INFO libjingle logging.
    // NOTE: this _must_ happen while |factory| is alive!
    Logging.enableTracing("logcat:", EnumSet.of(Logging.TraceLevel.TRACE_DEFAULT), Logging.Severity.LS_INFO);

    localMediaStream = factory.createLocalMediaStream("ARDAMS");

    // If video call is enabled and the device has camera(s)
    if (videoCallEnabled && numberOfCameras > 0) {
        String cameraDeviceName; // = CameraEnumerationAndroid.getDeviceName(0);
        String frontCameraDeviceName = CameraEnumerationAndroid.getNameOfFrontFacingDevice();
        String backCameraDeviceName = CameraEnumerationAndroid.getNameOfBackFacingDevice();

        // If current camera is set to front and the device has one
        if (currentCameraPosition==NBMCameraPosition.FRONT && frontCameraDeviceName!=null) {
            cameraDeviceName = frontCameraDeviceName;
        }
        // If current camera is set to back and the device has one
        else if (currentCameraPosition==NBMCameraPosition.BACK && backCameraDeviceName!=null) {
            cameraDeviceName = backCameraDeviceName;
        }
        // If current camera is set to any then we pick the first camera of the device, which
        // should be a back-facing camera according to libjingle API
        else {
            cameraDeviceName = CameraEnumerationAndroid.getDeviceName(0);
            currentCameraPosition = NBMCameraPosition.BACK;
        }

        Log.d(TAG, "Opening camera: " + cameraDeviceName);
        videoCapturer = VideoCapturerAndroid.create(cameraDeviceName, null);
        if (videoCapturer == null) {
            Log.d(TAG, "Error while opening camera");
            return;
        }
        localMediaStream.addTrack(createCapturerVideoTrack(videoCapturer));
    }

    // Create audio track
    localMediaStream.addTrack(factory.createAudioTrack(AUDIO_TRACK_ID, factory.createAudioSource(audioConstraints)));

    Log.d(TAG, "Local media stream created.");
}