Native WebRTC (C ++) with custom VideoCapturer does not work main_thread_.CalledOnValidThread () check

I compiled the native WebRTC (C ++) code and I play with peerconnection servers and client examples (under src\talk\examples\peerconnection ). In particular, I am trying to modify a client sample to stream a user-defined sequence of images, not video from a webcam. I used something like 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 create custom image frames. Every time I have a new image for a stream, I call SignalFrameCaptured(this, &frame) in VideoCapturer .

My problem is that in debug mode I get this failure:

 # # 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 I understand that this has something to do with the inconsistency between the stream that started the video stream and the stream that clicks on these individual frames. The former seems to be an internal WebRTC thread, and 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 fix this correctly? Thanks

+6
source share
1 answer

Just stumbled upon it myself, and I hope you have solved it now. As a rule, you should call SignalFrameCaptured in the initial stream - see the example in Google 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 .

+3
source

All Articles