Skip to content

Commit

Permalink
Bump to up HaishinKit.swift 1.5.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Jun 17, 2023
1 parent ce25ae7 commit 225c3f5
Show file tree
Hide file tree
Showing 22 changed files with 393 additions and 346 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ import io.flutter.plugin.common.MethodChannel
import java.lang.Exception

class RtmpStreamHandler(
private val plugin: HaishinKitPlugin,
handler: RtmpConnectionHandler?
) : MethodChannel.MethodCallHandler, IEventListener,
EventChannel.StreamHandler {
private val plugin: HaishinKitPlugin, handler: RtmpConnectionHandler?
) : MethodChannel.MethodCallHandler, IEventListener, EventChannel.StreamHandler {
companion object {
private const val TAG = "RtmpStream"
}
Expand All @@ -46,24 +44,54 @@ class RtmpStreamHandler(
instance = RtmpStream(it)
}
channel = EventChannel(
plugin.flutterPluginBinding.binaryMessenger,
"com.haishinkit.eventchannel/${hashCode()}"
plugin.flutterPluginBinding.binaryMessenger, "com.haishinkit.eventchannel/${hashCode()}"
)
channel.setStreamHandler(this)
}

override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
when (call.method) {
"$TAG#getHasAudio" -> {
result.success(instance?.audioSetting?.muted)
}

"$TAG#setHasAudio" -> {
val value = call.argument<Boolean?>("value")
value?.let {
instance?.audioSetting?.muted = !it
}
result.success(null)
}

"$TAG#getHasVideo" -> {
result.success(null)
}

"$TAG#setHasVideo" -> {
result.success(null)
}

"$TAG#setFrameRate" -> {
val value = call.argument<Int?>("value")
value?.let {
instance?.videoSetting?.frameRate = it
}
result.success(null)
}

"$TAG#setSessionPreset" -> {
// for iOS
result.success(null)
}

"$TAG#setAudioSettings" -> {
val source = call.argument<Map<String, Any?>>("settings") ?: return
(source["bitrate"] as? Int)?.let {
instance?.audioSetting?.bitRate = it
}
(source["muted"] as? Boolean)?.let {
instance?.audioSetting?.muted = it
}
result.success(null)
}

"$TAG#setVideoSettings" -> {
val source = call.argument<Map<String, Any?>>("settings") ?: return
(source["width"] as? Int)?.let {
Expand Down Expand Up @@ -91,9 +119,7 @@ class RtmpStreamHandler(
}
result.success(null)
}
"$TAG#setCaptureSettings" -> {
result.success(null)
}

"$TAG#attachAudio" -> {
val source = call.argument<Map<String, Any?>>("source")
if (source == null) {
Expand All @@ -103,6 +129,7 @@ class RtmpStreamHandler(
}
result.success(null)
}

"$TAG#attachVideo" -> {
val source = call.argument<Map<String, Any?>>("source")
if (source == null) {
Expand All @@ -114,6 +141,7 @@ class RtmpStreamHandler(
"front" -> {
facing = CameraCharacteristics.LENS_FACING_FRONT
}

"back" -> {
facing = CameraCharacteristics.LENS_FACING_BACK
}
Expand All @@ -131,6 +159,7 @@ class RtmpStreamHandler(
}
result.success(null)
}

"$TAG#registerTexture" -> {
val netStream = instance
if (netStream?.drawable == null) {
Expand All @@ -144,28 +173,32 @@ class RtmpStreamHandler(
val texture = (netStream.drawable as? NetStreamDrawableTexture)
val width = call.argument<Double>("width") ?: 0
val height = call.argument<Double>("height") ?: 0
texture?.imageExtent =
Size(width.toInt(), height.toInt())
texture?.imageExtent = Size(width.toInt(), height.toInt())
(plugin.flutterPluginBinding.applicationContext.getSystemService(Context.WINDOW_SERVICE) as? WindowManager)?.defaultDisplay?.orientation?.let {
netStream.deviceOrientation = it
}
result.success(texture?.id)
}
}

"$TAG#publish" -> {
instance?.publish(call.argument("name"))
result.success(null)
}

"$TAG#play" -> {
val name = call.argument<String>("name")
if (name != null) {
instance?.play(name)
}
result.success(null)
}

"$TAG#close" -> {
instance?.close()
result.success(null)
}

"$TAG#dispose" -> {
eventSink?.endOfStream()
instance?.close()
Expand Down
22 changes: 11 additions & 11 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ PODS:
- audio_session (0.0.1):
- Flutter
- Flutter (1.0.0)
- haishin_kit (0.9.2):
- haishin_kit (0.10.1):
- Flutter
- HaishinKit (= 1.3.0)
- HaishinKit (1.3.0):
- Logboard (~> 2.3.0)
- Logboard (2.3.0)
- permission_handler_apple (9.0.4):
- HaishinKit (= 1.5.2)
- HaishinKit (1.5.2):
- Logboard (~> 2.3.1)
- Logboard (2.3.1)
- permission_handler_apple (9.1.0):
- Flutter

DEPENDENCIES:
Expand All @@ -35,11 +35,11 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
audio_session: 4f3e461722055d21515cf3261b64c973c062f345
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
haishin_kit: 2e92b4d42bccda32bf35fa86a105fd7c5746dade
HaishinKit: 013229683accc4abe46630b04629da3ff90428b7
Logboard: f3a37d2a4040b82b7e2eb39765897e2c9c5ec024
permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce
haishin_kit: a7ed49a4b47b032202c8cca4a80544d4513f690d
HaishinKit: b42a0e86766957a1882c0f61f0ebf0111d581402
Logboard: 3d98bb85de6a36b255ab637e8178eb5671c5c3a6
permission_handler_apple: 8f116445eff3c0e7c65ad60f5fef5490aa94b4e4

PODFILE CHECKSUM: 1d4f584ecee31f81e6b1ae37103ab21a5f7aac05

COCOAPODS: 1.11.3
COCOAPODS: 1.12.1
5 changes: 4 additions & 1 deletion example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -338,10 +338,12 @@
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand All @@ -352,6 +354,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down
2 changes: 2 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class _MyAppState extends State<MyApp> {
});

RtmpStream stream = await RtmpStream.create(connection);
stream.audioSettings = AudioSettings(muted: false, bitrate: 64 * 1000);
stream.audioSettings = AudioSettings(bitrate: 64 * 1000);
stream.videoSettings = VideoSettings(
width: 480,
height: 272,
Expand Down
22 changes: 11 additions & 11 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ packages:
dependency: "direct main"
description:
name: audio_session
sha256: "655343841a723646f74932215c5785ef7156b76d2de4b99bcd3205476f08dc61"
sha256: "8a2bc5e30520e18f3fb0e366793d78057fb64cd5287862c76af0c8771f2a52ad"
url: "https://pub.dev"
source: hosted
version: "0.1.15"
version: "0.1.16"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -94,7 +94,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.10.0"
version: "0.11.0"
js:
dependency: transitive
description:
Expand Down Expand Up @@ -147,34 +147,34 @@ packages:
dependency: "direct main"
description:
name: permission_handler
sha256: "33c6a1253d1f95fd06fa74b65b7ba907ae9811f9d5c1d3150e51417d04b8d6a8"
sha256: "1b6b3e73f0bcbc856548bbdfb1c33084a401c4f143e220629a9055233d76c331"
url: "https://pub.dev"
source: hosted
version: "10.2.0"
version: "10.3.0"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
sha256: d8cc6a62ded6d0f49c6eac337e080b066ee3bce4d405bd9439a61e1f1927bfe8
sha256: "8f6a95ccbca13766882f95d32684d7c9bfe6c45650c32bedba948ef1c6a4ddf7"
url: "https://pub.dev"
source: hosted
version: "10.2.1"
version: "10.2.3"
permission_handler_apple:
dependency: transitive
description:
name: permission_handler_apple
sha256: ee96ac32f5a8e6f80756e25b25b9f8e535816c8e6665a96b6d70681f8c4f7e85
sha256: "08dcb6ce628ac0b257e429944b4c652c2a4e6af725bdf12b498daa2c6b2b1edb"
url: "https://pub.dev"
source: hosted
version: "9.0.8"
version: "9.1.0"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
sha256: "68abbc472002b5e6dfce47fe9898c6b7d8328d58b5d2524f75e277c07a97eb84"
sha256: de20a5c3269229c1ae2e5a6b822f6cb59578b23e8255c93fbeebfc82116e6b11
url: "https://pub.dev"
source: hosted
version: "3.9.0"
version: "3.10.0"
permission_handler_windows:
dependency: transitive
description:
Expand Down
5 changes: 2 additions & 3 deletions ios/Classes/ASObjectUil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import HaishinKit
enum ASObjectUtil {
static func removeEmpty(_ value: Any?) -> Any? {
if var value = value as? ASObject {
for var element in value {
for element in value {
value[element.key] = removeEmpty(element.value)
}
return value.isEmpty ? nil : value
Expand All @@ -17,12 +17,11 @@ enum ASObjectUtil {
return result.isEmpty ? nil : result
}
if let value = value {
if (value is ASUndefined) {
if value is ASUndefined {
return nil
}
return value
}
return nil
}
}

3 changes: 2 additions & 1 deletion ios/Classes/NetStreamDrawableTexture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class NetStreamDrawableTexture: NSObject, FlutterTexture {
static let defaultOptions: [String: Any] = [
kCVPixelBufferCGImageCompatibilityKey as String: true,
kCVPixelBufferCGBitmapContextCompatibilityKey as String: true,
kCVPixelBufferIOSurfacePropertiesKey as String: [:]
kCVPixelBufferIOSurfacePropertiesKey as String: NSDictionary()
]

var id: Int64 = 0
Expand All @@ -16,6 +16,7 @@ class NetStreamDrawableTexture: NSObject, FlutterTexture {
var videoFormatDescription: CMVideoFormatDescription?
var bounds: CGSize = .zero
var videoGravity: AVLayerVideoGravity = .resizeAspectFill
var videoOrientation: AVCaptureVideoOrientation = .portrait
private var currentSampleBuffer: CMSampleBuffer?
private let registry: FlutterTextureRegistry
private let context = CIContext()
Expand Down
Loading

0 comments on commit 225c3f5

Please sign in to comment.