libmediaplayerservice: Add new player for DASH
- Add new player factory to support dash playback.
- DASH urls end with .mpd. When media player receives
an url with .mpd, it will use new factory to instantiate the player
to be used for supporting DASH playback.
Change-Id: I69e5a08fb2baf89d97b1e0711dbe52a8b1c39c29
diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h
index 3b151ef..412448a 100644
--- a/include/media/MediaPlayerInterface.h
+++ b/include/media/MediaPlayerInterface.h
@@ -50,6 +50,7 @@
// The shared library with the test player is passed passed as an
// argument to the 'test:' url in the setDataSource call.
TEST_PLAYER = 5,
+ DASH_PLAYER = 6,
};
diff --git a/media/libmediaplayerservice/Android.mk b/media/libmediaplayerservice/Android.mk
index 8f21632..cce93e7 100644
--- a/media/libmediaplayerservice/Android.mk
+++ b/media/libmediaplayerservice/Android.mk
@@ -38,6 +38,7 @@
libstagefright_omx \
libstagefright_wfd \
libutils \
+ libdl \
libvorbisidec \
LOCAL_STATIC_LIBRARIES := \
diff --git a/media/libmediaplayerservice/MediaPlayerFactory.cpp b/media/libmediaplayerservice/MediaPlayerFactory.cpp
index 90aed39..3966b7f 100644
--- a/media/libmediaplayerservice/MediaPlayerFactory.cpp
+++ b/media/libmediaplayerservice/MediaPlayerFactory.cpp
@@ -30,6 +30,7 @@
#include "TestPlayerStub.h"
#include "StagefrightPlayer.h"
#include "nuplayer/NuPlayerDriver.h"
+#include <dlfcn.h>
namespace android {
@@ -339,6 +340,30 @@
registerFactory_l(new SonivoxPlayerFactory(), SONIVOX_PLAYER);
registerFactory_l(new TestPlayerFactory(), TEST_PLAYER);
+ const char* FACTORY_LIB = "libdashplayer.so";
+ const char* FACTORY_CREATE_FN = "CreateDASHFactory";
+
+ MediaPlayerFactory::IFactory* pFactory = NULL;
+ void* pFactoryLib = NULL;
+ typedef MediaPlayerFactory::IFactory* (*CreateDASHDriverFn)();
+
+ pFactoryLib = ::dlopen(FACTORY_LIB, RTLD_LAZY);
+ if (pFactoryLib == NULL) {
+ ALOGE("Failed to open FACTORY_LIB Error : %s ",::dlerror());
+ } else {
+ CreateDASHDriverFn pCreateFnPtr;
+ pCreateFnPtr = (CreateDASHDriverFn) dlsym(pFactoryLib, FACTORY_CREATE_FN);
+ if (pCreateFnPtr == NULL) {
+ ALOGE("Could not locate pCreateFnPtr");
+ } else {
+ pFactory = pCreateFnPtr();
+ if(pFactory == NULL) {
+ ALOGE("Failed to invoke CreateDASHDriverFn...");
+ } else {
+ registerFactory_l(pFactory,DASH_PLAYER);
+ }
+ }
+ }
sInitComplete = true;
}