ThibaultBee / StreamPack

SRT/RTMP/RTMPS live streaming libraries for Android
https://thibaultbee.github.io/StreamPack/index.html
Apache License 2.0
205 stars 70 forks source link

[Bug]: Possible bug in ByteBufferExtensions #158

Open tukez opened 3 months ago

tukez commented 3 months ago

Version

2.6.1

Environment that reproduces the issue

No devices.

RTMP/SRT/... Server

No server.

Audio configuration

No response

Video configuration

No response

Is it reproducible in the demos application?

Yes

Reproduction steps

byteBuffer.toByteArray()

Expected result

ByteBuffer.toByteArray() has two implementations, one for array backed buffers and one for others. The array backed implementation does not move the ByteBuffer position whereas the other implementation does.

Noticed this while reading the source code, a possible source of bugs.

Actual result

Implementation works the same for all ByteBuffers.

Additional context

No response

Relevant logs output

No response

ThibaultBee commented 2 months ago

Indeed. Just moving the position to the limit would do it.

StreamPack does not use the ByteBuffer once they have been read by toByteArray()

ThibaultBee commented 2 months ago

Could you have a look at https://github.com/ThibaultBee/StreamPack/pull/162?

tukez commented 2 months ago

Looks correct.