Skip to content

Commit

Permalink
fix(*): do not remove prefix of frame when frame does not have extra
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Mar 27, 2024
1 parent 99f158f commit adf88e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ fun ByteBuffer.extractRbsp(headerLength: Int): ByteBuffer {
* @return [ByteBuffer] without prefixes
*/
fun ByteBuffer.removePrefixes(prefixes: List<ByteBuffer>): ByteBuffer {
if (prefixes.isEmpty()) {
return this
}
val mutablePrefixes = prefixes.toMutableList()
var hasPrefix = true
while (hasPrefix) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ import java.nio.ByteBuffer
* Extracts csd buffers from MediaFormat.
* It can contains SPS, PPS for AVC.
*/
val MediaFormat.extra: List<ByteBuffer>
val MediaFormat.extra: List<ByteBuffer>?
get() {
if (!containsKey("csd-0") && !containsKey("csd-1") && !containsKey("csd-2")) {
return null
}

val extra = mutableListOf<ByteBuffer>()

getByteBuffer("csd-0")?.let {
Expand Down

0 comments on commit adf88e5

Please sign in to comment.