Use ByteBuffer.remaining() instead of ByteBuffer.limit() in BoxUtil

PiperOrigin-RevId: 610414628
This commit is contained in:
sheenachhabra 2024-02-26 08:22:10 -08:00 committed by Copybara-Service
parent e98858424a
commit 63a8fff69e

View File

@ -51,7 +51,7 @@ import java.util.List;
public static ByteBuffer wrapBoxesIntoBox(String boxType, List<ByteBuffer> boxes) {
int totalSize = BOX_TYPE_BYTES + BOX_SIZE_BYTES;
for (int i = 0; i < boxes.size(); i++) {
totalSize += boxes.get(i).limit();
totalSize += boxes.get(i).remaining();
}
ByteBuffer result = ByteBuffer.allocate(totalSize);
@ -72,7 +72,7 @@ import java.util.List;
public static ByteBuffer concatenateBuffers(ByteBuffer... buffers) {
int totalSize = 0;
for (ByteBuffer buffer : buffers) {
totalSize += buffer.limit();
totalSize += buffer.remaining();
}
ByteBuffer result = ByteBuffer.allocate(totalSize);