Android 2.3.4 - Http Live Streaming

I am working on this project for a client and we need to stream audio from the server to a device running Android Gingerbread. To get a stream, the Android client has to make a request for a variant playlist, and then make a request for the playlist itself (the one with URIs pointing to chunks of the TS file). The client application then decrypts the chunks and sends them to the platform for playback.

The problem I am facing is regarding the security part. Our client (the respective company) uses a proprietary encryption scheme that serves keys to decrypt fragments of the TS file ahead of time via an HTTP request, instead of following the HLS specification and serving the key files via the URI (s) listed in the index files themselves. As far as I can tell, Android Mediaplayer platform has the ability to find these keyfiles and generate / find the corresponding IVs to decrypt if the keyfiles URIs are in the index files.

Unfortunately, this all means that I cannot decrypt file chunks and play the stream without spaces between each segment - I accomplish this by making HTTP GET requests for each segment, loading them into internal memory, applying decrypt, and then playing them with with the following code:

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    File dir = new File(TS_FILE_DIR);
    String [] files = dir.list();

    mTsFiles = new ArrayList<File>();
    for (String file : files) {
        String path = TS_FILE_DIR + file;
        mTsFiles.add(new File(path));
    }

    mMediaController = new MediaController(this);
    mVideoView = (VideoView)findViewById(R.id.video_view_1);

    mVideoView.setVideoPath(mTsFiles.get(0).getAbsolutePath());
    mVideoView.setMediaController(mMediaController);
    mVideoView.setOnPreparedListener(new OnPreparedListener() {

        @Override
        public void onPrepared(MediaPlayer mp) {
            mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
            mp.start();
        }
    });
    mVideoView.setOnCompletionListener(new OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mp) {
            mp.pause();
            mp.reset();

            if (mIndex < mTsFiles.size()) {
                mIndex++;

                try {
                    mp.setDataSource(mTsFiles.get(mIndex).getAbsolutePath());
                    mp.prepareAsync();
                }
                catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

    });
}

      

I tried:

1) Using 2 media planners and switching between 2 media planners, but that doesn't work at all 2) Being in the source code for ICS to get an idea of ​​how it all works, but its very complicated and I don't know much about C ++

Is there something I have missed?

+3
java android http-live-streaming


source to share


No one has answered this question yet

Check out similar questions:

3606
Close / hide Android soft keyboard
3295
Why is the Android emulator so slow? How can we speed up the development of an Android emulator?
3288
Correct use cases for Android UserManager.isUserAGoat ()?
2609
Is there a unique identifier for an Android device?
2510
How to persist android activity state by persisting instance state?
2097
Is there a way to run Python on Android?
1858
"Debug certificate expired" error in Android Eclipse plugins
1844
What is "Context" on Android?
1695
How to use java.net.URLConnection to trigger and process HTTP requests
2
HTTP Live Streaming on Android from a dynamically generated playlist



All Articles
Loading...
X
Show
Funny
Dev
Pics