Reputation: 200
I am implementing calling feature using webrtc. I successfully able to make voice calls. But video call providing error. Even I could not add the local stream through VideoCapturerAndroid. I searched all the references found by googling but none of them worked for my case. I changed the media constraints(video) according to supporting formats, but no luck. Please help me to solve the problem.
It is showing runtime exception applicationContext not set.
W/System.err: java.lang.RuntimeException: applicationContext not set.
W/System.err: at org.webrtc.VideoCapturerAndroid.startCapture(VideoCapturerAndroid.java:499)
Full log is given below.
04-12 15:08:03.657 23560-24939/com.example.messenger D/VideoCapturerAndroid: VideoCapturerAndroid
04-12 15:08:03.657 23560-24939/com.example.messenger D/VideoCapturerAndroid: init: Camera 1, Facing front, Orientation 270
04-12 15:08:03.657 23560-24939/com.example.messenger D/VideoCapturerAndroid: Get supported formats.
04-12 15:08:03.657 23560-24939/com.example.messenger D/VideoCapturerAndroid: Opening camera 1
04-12 15:08:03.842 23560-23560/com.example.messenger V/ActivityThread: updateVisibility : ActivityRecord{152a65d3 token=android.os.BinderProxy@1d90e60a {com.example.messenger/com.example.messenger.activity.ChatActivity}} show : false
04-12 15:08:04.007 23560-24939/com.example.messenger D/VideoCapturerAndroid: Opening camera 0
04-12 15:08:04.192 23560-24939/com.example.messenger D/VideoCapturerAndroid: Get supported formats done.
04-12 15:08:04.197 23560-24939/com.example.messenger D/VideoCapturerAndroid: Supported formats for camera 1: [
{
"width": 1920,
"height": 1080,
"framerate": 30
},
{
"width": 1440,
"height": 1080,
"framerate": 30
},
{
"width": 1280,
"height": 960,
"framerate": 30
},
{
"width": 1280,
"height": 720,
"framerate": 30
},
{
"width": 1056,
"height": 864,
"framerate": 30
},
{
"width": 1024,
"height": 768,
"framerate": 30
},
{
"width": 1008,
"height": 566,
"framerate": 30
},
{
"width": 800,
"height": 600,
"framerate": 30
},
{
"width": 800,
"height": 480,
"framerate": 30
},
{
"width": 800,
"height": 450,
"framerate": 30
},
{
"width": 720,
"height": 480,
"framerate": 30
},
{
"width": 640,
"height": 480,
"framerate": 30
},
{
"width": 528,
"height": 432,
"framerate": 30
},
{
"width": 480,
"height": 320,
"framerate": 30
},
{
"width": 480,
"height": 270,
"framerate": 30
},
{
"width": 352,
"height": 288,
"framerate": 30
},
{
"width": 320,
"height": 240,
"framerate": 30
}
]
04-12 15:08:04.202 23560-24946/com.example.messenger D/VideoCapturerAndroid: startCapture requested: 640x480@30
04-12 15:08:04.202 23560-24946/com.example.messenger W/System.err: java.lang.RuntimeException: applicationContext not set.
04-12 15:08:04.202 23560-24946/com.example.messenger W/System.err: at org.webrtc.VideoCapturerAndroid.startCapture(VideoCapturerAndroid.java:499)
04-12 15:08:04.202 23560-24946/com.example.messenger E/rtc: #
# Fatal error in ../../talk/app/webrtc/java/jni/androidvideocapturer_jni.cc, line 126
# Check failed: !jni()->ExceptionCheck()
# error during VideoCapturerAndroid.startCapture
#
04-12 15:08:04.202 23560-24946/com.example.messenger A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 24946 (Thread-64952)
Thanks in advance.
Upvotes: 1
Views: 4374
Reputation: 2643
If you provide the code snippet you are using, it's easy to find the issue.
Below are steps to generate local video track from camera.
private VideoCapturer createCameraCapturer(CameraEnumerator enumerator) {
final String[] deviceNames = enumerator.getDeviceNames();
// First, try to find front facing camera
Log.d(TAG, "Looking for front facing cameras.");
for (String deviceName : deviceNames) {
if (enumerator.isFrontFacing(deviceName)) {
Log.d(TAG, "Creating front facing camera capturer.");
VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
if (videoCapturer != null) {
return videoCapturer;
}
}
}
// Front facing camera not found, try something else
Log.d(TAG, "Looking for other cameras.");
for (String deviceName : deviceNames) {
if (!enumerator.isFrontFacing(deviceName)) {
Log.d(TAG, "Creating other camera capturer.");
VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
if (videoCapturer != null) {
return videoCapturer;
}
}
}
return null;
}
VideoCapturer videoCapturer = createCameraCapturer(new Camera1Enumerator(captureToTexture()));
VideoSource videoSource = factory.createVideoSource(videoCapturer);
videoCapturer.startCapture(1200/*width*/, 720/*height*/, 25/*fps*/);
VideoTrack localVideoTrack = factory.createVideoTrack("NameYourTrack", videoSource);
Below code is to render the local video
EglBase rootEglBase = EglBase.create();
SurfaceViewRenderer pipRenderer = (SurfaceViewRenderer) findViewById(R.id.pip_video_view); //You need define your UI element to render video
pipRenderer.init(rootEglBase.getEglBaseContext(), null);
pipRenderer.setScalingType(ScalingType.SCALE_ASPECT_FIT);
localVideoTrack.setEnabled(true);
localVideoTrack.addRenderer(new VideoRenderer(pipRenderer));
Note: This code will work with latest WebRTC code base, if you are using old native library, you may need to update OR look for corresponding AppRTCMobile example.
Upvotes: 1