Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
xuning
/
livekitAndroidXuningTest
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
xuning
2025-09-30 13:03:14 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fcb1e490d831e2714f4321f7f3b9611905c26b8a
fcb1e490
1 parent
f42ec3a9
尝试接入图像处理
显示空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
57 行增加
和
0 行删除
livekit-android-sdk/src/main/java/io/livekit/android/room/track/video/OpenCVVideoProcessor.kt
livekit-android-sdk/src/main/java/io/livekit/android/room/track/video/OpenCVVideoProcessor.kt
0 → 100644
查看文件 @
fcb1e49
/*
* Copyright 2024 LiveKit, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.livekit.android.room.track.video
import livekit.org.webrtc.VideoFrame
import java.nio.ByteBuffer
// Native OpenCV implementation via JNI
class OpenCVVideoProcessor : ChainVideoProcessor() {
companion object {
init {
System.loadLibrary("rvmncnn")
}
}
private external fun processI420(y: ByteArray, u: ByteArray, v: ByteArray, width: Int, height: Int, rotation: Int, timestamp: Long): Array<ByteArray>
override fun onFrameCaptured(frame: VideoFrame) {
val buffer = frame.buffer
if (buffer !is VideoFrame.I420Buffer) {
continueChain(frame)
return
}
val yArray = ByteArray(buffer.strideY * buffer.height)
buffer.dataY.get(yArray)
val uArray = ByteArray(buffer.strideU * (buffer.height + 1) / 2)
buffer.dataU.get(uArray)
val vArray = ByteArray(buffer.strideV * (buffer.height + 1) / 2)
buffer.dataV.get(vArray)
val result = processI420(yArray, uArray, vArray, buffer.width, buffer.height, frame.rotation, frame.timestampNs)
val newY = ByteBuffer.wrap(result[0])
val newU = ByteBuffer.wrap(result[1])
val newV = ByteBuffer.wrap(result[2])
val newBuffer = livekit.org.webrtc.JavaI420Buffer.wrap(buffer.width, buffer.height, newY, buffer.width, newU, buffer.width / 2, newV, buffer.width / 2, null)
val newFrame = VideoFrame(newBuffer, frame.rotation, frame.timestampNs)
continueChain(newFrame)
}
}
\ No newline at end of file
...
...
请
注册
或
登录
后发表评论