Work on call recording
This commit is contained in:
@@ -4,17 +4,18 @@ import java.io.*
|
||||
import java.util.ArrayList
|
||||
import java.util.GregorianCalendar
|
||||
|
||||
class NewCallHistory(val aor: String, val peerUri: String, val direction: String) : Serializable {
|
||||
class CallHistory(val aor: String, val peerUri: String, val direction: String) : Serializable {
|
||||
|
||||
var startTime: GregorianCalendar? = null // Set to time when call is established (if ever)
|
||||
var stopTime = GregorianCalendar() // Set to time when call is closed
|
||||
var recording = ""
|
||||
|
||||
companion object {
|
||||
|
||||
private const val serialVersionUID: Long = 1
|
||||
private const val serialVersionUID: Long = 2
|
||||
private const val CALL_HISTORY_SIZE = 128
|
||||
|
||||
fun add(history: NewCallHistory) {
|
||||
fun add(history: CallHistory) {
|
||||
BaresipService.callHistory.add(history)
|
||||
if (aorHistorySize(history.aor) > CALL_HISTORY_SIZE) {
|
||||
var i = 0
|
||||
@@ -44,7 +45,7 @@ class NewCallHistory(val aor: String, val peerUri: String, val direction: String
|
||||
|
||||
fun save() {
|
||||
Log.d(TAG, "Saving history of ${BaresipService.callHistory.size} calls")
|
||||
val file = File(BaresipService.filesPath, "call_history")
|
||||
val file = File(BaresipService.filesPath, "history")
|
||||
try {
|
||||
val fos = FileOutputStream(file)
|
||||
val oos = ObjectOutputStream(fos)
|
||||
@@ -58,13 +59,13 @@ class NewCallHistory(val aor: String, val peerUri: String, val direction: String
|
||||
}
|
||||
|
||||
fun restore() {
|
||||
val file = File(BaresipService.filesPath, "call_history")
|
||||
val file = File(BaresipService.filesPath, "history")
|
||||
if (file.exists()) {
|
||||
try {
|
||||
val fis = FileInputStream(file)
|
||||
val ois = ObjectInputStream(fis)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
BaresipService.callHistory = ois.readObject() as ArrayList<NewCallHistory>
|
||||
BaresipService.callHistory = ois.readObject() as ArrayList<CallHistory>
|
||||
ois.close()
|
||||
fis.close()
|
||||
Log.d(TAG, "Restored history of ${BaresipService.callHistory.size} calls")
|
||||
@@ -77,28 +78,31 @@ class NewCallHistory(val aor: String, val peerUri: String, val direction: String
|
||||
@Suppress("UNUSED")
|
||||
fun print() {
|
||||
for (h in BaresipService.callHistory)
|
||||
Log.d(TAG, "[${h.aor}, ${h.peerUri}, ${h.direction}, ${h.startTime}, ${h.stopTime}]")
|
||||
Log.d(TAG, "[${h.aor}, ${h.peerUri}, ${h.direction}, ${h.startTime}," +
|
||||
"${h.stopTime}, ${h.recording}]")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CallHistory(val aor: String, val peerUri: String, val direction: String,
|
||||
val connected: Boolean) : Serializable {
|
||||
class NewCallHistory(val aor: String, val peerUri: String, val direction: String) : Serializable {
|
||||
|
||||
val time: GregorianCalendar = GregorianCalendar()
|
||||
var startTime: GregorianCalendar? = null
|
||||
var stopTime = GregorianCalendar()
|
||||
|
||||
companion object {
|
||||
|
||||
fun get(): ArrayList<CallHistory> {
|
||||
val file = File(BaresipService.filesPath, "calls")
|
||||
var result = ArrayList<CallHistory>()
|
||||
private const val serialVersionUID: Long = 1
|
||||
|
||||
fun get(): ArrayList<NewCallHistory> {
|
||||
val file = File(BaresipService.filesPath, "call_history")
|
||||
var result = ArrayList<NewCallHistory>()
|
||||
if (file.exists()) {
|
||||
try {
|
||||
val fis = FileInputStream(file)
|
||||
val ois = ObjectInputStream(fis)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
result = ois.readObject() as ArrayList<CallHistory>
|
||||
result = ois.readObject() as ArrayList<NewCallHistory>
|
||||
ois.close()
|
||||
fis.close()
|
||||
Log.d(TAG, "Got history of ${result.size} calls")
|
||||
|
||||
Reference in New Issue
Block a user