Skip to content

Commit

Permalink
Release 1.10.0: Develop to main (#1348)
Browse files Browse the repository at this point in the history
# Description

- Release 1.10.0: Develop to main

### Pre-launch Checklist

- [x] The [Documentation] is updated accordingly, or this PR doesn't
require it.
- [x] I have updated the `ExampleAppChangelog.txt` file with relevant
changes.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making, or this PR is
test-exempt.
- [x] All existing and new tests are passing.

<!-- Links -->

[Documentation]: https://www.100ms.live/docs
  • Loading branch information
ygit authored Mar 5, 2024
2 parents f51bb1b + d80b480 commit 002f076
Show file tree
Hide file tree
Showing 68 changed files with 3,356 additions and 1,006 deletions.
12 changes: 6 additions & 6 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
version: 0.1
cli:
version: 1.20.0
version: 1.20.1
plugins:
sources:
- id: trunk
ref: v1.4.3
ref: v1.4.4
uri: https://github.com/trunk-io/plugins
lint:
disabled:
- osv-scanner
enabled:
- [email protected].26
- [email protected].27
- [email protected]
- [email protected]
- [email protected].22
- [email protected].30
- [email protected]
- trufflehog@3.67.6
- trufflehog@3.68.4
- [email protected]
- [email protected]
- ktlint@1.1.1
- ktlint@1.2.1
- [email protected]
- [email protected]
- [email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import android.view.LayoutInflater
import android.widget.FrameLayout
import androidx.media3.common.Player
import androidx.media3.common.VideoSize
import androidx.media3.ui.AspectRatioFrameLayout.RESIZE_MODE_FIT
import androidx.media3.ui.AspectRatioFrameLayout.RESIZE_MODE_ZOOM
import androidx.media3.ui.PlayerView
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.ReactContext
Expand Down Expand Up @@ -133,26 +131,13 @@ class HMSHLSPlayer(context: ReactContext) : FrameLayout(context) {

localPlayerView?.player?.addListener(
object : Player.Listener {
override fun onSurfaceSizeChanged(
width: Int,
height: Int,
) {
super.onSurfaceSizeChanged(width, height)
}

override fun onVideoSizeChanged(videoSize: VideoSize) {
super.onVideoSizeChanged(videoSize)

if (videoSize.height != 0 && videoSize.width != 0) {
val width = videoSize.width.toDouble()
val height = videoSize.height.toDouble()

if (width >= height) {
playerView?.resizeMode = RESIZE_MODE_FIT
} else {
playerView?.resizeMode = RESIZE_MODE_ZOOM
}

val data = Arguments.createMap()
data.putDouble("width", width)
data.putDouble("height", height)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ class HMSManager(reactContext: ReactApplicationContext) :
hms?.stopRtmpAndRecording(callback)
}

// region - HLS Streaming

@ReactMethod
fun startHLSStreaming(
data: ReadableMap,
Expand All @@ -550,6 +552,24 @@ class HMSManager(reactContext: ReactApplicationContext) :
hms?.stopHLSStreaming(callback)
}

@ReactMethod
fun sendHLSTimedMetadata(
data: ReadableMap,
callback: Promise?,
) {
val rnSDK = HMSHelper.getHms(data, hmsCollection)
rnSDK?.let { sdk ->
sdk.sendHLSTimedMetadata(data, callback)
return
}
callback?.reject(
"6004",
"HMS SDK not initialized",
)
}

// endregion

@ReactMethod
fun changeName(
data: ReadableMap,
Expand Down Expand Up @@ -1396,6 +1416,24 @@ class HMSManager(reactContext: ReactApplicationContext) :
"HMS SDK not initialized",
)
}

@ReactMethod
fun fetchLeaderboard(
data: ReadableMap,
promise: Promise?,
) {
val rnSDK = HMSHelper.getHms(data, hmsCollection)
rnSDK?.let { sdk ->
sdk.interactivityCenter?.let { center ->
center.fetchLeaderboard(data, promise)
return
}
}
promise?.reject(
"6004",
"HMS SDK not initialized",
)
}
// endregion

// region ActivityLifecycleCallbacks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,8 @@ class HMSRNSDK(
)
}

// region - HLS Streaming

fun startHLSStreaming(
data: ReadableMap,
callback: Promise?,
Expand Down Expand Up @@ -1614,6 +1616,42 @@ class HMSRNSDK(
)
}

fun sendHLSTimedMetadata(
data: ReadableMap,
callback: Promise?,
) {
val metadataArrayList = data.getArray("metadata")?.toArrayList() as? ArrayList<HashMap<String, Any>>

if (metadataArrayList == null) {
val errorMessage = "sendHLSTimedMetadata: INVALID_METADATA"
rejectCallback(callback, errorMessage)
return
}

val metadata =
metadataArrayList.mapNotNull { map ->
val payload = map["payload"] as? String
val duration = map["duration"] as? Double

payload?.let { HMSHLSTimedMetadata(it, duration?.toLong() ?: 1) }
}

hmsSDK?.setHlsSessionMetadata(
metadata,
object : HMSActionResultListener {
override fun onSuccess() {
callback?.resolve(true)
}

override fun onError(error: HMSException) {
callback?.reject(error.code.toString(), error.message)
}
},
)
}

// endregion

fun changeName(
data: ReadableMap,
callback: Promise?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import live.hms.video.polls.models.answer.HMSPollQuestionAnswer
import live.hms.video.polls.models.answer.HmsPollAnswer
import live.hms.video.polls.models.answer.PollAnswerItem
import live.hms.video.polls.models.answer.PollAnswerResponse
import live.hms.video.polls.models.network.HMSPollResponsePeerInfo
import live.hms.video.polls.models.question.HMSPollQuestion
import live.hms.video.polls.models.question.HMSPollQuestionOption
import live.hms.video.polls.network.HMSPollLeaderboardEntry
import live.hms.video.polls.network.HMSPollLeaderboardSummary
import live.hms.video.polls.network.PollLeaderboardResponse
import live.hms.video.polls.network.PollResultsDisplay

object HMSInteractivityDecoder {
Expand Down Expand Up @@ -310,6 +314,87 @@ object HMSInteractivityDecoder {
return results
}

fun getPollLeaderboardResponse(pollLeaderboardResponse: PollLeaderboardResponse): WritableMap {
val results = Arguments.createMap()

pollLeaderboardResponse.hasNext?.let {
results.putBoolean("hasNext", it)
}
pollLeaderboardResponse.summary?.let {
results.putMap("summary", getHMSPollLeaderboardSummary(it))
}
pollLeaderboardResponse.entries?.let {
results.putArray("entries", getHMSPollLeaderboardEntries(it))
}
return results
}

private fun getHMSPollLeaderboardSummary(pollLeaderboardSummary: HMSPollLeaderboardSummary): WritableMap {
val summary = Arguments.createMap()
pollLeaderboardSummary.averageScore?.let {
summary.putDouble("averageScore", it.toDouble())
}
pollLeaderboardSummary.averageTime?.let {
summary.putString("averageTime", it.toString())
}
pollLeaderboardSummary.totalPeersCount?.let {
summary.putInt("totalPeersCount", it)
}
pollLeaderboardSummary.respondedCorrectlyPeersCount?.let {
summary.putInt("respondedCorrectlyPeersCount", it)
}
pollLeaderboardSummary.respondedPeersCount?.let {
summary.putInt("respondedPeersCount", it)
}
return summary
}

private fun getHMSPollLeaderboardEntries(pollLeaderboardEntries: List<HMSPollLeaderboardEntry>): WritableArray {
val list = Arguments.createArray()
pollLeaderboardEntries.forEach {
list.pushMap(getHMSPollLeaderboardEntry(it))
}
return list
}

private fun getHMSPollLeaderboardEntry(pollLeaderboardEntry: HMSPollLeaderboardEntry): WritableMap {
val entry = Arguments.createMap()
pollLeaderboardEntry.duration?.let {
entry.putString("duration", it.toString())
}
pollLeaderboardEntry.peer?.let {
entry.putMap("peer", getHMSPollResponsePeerInfo(it))
}
pollLeaderboardEntry.totalResponses?.let {
entry.putString("totalResponses", it.toString())
}
pollLeaderboardEntry.correctResponses?.let {
entry.putString("correctResponses", it.toString())
}
pollLeaderboardEntry.position?.let {
entry.putString("position", it.toString())
}
pollLeaderboardEntry.score?.let {
entry.putString("score", it.toString())
}
return entry
}

private fun getHMSPollResponsePeerInfo(pollResponsePeerInfo: HMSPollResponsePeerInfo): WritableMap {
val peerInfo = Arguments.createMap()
peerInfo.putString("userHash", pollResponsePeerInfo.hash)
pollResponsePeerInfo.peerid?.let {
peerInfo.putString("peerId", it)
}
pollResponsePeerInfo.userid?.let {
peerInfo.putString("customerUserId", it)
}
pollResponsePeerInfo.username?.let {
peerInfo.putString("userName", it)
}
return peerInfo
}

private fun getHMSPollQuestionResponseResult(hmsPollQuestionResponseResult: PollAnswerItem): WritableMap {
val result = Arguments.createMap()

Expand Down
Loading

0 comments on commit 002f076

Please sign in to comment.