Skip to content

Commit

Permalink
add save video feedback and avoid calculate ts on rtsp audio packets …
Browse files Browse the repository at this point in the history
…multiple times
  • Loading branch information
pedroSG94 committed Mar 23, 2024
1 parent a9e18a0 commit bf99b71
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/com/pedro/streamer/utils/Extensions.kt
Expand Up @@ -18,6 +18,7 @@ package com.pedro.streamer.utils

import android.app.Activity
import android.app.Service
import android.content.Context
import android.widget.Toast
import androidx.fragment.app.Fragment

Expand All @@ -35,4 +36,8 @@ fun Fragment.toast(message: String, duration: Int = Toast.LENGTH_SHORT) {

fun Service.toast(message: String, duration: Int = Toast.LENGTH_SHORT) {
Toast.makeText(this, message, duration).show()
}

fun Context.toast(message: String, duration: Int = Toast.LENGTH_SHORT) {
Toast.makeText(this, message, duration).show()
}
1 change: 1 addition & 0 deletions app/src/main/java/com/pedro/streamer/utils/PathUtils.kt
Expand Up @@ -36,5 +36,6 @@ object PathUtils {
@JvmStatic
fun updateGallery(context: Context, path: String) {
context.sendBroadcast(Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(File(path))))
context.toast("Video saved at: $path")
}
}
2 changes: 1 addition & 1 deletion rtsp/src/main/java/com/pedro/rtsp/rtp/packets/AacPacket.kt
Expand Up @@ -48,12 +48,12 @@ class AacPacket(
val fixedBuffer = byteBuffer.removeInfo(bufferInfo)
val length = fixedBuffer.remaining()
val maxPayload = maxPacketSize - (RtpConstants.RTP_HEADER_LENGTH + 4)
val ts = bufferInfo.presentationTimeUs * 1000
var sum = 0
while (sum < length) {
val size = if (length - sum < maxPayload) length - sum else maxPayload
val buffer = getBuffer(size + RtpConstants.RTP_HEADER_LENGTH + 4)
fixedBuffer.get(buffer, RtpConstants.RTP_HEADER_LENGTH + 4, size)
val ts = bufferInfo.presentationTimeUs * 1000
markPacket(buffer)
val rtpTs = updateTimeStamp(buffer, ts)

Expand Down
Expand Up @@ -44,12 +44,12 @@ class G711Packet(
) {
val length = bufferInfo.size - byteBuffer.position()
val maxPayload = maxPacketSize - RtpConstants.RTP_HEADER_LENGTH
val ts = bufferInfo.presentationTimeUs * 1000
var sum = 0
while (sum < length) {
val size = if (length - sum < maxPayload) length - sum else maxPayload
val buffer = getBuffer(size + RtpConstants.RTP_HEADER_LENGTH)
byteBuffer.get(buffer, RtpConstants.RTP_HEADER_LENGTH, size)
val ts = bufferInfo.presentationTimeUs * 1000
markPacket(buffer)
val rtpTs = updateTimeStamp(buffer, ts)
updateSeq(buffer)
Expand Down

0 comments on commit bf99b71

Please sign in to comment.