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/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;
 }