Skip to content

Commit

Permalink
Merge pull request #260 from 100mslive/develop
Browse files Browse the repository at this point in the history
Develop to main
  • Loading branch information
lavi-moolchandani authored Oct 25, 2021
2 parents f5888e1 + 3ad2b36 commit d07b1a8
Show file tree
Hide file tree
Showing 21 changed files with 20,455 additions and 8,724 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // From node_modules
implementation 'com.github.100mslive:android-sdk:v2.1.2'
implementation 'com.github.100mslive:android-sdk:v2.1.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
}
614 changes: 331 additions & 283 deletions android/src/main/java/com/reactnativehmssdk/HmsDecoder.kt

Large diffs are not rendered by default.

128 changes: 97 additions & 31 deletions android/src/main/java/com/reactnativehmssdk/HmsHelper.kt
Original file line number Diff line number Diff line change
@@ -1,58 +1,105 @@
package com.reactnativehmssdk

import live.hms.video.sdk.models.role.*
import live.hms.video.sdk.models.*
import com.facebook.react.bridge.ReadableMap
import live.hms.video.media.tracks.*
import live.hms.video.sdk.models.*
import live.hms.video.sdk.models.role.*

object HmsHelper {

fun getPeerFromPeerId(peerId: String?, peers: Array<HMSPeer>?): HMSPeer? {
if (peerId != null && peers != null) {
for (peer in peers) {
if (peerId == peer.peerID) {
return peer
fun areAllRequiredKeysAvailable(
map: ReadableMap?,
requiredKeys: Array<Pair<String, String>>
): Boolean {
if (map == null) {
return false
}
for ((key, value) in requiredKeys) {
if (map.hasKey(key)) {
when (value) {
"String" -> {
if (map.getString(key) == null) {
return false
}
}
"Boolean" -> {
if (map.getBoolean(key) == null) {
return false
}
}
"Array" -> {
if (map.getArray(key) == null) {
return false
}
}
"Int" -> {
if (map.getInt(key) == null) {
return false
}
}
"Map" -> {
if (map.getMap(key) == null) {
return false
}
}
}
} else {
return false
}
return null
}
return true
}

fun getRemotePeerFromPeerId(peerId: String?, peers: Array<HMSRemotePeer>?): HMSRemotePeer? {
if (peerId != null && peers != null) {
for (peer in peers) {
if (peerId == peer.peerID) {
return peer
}
fun getPeerFromPeerId(peerId: String?, peers: Array<HMSPeer>?): HMSPeer? {
if (peerId != null && peers != null) {
for (peer in peers) {
if (peerId == peer.peerID) {
return peer
}
}
return null
}
return null
}

fun getRolesFromRoleNames(targetedRoles: ArrayList<String>?, roles: List<HMSRole>?): List<HMSRole> {
val encodedRoles: MutableList<HMSRole> = mutableListOf()
fun getRemotePeerFromPeerId(peerId: String?, peers: Array<HMSRemotePeer>?): HMSRemotePeer? {
if (peerId != null && peers != null) {
for (peer in peers) {
if (peerId == peer.peerID) {
return peer
}
}
}
return null
}

if (targetedRoles != null && roles != null) {
for (role in roles) {
for (targetedRole in targetedRoles) {
if (targetedRole == role.name) {
encodedRoles.add(role)
}
fun getRolesFromRoleNames(
targetedRoles: ArrayList<String>?,
roles: List<HMSRole>?
): List<HMSRole> {
val encodedRoles: MutableList<HMSRole> = mutableListOf()

if (targetedRoles != null && roles != null) {
for (role in roles) {
for (targetedRole in targetedRoles) {
if (targetedRole == role.name) {
encodedRoles.add(role)
}
}
}
return encodedRoles.toList()
}
return encodedRoles.toList()
}

fun getRoleFromRoleName(role: String?, roles: List<HMSRole>?): HMSRole? {
if (role != null && roles!= null) {
for (hmsRole in roles) {
if (role == hmsRole.name) {
return hmsRole
}
fun getRoleFromRoleName(role: String?, roles: List<HMSRole>?): HMSRole? {
if (role != null && roles != null) {
for (hmsRole in roles) {
if (role == hmsRole.name) {
return hmsRole
}
}
return null
}
return null
}

fun getTrackFromTrackId(trackId: String?, remotePeers: Array<HMSRemotePeer>?): HMSTrack? {
if (trackId != null && remotePeers != null) {
Expand All @@ -68,4 +115,23 @@ object HmsHelper {
}
return null
}

fun getLocalTrackFromTrackId(trackId: String?, localPeer: HMSLocalPeer?): HMSTrack? {
if (trackId != null && localPeer != null) {
if (localPeer.audioTrack?.trackId == trackId) {
return localPeer.audioTrack as HMSTrack
}

if (localPeer.videoTrack?.trackId == trackId) {
return localPeer.videoTrack as HMSTrack
}

for (auxTrack in localPeer.auxiliaryTracks) {
if (auxTrack.trackId == trackId) {
return auxTrack
}
}
}
return null
}
}
Loading

0 comments on commit d07b1a8

Please sign in to comment.