Return null from PCFactory#createPeerConnection on failure.

Currently, invalid PeerConnection object is returned. With this change,
null is returned instead. This can be more easily handled in the
application layer.

Bug: webrtc:9440
Change-Id: I44dfee81a681f033b8d336c999d43ff1c69fb015
Reviewed-on: https://webrtc-review.googlesource.com/98480
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24637}
diff --git a/sdk/android/src/jni/pc/peerconnectionfactory.cc b/sdk/android/src/jni/pc/peerconnectionfactory.cc
index ba1be38..7296bcb 100644
--- a/sdk/android/src/jni/pc/peerconnectionfactory.cc
+++ b/sdk/android/src/jni/pc/peerconnectionfactory.cc
@@ -416,6 +416,9 @@
 
   rtc::scoped_refptr<PeerConnectionInterface> pc(f->CreatePeerConnection(
       rtc_config, std::move(peer_connection_dependencies)));
+  if (pc == nullptr) {
+    return 0;
+  }
 
   return jlongFromPointer(
       new OwnedPeerConnection(pc, std::move(observer), std::move(constraints)));