Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging HLS chunk requests

I want to monitor the switching between differnt bitrates on a HLS stream in Android. So i was thinking to monitor the HLS chunk requests. and parse these. Do you guys have any idea how i would go around and do this?

I have already tried monitoring the on videosizechanged but i do not think this will suffice...

        vv.setVideoPath("http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8");
        vv.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                mMediaPlayer = mp;
                mMediaPlayer.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() {
                    @Override
                    public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
                        Log.e(TAG, "perhaps changed bitrate?");
                    }
                });
            }
        });
        vv.start();

Any ideas are more than welcome.

like image 637
sn0ep Avatar asked Mar 24 '26 13:03

sn0ep


1 Answers

Unfortunately, it is not possible to do with android.media.MediaPlayer API. In the callback onVideoSizeChanged() there is no news about it. You can be lucky checking the callback android.media.MediaPlayer.OnInfoListener with the event MEDIA_INFO_BUFFERING_START and his extra, but the behaviour changes according to the manufacturer.

My suggestion is to switch to the new ExoPlayer, an open source project powered by Google. In the last release, it handles HLS. Through the class HlsChunkSource, you can retrieve information about all chunk request ( for instance by the method getChunkOperation() ).

like image 160
Dekra Avatar answered Mar 27 '26 11:03

Dekra



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!