I am using the Gradle dependency implementation 'org.webrtc:google-webrtc:1.0.30039'
This is the error:
E/rtc: Fatal error in: gen/sdk/android/generated_metrics_jni/../../../../../../../../usr/local/google/home/sakal/code/webrtc-aar-release/src/sdk/android/src/jni/jni_generator_helper.h, line 94 last system error: 0 Check failed: !env->ExceptionCheck() A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 11556 (network_thread ), pid 11515 (est.applicatoin)
onSignalingChange: HAVE_LOCAL_OFFER is the last log call before the exception.
An SDP is created but ICE trickling is not happening i.e OnIceGathering or OnIceCandidate is not called at all.
Java Activity Code:
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
DataChannel mainDataChannel;
PeerConnection mainPeerConnection;
PeerConnectionFactory factory;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initializePeerConnectionFactory();
initializeMyPeerConnection(); // Connection Initialization.
startConnection(); //Getting the offer
private void initializePeerConnectionFactory() {
PeerConnectionFactory.InitializationOptions initializationOptions =
PeerConnectionFactory.InitializationOptions.builder(this)
.setEnableInternalTracer(true)
.createInitializationOptions();
PeerConnectionFactory.initialize(initializationOptions);
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
factory = PeerConnectionFactory.builder()
.setOptions(options)
.createPeerConnectionFactory();
}
private void startConnection() {
Log.d(TAG, "startConnection: Starting Connection...");
//CreateOffer fires the request to get ICE candidates and finish the SDP. We can listen to all these events on the corresponding observers.
mainPeerConnection.createOffer(new SimpleSdpObserver() {
@Override
public void onCreateSuccess(SessionDescription sessionDescription) {
Log.d(TAG, "onCreateSuccess: " + sessionDescription.description);
mainPeerConnection.setLocalDescription(new SimpleSdpObserver(), sessionDescription);
}
@Override
public void onCreateFailure(String s) {
Log.e(TAG, "onCreateFailure: FAILED:" + s);
}
}, new MediaConstraints());
Log.d(TAG, "startConnection: Start Connection end");
}
private void initializeMyPeerConnection() {
Log.d(TAG, "initializeMyPeerConnection: Starting Initialization...");
mainPeerConnection = createPeerConnection(factory);
mainDataChannel = mainPeerConnection.createDataChannel("sendDataChannel", new DataChannel.Init());//Setting the data channel.
mainDataChannel.registerObserver(new DataChannel.Observer() {
@Override
public void onBufferedAmountChange(long l) {
}
@Override
public void onStateChange() {
//Data channel state change
Log.d(TAG, "onStateChange: " + mainDataChannel.state().toString());
}
@Override
public void onMessage(DataChannel.Buffer buffer) {
Toast.makeText(MainActivity.this, "Got the message!", Toast.LENGTH_SHORT).show();
}
});
Log.d(TAG, "initializeMyPeerConnection: Finished Initializing.");
}
private PeerConnection createPeerConnection(PeerConnectionFactory factory) {
List<PeerConnection.IceServer> iceServers = new LinkedList<>();
iceServers.add(PeerConnection.IceServer.builder("stun:stun.l.google.com:19302").createIceServer());
PeerConnection.RTCConfiguration rtcConfiguration = new PeerConnection.RTCConfiguration(iceServers);
PeerConnection.Observer pcObserver = new MyPeerConnectionObserver(TAG, mainPeerConnection);
return factory.createPeerConnection(rtcConfiguration, pcObserver);
}
}