Skip to content

Commit

Permalink
Merge pull request #661 from 100mslive/develop
Browse files Browse the repository at this point in the history
Release 0.7.3: Develop to main
  • Loading branch information
ygit authored Jun 23, 2022
2 parents 5df13ee + 2073f5d commit ee6de09
Show file tree
Hide file tree
Showing 404 changed files with 17,421 additions and 1,286 deletions.
5 changes: 5 additions & 0 deletions .pubignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ example/ios/Runner/GoogleService-Info.plist
*.p8
release-apps.sh
example/lib/firebase_options.dart

mobx-example-app
example_riverpod
demo_app_with_100ms_and_bloc
demo_with_getx_and_100ms
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.7.3 - 2022-06-23
- Added support for iOS Screenshare
- Added `HMSHLSRecordingConfig` to perform recording while HLS Streaming
- Updated error callback in `HMSUpdateListener` to `onHMSError`
- Updated to Native Android SDK 2.4.2 & Native iOS SDK 0.3.1

## 0.7.2 - 2022-06-02

- Segregated RTC Stats update notifications from `HMSUpdateListener` into `HMSStatsListener`
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ abstract class HMSUpdateListener {
/// This will be called when there is an error in the system
/// and SDK has already retried to fix the error
/// [error]: the error that occurred
void onError({required HMSException error});
void onHMSError({required HMSException error});
/// This is called when there is a new broadcast message from any other peer in the room
///
Expand Down Expand Up @@ -221,25 +221,26 @@ abstract class HMSUpdateListener {
HMSPeerUpdate
HMSPeerUpdate.peerJoined: A new peer joins the room
HMSPeerUpdate.peerLeft: An existing peer leaves the room
HMSPeerUpdate.roleUpdated
HMSPeerUpdate.metadataChanged
HMSPeerUpdate.nameChanged
HMSPeerUpdate.roleUpdated: When peer role is changed
HMSPeerUpdate.metadataChanged: When peer metadata changed
HMSPeerUpdate.nameChanged: When peer name change
HMSTrackUpdate
HMSTrackUpdate.trackAdded: A new track is added by a remote peer
HMSTrackUpdate.trackRemoved: An existing track is removed from a remote peer
HMSTrackUpdate.trackMuted: An existing track of a remote peer is muted
HMSTrackUpdate.trackUnMuted: An existing track of a remote peer is unmuted
HMSTrackUpdate.trackDegraded
HMSTrackUpdate.trackRestored
HMSTrackUpdate.trackDegraded: When track is degraded
HMSTrackUpdate.trackRestored: When track is restored
HMSRoomUpdate
HMSRoomUpdate.roomMuted
HMSRoomUpdate.roomUnmuted
HMSRoomUpdate.serverRecordingStateUpdated
HMSRoomUpdate.browserRecordingStateUpdated
HMSRoomUpdate.rtmpStreamingStateUpdated
HMSRoomUpdate.hlsStreamingStateUpdated
HMSRoomUpdate.roomMuted: When room is muted
HMSRoomUpdate.roomUnmuted: When room is unmuted
HMSRoomUpdate.serverRecordingStateUpdated: When server recording state is updated
HMSRoomUpdate.browserRecordingStateUpdated: When browser recording state is changed
HMSRoomUpdate.rtmpStreamingStateUpdated: When RTMP is started or stopped
HMSRoomUpdate.hlsStreamingStateUpdated: When HLS is started or stopped
HMSRoomUpdate.hlsRecordingStateUpdated: When hls recording state is updated
```

## 🛤 How to know the type and source of Track?
Expand Down Expand Up @@ -372,7 +373,7 @@ void onMessage({required HMSMessage message}){
abstract class HMSPreviewListener {
//you will get all error updates here
void onError({required HMSException error});
void onHMSError({required HMSException error});
//here you will get a room instance where you are going to join and your own local tracks to render the video by checking the type of trackKind and then using the
//above mentioned VideoView widget
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 32
compileSdkVersion 31

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -37,7 +37,7 @@ android {
}

dependencies {
implementation 'com.github.100mslive.android-sdk:lib:2.3.9'
implementation 'com.github.100mslive.android-sdk:lib:2.4.2'
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class HMSRoomExtension {
hashMap["browser_recording_state"] = HMSStreamingState.toDictionary(room.browserRecordingState)
hashMap["server_recording_state"] = HMSStreamingState.toDictionary(room.serverRecordingState)
hashMap["hls_streaming_state"] = HMSStreamingState.toDictionary(room.hlsStreamingState)
hashMap["hls_recording_state"] = HMSStreamingState.toDictionary(room.hlsRecordingState)
hashMap["peer_count"] = room.peerCount
hashMap["started_at"] = room.startedAt?:-1
hashMap["session_id"] = room.sessionId
Expand All @@ -40,6 +41,7 @@ class HMSRoomExtension {
HMSRoomUpdate.RTMP_STREAMING_STATE_UPDATED-> "rtmp_streaming_state_updated"
HMSRoomUpdate.HLS_STREAMING_STATE_UPDATED-> "hls_streaming_state_updated"
HMSRoomUpdate.BROWSER_RECORDING_STATE_UPDATED-> "browser_recording_state_updated"
HMSRoomUpdate.HLS_RECORDING_STATE_UPDATED-> "hls_recording_state_updated"
HMSRoomUpdate.ROOM_NAME_UPDATED->"room_name_updated"
HMSRoomUpdate.ROOM_PEER_COUNT_UPDATED->"room_peer_count_updated"
else-> "defaultUpdate"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

import live.hms.hmssdk_flutter.HMSExceptionExtension
import live.hms.hmssdk_flutter.HMSHLSVariantExtension
import live.hms.video.sdk.models.HMSBrowserRecordingState
import live.hms.video.sdk.models.HMSHLSStreamingState
import live.hms.video.sdk.models.HMSRtmpStreamingState
import live.hms.video.sdk.models.HMSServerRecordingState
import live.hms.video.sdk.models.*
import java.text.SimpleDateFormat

class HMSStreamingState {
companion object{
Expand All @@ -13,6 +11,8 @@ class HMSStreamingState {
if(hmsRtmpStreamingState == null)return null
map["running"] = hmsRtmpStreamingState.running
map["error"] = HMSExceptionExtension.toDictionary(hmsRtmpStreamingState.error)
if(hmsRtmpStreamingState.running)
map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsRtmpStreamingState.startedAt).toString()
return map
}

Expand All @@ -21,6 +21,8 @@ class HMSStreamingState {
if(hmsServerRecordingState == null)return null
map["running"] = hmsServerRecordingState.running
map["error"] = HMSExceptionExtension.toDictionary(hmsServerRecordingState.error)
if(hmsServerRecordingState.running)
map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsServerRecordingState.startedAt).toString()
return map
}

Expand All @@ -29,6 +31,8 @@ class HMSStreamingState {
if(hmsBrowserRecordingState == null)return null
map["running"] = hmsBrowserRecordingState.running
map["error"] = HMSExceptionExtension.toDictionary(hmsBrowserRecordingState.error)
if(hmsBrowserRecordingState.running)
map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsBrowserRecordingState.startedAt).toString()
return map
}

Expand All @@ -44,6 +48,15 @@ class HMSStreamingState {
return map
}

fun toDictionary(hmsHlsRecordingState: HmsHlsRecordingState?):HashMap<String,Any?>?{
val map = HashMap<String,Any?>()
if(hmsHlsRecordingState == null)return null
map["running"] = hmsHlsRecordingState.running
if(hmsHlsRecordingState.running == true)
map["started_at"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsHlsRecordingState.startedAt).toString()
return map
}

}

}
138 changes: 60 additions & 78 deletions android/src/main/kotlin/live/hms/hmssdk_flutter/HmssdkFlutterPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class HmssdkFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
lateinit var hmssdk: HMSSDK
private lateinit var hmsVideoFactory: HMSVideoViewFactory
private var requestChange: HMSRoleChangeRequest? = null
private var isStatsActive: Boolean = false

companion object {
var hmssdkFlutterPlugin: HmssdkFlutterPlugin? = null
Expand Down Expand Up @@ -275,20 +274,14 @@ class HmssdkFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
}
}

private var isRTCStatsListenerInit = false

private fun statsListenerAction(call: MethodCall, result: Result){
when (call.method) {
"start_stats_listener" -> {
if (!isRTCStatsListenerInit) {
hmssdk.addRtcStatsObserver(this.hmsStatsListener)
isRTCStatsListenerInit = true
}
isStatsActive = true
hmssdk.addRtcStatsObserver(this.hmsStatsListener)
}

"remove_stats_listener" -> {
isStatsActive = false
hmssdk.removeRtcStatsObserver()
}

else -> {
Expand Down Expand Up @@ -1012,19 +1005,17 @@ class HmssdkFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
hmsTrack: HMSTrack?,
hmsPeer: HMSPeer?
) {
if(isStatsActive) {
val args = HashMap<String, Any?>()
args["event_name"] = "on_remote_video_stats"
args["data"] = HMSRtcStatsExtension.toDictionary(
hmsRemoteVideoStats = videoStats,
peer = hmsPeer,
track = hmsTrack
)

if (args["data"] != null)
CoroutineScope(Dispatchers.Main).launch {
rtcSink?.success(args)
}
val args = HashMap<String, Any?>()
args["event_name"] = "on_remote_video_stats"
args["data"] = HMSRtcStatsExtension.toDictionary(
hmsRemoteVideoStats = videoStats,
peer = hmsPeer,
track = hmsTrack
)

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

Expand All @@ -1033,20 +1024,17 @@ class HmssdkFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
hmsTrack: HMSTrack?,
hmsPeer: HMSPeer?
) {
if(isStatsActive) {
val args = HashMap<String, Any?>()
args["event_name"] = "on_remote_audio_stats"
args["data"] = HMSRtcStatsExtension.toDictionary(
hmsRemoteAudioStats = audioStats,
peer = hmsPeer,
track = hmsTrack
)


if (args["data"] != null)
CoroutineScope(Dispatchers.Main).launch {
rtcSink?.success(args)
}
val args = HashMap<String, Any?>()
args["event_name"] = "on_remote_audio_stats"
args["data"] = HMSRtcStatsExtension.toDictionary(
hmsRemoteAudioStats = audioStats,
peer = hmsPeer,
track = hmsTrack
)

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

Expand All @@ -1055,20 +1043,17 @@ class HmssdkFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
hmsTrack: HMSTrack?,
hmsPeer: HMSPeer?
) {
if(isStatsActive) {
val args = HashMap<String, Any?>()
args["event_name"] = "on_local_video_stats"
args["data"] = HMSRtcStatsExtension.toDictionary(
hmsLocalVideoStats = videoStats,
peer = getLocalPeer(),
track = hmsTrack
)

val args = HashMap<String, Any?>()
args["event_name"] = "on_local_video_stats"
args["data"] = HMSRtcStatsExtension.toDictionary(
hmsLocalVideoStats = videoStats,
peer = getLocalPeer(),
track = hmsTrack
)

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

Expand All @@ -1077,41 +1062,38 @@ class HmssdkFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
hmsTrack: HMSTrack?,
hmsPeer: HMSPeer?
) {
if(isStatsActive) {
val args = HashMap<String, Any?>()
args["event_name"] = "on_local_audio_stats"
args["data"] = HMSRtcStatsExtension.toDictionary(
hmsLocalAudioStats = audioStats,
peer = getLocalPeer(),
track = hmsTrack
)
val args = HashMap<String, Any?>()
args["event_name"] = "on_local_audio_stats"
args["data"] = HMSRtcStatsExtension.toDictionary(
hmsLocalAudioStats = audioStats,
peer = getLocalPeer(),
track = hmsTrack
)

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

override fun onRTCStats(rtcStats: HMSRTCStatsReport) {
if(isStatsActive) {
val args = HashMap<String, Any?>()
args["event_name"] = "on_rtc_stats"
val dict = HashMap<String, Any?>()
dict["bytes_sent"] = rtcStats.combined.bytesSent
dict["bytes_received"] = rtcStats.combined.bitrateReceived
dict["bitrate_sent"] = rtcStats.combined.bitrateSent
dict["packets_received"] = rtcStats.combined.packetsReceived
dict["packets_lost"] = rtcStats.combined.packetsLost
dict["bitrate_received"] = rtcStats.combined.bitrateReceived
dict["round_trip_time"] = rtcStats.combined.roundTripTime

args["data"] = dict
if (args["data"] != null)
CoroutineScope(Dispatchers.Main).launch {
rtcSink?.success(args)
}
val args = HashMap<String, Any?>()
args["event_name"] = "on_rtc_stats"
val dict = HashMap<String, Any?>()
dict["bytes_sent"] = rtcStats.combined.bytesSent
dict["bytes_received"] = rtcStats.combined.bitrateReceived
dict["bitrate_sent"] = rtcStats.combined.bitrateSent
dict["packets_received"] = rtcStats.combined.packetsReceived
dict["packets_lost"] = rtcStats.combined.packetsLost
dict["bitrate_received"] = rtcStats.combined.bitrateReceived
dict["round_trip_time"] = rtcStats.combined.roundTripTime

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

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import live.hms.video.sdk.models.HMSHLSConfig
import live.hms.video.sdk.models.HMSHLSMeetingURLVariant
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel.Result
import live.hms.video.sdk.models.HMSHlsRecordingConfig

class HMSHLSAction {

Expand All @@ -28,19 +29,27 @@ class HMSHLSAction {

private fun hlsStreaming(call: MethodCall, result: Result,hmssdk:HMSSDK) {
val meetingUrlVariantsList = call.argument<List<Map<String,String>>>("meeting_url_variants")
val meetingUrlVariant1 : ArrayList<HMSHLSMeetingURLVariant> = ArrayList()
val recordingConfig = call.argument<Map<String,Boolean>>("recording_config") ?: null
val meetingUrlVariant : ArrayList<HMSHLSMeetingURLVariant> = ArrayList()

meetingUrlVariantsList?.forEach {
meetingUrlVariant1.add(
meetingUrlVariant.add(
HMSHLSMeetingURLVariant(
meetingUrl = it["meeting_url"]!!,
metadata = it["meta_data"]!!
)
)
}

val hlsConfig = HMSHLSConfig(meetingUrlVariant1)

val hlsConfig = if(recordingConfig!=null) {
val hmsHLSRecordingConfig = HMSHlsRecordingConfig(
singleFilePerLayer = recordingConfig?.get("single_file_per_layer")!!,
videoOnDemand = recordingConfig?.get("video_on_demand")!!
)
HMSHLSConfig(meetingUrlVariant, hmsHLSRecordingConfig)
}else{
HMSHLSConfig(meetingUrlVariant)
}
hmssdk.startHLSStreaming(config = hlsConfig, hmsActionResultListener = HMSCommonAction.getActionListener(result))
}

Expand Down
Loading

0 comments on commit ee6de09

Please sign in to comment.