Skip to content

Commit

Permalink
fix opus control header
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Feb 23, 2024
1 parent ce3d1d2 commit f1c3765
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ protected void onCreate(Bundle savedInstanceState) {
etUrl.setHint(R.string.hint_srt);
srtCamera1 = new SrtCamera1(openGlView, this);
srtCamera1.setAudioCodec(AudioCodec.OPUS);
srtCamera1.getStreamClient().setOnlyAudio(true);
openGlView.getHolder().addCallback(this);
openGlView.setOnTouchListener(this);
}
Expand Down
14 changes: 7 additions & 7 deletions srt/src/main/java/com/pedro/srt/mpeg2ts/packets/OpusPacket.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.pedro.srt.mpeg2ts.Pes
import com.pedro.srt.mpeg2ts.PesType
import com.pedro.srt.mpeg2ts.psi.PsiManager
import com.pedro.srt.srt.packets.data.PacketPosition
import com.pedro.srt.utils.toByteArray
import java.nio.ByteBuffer

/**
Expand Down Expand Up @@ -80,17 +81,16 @@ class OpusPacket(
}

private fun createControlHeader(payloadLength: Int): ByteArray {
// val bytes = payloadLength.toByteArray()
// val header = ByteArray(2 + bytes.size)
val bytes = payloadLength.toByteArray()
val header = ByteArray(2 + bytes.size)
// //header prefix
// header[0] = 0xFF.toByte()
// header[1] = 0xC0.toByte()
header[0] = 0x7F.toByte()
header[1] = 0xe0.toByte()
// //start_trim_flag 1b
// //end_trim_flag 1b
// //control_extension_flag 1b
// //Reserved 2b
// System.arraycopy(bytes, 0, header, 2, bytes.size)
// return header
return byteArrayOf()
System.arraycopy(bytes, 0, header, 2, bytes.size)
return header
}
}
11 changes: 2 additions & 9 deletions srt/src/main/java/com/pedro/srt/mpeg2ts/psi/Pmt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Pmt(
bytes
}
Codec.OPUS -> {
val bytes = ByteArray(16)
val bytes = ByteArray(10)
bytes[0] = 0x05
bytes[1] = 0x04

Expand All @@ -91,13 +91,6 @@ class Pmt(
bytes[8] = 0x80.toByte()
bytes[9] = 2

bytes[10] = 0x0A
bytes[11] = 0x04
bytes[12] = 0x75
bytes[13] = 0x6E
bytes[14] = 0x64
bytes[15] = 0x00

bytes
}
else -> {
Expand All @@ -111,7 +104,7 @@ class Pmt(
service.tracks.forEach { track ->
size += 5
if (track.codec == Codec.HEVC) size += 6
else if (track.codec == Codec.OPUS) size += 16
else if (track.codec == Codec.OPUS) size += 10
}
return size
}
Expand Down

0 comments on commit f1c3765

Please sign in to comment.