| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 import java.io.File; | 41 import java.io.File; |
| 42 import java.io.IOException; | 42 import java.io.IOException; |
| 43 import java.util.EnumSet; | 43 import java.util.EnumSet; |
| 44 import java.util.LinkedList; | 44 import java.util.LinkedList; |
| 45 import java.util.Timer; | 45 import java.util.Timer; |
| 46 import java.util.TimerTask; | 46 import java.util.TimerTask; |
| 47 import java.util.regex.Matcher; | 47 import java.util.regex.Matcher; |
| 48 import java.util.regex.Pattern; | 48 import java.util.regex.Pattern; |
| 49 | 49 |
| 50 import javax.microedition.khronos.egl.EGLContext; |
| 51 |
| 50 /** | 52 /** |
| 51 * Peer connection client implementation. | 53 * Peer connection client implementation. |
| 52 * | 54 * |
| 53 * <p>All public methods are routed to local looper thread. | 55 * <p>All public methods are routed to local looper thread. |
| 54 * All PeerConnectionEvents callbacks are invoked from the same looper thread. | 56 * All PeerConnectionEvents callbacks are invoked from the same looper thread. |
| 55 * This class is a singleton. | 57 * This class is a singleton. |
| 56 */ | 58 */ |
| 57 public class PeerConnectionClient { | 59 public class PeerConnectionClient { |
| 58 public static final String VIDEO_TRACK_ID = "ARDAMSv0"; | 60 public static final String VIDEO_TRACK_ID = "ARDAMSv0"; |
| 59 public static final String AUDIO_TRACK_ID = "ARDAMSa0"; | 61 public static final String AUDIO_TRACK_ID = "ARDAMSa0"; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 252 |
| 251 executor.execute(new Runnable() { | 253 executor.execute(new Runnable() { |
| 252 @Override | 254 @Override |
| 253 public void run() { | 255 public void run() { |
| 254 createPeerConnectionFactoryInternal(context); | 256 createPeerConnectionFactoryInternal(context); |
| 255 } | 257 } |
| 256 }); | 258 }); |
| 257 } | 259 } |
| 258 | 260 |
| 259 public void createPeerConnection( | 261 public void createPeerConnection( |
| 260 final EglBase.Context renderEGLContext, | 262 final EGLContext renderEGLContext, |
| 261 final VideoRenderer.Callbacks localRender, | 263 final VideoRenderer.Callbacks localRender, |
| 262 final VideoRenderer.Callbacks remoteRender, | 264 final VideoRenderer.Callbacks remoteRender, |
| 263 final SignalingParameters signalingParameters) { | 265 final SignalingParameters signalingParameters) { |
| 264 if (peerConnectionParameters == null) { | 266 if (peerConnectionParameters == null) { |
| 265 Log.e(TAG, "Creating peer connection without initializing factory."); | 267 Log.e(TAG, "Creating peer connection without initializing factory."); |
| 266 return; | 268 return; |
| 267 } | 269 } |
| 268 this.localRender = localRender; | 270 this.localRender = localRender; |
| 269 this.remoteRender = remoteRender; | 271 this.remoteRender = remoteRender; |
| 270 this.signalingParameters = signalingParameters; | 272 this.signalingParameters = signalingParameters; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 "OfferToReceiveAudio", "true")); | 422 "OfferToReceiveAudio", "true")); |
| 421 if (videoCallEnabled || peerConnectionParameters.loopback) { | 423 if (videoCallEnabled || peerConnectionParameters.loopback) { |
| 422 sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair( | 424 sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair( |
| 423 "OfferToReceiveVideo", "true")); | 425 "OfferToReceiveVideo", "true")); |
| 424 } else { | 426 } else { |
| 425 sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair( | 427 sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair( |
| 426 "OfferToReceiveVideo", "false")); | 428 "OfferToReceiveVideo", "false")); |
| 427 } | 429 } |
| 428 } | 430 } |
| 429 | 431 |
| 430 private void createPeerConnectionInternal(EglBase.Context renderEGLContext) { | 432 private void createPeerConnectionInternal(EGLContext renderEGLContext) { |
| 431 if (factory == null || isError) { | 433 if (factory == null || isError) { |
| 432 Log.e(TAG, "Peerconnection factory is not created"); | 434 Log.e(TAG, "Peerconnection factory is not created"); |
| 433 return; | 435 return; |
| 434 } | 436 } |
| 435 Log.d(TAG, "Create peer connection."); | 437 Log.d(TAG, "Create peer connection."); |
| 436 | 438 |
| 437 Log.d(TAG, "PCConstraints: " + pcConstraints.toString()); | 439 Log.d(TAG, "PCConstraints: " + pcConstraints.toString()); |
| 438 if (videoConstraints != null) { | 440 if (videoConstraints != null) { |
| 439 Log.d(TAG, "VideoConstraints: " + videoConstraints.toString()); | 441 Log.d(TAG, "VideoConstraints: " + videoConstraints.toString()); |
| 440 } | 442 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 469 mediaStream = factory.createLocalMediaStream("ARDAMS"); | 471 mediaStream = factory.createLocalMediaStream("ARDAMS"); |
| 470 if (videoCallEnabled) { | 472 if (videoCallEnabled) { |
| 471 String cameraDeviceName = CameraEnumerationAndroid.getDeviceName(0); | 473 String cameraDeviceName = CameraEnumerationAndroid.getDeviceName(0); |
| 472 String frontCameraDeviceName = | 474 String frontCameraDeviceName = |
| 473 CameraEnumerationAndroid.getNameOfFrontFacingDevice(); | 475 CameraEnumerationAndroid.getNameOfFrontFacingDevice(); |
| 474 if (numberOfCameras > 1 && frontCameraDeviceName != null) { | 476 if (numberOfCameras > 1 && frontCameraDeviceName != null) { |
| 475 cameraDeviceName = frontCameraDeviceName; | 477 cameraDeviceName = frontCameraDeviceName; |
| 476 } | 478 } |
| 477 Log.d(TAG, "Opening camera: " + cameraDeviceName); | 479 Log.d(TAG, "Opening camera: " + cameraDeviceName); |
| 478 videoCapturer = VideoCapturerAndroid.create(cameraDeviceName, null, | 480 videoCapturer = VideoCapturerAndroid.create(cameraDeviceName, null, |
| 479 peerConnectionParameters.captureToTexture ? renderEGLContext : null); | 481 peerConnectionParameters.captureToTexture ? new EglBase.Context(render
EGLContext) : null); |
| 480 if (videoCapturer == null) { | 482 if (videoCapturer == null) { |
| 481 reportError("Failed to open camera"); | 483 reportError("Failed to open camera"); |
| 482 return; | 484 return; |
| 483 } | 485 } |
| 484 mediaStream.addTrack(createVideoTrack(videoCapturer)); | 486 mediaStream.addTrack(createVideoTrack(videoCapturer)); |
| 485 } | 487 } |
| 486 | 488 |
| 487 mediaStream.addTrack(factory.createAudioTrack( | 489 mediaStream.addTrack(factory.createAudioTrack( |
| 488 AUDIO_TRACK_ID, | 490 AUDIO_TRACK_ID, |
| 489 factory.createAudioSource(audioConstraints))); | 491 factory.createAudioSource(audioConstraints))); |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 public void onCreateFailure(final String error) { | 1076 public void onCreateFailure(final String error) { |
| 1075 reportError("createSDP error: " + error); | 1077 reportError("createSDP error: " + error); |
| 1076 } | 1078 } |
| 1077 | 1079 |
| 1078 @Override | 1080 @Override |
| 1079 public void onSetFailure(final String error) { | 1081 public void onSetFailure(final String error) { |
| 1080 reportError("setSDP error: " + error); | 1082 reportError("setSDP error: " + error); |
| 1081 } | 1083 } |
| 1082 } | 1084 } |
| 1083 } | 1085 } |
| OLD | NEW |