/** * Adds a new media stream track to be sent on this peer connection, and returns * the newly created RtpSender. If streamIds are specified, the RtpSender will * be associated with the streams specified in the streamIds list. * * @throws IllegalStateException if an error accors in C++ addTrack. * An error can occur if: * - A sender already exists for the track. * - The peer connection is closed. */ public RtpSender addTrack(MediaStreamTrack track) { return addTrack(track, Collections.emptyList()); }
public PeerConnection createPeerConnection() { Log.i(TAG, "Create PeerConnection ..."); PeerConnection.RTCConfiguration configuration = new PeerConnection.RTCConfiguration(new ArrayList<>()); PeerConnection connection = mPeerConnectionFactory.createPeerConnection(configuration, mPeerConnectionObserver); if (connection == null) { Log.e(TAG, "Failed to createPeerConnection !"); return null; } connection.addTrack(mVideoTrack); connection.addTrack(mAudioTrack); return connection; }