Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is MediaCodec.BufferInfo‘s size is length, not endIndex ? #1341

Closed
KittenBall opened this issue Nov 14, 2023 · 4 comments
Closed

Is MediaCodec.BufferInfo‘s size is length, not endIndex ? #1341

KittenBall opened this issue Nov 14, 2023 · 4 comments

Comments

@KittenBall
Copy link

https://github.com/pedroSG94/RootEncoder/blob/master/rtmp/src/main/java/com/pedro/rtmp/flv/audio/AacPacket.kt#L79

header[1] = Type.RAW.mark
buffer = ByteArray(info.size - info.offset + header.size)

byteBuffer.get(buffer, header.size, info.size - info.offset)

I think the correct code is

header[1] = Type.RAW.mark
buffer = ByteArray(info.size + header.size)
buffer.position(info.offset)
byteBuffer.get(buffer, header.size, info.size)

I have not test, let me know if I wrong, thank you !

@pedroSG94
Copy link
Owner

pedroSG94 commented Nov 14, 2023

Hello,

You are right, but it is already done by MediaCodec class but maybe I should do it anyway for sanity.
I will need to apply this to all protocols and packets

@KittenBall
Copy link
Author

Yes, most of time, MediaInfo's offset is 0, so this problem does not appear.

@pedroSG94
Copy link
Owner

This should be solved here:
#1344

@KittenBall
Copy link
Author

Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants