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 there a way to listen to the frames of RTMP packets? #1621

Open
AnthonyWu-kkstream opened this issue Oct 23, 2024 · 6 comments
Open

Is there a way to listen to the frames of RTMP packets? #1621

AnthonyWu-kkstream opened this issue Oct 23, 2024 · 6 comments

Comments

@AnthonyWu-kkstream
Copy link

Hello @pedroSG94,
I have a situation where, when the network speed is very poor, the streaming becomes unstable or even stops. Is there a way to listen to the frames of RTMP packets so that I can use the packet information to verify that the current frame is correct?

@pedroSG94
Copy link
Owner

I don't know what do you mean with "verify that the current frame is correct" but you have multiple methods related to get info about frames in the stream:

 abstract fun hasCongestion(percentUsed: Float): Boolean
 @Throws(RuntimeException::class)
 abstract fun resizeCache(newSize: Int)
 abstract fun clearCache()
 abstract fun getCacheSize(): Int
 abstract fun getItemsInCache(): Int
 abstract fun getSentAudioFrames(): Long
 abstract fun getSentVideoFrames(): Long
 abstract fun getDroppedAudioFrames(): Long
 abstract fun getDroppedVideoFrames(): Long
 abstract fun resetSentAudioFrames()
 abstract fun resetSentVideoFrames()
 abstract fun resetDroppedAudioFrames()
 abstract fun resetDroppedVideoFrames()

You can access all this methods with:

rtmpStream.getStreamClient().hasCongestion(20f)

@AnthonyWu-kkstream
Copy link
Author

Hello @pedroSG94 , thanks your reply.
Apologies for the confusion earlier. What I meant to ask is whether there’s a listener mechanism that allows me to capture and inspect RTMP packet-related information, rather than verifying if the current frame is correct. I’m looking for a way to better understand the instability during streaming when network speeds are poor.

@pedroSG94
Copy link
Owner

I don't have a way to do it. I think It is not a correct way to work, return frames is not recommended.
What do you want to check in the frame to know if the frame is correct?

@AnthonyWu-kkstream
Copy link
Author

I aim to define the streaming status based on RTMP packet information to provide the client app with the current streaming status. Therefore, I am looking for a way to use RTMP information to determine the status.

@pedroSG94
Copy link
Owner

But you don't need get frames to know if the stream status is poor. You can use the bitrate and the method hasCongestion to know it.

If your internet speed is not enough to send frames the bitrate provided in the callback will be lower than the provided in prepareVideo + prepareAudio methods.

Also, you can check if frames in cache increase or the percent of the cache filled to know if you can't send frames with enough speed using hasCongestion method and methods provided in my other comment.

@AnthonyWu-kkstream
Copy link
Author

Hello,
I got it.
Thanks your idea and suggestion.

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

No branches or pull requests

2 participants