Skip to content

Commit

Permalink
Bump up HaishinKit.kt to 0.13.2
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Feb 25, 2024
1 parent fafc22d commit e3477ab
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ android {
}

dependencies {
implementation 'com.github.shogo4405.HaishinKit~kt:haishinkit:0.13.1'
implementation 'com.github.shogo4405.HaishinKit~kt:haishinkit:0.13.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.haishinkit.haishin_kit

import android.os.Handler
import android.os.Looper
import androidx.annotation.NonNull
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
Expand All @@ -24,13 +23,13 @@ class HaishinKitPlugin : FlutterPlugin, MethodCallHandler {
handlers.remove(id)
}

override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
this.flutterPluginBinding = flutterPluginBinding
channel = MethodChannel(flutterPluginBinding.binaryMessenger, CHANNEL_NAME)
channel.setMethodCallHandler(this)
}

override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
override fun onMethodCall(call: MethodCall, result: Result) {
val memory = call.argument<Int>("memory")
if (memory != null) {
val handler = handlers[memory]
Expand Down Expand Up @@ -66,7 +65,7 @@ class HaishinKitPlugin : FlutterPlugin, MethodCallHandler {
}
}

override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
channel.setMethodCallHandler(null)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class RtmpStreamHandler(
}
val handler = Handler()
handler.postDelayed({
if (instance?.drawable != null) {
if (instance?.view != null) {
camera?.open(facing)
}
}, 750)
Expand All @@ -177,15 +177,15 @@ class RtmpStreamHandler(

"$TAG#registerTexture" -> {
val netStream = instance
if (netStream?.drawable == null) {
if (netStream?.view == null) {
val texture = StreamDrawableTexture(plugin.flutterPluginBinding)
texture.attachStream(netStream)
if (camera?.stream != null) {
camera?.open()
}
result.success(texture.id)
} else {
val texture = (netStream.drawable as? StreamDrawableTexture)
val texture = (netStream.view as? StreamDrawableTexture)
result.success(texture?.id)
}
}
Expand All @@ -196,13 +196,13 @@ class RtmpStreamHandler(

"$TAG#updateTextureSize" -> {
val netStream = instance
if (netStream?.drawable != null) {
val texture = (netStream.drawable as? StreamDrawableTexture)
if (netStream?.view != null) {
val texture = (netStream.view as? StreamDrawableTexture)
val width = call.argument<Double>("width") ?: 0
val height = call.argument<Double>("height") ?: 0
texture?.imageExtent = Size(width.toInt(), height.toInt())
(plugin.flutterPluginBinding.applicationContext.getSystemService(Context.WINDOW_SERVICE) as? WindowManager)?.defaultDisplay?.orientation?.let {
netStream.videoSource?.screen?.deviceOrientation = it
camera?.video?.deviceOrientation = it
}
result.success(texture?.id)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import com.haishinkit.graphics.PixelTransform
import com.haishinkit.graphics.VideoGravity
import com.haishinkit.graphics.effect.VideoEffect
import com.haishinkit.media.Stream
import com.haishinkit.media.StreamDrawable
import com.haishinkit.media.StreamView
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.view.TextureRegistry

class StreamDrawableTexture(binding: FlutterPlugin.FlutterPluginBinding) :
StreamDrawable {
StreamView {
override var videoGravity: VideoGravity
get() = pixelTransform.videoGravity
set(value) {
Expand Down Expand Up @@ -46,9 +46,9 @@ class StreamDrawableTexture(binding: FlutterPlugin.FlutterPluginBinding) :

private var stream: Stream? = null
set(value) {
field?.drawable = null
field?.view = null
field = value
field?.drawable = this
field?.view = this
pixelTransform.screen = value?.screen
}

Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.1.0'
classpath 'com.android.tools.build:gradle:8.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip

0 comments on commit e3477ab

Please sign in to comment.