Skip to content

feat: add custom video source.#138

Open
cloudwebrtc wants to merge 2 commits intomainfrom
feat/add-custom-video-source
Open

feat: add custom video source.#138
cloudwebrtc wants to merge 2 commits intomainfrom
feat/add-custom-video-source

Conversation

@cloudwebrtc
Copy link
Copy Markdown
Member

feat: custom video source via RTCVideoSource::OnCapturedFrame

Let's applications inject their own video frames into the libwebrtc pipeline
without going through a camera or desktop capturer. Adds a wxWidgets demo
that uses the new API to stream synthetic SMPTE colour bars between two
in-process peer connections.

Public API additions

  • RTCVideoSource::OnCapturedFrame(scoped_refptr<RTCVideoFrame>)
  • RTCVideoSource::GetSourceType()
  • RTCPeerConnectionFactory::CreateCustomVideoSource(string video_source_label, scoped_refptr<RTCMediaConstraints> constraints)

Implementation notes

  • internal::VideoCapturer::OnFrame promoted from protected to public
    so RTCVideoSourceImpl can forward user frames into the broadcaster
    without a friend declaration.
  • RTCVideoSourceImpl gains a second constructor that stores a
    shared_ptr<internal::VideoCapturer>; the desktop-source path keeps the
    old single-arg ctor and treats OnCapturedFrame as a no-op.
  • RTCVideoFrame::timestamp_us == 0 falls back to webrtc::TimeMicros() so
    callers can omit the timestamp.

Demo: examples/wx_loop_back_demo

  • wxWidgets app (CMake + find_package(wxWidgets)).
  • Two in-process RTCPeerConnections, full offer/answer + ICE exchange,
    one audio track and one synthetic video track.
  • Frame producer pushes 640×480 I420 SMPTE colour bars scrolling at
    ~120 px/sec via OnCapturedFrame.
  • Decoded remote video rendered into a wxPanel (I420 → ABGR via
    libyuv → wxImagewxBitmap).
  • macOS bundling: post-build copies libwebrtc.dylib into
    Contents/Frameworks/, rewrites the executable's recorded dependency to
    @rpath/libwebrtc.dylib, ad-hoc re-signs both binaries.
  • README with build, run, and verification steps.
image

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

Successfully merging this pull request may close these issues.

1 participant