Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing Custom Capture in Libwebrtc? #87

Open
szpnygo opened this issue Jul 25, 2023 · 1 comment
Open

Implementing Custom Capture in Libwebrtc? #87

szpnygo opened this issue Jul 25, 2023 · 1 comment

Comments

@szpnygo
Copy link

szpnygo commented Jul 25, 2023

I'm currently working on a project where I need to implement custom capture functionality using Libwebrtc.

As a beginner exploring the vast landscape of WebRTC, I've been trying to customize the VideoCapturer. While attempting to extend the RTCVideoCapturer class, I noticed there doesn't seem to be an 'OnFrame' method that allows me to pass my customized frame.

I'd like to confirm if this would be the appropriate and recommended way to achieve my objective. If not, could you kindly suggest an alternative approach?

@szpnygo
Copy link
Author

szpnygo commented Nov 18, 2023

I added a new function in RTCVideoCapturer

virtual void GenerateFrame(scoped_refptr<RTCVideoFrame> frame) = 0

void GenerateFrame(scoped_refptr<RTCVideoFrame> frame) override {
    if (video_capturer_ != nullptr) {
      VideoFrameBufferImpl* impl =
          static_cast<VideoFrameBufferImpl*>(frame.get());

      auto newFrame = webrtc::VideoFrame::Builder()
                          .set_video_frame_buffer(impl->buffer())
                          .set_rotation(static_cast<webrtc::VideoRotation>(
                              impl->rotation()))
                          .set_timestamp_us(rtc::TimeMicros())
                          .build();

      video_capturer_->GenerateFrame(newFrame);
    }
  }

Additionally, I added a new method in VideoCapturer:

virtual void GenerateFrame(const VideoFrame& frame) { OnFrame(frame); }

After implementing this, I achieved my goal. However, I'm uncertain if this is the correct approach. Will the library continue to support such objectives in the future?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant