Handle dmabuf using existing capture path#1279
Conversation
Changeset ✓This PR includes a changeset covering all affected packages:
|
5013593 to
ac1b1d7
Compare
| pub fn capture_frame<T: AsRef<dyn VideoBuffer>>(&self, frame: &VideoFrame<T>) { | ||
| self.handle.capture_frame(frame) | ||
| } | ||
|
|
||
| /// Captures one pre-encoded video access unit. | ||
| pub fn capture_encoded_frame(&self, frame: &EncodedVideoFrame<'_>) -> bool { | ||
| self.handle.capture_encoded_frame(frame) | ||
| } | ||
|
|
||
| /// Returns and clears the pending keyframe request raised by the | ||
| /// pass-through encoder (PLI/FIR or reconfiguration). | ||
| pub fn take_keyframe_request(&self) -> bool { | ||
| self.handle.take_keyframe_request() | ||
| } | ||
|
|
||
| /// Returns and clears the pending rate-control target raised by the | ||
| /// pass-through encoder. | ||
| pub fn take_rate_control_request(&self) -> Option<EncodedRateControl> { | ||
| self.handle.take_rate_control_request() | ||
| self.handle.capture_frame(frame); | ||
| } |
There was a problem hiding this comment.
🟡 Recommended replacement for capturing camera buffers can no longer report dropped frames
The public capture method (capture_frame at libwebrtc/src/video_source.rs:96-98) throws away the accept/drop result returned by the lower layer, so callers migrating from the now-deprecated dmabuf method (which returned a boolean) can no longer tell whether a submitted frame was dropped.
Impact: Code that relied on knowing a frame was dropped for pacing/statistics loses that signal after following the recommended migration.
Return-value swallowed at the public wrapper
The inner implementation was changed to return bool and explicitly documented as "Returns false if the frame was dropped by the adapter" (libwebrtc/src/native/video_source.rs:125-127,160). The deprecated capture_dmabuf_frame_with_metadata (libwebrtc/src/video_source.rs:133-157) returns bool, and its #[deprecated] note tells users to migrate to capture_frame. However the public capture_frame at libwebrtc/src/video_source.rs:96-98 terminates the call with ; and returns (), discarding the boolean. Migrating dmabuf users therefore lose the drop-detection return value that the deprecated API provided. Propagating the bool here would be a (nearly) non-breaking change since existing capture_frame(&f); statement callers are unaffected.
| pub fn capture_frame<T: AsRef<dyn VideoBuffer>>(&self, frame: &VideoFrame<T>) { | |
| self.handle.capture_frame(frame) | |
| } | |
| /// Captures one pre-encoded video access unit. | |
| pub fn capture_encoded_frame(&self, frame: &EncodedVideoFrame<'_>) -> bool { | |
| self.handle.capture_encoded_frame(frame) | |
| } | |
| /// Returns and clears the pending keyframe request raised by the | |
| /// pass-through encoder (PLI/FIR or reconfiguration). | |
| pub fn take_keyframe_request(&self) -> bool { | |
| self.handle.take_keyframe_request() | |
| } | |
| /// Returns and clears the pending rate-control target raised by the | |
| /// pass-through encoder. | |
| pub fn take_rate_control_request(&self) -> Option<EncodedRateControl> { | |
| self.handle.take_rate_control_request() | |
| self.handle.capture_frame(frame); | |
| } | |
| pub fn capture_frame<T: AsRef<dyn VideoBuffer>>(&self, frame: &VideoFrame<T>) -> bool { | |
| self.handle.capture_frame(frame) | |
| } |
Was this helpful? React with 👍 or 👎 to provide feedback.
Previously, dedicated methods on
NativeVideoSourcewere used to capture dmabuf; these have been deprecated and dmabuf is now handled byNativeBuffer(also handles analogous zero-copyCVPixelBufferfor Apple platforms). See the updated example for new usage.