Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development'
Browse files Browse the repository at this point in the history
  • Loading branch information
dsilhavy committed Aug 25, 2023
2 parents 8e548cb + 18d12cc commit c985de4
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 12 deletions.
2 changes: 1 addition & 1 deletion fivegmag_5GMSdAwareApplication/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion fivegmag_5GMSdAwareApplication/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions fivegmag_5GMSdAwareApplication/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
minSdk 29
targetSdk 32
versionCode 1
versionName "1.0.1"
versionName "1.0.2"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -39,9 +39,10 @@ dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'org.greenrobot:eventbus:3.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.fivegmag:a5gmscommonlibrary:1.0.1'
implementation 'com.fivegmag:a5gmsmediastreamhandler:1.0.1'
implementation 'com.fivegmag:a5gmscommonlibrary:1.0.2'
implementation 'com.fivegmag:a5gmsmediastreamhandler:1.0.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
Expand All @@ -50,4 +51,17 @@ dependencies {
def retrofit_version = "2.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
}

task CaptureLibraryVersion {
def libDef = project.configurations.getByName('implementation').allDependencies.matching {
it.group.equals("com.fivegmag")
}
if (libDef.size() > 0) {
android.buildTypes.each {
libDef.forEach { item ->
it.buildConfigField 'String', "LIB_VERSION_" + item.name, "\"${item.version}\""
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
<!--<entry key="m8LocalAfAndAs">m8/config_local_af.json</entry>-->
<entry key="m85GMAGHost">https://rt.5g-mag.com/</entry>
<!-- <entry key="m8LocalDummyHost">http://10.147.67.179:3003/m8/</entry>-->
<entry key="m8LocalDummyHost">http://192.168.2.1:3003/m8/</entry>
<!-- <entry key="m8LocalDummyHost">http://194.95.175.90:3003/m8/</entry> -->
</properties>
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ https://drive.google.com/file/d/1cinCiA778IErENZ3JN52VFW-1ffHpx7Z/view

package com.fivegmag.a5gmsdawareapplication

import android.content.pm.PackageManager
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.Button
import android.widget.Spinner
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.media3.common.util.UnstableApi
import com.fivegmag.a5gmscommonlibrary.models.EntryPoint
Expand All @@ -26,6 +29,7 @@ import com.fivegmag.a5gmsmediastreamhandler.MediaSessionHandlerAdapter
import androidx.media3.ui.PlayerView
import kotlinx.serialization.json.*
import okhttp3.ResponseBody
import org.greenrobot.eventbus.EventBus
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
Expand All @@ -36,12 +40,14 @@ import java.net.URI
import java.util.*


const val TAG = "5GMS Aware Application"
const val TAG_AWARE_APPLICATION = "5GMS Aware Application"

@UnstableApi class MainActivity : AppCompatActivity(), AdapterView.OnItemSelectedListener {
@UnstableApi
class MainActivity : AppCompatActivity(), AdapterView.OnItemSelectedListener {

private val mediaSessionHandlerAdapter = MediaSessionHandlerAdapter()
private val exoPlayerAdapter = ExoPlayerAdapter()
private val mediaStreamHandlerEventHandler = MediaStreamHandlerEventHandler()
private var currentSelectedStreamIndex: Int = 0
private lateinit var currentSelectedM8Key: String
private lateinit var m8InterfaceApi: M8InterfaceApi
Expand All @@ -57,23 +63,50 @@ const val TAG = "5GMS Aware Application"
loadConfiguration()
populateM8SelectionSpinner()
exoPlayerView = findViewById(R.id.idExoPlayerVIew)
setApplicationVersionNumber()
printDependenciesVersionNumbers()
registerButtonListener()
mediaSessionHandlerAdapter.initialize(
this,
exoPlayerAdapter,
::onConnectionToMediaSessionHandlerEstablished
)
val representationInfoTextView = findViewById<TextView>(R.id.representationInfo)
mediaStreamHandlerEventHandler.initialize(representationInfoTextView, this)
} catch (e: Exception) {
e.printStackTrace()
}
}

override fun onStop() {
EventBus.getDefault().unregister(mediaStreamHandlerEventHandler)
super.onStop()
// Unbind from the service
mediaSessionHandlerAdapter.reset(this)
}

override fun onStart() {
super.onStart()
EventBus.getDefault().register(mediaStreamHandlerEventHandler)
}

private fun setApplicationVersionNumber() {
try {
val packageInfo = packageManager.getPackageInfo(packageName, 0)
val versionName = packageInfo.versionName
val versionTextView = findViewById<TextView>(R.id.versionNumber)
val versionText = getString(R.string.versionTextField, versionName)
versionTextView.text = versionText
} catch (e: PackageManager.NameNotFoundException) {
e.printStackTrace()
}
}

private fun printDependenciesVersionNumbers() {
Log.d(TAG_AWARE_APPLICATION, "5GMS Common Library Version: ${BuildConfig.LIB_VERSION_a5gmscommonlibrary}")
Log.d(TAG_AWARE_APPLICATION, "5GMS Media Stream Handler Version: ${BuildConfig.LIB_VERSION_a5gmsmediastreamhandler}")
}

private fun loadConfiguration() {
try {
val inputStream: InputStream = this.assets.open("config.properties.xml")
Expand Down Expand Up @@ -159,7 +192,7 @@ const val TAG = "5GMS Aware Application"
}

private fun replaceDoubleTicks(value: String): String {
return value.replace("\"", "");
return value.replace("\"", "")
}

override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
Expand All @@ -168,22 +201,24 @@ const val TAG = "5GMS Aware Application"
R.id.idStreamSpinner -> {
currentSelectedStreamIndex = position
}

R.id.idM8Spinner -> {
currentSelectedM8Key = parent.selectedItem as String
val selectedUri = URI(configProperties.getProperty(currentSelectedM8Key))
if(selectedUri.isAbsolute) {
if (selectedUri.isAbsolute) {
setM8DataViaEndpoint(selectedUri.toString())
} else {
setM8DataViaJson(selectedUri.toString())
}
}

else -> { // Note the block
}
}
}
}

private fun setM8DataViaEndpoint(m8HostingEndpoint : String) {
private fun setM8DataViaEndpoint(m8HostingEndpoint: String) {
try {
initializeRetrofitForM8InterfaceApi(m8HostingEndpoint)
val call: Call<ResponseBody>? =
Expand Down Expand Up @@ -234,9 +269,9 @@ const val TAG = "5GMS Aware Application"

for (serviceListEntry in jsonServiceList) {
val itemAsJsonObject = Json.parseToJsonElement(serviceListEntry.toString()).jsonObject
var name: String =
val name: String =
replaceDoubleTicks(itemAsJsonObject["name"].toString())
var provisioningSessionId =
val provisioningSessionId =
replaceDoubleTicks(itemAsJsonObject["provisioningSessionId"].toString())

val entryPoints = ArrayList<EntryPoint>()
Expand Down
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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,24 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/idStreamSpinner" />

<TextView
android:id="@+id/representationInfo"
android:layout_width="348dp"
android:layout_height="19dp"
android:text=""
android:textColor="#FFFFFF"
app:layout_constraintStart_toStartOf="@+id/idExoPlayerVIew"
app:layout_constraintTop_toTopOf="@+id/idExoPlayerVIew" />

<TextView
android:id="@+id/versionNumber"
android:layout_width="146dp"
android:layout_height="20dp"
android:layout_marginBottom="16dp"
android:text="@string/versionTextField"
android:textAlignment="textEnd"
app:layout_constraintBottom_toTopOf="@+id/idExoPlayerVIew"
app:layout_constraintEnd_toEndOf="@+id/idExoPlayerVIew" />


</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,24 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/idStreamSpinner" />

<TextView
android:id="@+id/representationInfo"
android:layout_width="352dp"
android:layout_height="23dp"
android:text=""
android:textColor="#FFFFFF"
app:layout_constraintStart_toStartOf="@+id/idExoPlayerVIew"
app:layout_constraintTop_toTopOf="@+id/idExoPlayerVIew" />

<TextView
android:id="@+id/versionNumber"
android:layout_width="162dp"
android:layout_height="23dp"
android:layout_marginBottom="20dp"
android:text="@string/versionTextField"
android:textAlignment="textEnd"
app:layout_constraintBottom_toTopOf="@+id/representationInfo"
app:layout_constraintEnd_toEndOf="@+id/idExoPlayerVIew" />


</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
<string name="labelM8Selection">Select M8 Input</string>
<string name="labelStreamSelection">Select a Stream</string>
<string name="startPlaybackButton">Start Playback</string>
<string name="representationInfo">%1$s kbit/s - Rep ID: %2$s</string>
<string name="versionTextField">Version: %s</string>
</resources>

0 comments on commit c985de4

Please sign in to comment.