Skip to content

Commit 99bc51d

Browse files
committed
Merge remote-tracking branch 'origin/development'
2 parents 9562d85 + 5722422 commit 99bc51d

File tree

11 files changed

+355
-34
lines changed

11 files changed

+355
-34
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: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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.JsonFilter
14+
import com.fasterxml.jackson.annotation.JsonIgnore
15+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
16+
import com.fivegmag.a5gmscommonlibrary.models.EndpointAddress
17+
import com.fivegmag.a5gmscommonlibrary.models.TypedLocation
18+
import kotlinx.parcelize.Parcelize
19+
20+
@Parcelize
21+
@JsonIgnoreProperties(ignoreUnknown = true)
22+
data class ConsumptionReport(
23+
val mediaPlayerEntry: String,
24+
val reportingClientId: String,
25+
val consumptionReportingUnits: ArrayList<ConsumptionReportingUnit>
26+
) : Parcelable
27+
28+
@Parcelize
29+
@JsonIgnoreProperties(ignoreUnknown = true)
30+
@JsonFilter("consumptionReportingUnitFilter")
31+
data class ConsumptionReportingUnit(
32+
val mediaConsumed: String,
33+
var clientEndpointAddress: EndpointAddress? = null,
34+
var serverEndpointAddress: EndpointAddress? = null,
35+
val startTime: String,
36+
var duration: Int,
37+
var locations: ArrayList<TypedLocation>? = ArrayList(),
38+
@JsonIgnore
39+
var mimeType: String? = null,
40+
@JsonIgnore
41+
var finished: Boolean = false
42+
) : Parcelable
Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
package com.fivegmag.a5gmscommonlibrary.eventbus
2+
3+
import android.telephony.CellInfo
4+
import androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime
5+
import androidx.media3.exoplayer.source.LoadEventInfo
26
import androidx.media3.exoplayer.source.MediaLoadData
37

4-
class DownstreamFormatChangedEvent(val mediaLoadData: MediaLoadData)
8+
class DownstreamFormatChangedEvent(
9+
val eventTime: EventTime,
10+
val mediaLoadData: MediaLoadData
11+
)
12+
13+
class PlaybackStateChangedEvent(
14+
val eventTime: EventTime,
15+
val playbackState: String
16+
)
17+
18+
class LoadStartedEvent(
19+
val eventTime: EventTime,
20+
val loadEventInfo: LoadEventInfo,
21+
val mediaLoadData: MediaLoadData
22+
)
23+
24+
class CellInfoUpdatedEvent(
25+
val cellInfoList: MutableList<CellInfo>
26+
)

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ 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 GET_CONSUMPTION_REPORT = 11
41+
const val CONSUMPTION_REPORT = 12
42+
const val UPDATE_PLAYBACK_CONSUMPTION_REPORTING_CONFIGURATION = 13
4043
}
4144

