Skip to content

Commit

Permalink
fix: build error
Browse files Browse the repository at this point in the history
  • Loading branch information
LichKing-2234 committed May 19, 2021
1 parent 3482833 commit 8c80c1e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 10 deletions.
Expand Up @@ -109,7 +109,12 @@ class AgoraRtcEnginePlugin : FlutterPlugin, MethodCallHandler, EventChannel.Stre
val textureRegistry = registrar?.textures() ?: binding?.textureRegistry
val messenger = registrar?.messenger() ?: binding?.binaryMessenger
if (call.method == "createTextureRender") {
val id = AgoraTextureViewFactory.createTextureRender(textureRegistry!!, messenger!!, this, rtcChannelPlugin)
val id = AgoraTextureViewFactory.createTextureRender(
textureRegistry!!,
messenger!!,
this,
rtcChannelPlugin
)
result.success(id)
return
} else if (call.method == "destroyTextureRender") {
Expand Down
Expand Up @@ -79,17 +79,39 @@ class TextureRender(
return render.pixelFormat
}

override fun consumeByteBufferFrame(buffer: ByteBuffer?, format: Int, width: Int, height: Int, rotation: Int, timestamp: Long) {
override fun consumeByteBufferFrame(
buffer: ByteBuffer?,
format: Int,
width: Int,
height: Int,
rotation: Int,
timestamp: Long
) {
updateTextureSize(width, height)
render.consume(buffer, format, width, height, rotation, timestamp)
}

override fun consumeByteArrayFrame(data: ByteArray?, format: Int, width: Int, height: Int, rotation: Int, timestamp: Long) {
override fun consumeByteArrayFrame(
data: ByteArray?,
format: Int,
width: Int,
height: Int,
rotation: Int,
timestamp: Long
) {
updateTextureSize(width, height)
render.consume(data, format, width, height, rotation, timestamp)
}

override fun consumeTextureFrame(textureId: Int, format: Int, width: Int, height: Int, rotation: Int, timestamp: Long, matrix: FloatArray?) {
override fun consumeTextureFrame(
textureId: Int,
format: Int,
width: Int,
height: Int,
rotation: Int,
timestamp: Long,
matrix: FloatArray?
) {
updateTextureSize(width, height)
render.consume(textureId, format, width, height, rotation, timestamp, matrix)
}
Expand All @@ -106,17 +128,18 @@ class TextureRender(
this.javaClass.declaredMethods.find { it.name == call.method }?.let { function ->
function.let { method ->
val parameters = mutableListOf<Any?>()
function.parameters.forEach { parameter ->
val map = call.arguments<Map<*, *>>()
if (map.containsKey(parameter.name)) {
parameters.add(map[parameter.name])
call.arguments<Map<*, *>>()?.let { args ->
args.values.forEach {
parameters.add(it)
}
}
try {
method.invoke(this, *parameters.toTypedArray())
result.success(null)
return@onMethodCall
} catch (e: Exception) {
e.printStackTrace()
result.error(e.toString(), null, null)
}
}
}
Expand All @@ -128,7 +151,10 @@ class TextureRender(
val channel = (data["channelId"] as? String)?.let { getChannel(it) }
if (uid == 0) {
getEngine()?.setLocalVideoRenderer(this)
getEngine()?.setLocalRenderMode(Constants.RENDER_MODE_FIT, Constants.VIDEO_MIRROR_MODE_ENABLED)
getEngine()?.setLocalRenderMode(
Constants.RENDER_MODE_FIT,
Constants.VIDEO_MIRROR_MODE_ENABLED
)
} else {
channel?.let {
it.setRemoteVideoRenderer(uid, this)
Expand All @@ -155,7 +181,12 @@ class AgoraTextureViewFactory(
companion object {
private val renders = mutableMapOf<Long, TextureRender>()

fun createTextureRender(textureRegistry: TextureRegistry, messenger: BinaryMessenger, rtcEnginePlugin: AgoraRtcEnginePlugin, rtcChannelPlugin: AgoraRtcChannelPlugin): Long {
fun createTextureRender(
textureRegistry: TextureRegistry,
messenger: BinaryMessenger,
rtcEnginePlugin: AgoraRtcEnginePlugin,
rtcChannelPlugin: AgoraRtcChannelPlugin
): Long {
val render = TextureRender(textureRegistry, messenger, rtcEnginePlugin, rtcChannelPlugin)
val id = render.getId()
renders[id] = render
Expand Down
1 change: 1 addition & 0 deletions lib/src/rtc_render_view.dart
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter/widgets.dart';

import 'enum_converter.dart';
import 'enums.dart';
import 'rtc_engine.dart';

final Map<int, MethodChannel> _channels = {};

Expand Down

0 comments on commit 8c80c1e

Please sign in to comment.