feat: add VideoBufferConverter.convertToI420 #192
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey, now that you added
CustomVIdeoSource
that can acceptVideoFrame
s that needI420Buffer
s,it might be useful to be able to use RGB frames.
VideoBufferConverter
hasconvertFromI420
to be able to take frames from sinks and convert them to RGB,so I added
convertToI420
to convert a buffer (byte[]
orByteBuffer
) toI420Buffer
.Like the existing
VideoDesktopSource
, this useslibyuv::ConvertToI420
.Example usage based on
custom_video_source.md
:I then added tests for
VideoBufferConverter
:byte[]
or a directByteBuffer
or a non-directByteBuffer
(6 tests)To test the conversion itself did something I generated I420/RGBA data that contained sequential numbers just so it wouldn't be zero or constant (see
initializeI420Buffer
/initializeRGBAArray
/initializeRGBABuffer
), then calledVideoBufferConverter
to perform the conversion, and then check that each channel of the destination buffer has at least one non-zero byte (seeverifyI420Buffer
/verifyRGBAArray
/verifyRGBABuffer
).Thanks!