https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
a

Abdullah Musa

11/18/2023, 12:28 PM
Hey everyone! I have a project I'm working on in Uni, that uses KMP and Compose Multiplatform for Android and Desktop. I'm trying to implement broadcasting video using WebRTC, using the webrtc-java library on the desktop end, and I'm currently stuck at displaying the received
VideoFrames
. How can I achieve this?
d

Dominaezzz

11/18/2023, 5:17 PM
You should be able to draw the frames to a canvas. Can't vouch for the performance
a

Abdullah Musa

11/18/2023, 8:11 PM
I'm not very familiar with canvas or rendering. Can you provide some documentation, demo or tutorial on how to do this? The library uses a
NativeI420Buffer
with these properties:
Copy code
ByteBuffer dataY;
ByteBuffer dataU;
ByteBuffer dataV;
int strideY;
int strideU;
int strideV;
int width;
int height;
t

Timo Drick

12/02/2023, 12:25 PM
Don't think this is supported by skia. Here is sample code how to put data into a Bitmap with BGRA_8888 format:
Copy code
val skiaFormat = ImageInfo(targetWidth, targetHeight, ColorType.BGRA_8888, ColorAlphaType.OPAQUE)
val bufferBitmap = Bitmap().also {
   it.allocPixels(skiaFormat)
}
// Than you can put data into this bitmap:
bufferBitmap.installPixels(jArray) // this is a ByteArray with the data in correct format.
Maybe the library you are using is able to convert the image into a format which is supported in skia.
2 Views