summaryrefslogtreecommitdiffstats
path: root/media/libmediaplayerservice/MediaPlayerService.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'media/libmediaplayerservice/MediaPlayerService.cpp')
-rw-r--r--media/libmediaplayerservice/MediaPlayerService.cpp113
1 files changed, 68 insertions, 45 deletions
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index c43e9bb..439e4ce 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -56,9 +56,9 @@
#include "MetadataRetrieverClient.h"
#include "MidiFile.h"
-#include <media/PVPlayer.h>
#include "TestPlayerStub.h"
#include "StagefrightPlayer.h"
+#include "nuplayer/NuPlayerDriver.h"
#include <OMX.h>
@@ -196,11 +196,6 @@ extmap FILE_EXTS [] = {
{".rtttl", SONIVOX_PLAYER},
{".rtx", SONIVOX_PLAYER},
{".ota", SONIVOX_PLAYER},
-#ifndef NO_OPENCORE
- {".wma", PV_PLAYER},
- {".wmv", PV_PLAYER},
- {".asf", PV_PLAYER},
-#endif
};
// TODO: Find real cause of Audio/Video delay in PV framework and remove this workaround
@@ -284,6 +279,26 @@ sp<IMediaPlayer> MediaPlayerService::create(pid_t pid, const sp<IMediaPlayerClie
return c;
}
+sp<IMediaPlayer> MediaPlayerService::create(
+ pid_t pid, const sp<IMediaPlayerClient> &client,
+ const sp<IStreamSource> &source, int audioSessionId) {
+ int32_t connId = android_atomic_inc(&mNextConnId);
+ sp<Client> c = new Client(this, pid, connId, client, audioSessionId);
+
+ LOGV("Create new client(%d) from pid %d, audioSessionId=%d",
+ connId, pid, audioSessionId);
+
+ if (OK != c->setDataSource(source)) {
+ c.clear();
+ } else {
+ wp<Client> w = c;
+ Mutex::Autolock lock(mLock);
+ mClients.add(w);
+ }
+
+ return c;
+}
+
sp<IOMX> MediaPlayerService::getOMX() {
Mutex::Autolock autoLock(mLock);
@@ -691,14 +706,6 @@ player_type getPlayerType(int fd, int64_t offset, int64_t length)
if (ident == 0x5367674f) // 'OggS'
return STAGEFRIGHT_PLAYER;
-#ifndef NO_OPENCORE
- if (ident == 0x75b22630) {
- // The magic number for .asf files, i.e. wmv and wma content.
- // These are not currently supported through stagefright.
- return PV_PLAYER;
- }
-#endif
-
// Some kind of MIDI?
EAS_DATA_HANDLE easdata;
if (EAS_Init(&easdata) == EAS_SUCCESS) {
@@ -725,6 +732,21 @@ player_type getPlayerType(const char* url)
return TEST_PLAYER;
}
+ char value[PROPERTY_VALUE_MAX];
+ if (!property_get("media.httplive.disable-nuplayer", value, NULL)
+ || (strcasecmp(value, "true") && strcmp(value, "1"))) {
+ if (!strncasecmp("http://", url, 7)) {
+ size_t len = strlen(url);
+ if (len >= 5 && !strcasecmp(".m3u8", &url[len - 5])) {
+ return NU_PLAYER;
+ }
+
+ if (strstr(url,"m3u8")) {
+ return NU_PLAYER;
+ }
+ }
+ }
+
// use MidiFile for MIDI extensions
int lenURL = strlen(url);
for (int i = 0; i < NELEM(FILE_EXTS); ++i) {
@@ -737,16 +759,6 @@ player_type getPlayerType(const char* url)
}
}
- if (!strncasecmp(url, "rtsp://", 7)) {
- char value[PROPERTY_VALUE_MAX];
- if (property_get("media.stagefright.enable-rtsp", value, NULL)
- && (strcmp(value, "1") && strcasecmp(value, "true"))) {
- // For now, we're going to use PV for rtsp-based playback
- // by default until we can clear up a few more issues.
- return PV_PLAYER;
- }
- }
-
return getDefaultPlayerType();
}
@@ -755,12 +767,6 @@ static sp<MediaPlayerBase> createPlayer(player_type playerType, void* cookie,
{
sp<MediaPlayerBase> p;
switch (playerType) {
-#ifndef NO_OPENCORE
- case PV_PLAYER:
- LOGV(" create PVPlayer");
- p = new PVPlayer();
- break;
-#endif
case SONIVOX_PLAYER:
LOGV(" create MidiFile");
p = new MidiFile();
@@ -769,10 +775,17 @@ static sp<MediaPlayerBase> createPlayer(player_type playerType, void* cookie,
LOGV(" create StagefrightPlayer");
p = new StagefrightPlayer;
break;
+ case NU_PLAYER:
+ LOGV(" create NuPlayer");
+ p = new NuPlayerDriver;
+ break;
case TEST_PLAYER:
LOGV("Create Test Player stub");
p = new TestPlayerStub();
break;
+ default:
+ LOGE("Unknown player type: %d", playerType);
+ return NULL;
}
if (p != NULL) {
if (p->initCheck() == NO_ERROR) {
@@ -891,7 +904,31 @@ status_t MediaPlayerService::Client::setDataSource(int fd, int64_t offset, int64
return mStatus;
}
-status_t MediaPlayerService::Client::setVideoSurface(const sp<ISurface>& surface)
+status_t MediaPlayerService::Client::setDataSource(
+ const sp<IStreamSource> &source) {
+ // create the right type of player
+ sp<MediaPlayerBase> p = createPlayer(NU_PLAYER);
+
+ if (p == NULL) {
+ return NO_INIT;
+ }
+
+ if (!p->hardwareOutput()) {
+ mAudioOutput = new AudioOutput(mAudioSessionId);
+ static_cast<MediaPlayerInterface*>(p.get())->setAudioSink(mAudioOutput);
+ }
+
+ // now set data source
+ mStatus = p->setDataSource(source);
+
+ if (mStatus == OK) {
+ mPlayer = p;
+ }
+
+ return mStatus;
+}
+
+status_t MediaPlayerService::Client::setVideoSurface(const sp<Surface>& surface)
{
LOGV("[%d] setVideoSurface(%p)", mConnId, surface.get());
sp<MediaPlayerBase> p = getPlayer();
@@ -966,20 +1003,6 @@ status_t MediaPlayerService::Client::getMetadata(
return OK;
}
-status_t MediaPlayerService::Client::suspend() {
- sp<MediaPlayerBase> p = getPlayer();
- if (p == 0) return UNKNOWN_ERROR;
-
- return p->suspend();
-}
-
-status_t MediaPlayerService::Client::resume() {
- sp<MediaPlayerBase> p = getPlayer();
- if (p == 0) return UNKNOWN_ERROR;
-
- return p->resume();
-}
-
status_t MediaPlayerService::Client::prepareAsync()
{
LOGV("[%d] prepareAsync", mConnId);