-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shows the current selected bitrate and the corresponding Representati…
…onID as an overlay on top of the video. (#23)
- Loading branch information
Showing
7 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...n/app/src/main/java/com/fivegmag/a5gmsdawareapplication/MediaStreamHandlerEventHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.fivegmag.a5gmsdawareapplication | ||
|
||
import android.content.Context | ||
import android.widget.TextView | ||
import androidx.media3.common.util.UnstableApi | ||
import com.fivegmag.a5gmscommonlibrary.eventbus.DownstreamFormatChangedEvent | ||
import org.greenrobot.eventbus.Subscribe | ||
import org.greenrobot.eventbus.ThreadMode | ||
|
||
@UnstableApi | ||
/** | ||
* This class handles messages that are dispatched by the Media Stream Handler. | ||
* Implements a pub/sub pattern using the eventbus library. | ||
* | ||
*/ | ||
class MediaStreamHandlerEventHandler { | ||
|
||
private lateinit var representationInfoTextView: TextView | ||
private lateinit var context: Context | ||
|
||
fun initialize(repInfoTextView: TextView, ctxt: Context) { | ||
representationInfoTextView = repInfoTextView | ||
context = ctxt | ||
} | ||
|
||
@Subscribe(threadMode = ThreadMode.MAIN) | ||
fun onDownstreamFormatChangedEvent(event: DownstreamFormatChangedEvent) { | ||
// Handle the event | ||
if (event.mediaLoadData.trackFormat?.containerMimeType?.contains( | ||
"video", | ||
ignoreCase = true | ||
) == true | ||
) { | ||
val kbitsPerSecond = | ||
event.mediaLoadData.trackFormat?.peakBitrate?.div(1000).toString() | ||
val id = event.mediaLoadData.trackFormat?.id.toString() | ||
val text = context.getString(R.string.representationInfo, kbitsPerSecond, id) | ||
representationInfoTextView.text = text | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters