Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebRTC native (C++) with custom VideoCapturer fails main_thread_.CalledOnValidThread() check

I compiled the WebRTC native code (C++) and I'm playing with peerconnection server and client examples (under src\talk\examples\peerconnection). In particular I am trying to change the client sample to stream a custom sequence of images rather than the webcam video. I used something similar to http://sourcey.com/webrtc-custom-opencv-video-capture/ as a starting point, where a custom VideoCapturerFactory returns a custom VideoCapturer that I can use to generate custom image frames. Every time I have a new image to stream, I call SignalFrameCaptured(this, &frame) on the VideoCapturer.

My problem is that, in debug mode, I get this crash:

#
# Fatal error in e:\webrtc\webrtc checkout\src\webrtc\modules\video_coding\main\source\video_sender.cc, line 90
# Check failed: main_thread_.CalledOnValidThread()
#

And my understanding is that it has something to do with an inconsistency between the thread which started the video stream and the thread which is pushing these individual frames. It seems as though the former is an internal WebRTC thread, while the latter is currently the main thread of the application.

Things work in Release mode because this thread check is disabled.

Any idea how to properly fix this? Thanks

like image 684
eran Avatar asked Jul 19 '15 17:07

eran


1 Answers

Just stumbled on it myself, and I hope you solved it by now. Generally, you're supposed to invoke SignalFrameCaptured on the start thread -- see example in Google's code:

https://chromium.googlesource.com/external/webrtc/+/edd8fefa9b31f903eefe1e9fcabb09a5d6fc1ad1/talk/app/webrtc/objc/avfoundationvideocapturer.mm#419 (line 419)

As you can see, this is a recent change.

like image 154
Ilya Avatar answered Sep 30 '22 15:09

Ilya