androidandroid-mediaplayerstagefrightopencore

Android MusicPlayer uses Stagefright or opencore


I read that if media.stagefright.enable-player is set true then the device uses Stagefright. In my device's build.prop i see

media.stagefright.enable-player = false

When i tired below

MediaPlayer mp = new MediaPlayer();
mp.setDataSource(String.format("http://127.0.0.1:%d/", socketPort));
mp.prepare();
mp.start();

I hosted a server socket to which the mediaplayer connects

ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket(0);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
         socketPort = serverSocket.getLocalPort();

        Socket socket = null;
        try {
            socket = serverSocket.accept();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        InputStream is = null;
        try {
            is = socket.getInputStream();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        byte [] temp = new byte [1024];     
        int bsize = -1;
        while(bsize <= 0) {
            try {
                bsize = is.read(temp);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        final String readData = new String(temp);
        Log.e("readDta",readData);

The log i get is

11-22 15:06:56.656: E/readDta(8737): GET / HTTP/1.111-22 15:06:56.656: E/readDta(8737): Host: 127.0.0.111-22 15:06:56.656: E/readDta(8737): User-Agent: stagefright/1.1 (Linux;Android 2.3.6)

Now my doubt is,, how it shows me User-Agent: stagefright/1.1 though it's set media.stagefright.enable-player = false in build.prop ?

If it's not a way to determine which is used, how can i detect whether opencore or stagefright ?


Solution

  • From your logs, I feel that the version of Android is Froyo 2.2.3 which is the probably one of the last versions before Stagefright became a default. The choice of player is dependent on multiple conditions like whether it is a file source or http source or rtsp source.

    In Froyo 2.2.3, there are 2 keys for enabling Stagefright player and a build flag. To enable the use of Stagefright player for normal playback, you need to build the framework code with BUILD_WITH_FULL_STAGEFRIGHT as observed from here: http://androidxref.com/2.2.3/xref/frameworks/base/media/libmediaplayerservice/MediaPlayerService.cpp#670

    getDefaultPlayer is called for multiple conditions and in cases where the aforementioned macro is defined, it would try to check the value of the system property "media.stagefright.enable-player" (Ref: http://androidxref.com/2.2.3/xref/frameworks/base/media/libmediaplayerservice/MediaPlayerService.cpp#750)

    In your case for http source, there is a different system property which is checked viz., "media.stagefright.enable-http". In your case, I feel that this is enabled/set to true and hence, Stagefright player is being employed. Please set this to false to enable PV_Player only.