4245
object SessionHandlerEvents {
@@ -54,4 +57,10 @@ object ContentTypes {
5457
object UserAgentTokens {
5558
const val FIVE_G_MS_REL_17_MEDIA_STREAM_HANDLER = "5GMSMediaStreamHandler/17"
5659
const val FIVE_G_MS_REL_17_MEDIA_SESSION_HANDLER = "5GMSMediaSessionHandler/17"
60+
}
61+
62+
object HostInfoTypes {
63+
const val IP_V4 = "ipv4"
64+
const val IP_V6 = "ipv6"
65+
const val DOMAIN_NAME = "domain_name"
5766
}

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

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
package com.fivegmag.a5gmscommonlibrary.helpers
22

3+
import com.fivegmag.a5gmscommonlibrary.models.EndpointAddress
4+
import com.fivegmag.a5gmscommonlibrary.models.HostInfo
35
import java.text.SimpleDateFormat
46
import java.time.Duration
57
import java.util.Date
68
import java.util.Random
79
import java.util.TimeZone
810
import okhttp3.Headers
11+
import java.net.NetworkInterface
12+
import java.net.URL
13+
import java.time.Instant
14+
import java.util.Locale
15+
import java.util.UUID
916

1017
class Utils {
1118

@@ -25,6 +32,23 @@ class Utils {
2532
return dateFormat.format(date)
2633
}
2734

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

@@ -69,7 +93,7 @@ class Utils {
6993
}
7094
val headersToValidate = arrayOf("last-modified", "etag")
7195

72-
return headersToValidate.all { header ->
96+
return headersToValidate.any { header ->
7397
hasHeaderChanged(
7498
headers.get(header),
7599
previousResponseHeaders.get(header)
@@ -80,4 +104,90 @@ class Utils {
80104
private fun hasHeaderChanged(headerA: String?, headerB: String?): Boolean {
81105
return headerA == null || headerB == null || headerA != headerB
82106
}
107+
108+
fun getIpAddress(ipVer: Int): String? {
109+
val interfaces = NetworkInterface.getNetworkInterfaces()
110+
while (interfaces.hasMoreElements()) {
111+
val networkInterface = interfaces.nextElement()
112+
val addresses = networkInterface.inetAddresses
113+
while (addresses.hasMoreElements()) {
114+
val address = addresses.nextElement()
115+
if (!address.isLoopbackAddress && address.isSiteLocalAddress) {
116+
if ((ipVer == 4 && address.hostAddress.contains(".")) ||
117+
(ipVer == 6 && address.hostAddress.contains(":"))
118+
) {
119+
return address.hostAddress.toString()
120+
}
121+
}
122+
}
123+
}
124+
125+
return null
126+
}
127+
128+
fun getHostInfo(urlString: String): HostInfo? {
129+
try {
130+
val url = URL(urlString)
131+
val host = url.host
132+
133+
// Check if it's a valid IPv4 address
134+
val ipv4Regex = """^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$""".toRegex()
135+
if (ipv4Regex.matches(host)) {
136+
return HostInfo(HostInfoTypes.IP_V4, host)
137+
}
138+
139+
// Check if it's a valid IPv6 address
140+
val ipv6Regex = """^\[([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\]$""".toRegex()
141+
if (ipv6Regex.matches(host)) {
142+
return HostInfo(HostInfoTypes.IP_V6, host)
143+
}
144+
145+
// Remove leading "www." from the domain
146+
val domain = if (host.startsWith("www.")) host.substring(4) else host
147+
148+
// Assume it's a domain name
149+
return HostInfo(HostInfoTypes.DOMAIN_NAME, domain)
150+
} catch (e: Exception) {
151+
return null
152+
}
153+
}
154+
155+
fun getPort(url: String): Int? {
156+
try {
157+
val url = URL(url)
158+
val port = url.port
159+
if (port == -1) {
160+
return url.defaultPort
161+
}
162+
163+
return port
164+
} catch (e: Exception) {
165+
return null
166+
}
167+
}
168+
169+
fun getEndpointAddressByRequestUrl(
170+
requestUrl: String
171+
): EndpointAddress? {
172+
try {
173+
val hostInfo = getHostInfo(requestUrl)
174+
val port = getPort(requestUrl)
175+
176+
if (hostInfo != null && port != null) {
177+
return when (hostInfo.type) {
178+
HostInfoTypes.IP_V4 -> EndpointAddress(null, hostInfo.host, null, port)
179+
HostInfoTypes.IP_V6 -> EndpointAddress(null, null, hostInfo.host, port)
180+
HostInfoTypes.DOMAIN_NAME -> EndpointAddress(hostInfo.host, null, null, port)
181+
else -> null
182+
}
183+
}
184+
185+
return null
186+
187+
} catch (e: Exception) {
188+
return null
189+
}
190+
191+
}
192+
83193
}

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

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.fivegmag.a5gmscommonlibrary.models
2+
3+
import android.os.Parcelable
4+
import kotlinx.parcelize.Parcelize
5+
6+
@Parcelize
7+
data class PlaybackRequest(
8+
val entryPoints: ArrayList<EntryPoint>,
9+
val playbackConsumptionReportingConfiguration: PlaybackConsumptionReportingConfiguration
10+
) : Parcelable
11+
12+
@Parcelize
13+
data class PlaybackConsumptionReportingConfiguration(
14+
var accessReporting : Boolean? = false,
15+
var locationReporting : Boolean? = false
16+
) : Parcelable

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,20 @@ import kotlinx.parcelize.Parcelize
1616
data class ServiceAccessInformation(
1717
val provisioningSessionId : String,
1818
val provisioningSessionType: String?,
19-
val streamingAccess: StreamingAccess
19+
val streamingAccess: StreamingAccess,
20+
var clientConsumptionReportingConfiguration: ClientConsumptionReportingConfiguration?
2021
) : Parcelable
2122

2223
@Parcelize
2324
data class StreamingAccess(
2425
val entryPoints: ArrayList<EntryPoint>?
2526
) : Parcelable
27+
28+
@Parcelize
29+
data class ClientConsumptionReportingConfiguration(
30+
val serverAddresses : ArrayList<String>,
31+
val locationReporting: Boolean,
32+
val samplePercentage: Float,
33+
val reportingInterval: Int? = null,
34+
val accessReporting: Boolean
35+
) : Parcelable

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,30 @@ https://drive.google.com/file/d/1cinCiA778IErENZ3JN52VFW-1ffHpx7Z/view
99

1010
package com.fivegmag.a5gmscommonlibrary.models
1111

12+
import android.os.Parcelable
13+
import kotlinx.parcelize.Parcelize
14+
15+
@Parcelize
1216
data class TypedLocation(
13-
val locationIdentifierType: String,
17+
val locationIdentifierType: CellIdentifierType,
1418
val location: String
15-
)
19+
) : Parcelable
1620

21+
@Parcelize
1722
data class EndpointAddress(
23+
val domainName: String? = null,
1824
val ipv4Addr: String? = null,
1925
val ipv6Addr: String? = null,
20-
val portNumber: UInt
26+
val portNumber: Int
27+
) : Parcelable
28+
29+
@Parcelize
30+
enum class CellIdentifierType : Parcelable {
31+
CGI,
32+
ECGI,
33+
NCGI
34+
}
35+
data class HostInfo(
36+
val type: String,
37+
val host: String
2138
)

0 commit comments

Comments
 (0)