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 | |
52 /** | 50 /** |
53 * Peer connection client implementation. | 51 * Peer connection client implementation. |
54 * | 52 * |
55 * <p>All public methods are routed to local looper thread. | 53 * <p>All public methods are routed to local looper thread. |
56 * All PeerConnectionEvents callbacks are invoked from the same looper thread. | 54 * All PeerConnectionEvents callbacks are invoked from the same looper thread. |
57 * This class is a singleton. | 55 * This class is a singleton. |
58 */ | 56 */ |
59 public class PeerConnectionClient { | 57 public class PeerConnectionClient { |
60 public static final String VIDEO_TRACK_ID = "ARDAMSv0"; | 58 public static final String VIDEO_TRACK_ID = "ARDAMSv0"; |
61 public static final String AUDIO_TRACK_ID = "ARDAMSa0"; | 59 public static final String AUDIO_TRACK_ID = "ARDAMSa0"; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 250 |
253 executor.execute(new Runnable() { | 251 executor.execute(new Runnable() { |
254 @Override | 252 @Override |
255 public void run() { | 253 public void run() { |
256 createPeerConnectionFactoryInternal(context); | 254 createPeerConnectionFactoryInternal(context); |
257 } | 255 } |
258 }); | 256 }); |
259 } | 257 } |
260 | 258 |
261 public void createPeerConnection( | 259 public void createPeerConnection( |
262 final EGLContext renderEGLContext, | 260 final EglBase.Context renderEGLContext, |
263 final VideoRenderer.Callbacks localRender, | 261 final VideoRenderer.Callbacks localRender, |
264 final VideoRenderer.Callbacks remoteRender, | 262 final VideoRenderer.Callbacks remoteRender, |
265 final SignalingParameters signalingParameters) { | 263 final SignalingParameters signalingParameters) { |
266 if (peerConnectionParameters == null) { | 264 if (peerConnectionParameters == null) { |
267 Log.e(TAG, "Creating peer connection without initializing factory."); | 265 Log.e(TAG, "Creating peer connection without initializing factory."); |
268 return; | 266 return; |
269 } | 267 } |
270 this.localRender = localRender; | 268 this.localRender = localRender; |
271 this.remoteRender = remoteRender; | 269 this.remoteRender = remoteRender; |
272 this.signalingParameters = signalingParameters; | 270 this.signalingParameters = signalingParameters; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 "OfferToReceiveAudio", "true")); | 420 "OfferToReceiveAudio", "true")); |
423 if (videoCallEnabled || peerConnectionParameters.loopback) { | 421 if (videoCallEnabled || peerConnectionParameters.loopback) { |
424 sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair( | 422 sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair( |
425 "OfferToReceiveVideo", "true")); | 423 "OfferToReceiveVideo", "true")); |
426 } else { | 424 } else { |
427 sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair( | 425 sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair( |
428 "OfferToReceiveVideo", "false")); | 426 "OfferToReceiveVideo", "false")); |
429 } | 427 } |
430 } | 428 } |
431 | 429 |
432 private void createPeerConnectionInternal(EGLContext renderEGLContext) { | 430 private void createPeerConnectionInternal(EglBase.Context renderEGLContext) { |
433 if (factory == null || isError) { | 431 if (factory == null || isError) { |
434 Log.e(TAG, "Peerconnection factory is not created"); | 432 Log.e(TAG, "Peerconnection factory is not created"); |
435 return; | 433 return; |
436 } | 434 } |
437 Log.d(TAG, "Create peer connection."); | 435 Log.d(TAG, "Create peer connection."); |
438 | 436 |
439 Log.d(TAG, "PCConstraints: " + pcConstraints.toString()); | 437 Log.d(TAG, "PCConstraints: " + pcConstraints.toString()); |
440 if (videoConstraints != null) { | 438 if (videoConstraints != null) { |
441 Log.d(TAG, "VideoConstraints: " + videoConstraints.toString()); | 439 Log.d(TAG, "VideoConstraints: " + videoConstraints.toString()); |
442 } | 440 } |
(...skipping 28 matching lines...) Expand all Loading... |
471 mediaStream = factory.createLocalMediaStream("ARDAMS"); | 469 mediaStream = factory.createLocalMediaStream("ARDAMS"); |
472 if (videoCallEnabled) { | 470 if (videoCallEnabled) { |
473 String cameraDeviceName = CameraEnumerationAndroid.getDeviceName(0); | 471 String cameraDeviceName = CameraEnumerationAndroid.getDeviceName(0); |
474 String frontCameraDeviceName = | 472 String frontCameraDeviceName = |
475 CameraEnumerationAndroid.getNameOfFrontFacingDevice(); | 473 CameraEnumerationAndroid.getNameOfFrontFacingDevice(); |
476 if (numberOfCameras > 1 && frontCameraDeviceName != null) { | 474 if (numberOfCameras > 1 && frontCameraDeviceName != null) { |
477 cameraDeviceName = frontCameraDeviceName; | 475 cameraDeviceName = frontCameraDeviceName; |
478 } | 476 } |
479 Log.d(TAG, "Opening camera: " + cameraDeviceName); | 477 Log.d(TAG, "Opening camera: " + cameraDeviceName); |
480 videoCapturer = VideoCapturerAndroid.create(cameraDeviceName, null, | 478 videoCapturer = VideoCapturerAndroid.create(cameraDeviceName, null, |
481 peerConnectionParameters.captureToTexture ? new EglBase.Context(render
EGLContext) : null); | 479 peerConnectionParameters.captureToTexture ? renderEGLContext : null); |
482 if (videoCapturer == null) { | 480 if (videoCapturer == null) { |
483 reportError("Failed to open camera"); | 481 reportError("Failed to open camera"); |
484 return; | 482 return; |
485 } | 483 } |
486 mediaStream.addTrack(createVideoTrack(videoCapturer)); | 484 mediaStream.addTrack(createVideoTrack(videoCapturer)); |
487 } | 485 } |
488 | 486 |
489 mediaStream.addTrack(factory.createAudioTrack( | 487 mediaStream.addTrack(factory.createAudioTrack( |
490 AUDIO_TRACK_ID, | 488 AUDIO_TRACK_ID, |
491 factory.createAudioSource(audioConstraints))); | 489 factory.createAudioSource(audioConstraints))); |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 public void onCreateFailure(final String error) { | 1074 public void onCreateFailure(final String error) { |
1077 reportError("createSDP error: " + error); | 1075 reportError("createSDP error: " + error); |
1078 } | 1076 } |
1079 | 1077 |
1080 @Override | 1078 @Override |
1081 public void onSetFailure(final String error) { | 1079 public void onSetFailure(final String error) { |
1082 reportError("setSDP error: " + error); | 1080 reportError("setSDP error: " + error); |
1083 } | 1081 } |
1084 } | 1082 } |
1085 } | 1083 } |
OLD | NEW |