Recording enc and dec files may not be created during the same second
This commit is contained in:
@@ -579,8 +579,12 @@ class BaresipService: Service() {
|
|||||||
|
|
||||||
if (ev[0] == "sndfile dump") {
|
if (ev[0] == "sndfile dump") {
|
||||||
Log.d(TAG, "Got sndfile dump ${ev[1]}")
|
Log.d(TAG, "Got sndfile dump ${ev[1]}")
|
||||||
if (Call.inCall())
|
if (Call.inCall()) {
|
||||||
Call.calls()[0].dumpfile = ev[1]
|
if (ev[1].endsWith("enc.wav"))
|
||||||
|
Call.calls()[0].dumpfiles[0] = ev[1]
|
||||||
|
else
|
||||||
|
Call.calls()[0].dumpfiles[1] = ev[1]
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -885,8 +889,8 @@ class BaresipService: Service() {
|
|||||||
val history = CallHistory(aor, call.peerUri, call.dir)
|
val history = CallHistory(aor, call.peerUri, call.dir)
|
||||||
history.startTime = call.startTime
|
history.startTime = call.startTime
|
||||||
history.stopTime = GregorianCalendar()
|
history.stopTime = GregorianCalendar()
|
||||||
if (call.startTime != null && call.dumpfile != "")
|
if (call.startTime != null && call.dumpfiles[0] != "")
|
||||||
history.recording = call.dumpfile.substringBeforeLast("-")
|
history.recording = call.dumpfiles
|
||||||
CallHistory.add(history)
|
CallHistory.add(history)
|
||||||
CallHistory.save()
|
CallHistory.save()
|
||||||
ua.account.missedCalls = ua.account.missedCalls || missed
|
ua.account.missedCalls = ua.account.missedCalls || missed
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Call(val callp: Long, val ua: UserAgent, val peerUri: String, val dir: Str
|
|||||||
var zid = ""
|
var zid = ""
|
||||||
var startTime: GregorianCalendar? = null // Set when call is established
|
var startTime: GregorianCalendar? = null // Set when call is established
|
||||||
var referTo = ""
|
var referTo = ""
|
||||||
var dumpfile = ""
|
var dumpfiles = arrayOf("", "")
|
||||||
|
|
||||||
fun add() {
|
fun add() {
|
||||||
BaresipService.calls.add(0, this)
|
BaresipService.calls.add(0, this)
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class CallDetailsAdapter(private val ctx: Context, private val rows: ArrayList<C
|
|||||||
val duration = (stopTime.time.time - startTime.time.time) / 1000
|
val duration = (stopTime.time.time - startTime.time.time) / 1000
|
||||||
viewHolder.durationView.text = DateUtils.formatElapsedTime(duration)
|
viewHolder.durationView.text = DateUtils.formatElapsedTime(duration)
|
||||||
val recording = rows[position].recording
|
val recording = rows[position].recording
|
||||||
if (recording != "") {
|
if (recording[0] != "") {
|
||||||
viewHolder.durationView.typeface = Typeface.DEFAULT_BOLD
|
viewHolder.durationView.typeface = Typeface.DEFAULT_BOLD
|
||||||
viewHolder.durationView.setOnClickListener {
|
viewHolder.durationView.setOnClickListener {
|
||||||
Utils.playRecording(ctx, recording)
|
Utils.playRecording(ctx, recording)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class CallHistory(val aor: String, val peerUri: String, val direction: String) :
|
|||||||
|
|
||||||
var startTime: GregorianCalendar? = null // Set to time when call is established (if ever)
|
var startTime: GregorianCalendar? = null // Set to time when call is established (if ever)
|
||||||
var stopTime = GregorianCalendar() // Set to time when call is closed
|
var stopTime = GregorianCalendar() // Set to time when call is closed
|
||||||
var recording = ""
|
var recording = arrayOf("", "") // Encoder and decoder recording files
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ class CallHistory(val aor: String, val peerUri: String, val direction: String) :
|
|||||||
if (aorHistorySize(history.aor) > CALL_HISTORY_SIZE) {
|
if (aorHistorySize(history.aor) > CALL_HISTORY_SIZE) {
|
||||||
for (h in BaresipService.callHistory)
|
for (h in BaresipService.callHistory)
|
||||||
if (h.aor == history.aor) {
|
if (h.aor == history.aor) {
|
||||||
if (h.recording != "")
|
if (h.recording[0] != "")
|
||||||
deleteRecording(h.recording)
|
deleteRecording(h.recording)
|
||||||
BaresipService.callHistory.remove(h)
|
BaresipService.callHistory.remove(h)
|
||||||
break
|
break
|
||||||
@@ -32,7 +32,7 @@ class CallHistory(val aor: String, val peerUri: String, val direction: String) :
|
|||||||
for (i in BaresipService.callHistory.indices.reversed()) {
|
for (i in BaresipService.callHistory.indices.reversed()) {
|
||||||
val h = BaresipService.callHistory[i]
|
val h = BaresipService.callHistory[i]
|
||||||
if (h.aor == aor) {
|
if (h.aor == aor) {
|
||||||
if (h.recording != "")
|
if (h.recording[0] != "")
|
||||||
deleteRecording(h.recording)
|
deleteRecording(h.recording)
|
||||||
BaresipService.callHistory.removeAt(i)
|
BaresipService.callHistory.removeAt(i)
|
||||||
}
|
}
|
||||||
@@ -81,16 +81,16 @@ class CallHistory(val aor: String, val peerUri: String, val direction: String) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteRecording(recording: String) {
|
fun deleteRecording(recording: Array<String>) {
|
||||||
Utils.deleteFile(File("$recording-enc.wav"))
|
Utils.deleteFile(File(recording[0]))
|
||||||
Utils.deleteFile(File("$recording-dec.wav"))
|
Utils.deleteFile(File(recording[1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("UNUSED")
|
@Suppress("UNUSED")
|
||||||
fun print() {
|
fun print() {
|
||||||
for (h in BaresipService.callHistory)
|
for (h in BaresipService.callHistory)
|
||||||
Log.d(TAG, "[${h.aor}, ${h.peerUri}, ${h.direction}, ${h.startTime}," +
|
Log.d(TAG, "[${h.aor}, ${h.peerUri}, ${h.direction}, ${h.startTime}," +
|
||||||
"${h.stopTime}, ${h.recording}]")
|
"${h.stopTime}, ${h.recording}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class CallListAdapter(private val ctx: Context, private val account: Account,
|
|||||||
viewHolder.directionsView.removeAllViews()
|
viewHolder.directionsView.removeAllViews()
|
||||||
var count = 1
|
var count = 1
|
||||||
for (d in callRow.details) {
|
for (d in callRow.details) {
|
||||||
if (d.recording != "")
|
if (d.recording[0] != "")
|
||||||
viewHolder.timeView.typeface = Typeface.DEFAULT_BOLD
|
viewHolder.timeView.typeface = Typeface.DEFAULT_BOLD
|
||||||
if (count > 3) {
|
if (count > 3) {
|
||||||
viewHolder.etcView.text = "..."
|
viewHolder.etcView.text = "..."
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import kotlin.collections.ArrayList
|
|||||||
class CallRow(val aor: String, val peerUri: String, val direction: Int,
|
class CallRow(val aor: String, val peerUri: String, val direction: Int,
|
||||||
startTime: GregorianCalendar?,
|
startTime: GregorianCalendar?,
|
||||||
val stopTime: GregorianCalendar,
|
val stopTime: GregorianCalendar,
|
||||||
val recording: String)
|
val recording: Array<String>)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class Details(val direction: Int, val startTime: GregorianCalendar?,
|
class Details(val direction: Int, val startTime: GregorianCalendar?,
|
||||||
val stopTime: GregorianCalendar, val recording: String)
|
val stopTime: GregorianCalendar, val recording: Array<String>)
|
||||||
|
|
||||||
val details = ArrayList<Details>()
|
val details = ArrayList<Details>()
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import androidx.activity.result.contract.ActivityResultContracts
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.tutpro.baresip.databinding.ActivityCallsBinding
|
import com.tutpro.baresip.databinding.ActivityCallsBinding
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class CallsActivity : AppCompatActivity() {
|
class CallsActivity : AppCompatActivity() {
|
||||||
|
|
||||||
@@ -277,7 +276,7 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private fun removeUaHistoryAt(i: Int) {
|
private fun removeUaHistoryAt(i: Int) {
|
||||||
for (details in uaHistory[i].details) {
|
for (details in uaHistory[i].details) {
|
||||||
if (details.recording != "")
|
if (details.recording[0] != "")
|
||||||
CallHistory.deleteRecording(details.recording)
|
CallHistory.deleteRecording(details.recording)
|
||||||
BaresipService.callHistory.removeAll {
|
BaresipService.callHistory.removeAll {
|
||||||
it.startTime == details.startTime && it.stopTime == details.stopTime
|
it.startTime == details.startTime && it.stopTime == details.stopTime
|
||||||
|
|||||||
@@ -995,7 +995,7 @@ object Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun playRecording(ctx: Context, recording: String) {
|
fun playRecording(ctx: Context, recording: Array<String>) {
|
||||||
Log.d(TAG, "Playing recording $recording")
|
Log.d(TAG, "Playing recording $recording")
|
||||||
val decPlayer = MediaPlayer()
|
val decPlayer = MediaPlayer()
|
||||||
decPlayer.apply {
|
decPlayer.apply {
|
||||||
@@ -1025,7 +1025,7 @@ object Utils {
|
|||||||
it.release()
|
it.release()
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
val file = "$recording-enc.wav"
|
val file = recording[0]
|
||||||
val encFile = File(file).copyTo(File(BaresipService.filesPath + "/tmp/encode.wav"), true)
|
val encFile = File(file).copyTo(File(BaresipService.filesPath + "/tmp/encode.wav"), true)
|
||||||
val encUri = encFile.toUri()
|
val encUri = encFile.toUri()
|
||||||
setDataSource(ctx, encUri)
|
setDataSource(ctx, encUri)
|
||||||
@@ -1045,7 +1045,7 @@ object Utils {
|
|||||||
it.release()
|
it.release()
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
val file = "$recording-dec.wav"
|
val file = recording[1]
|
||||||
val decFile = File(file).copyTo(File(BaresipService.filesPath + "/tmp/decode.wav"), true)
|
val decFile = File(file).copyTo(File(BaresipService.filesPath + "/tmp/decode.wav"), true)
|
||||||
val decUri = decFile.toUri()
|
val decUri = decFile.toUri()
|
||||||
setDataSource(ctx, decUri)
|
setDataSource(ctx, decUri)
|
||||||
|
|||||||
Reference in New Issue
Block a user