sourcey / libsourcey

C++14 evented IO libraries for high performance networking and media based applications
https://sourcey.com/libsourcey
GNU Lesser General Public License v2.1
1.31k stars 347 forks source link

building WebRTC Custom OpenCV Video Capture example #252

Open mcajkovs opened 6 years ago

mcajkovs commented 6 years ago

Configuration: OS: Ubuntu 18.04.1 LTS Libsourcey: commit: ce311ff22, date: Sun Mar 25 12:32:55 2018, tag: 1.1.4 WebRTC: webrtc-22215-ab42706-linux-x64.tar.gz from this page OpenCV: 3.4.2 installed using this script

I've successfully compiled libsourcey flowing this tutorial I've used prebuild WebRTC libraries except building it myself. The flags I've used:

CMAKE_BUILD_TYPE = RELEASE
OPENCV_LINK_SHARED_LIBS = FALSE
WEBRTC_ROOT_DIR = /home/marek/webrtc
WITH_OPENSSL = FALSE
BUILD_SHARED_LIBS = FALSE
WITH_FFMPEG = TRUE
BUILD_SAMPLES = TRUE
WITH_OPENCV = FALSE

But I'm unable to compile example from this page

To compile the mentioned example I've created ~/libsourcey/src/webrtc/samples/custom_opencv_video_capture which contains CustomVideoCapturer.cpp and CustomVideoCapturer.h and added add_subdirectory(custom_opencv_video_capture) to ~/libsourcey/src/webrtc/samples/CMakeLists.txt

Is suspect that the errors are due to old version of example (the former is from 2014) Is there more recent version of mentioned example ?

Errors during compilation:

[ 97%] Building CXX object webrtc/samples/custom_opencv_video_capture/CMakeFiles/marek.dir/CustomVideoCapturer.cpp.o
In file included from /home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:1:0:
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:19:50: error: ‘uint32’ was not declared in this scope
     virtual bool GetPreferredFourccs(std::vector<uint32>* fourccs) override;
                                                  ^~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:19:50: note: suggested alternative: ‘rintf32’
     virtual bool GetPreferredFourccs(std::vector<uint32>* fourccs) override;
                                                  ^~~~~~
                                                  rintf32
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:19:56: error: template argument 1 is invalid
     virtual bool GetPreferredFourccs(std::vector<uint32>* fourccs) override;
                                                        ^
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:19:56: error: template argument 2 is invalid
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:24:49: error: ISO C++ forbids declaration of ‘DISALLOW_COPY_AND_ASSIGN’ with no type [-fpermissive]
     DISALLOW_COPY_AND_ASSIGN(CustomVideoCapturer);
                                                 ^
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:29:58: error: ‘CapturedFrame’ in namespace ‘cricket’ does not name a type
     void SignalFrameCapturedOnStartThread(const cricket::CapturedFrame* frame);
                                                          ^~~~~~~~~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:32:10: error: ‘Thread’ in namespace ‘rtc’ does not name a type
     rtc::Thread*  m_startThread; //video capture thread
          ^~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:19:18: error: ‘virtual bool videocapture::CustomVideoCapturer::GetPreferredFourccs(int*)’ marked ‘override’, but does not override
     virtual bool GetPreferredFourccs(std::vector<uint32>* fourccs) override;
                  ^~~~~~~~~~~~~~~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:24:30: error: cannot declare parameter to be of abstract type ‘videocapture::CustomVideoCapturer’
     DISALLOW_COPY_AND_ASSIGN(CustomVideoCapturer);
                              ^~~~~~~~~~~~~~~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:8:7: note:   because the following virtual functions are pure within ‘videocapture::CustomVideoCapturer’:
 class CustomVideoCapturer :
       ^~~~~~~~~~~~~~~~~~~
In file included from /home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:4:0,
                 from /home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:1:
/home/marek/webrtc/include/media/base/videocapturer.h:227:16: note:     virtual bool cricket::VideoCapturer::GetPreferredFourccs(std::vector<unsigned int>*)
   virtual bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) = 0;
                ^~~~~~~~~~~~~~~~~~~
