diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f7b2849..f24b9dbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 3.8.2-beta.2 + +### Features + +Added a new [ScaleType](https://api-references.dolby.io/comms-sdk-flutter/dolbyio_comms_sdk_flutter/ScaleType.html) argument to the [VideoView](https://api-references.dolby.io/comms-sdk-flutter/dolbyio_comms_sdk_flutter/VideoView-class.html) creation methods. The argument lets you select how you want to display a video stream in the VideoView area. You can either use the `fill` or `fit` value. + ## 3.8.2-beta.1 ### Bug Fixes diff --git a/android/gradle.properties b/android/gradle.properties index da7edc77..286d59cc 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,2 +1,2 @@ -COMMS_SDK_VERSION="3.8.2-beta.1" +COMMS_SDK_VERSION="3.8.2-beta.2" COMPONENT_NAME="flutter-sdk" \ No newline at end of file diff --git a/android/src/main/kotlin/io/dolby/comms/sdk/flutter/NativeView.kt b/android/src/main/kotlin/io/dolby/comms/sdk/flutter/NativeView.kt index 20c22bb3..24cc3529 100644 --- a/android/src/main/kotlin/io/dolby/comms/sdk/flutter/NativeView.kt +++ b/android/src/main/kotlin/io/dolby/comms/sdk/flutter/NativeView.kt @@ -2,10 +2,7 @@ package io.dolby.comms.sdk.flutter import com.voxeet.sdk.views.VideoView import android.content.Context -import android.view.View import com.voxeet.VoxeetSDK -import io.dolby.comms.sdk.flutter.mapper.MediaStreamMapper -import io.dolby.comms.sdk.flutter.mapper.ParticipantMapper import io.flutter.plugin.common.BinaryMessenger import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel @@ -49,6 +46,7 @@ class NativeView(context: Context, id: Int, messenger: BinaryMessenger): Platfor val participantId = arguments?.get("participant_id") as String? val mediaStreamLabel = arguments?.get("media_stream_label") as String? + val scaleType = arguments?.get("scale_type") as String? if (participantId != null && mediaStreamLabel != null) { VoxeetSDK.conference() @@ -60,6 +58,8 @@ class NativeView(context: Context, id: Int, messenger: BinaryMessenger): Platfor videoView.unAttach() } + setScaleType(scaleType) + result.success(null) } ?: result.error("INVALID_ARGUMENTS", "Invalid arguments for attach method: $arguments", null) @@ -70,6 +70,14 @@ class NativeView(context: Context, id: Int, messenger: BinaryMessenger): Platfor result.success(null) } + fun setScaleType(scaleType: String?) { + when (scaleType) { + "SCALE_TYPE_FIT" -> videoView.setVideoFit() + "SCALE_TYPE_FILL" -> videoView.setVideoFill() + else -> videoView.setVideoFill() + } + } + override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) { when (call.method) { ::isAttached.name -> isAttached(result) diff --git a/ios/Classes/PluginInfo.swift b/ios/Classes/PluginInfo.swift index 9c58254e..1e40e10e 100644 --- a/ios/Classes/PluginInfo.swift +++ b/ios/Classes/PluginInfo.swift @@ -2,5 +2,5 @@ import Foundation enum PluginInfo { static let componentName = "flutter-sdk" - static let sdkVersion = "3.8.2-beta.1" + static let sdkVersion = "3.8.2-beta.2" } diff --git a/ios/Classes/VideoView/FLVideoView.swift b/ios/Classes/VideoView/FLVideoView.swift index e596a16a..a9303f6f 100644 --- a/ios/Classes/VideoView/FLVideoView.swift +++ b/ios/Classes/VideoView/FLVideoView.swift @@ -18,6 +18,7 @@ class FLVideoView: NSObject, FlutterPlatformView { } methodChannel = FlutterMethodChannel(name: "video_view_\(viewId)_method_channel", binaryMessenger: messenger) _view = VTVideoView() + _view.clipsToBounds = true; super.init() methodChannel.setMethodCallHandler { [weak self] (call, result) in @@ -40,7 +41,8 @@ class FLVideoView: NSObject, FlutterPlatformView { do { let participantId: String? = try flutterArguments.asDictionary(argKey: "participant_id").decode() let mediaStreamId: String? = try flutterArguments.asDictionary(argKey: "media_stream_id").decode() - try attach(participantId: participantId, mediaStreamId: mediaStreamId) + let scaleType: String? = try flutterArguments.asDictionary(argKey: "scale_type").decode() + try attach(participantId: participantId, mediaStreamId: mediaStreamId, scaleType: scaleType) } catch { completionHandler.failure(error) } @@ -65,7 +67,7 @@ class FLVideoView: NSObject, FlutterPlatformView { completionHandler.success(flutterConvertible: false) // TODO: Implement this properly } - private func attach(participantId: String?, mediaStreamId: String?) throws { + private func attach(participantId: String?, mediaStreamId: String?, scaleType: String?) throws { guard let participantId = participantId, participantId != "", let mediaStreamId = mediaStreamId, mediaStreamId != "", @@ -78,8 +80,20 @@ class FLVideoView: NSObject, FlutterPlatformView { _view.unattach() return } + updateScaleType(view: _view, scaleType: scaleType) _view.attach(participant: participantObject, stream: mediaStreamObject) } + + private func updateScaleType(view: VTVideoView, scaleType: String?, animated: Bool = false) { + switch scaleType { + case "SCALE_TYPE_FILL": + view.contentFill(true, animated: animated) + case "SCALE_TYPE_FIT": + view.contentFill(false, animated: animated) + default: + break + } + } } extension FLVideoView: FlutterBinding { diff --git a/lib/dolbyio_comms_sdk_flutter.dart b/lib/dolbyio_comms_sdk_flutter.dart index 4a29a5fa..1a76e126 100644 --- a/lib/dolbyio_comms_sdk_flutter.dart +++ b/lib/dolbyio_comms_sdk_flutter.dart @@ -76,6 +76,7 @@ export 'src/sdk_api/models/spatial.dart' export 'src/sdk_api/models/video_presentation.dart' show VideoPresentation; export 'src/sdk_api/models/streams.dart' show MediaStream, MediaStreamType; export 'src/dolbyio_comms_sdk_native_events.dart' show Event; -export 'src/sdk_api/view/video_view.dart' show VideoView, VideoViewController; +export 'src/sdk_api/view/video_view.dart' + show VideoView, VideoViewController, ScaleType; export 'src/sdk_api/models/audio.dart' show AudioCaptureOptions, AudioCaptureMode, NoiseReduction; diff --git a/lib/src/sdk_api/view/video_view.dart b/lib/src/sdk_api/view/video_view.dart index db53057e..d722b16f 100644 --- a/lib/src/sdk_api/view/video_view.dart +++ b/lib/src/sdk_api/view/video_view.dart @@ -91,19 +91,28 @@ class VideoView extends StatefulWidget { /// @internal final VideoViewController? videoViewController; + /// @internal + final ScaleType? scaleType; + /// A constructor that should be used when the [VideoView] is an element in a collection /// widget, such as a [GridView] or a [ListView]. The constructor requires providing the - /// [Participant] for whom the [MediaStream] should be displayed, the [MediaStream], and an + /// [Participant] for whom the [MediaStream] should be displayed, the [MediaStream], the [ScaleType], and an /// optional [Key]. const VideoView.withMediaStream( - {required this.participant, required this.mediaStream, Key? key}) + {required this.participant, + required this.mediaStream, + this.scaleType = ScaleType.fill, + Key? key}) : videoViewController = null, super(key: key); - /// A constructor that shuold be used when the [VideoView] is used as a stand-alone widget + /// A constructor that should be used when the [VideoView] is used as a stand-alone widget /// outside of collection widgets such as [GridView] or [ListView]. The constructor requires - /// providing the [VideoViewController] and, optionally, a [Key]. - const VideoView({required this.videoViewController, Key? key}) + /// providing the [VideoViewController], the [ScaleType], and an optional [Key]. + const VideoView( + {required this.videoViewController, + this.scaleType = ScaleType.fill, + Key? key}) : participant = null, mediaStream = null, super(key: key); @@ -122,6 +131,7 @@ class _VideoViewState extends State { Participant? _participant; MediaStream? _mediaStream; int viewNumber; + ScaleType? _scaleType; MethodChannel? _methodChannel; _VideoViewState() : viewNumber = _getNextViewNubmer(); @@ -130,6 +140,7 @@ class _VideoViewState extends State { void initState() { widget.videoViewController?._updateState(this); _updateParticipantAndStream(); + _scaleType = widget.scaleType; super.initState(); } @@ -137,6 +148,7 @@ class _VideoViewState extends State { void didUpdateWidget(covariant VideoView oldWidget) { widget.videoViewController?._updateState(this); _updateParticipantAndStream(); + _scaleType = widget.scaleType; super.didUpdateWidget(oldWidget); } @@ -165,6 +177,11 @@ class _VideoViewState extends State { creationParams["media_stream_label"] = mediaStreamLabel; } + final scaleType = _scaleType?._value; + if (scaleType != null) { + creationParams["scale_type"] = scaleType; + } + if (defaultTargetPlatform == TargetPlatform.android) { _methodChannel?.invokeMethod("attach", creationParams); @@ -264,3 +281,16 @@ class _VideoViewState extends State { return Future.error("The VideoView has not been instantiated yet."); } } + +/// The ScaleType enum lets you select how you want to display a video stream in the VideoView area. +enum ScaleType { + /// Modifies the hight and width of a video stream to match the VideoView area. + fill('SCALE_TYPE_FILL'), + + /// Scales a video stream to fit the VideoView area but keeping the video aspect ratio. + fit('SCALE_TYPE_FIT'); + + final String _value; + + const ScaleType(this._value); +} diff --git a/pubspec.yaml b/pubspec.yaml index 6a9463cf..291b2bbc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: dolbyio_comms_sdk_flutter description: > Dolby.io Communications SDK for Flutter allows you to create high-quality video conferencing applications for multiple platforms using a single codebase. -version: 3.8.2-beta.1 +version: 3.8.2-beta.2 homepage: https://github.com/DolbyIO/comms-sdk-flutter environment: diff --git a/scripts/run-mocked-integration-tests-android.sh b/scripts/run-mocked-integration-tests-android.sh index 892aa10a..426a18d7 100755 --- a/scripts/run-mocked-integration-tests-android.sh +++ b/scripts/run-mocked-integration-tests-android.sh @@ -21,7 +21,8 @@ avdmanager list avd echo "Create system image: $system_image" echo "no" | avdmanager --verbose create avd --force --name $device_name --abi "default/x86" --package "$system_image" -echo "disk.dataPartition.size=1024MB" >> ~/.android/avd/$device_name.avd/config.ini +echo "disk.dataPartition.size=8G" >> ~/.android/avd/$device_name.avd/config.ini +echo "hw.ramSize = 3.072MB" >> ~/.android/avd/$device_name.avd/config.ini touch ~/.android/emu-update-last-check.ini ls -la ~/.android/ diff --git a/test_app/integration_tests/android_mocks/src/main/java/com/voxeet/sdk/views/VideoView.java b/test_app/integration_tests/android_mocks/src/main/java/com/voxeet/sdk/views/VideoView.java index 8ee4bc27..92e32a7e 100644 --- a/test_app/integration_tests/android_mocks/src/main/java/com/voxeet/sdk/views/VideoView.java +++ b/test_app/integration_tests/android_mocks/src/main/java/com/voxeet/sdk/views/VideoView.java @@ -61,4 +61,12 @@ public void attach(@NotNull String participantId, @NotNull MediaStream mediaStre this.peerId = participantId; this.stream = mediaStream; } + + public void setVideoFill() { + + } + + public void setVideoFit() { + + } } diff --git a/test_app/integration_tests/ios_mocks/VoxeetSDKMock/Classes/VTVideoView.swift b/test_app/integration_tests/ios_mocks/VoxeetSDKMock/Classes/VTVideoView.swift index 7357001e..5fbbcd20 100644 --- a/test_app/integration_tests/ios_mocks/VoxeetSDKMock/Classes/VTVideoView.swift +++ b/test_app/integration_tests/ios_mocks/VoxeetSDKMock/Classes/VTVideoView.swift @@ -16,4 +16,8 @@ open class VTVideoView: UIView { public func unattach() { fatalError("UnImplemented") } + + public func contentFill(_ fill: Bool, animated: Bool) { + fatalError("UnImplemented") + } } diff --git a/test_app/ios/Podfile.lock b/test_app/ios/Podfile.lock index 601b7620..a3eef4f5 100644 --- a/test_app/ios/Podfile.lock +++ b/test_app/ios/Podfile.lock @@ -41,11 +41,12 @@ PODS: - Flutter - permission_handler_apple (9.0.4): - Flutter - - SDWebImage (5.15.6): - - SDWebImage/Core (= 5.15.6) - - SDWebImage/Core (5.15.6) - - shared_preferences_ios (0.0.1): + - SDWebImage (5.15.7): + - SDWebImage/Core (= 5.15.7) + - SDWebImage/Core (5.15.7) + - shared_preferences_foundation (0.0.1): - Flutter + - FlutterMacOS - SwiftyGif (5.4.4) - VoxeetSDK (3.8.3) @@ -55,7 +56,7 @@ DEPENDENCIES: - Flutter (from `Flutter`) - integration_test (from `.symlinks/plugins/integration_test/ios`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - - shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`) + - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`) SPEC REPOS: trunk: @@ -76,22 +77,22 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/integration_test/ios" permission_handler_apple: :path: ".symlinks/plugins/permission_handler_apple/ios" - shared_preferences_ios: - :path: ".symlinks/plugins/shared_preferences_ios/ios" + shared_preferences_foundation: + :path: ".symlinks/plugins/shared_preferences_foundation/ios" SPEC CHECKSUMS: DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 dolbyio_comms_sdk_flutter: 133e16950e406a6f6ee4f786a835fc6e01bb9f95 - file_picker: 817ab1d8cd2da9d2da412a417162deee3500fc95 + file_picker: ce3938a0df3cc1ef404671531facef740d03f920 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 integration_test: a1e7d09bd98eca2fc37aefd79d4f41ad37bdbbe5 permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce - SDWebImage: d47d81bea8a77187896b620dc79c3c528e8906b9 - shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad + SDWebImage: 25bac438318faf37e35650619ebc288a9061d292 + shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472 SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f VoxeetSDK: 164aa55773192104d4a57a6952507722330d15f1 PODFILE CHECKSUM: ad35eb4c4f8efa60cf39d5ae575517a0e24a77af -COCOAPODS: 1.11.3 +COCOAPODS: 1.12.0 diff --git a/test_app/pubspec.lock b/test_app/pubspec.lock index a70ddfae..91982829 100644 --- a/test_app/pubspec.lock +++ b/test_app/pubspec.lock @@ -71,7 +71,7 @@ packages: path: ".." relative: true source: path - version: "3.8.2-beta.1" + version: "3.8.2-beta.2" fake_async: dependency: transitive description: diff --git a/test_app/pubspec.yaml b/test_app/pubspec.yaml index 59414c80..88f14165 100644 --- a/test_app/pubspec.yaml +++ b/test_app/pubspec.yaml @@ -1,7 +1,7 @@ name: dolbyio_comms_sdk_flutter_example description: Demonstrates how to use the dolbyio_comms_sdk_flutter plugin. -version: 3.8.2+1 +version: 3.8.2+2 # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages.