Skip to content

Commit

Permalink
Merge pull request #779 from 100mslive/develop
Browse files Browse the repository at this point in the history
Release 0.7.4: Develop to main
  • Loading branch information
ygit authored Jul 29, 2022
2 parents ee6de09 + db0f6ca commit f2e2ce4
Show file tree
Hide file tree
Showing 457 changed files with 9,176 additions and 2,494 deletions.
5 changes: 4 additions & 1 deletion .pubignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ example/android/fastlane/Pluginfile
example/android/fastlane/README.md
example/android/fastlane/report.xml
example/android/build/
example/android/flutter-hms-4aea6d38fd2a.json

example/ios/fastlane/Appfile
example/ios/fastlane/Fastfile
example/ios/fastlane/Pluginfile
example/ios/fastlane/README.md
example/ios/fastlane/report.xml
example/ios/pods/
example/ios/flutter-hms-4aea6d38fd2a.json

example/android/app/google-services.json
example/ios/Runner/GoogleService-Info.plist
Expand All @@ -24,4 +26,5 @@ example/lib/firebase_options.dart
mobx-example-app
example_riverpod
demo_app_with_100ms_and_bloc
demo_with_getx_and_100ms
demo_with_getx_and_100ms
sample\ apps/
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## 0.7.4 - 2022-07-29

### Added

- Added APIs to stream device audio in different modes
- Added APIs to view and change the output speaker selected by the SDK to playout
- setAudioMode API to change the Audio out mode manually between in-call volume and media volume

### Fixed

- Calling `switchCamera` API leads to triggering of onSuccess callback twice
- onRoomUpdate with type `HMSRoomUpdate.ROOM_PEER_COUNT_UPDATED` not getting called when peer count changes in the room
- Peer not able to publish tracks when updated to WebRTC from HLS if rejoins after a reconnection in WebRTC Mode

### Changed

- `HMSHLSConfig` is now an optional parameter while calling startHLSStreaming and stopHLSStreaming
- The `meetingUrl` parameter is optional while creating the `HMSHLSMeetingURLVariant` instance for HMSHLSConfig. If nothing is provided HMS system will take the default meetingUrl for starting HLS stream
- changeRoleForce permission in HMSRole is now removed and no longer used
- recording permission in HMSRole is now broken into - `browserRecording` and `rtmpStreaming`
- streaming permission in HMSRole is now `hlsStreaming`


## 0.7.3 - 2022-06-23
- Added support for iOS Screenshare
- Added `HMSHLSRecordingConfig` to perform recording while HLS Streaming
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ android {
}

dependencies {
implementation 'com.github.100mslive.android-sdk:lib:2.4.2'
implementation 'com.github.100mslive.android-sdk:lib:2.4.7'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
implementation "org.jetbrains.kotlin:kotlin-script-runtime:1.5.0"
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<uses-permission android:name="android.permission.RECORD_AUDIO"/>

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH" />

<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

Expand Down
2 changes: 2 additions & 0 deletions android/src/main/kotlin/live/hms/hmssdk_flutter/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package live.hms.hmssdk_flutter
class Constants {
companion object{
const val SCREEN_SHARE_INTENT_REQUEST_CODE = 192

const val AUDIO_SHARE_INTENT_REQUEST_CODE = 182
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ package live.hms.hmssdk_flutter

import live.hms.video.error.HMSException
import live.hms.video.sdk.models.HMSHLSVariant
import java.text.SimpleDateFormat

class HMSHLSVariantExtension {
companion object{
fun toDictionary(hmshlsVariant: HMSHLSVariant?):HashMap<String,Any>?{
val args=HashMap<String,Any>()
if (hmshlsVariant == null)return null
args.put("hls_stream_url",hmshlsVariant.hlsStreamUrl?:"")
args.put("meeting_url",hmshlsVariant.meetingUrl?:"")
args.put("metadata",hmshlsVariant.metadata?:"")
args.put("started_at",hmshlsVariant.startedAt?:-1)
args["hls_stream_url"] = hmshlsVariant.hlsStreamUrl?:""
args["meeting_url"] = hmshlsVariant.meetingUrl?:""
args["metadata"] = hmshlsVariant.metadata?:""
args["started_at"] =
SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmshlsVariant.startedAt).toString()
return args
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class HMSVideoTrackSettingsExtension {
map["video_codec"] = getValueOfHMSVideoCodec(hmsVideoTrackSettings?.codec)!!
map["max_bit_rate"] = hmsVideoTrackSettings?.maxBitRate!!
map["max_frame_rate"] = hmsVideoTrackSettings.maxFrameRate
map["disable_auto_resize"] = hmsVideoTrackSettings.disableAutoResize
return map
}

Expand Down
117 changes: 115 additions & 2 deletions android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.content.Intent
import android.media.projection.MediaProjectionManager
import android.os.Build
import androidx.annotation.NonNull

import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.activity.ActivityAware
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
Expand All @@ -22,6 +21,7 @@ import kotlinx.coroutines.launch
import live.hms.hmssdk_flutter.hms_role_components.AudioParamsExtension
import live.hms.hmssdk_flutter.hms_role_components.VideoParamsExtension
import live.hms.hmssdk_flutter.views.HMSVideoViewFactory
import live.hms.video.audio.HMSAudioManager.*
import live.hms.video.connection.stats.*
import live.hms.video.error.HMSException
import live.hms.video.media.codec.HMSAudioCodec
Expand All @@ -32,12 +32,14 @@ import live.hms.video.media.settings.HMSVideoTrackSettings
import live.hms.video.media.tracks.*
import live.hms.video.sdk.*
import live.hms.video.sdk.models.*
import live.hms.video.sdk.models.enums.AudioMixingMode
import live.hms.video.sdk.models.enums.HMSPeerUpdate
import live.hms.video.sdk.models.enums.HMSRoomUpdate
import live.hms.video.sdk.models.enums.HMSTrackUpdate
import live.hms.video.sdk.models.role.HMSRole
import live.hms.video.sdk.models.trackchangerequest.HMSChangeTrackStateRequest
import live.hms.video.utils.HMSLogger
import live.hms.video.audio.HMSAudioManager.*


/** HmssdkFlutterPlugin */
Expand Down Expand Up @@ -165,6 +167,12 @@ class HmssdkFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
"start_stats_listener", "remove_stats_listener" -> {
statsListenerAction(call, result)
}
"get_audio_devices_list","get_current_audio_device","switch_audio_output" -> {
HMSAudioDeviceAction.audioDeviceActions(call,result,hmssdk)
}
"start_audio_share","stop_audio_share","set_audio_mixing_mode"->{
audioShare(call,result)
}
else -> {
result.notImplemented()
}
Expand Down Expand Up @@ -290,6 +298,25 @@ class HmssdkFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
}
}

private fun audioShare(call: MethodCall,result: Result){
when (call.method) {
"start_audio_share" -> {
startAudioShare(call,result)
}

"stop_audio_share" -> {
stopAudioShare(result)
}
"set_audio_mixing_mode" -> {
setAudioMixingMode(call,result)
}

else -> {
result.notImplemented()
}
}
}

override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
channel.setMethodCallHandler(null)
meetingEventChannel.setStreamHandler(null)
Expand Down Expand Up @@ -318,7 +345,9 @@ class HmssdkFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
val config = getConfig(call)

hmssdk.join(config, this.hmsUpdateListener)
hmssdk.setAudioDeviceChangeListener(audioDeviceChangeListener)
result.success(null)

}

private fun getConfig(
Expand Down Expand Up @@ -494,6 +523,7 @@ class HmssdkFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
this.requestChange!!,
hmsActionResultListener = HMSCommonAction.getActionListener(result)
)
requestChange = null
}

var hmsAudioListener = object : HMSAudioListener {
Expand Down Expand Up @@ -932,7 +962,7 @@ class HmssdkFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
}

private fun changeName(call: MethodCall, result: Result) {
val name = call.argument<String>("name");
val name = call.argument<String>("name")
hmssdk.changeName(
name = name!!,
hmsActionResultListener = HMSCommonAction.getActionListener(result)
Expand Down Expand Up @@ -972,10 +1002,58 @@ class HmssdkFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
}, data)
}



private fun stopScreenShare(result: Result) {
hmssdk.stopScreenshare(HMSCommonAction.getActionListener(result))
}

private var androidAudioShareResult: Result? = null
private var mode: String? = "TALK_AND_MUSIC"
private fun startAudioShare(call: MethodCall,result: Result){
androidAudioShareResult = result
mode = call.argument<String>("audio_mixing_mode")
val mediaProjectionManager: MediaProjectionManager? = activity.getSystemService(
Context.MEDIA_PROJECTION_SERVICE
) as MediaProjectionManager
activity.startActivityForResult(
mediaProjectionManager?.createScreenCaptureIntent(),
Constants.AUDIO_SHARE_INTENT_REQUEST_CODE
)
}

fun requestAudioShare(data: Intent?) {

hmssdk.startAudioshare(object : HMSActionResultListener {
override fun onError(error: HMSException) {
CoroutineScope(Dispatchers.Main).launch {
androidAudioShareResult?.success(HMSExceptionExtension.toDictionary(error))
androidAudioShareResult = null
}
}

override fun onSuccess() {
CoroutineScope(Dispatchers.Main).launch {
androidAudioShareResult?.success(null)
androidAudioShareResult = null
}
}
},data, audioMixingMode = AudioMixingMode.valueOf(mode!!))
}