In file included from /home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:1:0:
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:37:1: error: expected class-name before ‘{’ token
 {
 ^
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:42:59: error: ‘Device’ in namespace ‘cricket’ does not name a type
     virtual cricket::VideoCapturer* Create(const cricket::Device& device) {
                                                           ^~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h: In member function ‘virtual cricket::VideoCapturer* videocapture::VideoCapturerFactoryCustom::Create(const int&)’:
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:45:53: error: request for member ‘id’ in ‘device’, which is of non-class type ‘const int’
         return new CustomVideoCapturer( atoi(device.id.c_str()));
                                                     ^~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:45:64: error: invalid new-expression of abstract class type ‘videocapture::CustomVideoCapturer’
         return new CustomVideoCapturer( atoi(device.id.c_str()));
                                                                ^
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp: In member function ‘virtual cricket::CaptureState videocapture::CustomVideoCapturer::Start(const cricket::VideoFormat&)’:
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:46:5: error: ‘m_startThread’ was not declared in this scope
     m_startThread = rtc::Thread::Current();
     ^~~~~~~~~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:46:5: note: suggested alternative: ‘g_pthread’
     m_startThread = rtc::Thread::Current();
     ^~~~~~~~~~~~~
     g_pthread
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp: In member function ‘virtual void videocapture::CustomVideoCapturer::Stop()’:
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:63:5: error: ‘m_startThread’ was not declared in this scope
     m_startThread = nullptr;
     ^~~~~~~~~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:63:5: note: suggested alternative: ‘g_pthread’
     m_startThread = nullptr;
     ^~~~~~~~~~~~~
     g_pthread
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp: In static member function ‘static void* videocapture::CustomVideoCapturer::grabCapture(void*)’:
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:84:28: error: no matching function for call to ‘webrtc::VideoFrame::VideoFrame()’
         webrtc::VideoFrame vframe;
                            ^~~~~~
In file included from /home/marek/webrtc/include/media/base/videobroadcaster.h:18:0,
                 from /home/marek/webrtc/include/media/base/videocapturer.h:25,
                 from /home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.h:4,
                 from /home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:1:
/home/marek/webrtc/include/api/video/video_frame.h:40:3: note: candidate: webrtc::VideoFrame::VideoFrame(webrtc::VideoFrame&&)
   VideoFrame(VideoFrame&&);
   ^~~~~~~~~~
/home/marek/webrtc/include/api/video/video_frame.h:40:3: note:   candidate expects 1 argument, 0 provided
/home/marek/webrtc/include/api/video/video_frame.h:39:3: note: candidate: webrtc::VideoFrame::VideoFrame(const webrtc::VideoFrame&)
   VideoFrame(const VideoFrame&);
   ^~~~~~~~~~
/home/marek/webrtc/include/api/video/video_frame.h:39:3: note:   candidate expects 1 argument, 0 provided
/home/marek/webrtc/include/api/video/video_frame.h:31:3: note: candidate: webrtc::VideoFrame::VideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>&, uint32_t, int64_t, webrtc::VideoRotation)
   VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
   ^~~~~~~~~~
/home/marek/webrtc/include/api/video/video_frame.h:31:3: note:   candidate expects 4 arguments, 0 provided
/home/marek/webrtc/include/api/video/video_frame.h:26:3: note: candidate: webrtc::VideoFrame::VideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>&, webrtc::VideoRotation, int64_t)
   VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
   ^~~~~~~~~~
/home/marek/webrtc/include/api/video/video_frame.h:26:3: note:   candidate expects 3 arguments, 0 provided
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:85:24: error: ‘class webrtc::VideoFrame’ has no member named ‘CreateEmptyFram ’
         if(0 != vframe.CreateEmptyFrame(bgra.cols, bgra.rows, bgra.cols, (bgra.cols+1) /2, (bgra.cols+1) /2) )
                        ^~~~~~~~~~~~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:90:25: error: ‘ConvertToI420’ is not a member of ‘webrtc’
         if(0 != webrtc::ConvertToI420(webrtc::kBGRA, bgra.ptr(), 0, 0, bgra.cols, bgra.rows, 0, webrtc::kVideoRotation_0, &vframe) ){
                         ^~~~~~~~~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:90:25: note: suggested alternative: ‘ConvertFromI420’
         if(0 != webrtc::ConvertToI420(webrtc::kBGRA, bgra.ptr(), 0, 0, bgra.cols, bgra.rows, 0, webrtc::kVideoRotation_0, &vframe) ){
                         ^~~~~~~~~~~~~
                         ConvertFromI420
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:90:47: error: ‘kBGRA’ is not a member of ‘webrtc’
         if(0 != webrtc::ConvertToI420(webrtc::kBGRA, bgra.ptr(), 0, 0, bgra.cols, bgra.rows, 0, webrtc::kVideoRotation_0, &vframe) ){
                                               ^~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:97:34: error: ‘WebRtcCapturedFrame’ is not a member of ‘cricket’
         std::shared_ptr<cricket::WebRtcCapturedFrame> webrtc_frame(new cricket::WebRtcCapturedFrame(vframe, &capture_buffer_[0], length));
                                  ^~~~~~~~~~~~~~~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:97:34: error: ‘WebRtcCapturedFrame’ is not a member of ‘cricket’
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:97:53: error: template argument 1 is invalid
         std::shared_ptr<cricket::WebRtcCapturedFrame> webrtc_frame(new cricket::WebRtcCapturedFrame(vframe, &capture_buffer_[0], length));
                                                     ^
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:97:72: error: expected type-specifier
         std::shared_ptr<cricket::WebRtcCapturedFrame> webrtc_frame(new cricket::WebRtcCapturedFrame(vframe, &capture_buffer_[0], length));
                                                                        ^~~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:100:17: error: ‘class videocapture::CustomVideoCapturer’ has no member named  m_startThread’
         if (vc->m_startThread->IsCurrent()) {
                 ^~~~~~~~~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:101:17: error: ‘class videocapture::CustomVideoCapturer’ has no member named  SignalFrameCaptured’; did you mean ‘grabCapture’?
             vc->SignalFrameCaptured(vc, webrtc_frame.get());
                 ^~~~~~~~~~~~~~~~~~~
                 grabCapture
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:101:54: error: request for member ‘get’ in ‘webrtc_frame’, which is of non-class type ‘int’
             vc->SignalFrameCaptured(vc, webrtc_frame.get());
                                                      ^~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:103:17: error: ‘class videocapture::CustomVideoCapturer’ has no member named  m_startThread’
             vc->m_startThread->Invoke<void>(rtc::Bind(&CustomVideoCapturer::SignalFrameCapturedOnStartThread, vc, webrtc_frame.get()));
                 ^~~~~~~~~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:103:39: error: expected primary-expression before ‘void’
             vc->m_startThread->Invoke<void>(rtc::Bind(&CustomVideoCapturer::SignalFrameCapturedOnStartThread, vc, webrtc_frame.get()));
                                       ^~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp: At global scope:
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:109:75: error: ‘CapturedFrame’ in namespace ‘cricket’ does not name a type
 void CustomVideoCapturer::SignalFrameCapturedOnStartThread(const cricket::CapturedFrame* frame)
                                                                           ^~~~~~~~~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp: In member function ‘void videocapture::CustomVideoCapturer::SignalFrameCapturedOnStartThread(const int*)’:
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:111:5: error: ‘SignalFrameCaptured’ was not declared in this scope
     SignalFrameCaptured(this, frame);
     ^~~~~~~~~~~~~~~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:111:5: note: suggested alternative: ‘grabCapture’
     SignalFrameCaptured(this, frame);
     ^~~~~~~~~~~~~~~~~~~
     grabCapture
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp: At global scope:
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:119:59: error: ‘uint32’ was not declared in this scope
 bool CustomVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs)
                                                           ^~~~~~
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:119:59: note: suggested alternative: ‘rintf32’
 bool CustomVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs)
                                                           ^~~~~~
                                                           rintf32
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:119:65: error: template argument 1 is invalid
 bool CustomVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs)
                                                                 ^
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:119:65: error: template argument 2 is invalid
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp: In member function ‘virtual bool videocapture::CustomVideoCapturer::GetPreferredFourccs(int*)’:
/home/marek/libsourcey/src/webrtc/samples/custom_opencv_video_capture/CustomVideoCapturer.cpp:123:14: error: request for member ‘push_back’ in ‘* fourccs’, which is of non-class type ‘int’
     fourccs->push_back(cricket::FOURCC_I420);
              ^~~~~~~~~
webrtc/samples/custom_opencv_video_capture/CMakeFiles/marek.dir/build.make:62: recipe for target 'webrtc/samples/custom_opencv_video_capture/CMakeFiles/marek.dir/CustomVideoCapturer.cpp.o' failed
make[2]: *** [webrtc/samples/custom_opencv_video_capture/CMakeFiles/marek.dir/CustomVideoCapturer.cpp.o] Error 1
CMakeFiles/Makefile2:2694: recipe for target 'webrtc/samples/custom_opencv_video_capture/CMakeFiles/marek.dir/all' failed
make[1]: *** [webrtc/samples/custom_opencv_video_capture/CMakeFiles/marek.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
aviontics commented 5 years ago

Have same problem

ziriax commented 5 years ago

Might be related to this?