How to access your own libmediaplayerservice library from libmedia_jni in Android Gingerbread

By default, Android Gigerbread 2.3 uses PV_Player (opencore library). I found one solution, it should be a fixed system build.prop file, but I do not want to fix the system. I want to create my own library using the android media framework that will use the StageFright player. I know that libmediaplayerservice decides the player choice. Take a look at the media infrastructure

I want to create a library according to the Android infrastructure -

libmedia_jni_own libmedia_own libmediaplayerservice_own

But the problem is that libmedia does not directly interact with the libmediaplayerservice library, it does not directly depend on the libmediaplayerservice library. So he cannot create a game player. Libmedia communicates with the libmediaplayerservice library through the IPC Binder mechanism. How can I fix the libmedia source library so that it can access my libmediaplayerservice library and be able to create a StageFright player, as well as all access to the StageFright recorder, etc. Instead of the opencore library.

+6
source share
2 answers

I do not think that you can change the way the multimedia service works without fixing the system. Since the media service and its libraries are located in the system partition, you have no way to capture the jni load. If you use a none-AOSP router (for example, Samsung, HTC stocks, etc.), you can’t just swap files, because those in the warehouse contain many links to their own libraries.

+1
source

After examining the Android source code in which you mention the Binder mechanism, you should look at the getMediaPlayerService () method and check how the service manager processes the media server. If you can fix this method and correctly define your service, you should be fine.

IMediaDeathNotifier::getMediaPlayerService() { LOGV("getMediaPlayerService"); Mutex::Autolock _l(sServiceLock); if (sMediaPlayerService.get() == 0) { sp<IServiceManager> sm = defaultServiceManager(); sp<IBinder> binder; do { binder = sm->getService(String16("media.player")); if (binder != 0) { break; } LOGW("Media player service not published, waiting..."); usleep(500000); // 0.5 s } while(true); if (sDeathNotifier == NULL) { sDeathNotifier = new DeathNotifier(); } binder->linkToDeath(sDeathNotifier); sMediaPlayerService = interface_cast<IMediaPlayerService>(binder); } LOGE_IF(sMediaPlayerService == 0, "no media player service!?"); return sMediaPlayerService; } 

This method is located in: frameworks/base/media/libmedia/IMediaDeathNotifier.cpp

In addition, the service is installed by calling:

  void MediaPlayerService::instantiate() { defaultServiceManager()->addService( String16("media.player"), new MediaPlayerService()); } 

which can be found at: /frameworks/base/media/libmediaplayerservice/MediaPlayerService.cpp

+1
source

Source: https://habr.com/ru/post/915594/


All Articles