Skip to content

Commit 4624977

Browse files
authored
Fix/consumption reporting changes (#20)
* Increase version number to 1.1.0 * Use ArrayList instead of Array * Add required changes for consumption reporting * Adjust consumption report models * Add missing fields to model classes and move function to derive IP address to utils class
1 parent d1e604b commit 4624977

File tree

8 files changed

+100
-38
lines changed

8 files changed

+100
-38
lines changed

.idea/misc.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ android {
1313
minSdk 29
1414
targetSdk 32
1515
versionCode 1
16-
versionName "1.0.2"
16+
versionName "1.1.0"
1717

1818
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1919
}
@@ -38,7 +38,7 @@ publishing {
3838
release(MavenPublication) {
3939
groupId = 'com.fivegmag'
4040
artifactId = 'a5gmscommonlibrary'
41-
version = '1.0.2'
41+
version = '1.1.0'
4242

4343
afterEvaluate {
4444
from components.release
@@ -63,6 +63,8 @@ dependencies {
6363
implementation 'androidx.appcompat:appcompat:1.6.1'
6464
implementation 'com.google.android.material:material:1.8.0'
6565
implementation "androidx.media3:media3-exoplayer:1.0.2"
66+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.1'
67+
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.12.1'
6668
testImplementation 'junit:junit:4.13.2'
6769
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
6870
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
License: 5G-MAG Public License (v1.0)
3+
Author: Daniel Silhavy
4+
Copyright: (C) 2023 Fraunhofer FOKUS
5+
For full license terms please see the LICENSE file distributed with this
6+
program. If this file is missing then the license can be retrieved from
7+
https://drive.google.com/file/d/1cinCiA778IErENZ3JN52VFW-1ffHpx7Z/view
8+
*/
9+
10+
package com.fivegmag.a5gmscommonlibrary.consumptionReporting
11+
12+
import android.os.Parcelable
13+
import com.fasterxml.jackson.annotation.JsonIgnore
14+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
15+
import com.fivegmag.a5gmscommonlibrary.models.EndpointAddress
16+
import com.fivegmag.a5gmscommonlibrary.models.TypedLocation
17+
import kotlinx.parcelize.Parcelize
18+
19+
@Parcelize
20+
@JsonIgnoreProperties(ignoreUnknown = true)
21+
data class ConsumptionReport(
22+
val mediaPlayerEntry: String,
23+
val reportingClientId: String,
24+
val consumptionReportingUnits: ArrayList<ConsumptionReportingUnit>
25+
) : Parcelable
26+
27+
@Parcelize
28+
@JsonIgnoreProperties(ignoreUnknown = true)
29+
data class ConsumptionReportingUnit(
30+
val mediaConsumed: String,
31+
var mediaEndpointAddress: EndpointAddress? = null,
32+
val startTime: String,
33+
var duration: Int,
34+
var locations: ArrayList<TypedLocation>? = ArrayList(),
35+
//@JsonIgnore
36+
var mimeType: String? = null,
37+
//@JsonIgnore
38+
var finished: Boolean = false
39+
) : Parcelable
40+

app/src/main/java/com/fivegmag/a5gmscommonlibrary/helpers/Constants.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ object SessionHandlerMessageTypes {
3737
const val UPDATE_LOOKUP_TABLE = 8
3838
const val SET_M5_ENDPOINT = 9
3939
const val START_PLAYBACK_BY_SERVICE_LIST_ENTRY_MESSAGE = 10
40-
const val CONSUMPTION_REPORTING_MESSAGE = 11
40+
const val GET_CONSUMPTION_REPORT = 11
41+
const val CONSUMPTION_REPORT = 12
4142
}
4243

4344
object SessionHandlerEvents {

app/src/main/java/com/fivegmag/a5gmscommonlibrary/helpers/Utils.kt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import java.util.Date
66
import java.util.Random
77
import java.util.TimeZone
88
import okhttp3.Headers
9+
import java.net.NetworkInterface
10+
import java.time.Instant
11+
import java.util.Locale
12+
import java.util.UUID
913

1014
class Utils {
1115

@@ -25,6 +29,23 @@ class Utils {
2529
return dateFormat.format(date)
2630
}
2731

32+
fun generateUUID(): String {
33+
val uuid = UUID.randomUUID()
34+
return uuid.toString()
35+
}
36+
37+
fun formatDateToOpenAPIFormat(date: Date): String {
38+
val format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault())
39+
return format.format(date)
40+
}
41+
42+
fun calculateTimestampDifferenceInSeconds(timestamp1: String, timestamp2: String): Long {
43+
val instant1 = Instant.parse(timestamp1)
44+
val instant2 = Instant.parse(timestamp2)
45+
val duration = Duration.between(instant1, instant2)
46+
return duration.seconds
47+
}
48+
2849
fun getCurrentXsDateTime(): String {
2950
val currentTimestamp = getCurrentTimestamp()
3051

@@ -80,4 +101,25 @@ class Utils {
80101
private fun hasHeaderChanged(headerA: String?, headerB: String?): Boolean {
81102
return headerA == null || headerB == null || headerA != headerB
82103
}
104+
105+
fun getIpAddress(ipVer: Int): String? {
106+
val interfaces = NetworkInterface.getNetworkInterfaces()
107+
while (interfaces.hasMoreElements()) {
108+
val networkInterface = interfaces.nextElement()
109+
val addresses = networkInterface.inetAddresses
110+
while (addresses.hasMoreElements()) {
111+
val address = addresses.nextElement()
112+
if (!address.isLoopbackAddress && address.isSiteLocalAddress) {
113+
if ((ipVer == 4 && address.hostAddress.contains("."))||
114+
(ipVer == 6 && address.hostAddress.contains(":"))
115+
){
116+
return address.hostAddress.toString()
117+
}
118+
}
119+
}
120+
}
121+
122+
return null
123+
}
124+
83125
}

app/src/main/java/com/fivegmag/a5gmscommonlibrary/models/ConsumptionReporting.kt

Lines changed: 0 additions & 30 deletions
This file was deleted.

app/src/main/java/com/fivegmag/a5gmscommonlibrary/models/ServiceAccessInformation.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ data class StreamingAccess(
2727

2828
@Parcelize
2929
data class ClientConsumptionReportingConfiguration(
30-
val serverAddresses : Array<String>,
30+
val serverAddresses : ArrayList<String>,
3131
val locationReporting: Boolean,
3232
val samplePercentage: Float,
33-
val reportingInterval: UInt,
33+
val reportingInterval: Int? = null,
3434
val accessReporting: Boolean
3535
) : Parcelable

app/src/main/java/com/fivegmag/a5gmscommonlibrary/models/SharedDataTypes.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@ import kotlinx.parcelize.Parcelize
1414

1515
@Parcelize
1616
data class TypedLocation(
17-
val locationIdentifierType: String,
17+
val locationIdentifierType: CellIdentifierType,
1818
val location: String
1919
) : Parcelable
2020

2121
@Parcelize
2222
data class EndpointAddress(
23+
val domainName: String? = null,
2324
val ipv4Addr: String? = null,
2425
val ipv6Addr: String? = null,
2526
val portNumber: UInt
26-
) : Parcelable
27+
) : Parcelable
28+
29+
@Parcelize
30+
enum class CellIdentifierType : Parcelable {
31+
CGI,
32+
ECGI,
33+
NCGI
34+
}

0 commit comments

Comments
 (0)