I'm playing an HLS file using ExoPlayer and i'm trying to get the actual observed bitrate (not the indicated bitrate). I now there is the onInFoListener interface but documentation is sketchy, can
stackoverflow.com
Any help to get this working in B4A would be greatly appreciated!
I am using the HLS video streaming method, and after looking into this some more, and I could be wrong, but it looks like the values for "averageBitrate" and "peakBitrate" are simply read from a TAG in the video stream and is NOT a runtime-calculated value:
averageBitrate
public final int averageBitrate
The average bitrate in bits per second, or NO_VALUEif unknown or not applicable. The way in which this field is populated depends on the type of media to which the format corresponds:
HLS variants: The AVERAGE-BANDWIDTH attribute defined on the corresponding EXT-X-STREAM-INF tag in the master playlist, or NO_VALUE if not present.
SmoothStreaming track elements: The Bitrate attribute defined on the corresponding TrackElement in the manifest, or NO_VALUE if not present.
Progressive container formats: Often NO_VALUE, but may be populated with the average bitrate of the container if known.
Sample formats: Often NO_VALUE, but may be populated with the average bitrate of the stream of samples with type sampleMimeType if known. Note that if sampleMimeType is a compressed format (e.g., MimeTypes.AUDIO_AAC), then this bitrate is for the stream of still compressed samples.
So, since I want to know the actual real-time bitrate and not what the media tags say the video is suppose to be, it looks like I need to use this method:
I'm playing an HLS file using ExoPlayer and i'm trying to get the actual observed bitrate (not the indicated bitrate). I now there is the onInFoListener interface but documentation is sketchy, can
stackoverflow.com
But again, I have not idea how to implement this in B4A
Would it be possible to update the Exoplayer for B4A? In the mean while, the original library supports reading MP3 tags, which is interesting for displaying info (like the title of the current song playing) on radio streams. I can download this data manually from the radio's website using...
Thank you for that tip, but it looks like that method gets the info from Metadata, which appears to be just the static data provided by the stream source, and not actual real-time data like the live bitrate which can be quite different from the documented (in the meta data) bitrate of the source media.
To get the real-time/actual bitrate, it looks like I have to intercept these two events in the exoplayer:
B4X:
onLoadStarted(int sourceId, long length, int type, int trigger, Format format, int mediaStartTimeMs, int mediaEndTimeMs)
onLoadCompleted(int sourceId, long bytesLoaded, int type, int trigger, Format format, int mediaStartTimeMs, int mediaEndTimeMs, long elapsedRealtimeMs, long loadDurationMs)
I figured out a way to get the real-time bitrate using the code from the below thread and simply calculate how many bits were received each second (using the getTotalRxBytes value):
This question suddenly popped into my head. I was just wondering what is the best solution for monitoring In/Out data usage on 1. Wi-Fi and 2. 3G/4G(LTA). Cheers...
www.b4x.com
This method assumes all the incoming bytes are related to my app, which is not a bad assumption considering my app is a video app and data usage from other apps would be minimal in comparison.