private fun stopAudioShare(result: Result){
hmssdk.stopAudioshare(HMSCommonAction.getActionListener(result))
}

private fun setAudioMixingMode(call: MethodCall,result: Result){
val mode = call.argument<String>("audio_mixing_mode")
if(mode!=null) {
val audioMixingMode: AudioMixingMode = AudioMixingMode.valueOf(mode)
hmssdk.setAudioMixingMode(audioMixingMode)
}

}


private fun getAllTracks(call: MethodCall, result: Result) {
val peerId: String? = call.argument<String>("peer_id")
Expand Down Expand Up @@ -1098,4 +1176,39 @@ class HmssdkFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,

}

private val audioDeviceChangeListener = object: AudioManagerDeviceChangeListener {
override fun onAudioDeviceChanged(p0: AudioDevice?, p1: Set<AudioDevice>?) {
val args = HashMap<String, Any?>()
args["event_name"] = "on_audio_device_changed"
val dict = HashMap<String, Any?>()
if (p0!=null){
dict["current_audio_device"] = p0.name
}
if(p1!=null){
val audioDevicesList = ArrayList<String>();
for (device in hmssdk.getAudioDevicesList()){
audioDevicesList.add(device.name);
}
dict["available_audio_device"] = audioDevicesList
}
args["data"] = dict
if (args["data"] != null)
CoroutineScope(Dispatchers.Main).launch {
eventSink?.success(args)
}
}

override fun onError(e: HMSException?){

val args = HashMap<String, Any?>()
args.put("event_name", "on_error")
args.put("data", HMSExceptionExtension.toDictionary(e))

if (args["data"] != null)
CoroutineScope(Dispatchers.Main).launch {
previewSink?.success(args)
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ class PermissionParamsExtension {
fun toDictionary(permissionsParams: PermissionsParams?):HashMap<String,Any>?{
val args=HashMap<String,Any>()
if(permissionsParams==null)return null
args.put("un_mute",permissionsParams.unmute)
args.put("change_role",permissionsParams.changeRole)
args.put("end_room",permissionsParams.endRoom)
args.put("mute",permissionsParams.mute)
args.put("change_role_force",permissionsParams.changeRoleForce)
args.put("remove_others",permissionsParams.removeOthers)
args.put("stop_presentation",permissionsParams.recording)
args["browser_recording"] = permissionsParams.browserRecording
args["change_role"] = permissionsParams.changeRole
args["end_room"] = permissionsParams.endRoom
args["hls_streaming"] = permissionsParams.hlsStreaming
args["mute"] = permissionsParams.mute
args["remove_others"] = permissionsParams.removeOthers
args["rtmp_streaming"] = permissionsParams.rtmpStreaming
args["un_mute"] = permissionsParams.unmute
return args
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package live.hms.hmssdk_flutter
import android.util.Log
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel.Result
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import live.hms.video.audio.HMSAudioManager
import live.hms.video.media.tracks.*
import live.hms.video.sdk.*
import live.hms.video.sdk.models.*



class HMSAudioDeviceAction {
companion object {
fun audioDeviceActions(call: MethodCall, result: Result,hmssdk:HMSSDK) {
when (call.method) {
"get_audio_devices_list" -> {
getAudioDevicesList(call, result,hmssdk)
}
"get_current_audio_device"-> {
getCurrentDevice(call,result,hmssdk)
}
"switch_audio_output" -> {
switchAudioOutput(call,result,hmssdk)
}
else -> {
result.notImplemented()
}
}
}

private fun getAudioDevicesList(call: MethodCall, result: Result,hmssdk:HMSSDK){
val audioDevicesList = ArrayList<String>();
for (device in hmssdk.getAudioDevicesList()){
audioDevicesList.add(device.name);
}
CoroutineScope(Dispatchers.Main).launch {
result.success(audioDevicesList)
}
}

private fun getCurrentDevice(call: MethodCall, result: Result,hmssdk:HMSSDK){
CoroutineScope(Dispatchers.Main).launch {
result.success(hmssdk.getAudioOutputRouteType().name)
}
}

private fun switchAudioOutput(call: MethodCall, result: Result,hmssdk:HMSSDK){
var argument:String? = call.argument<String>("audio_device_name")
if(argument!=null){
var audioDevice:HMSAudioManager.AudioDevice = HMSAudioManager.AudioDevice.valueOf(argument)
hmssdk.switchAudioOutput(audioDevice)
}

}
}
}
Loading

0 comments on commit f2e2ce4

Please sign in to comment.