WebRTCMediaProvider: Creating peer connection without initializing factory.

buzolive

New Member
when i am going to live then app crash due to this exception ,please provide me exact solution i am providing you my code..

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.flashphoner.fpwcsapi.webrtc.MediaConnection.setMediaConnectionListener(com.flashphoner.fpwcsapi.webrtc.MediaConnectionListener)' on a null object reference
at com.flashphoner.fpwcsapi.session.Stream$2.run(Stream.java:243)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:192)
at com.flashphoner.fpwcsapi.util.LooperExecutor.run(LooperExecutor.java:44)


Flashphoner.init(this);

Flashphoner.getAudioManager().setUseSpeakerPhone(true);

binding.localRender.setZOrderMediaOverlay(true);

binding.preview.setPosition(0, 0, 100, 100);

binding.localRender.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL);

binding.localRender.setMirror(true);
binding.localRender.requestLayout();

SessionOptions sessionOptions = new SessionOptions(url);
sessionOptions.setLocalRenderer(binding.localRender);

session = Flashphoner.createSession(sessionOptions);

session.on(new SessionEvent() {
@Override
public void onAppData(Data data) {

Commn.showErrorLog("onAppData" + data.toString() + "");

}

@Override
public void onConnected(final Connection connection) {
runOnUiThread(() -> {

Commn.showErrorLog("my_stream_name:" + stream_id + "");
StreamOptions streamOptions = new StreamOptions(stream_id);
VideoConstraints videoConstraints = new VideoConstraints();
//videoConstraints.setCameraId(((MediaDevice)mCameraSpinner.getSpinner().getSelectedItem()).getId());
videoConstraints.setCameraId(Flashphoner.getMediaDevices().getVideoList().get(1).getId());
DisplayMetrics metrics = getResources().getDisplayMetrics();
Commn.showErrorLog("my resolution:" + "width:" + metrics.widthPixels + ",height:" + metrics.heightPixels + "");

videoConstraints.setResolution(metrics.widthPixels, metrics.heightPixels);
streamOptions.getConstraints().setVideoConstraints(videoConstraints);
streamOptions.setConstraints(new Constraints(new AudioConstraints(), videoConstraints));

publishStream = session.createStream(streamOptions);
publishStream.publish();
publishStream.on(new StreamStatusEvent() {
@Override
public void onStreamStatus(Stream stream, StreamStatus streamStatus) {

Commn.showDebugLog("onConnected" + String.valueOf(streamStatus));

runOnUiThread(() -> {
binding.rlBottomContent.setVisibility(View.VISIBLE);
isStream_started = true;


});

if (StreamStatus.FAILED.equals(streamStatus)) {

switch (stream.getInfo()) {
case StreamStatusInfo.SESSION_DOES_NOT_EXIST:
Commn.showErrorLog(streamStatus + ": Actual session does not exist");
break;
case StreamStatusInfo.STOPPED_BY_PUBLISHER_STOP:
Commn.showErrorLog(streamStatus + ": Related publisher stopped its stream or lost connection");
break;
case StreamStatusInfo.SESSION_NOT_READY:
Commn.showErrorLog(streamStatus + ": Session is not initialized or terminated on play ordinary stream");
break;
case StreamStatusInfo.RTSP_STREAM_NOT_FOUND:
Commn.showErrorLog(streamStatus + ": Rtsp stream not found where agent received '404-Not Found'");
break;
case StreamStatusInfo.FAILED_TO_CONNECT_TO_RTSP_STREAM:
Commn.showErrorLog(streamStatus + ": Failed to connect to rtsp stream");
break;
case StreamStatusInfo.FILE_NOT_FOUND:
Commn.showErrorLog(streamStatus + ": File does not exist, check filename");
break;
case StreamStatusInfo.FILE_HAS_WRONG_FORMAT:
Commn.showErrorLog(streamStatus + ": File has wrong format on play vod, this format is not supported");
break;
case StreamStatusInfo.STREAM_NAME_ALREADY_IN_USE:
Commn.myToast(context, "Server already has a publish stream with the same name, try using different one");
Commn.showErrorLog(streamStatus + ": Server already has a publish stream with the same name, try using different one");
break;
default: {
Commn.showErrorLog(stream.getInfo());
}
}
} else {
Commn.showErrorLog(streamStatus.toString());
}
}
});


});

}

@Override
public void onRegistered(Connection connection) {
Commn.showErrorLog("onRegistered" + connection.getStatus() + "");

}

@Override
public void onDisconnection(final Connection connection) {
runOnUiThread(() -> {

});
}
});


session.connect(new Connection());
 

Max

Administrator
Staff member
Good day.
Please check if the problem persists using Streaming-min example application. If not, please modify Streaming-min application source code minimally to reproduce the issue, and send the source code archive using this private form
 

buzolive

New Member
Good day.
Please check if the problem persists using Streaming-min example application. If not, please modify Streaming-min application source code minimally to reproduce the issue, and send the source code archive using this private form
now sdk support min sdk oreo how to support for lower versions devices sir
 
Top