virtual status_t attachAuxEffect(int effectId) = 0;
virtual status_t setParameter(int key, const Parcel& request) = 0;
virtual status_t getParameter(int key, Parcel* reply) = 0;
- virtual status_t setMediaPlayerType(int playerType) = 0;
// Invoke a generic method on the player by using opaque parcels
// for the request and reply.
status_t attachAuxEffect(int effectId);
status_t setParameter(int key, const Parcel& request);
status_t getParameter(int key, Parcel* reply);
- status_t setMediaPlayerType(int playerType);
private:
void clear_l();
int mVideoHeight;
int mAudioSessionId;
float mSendLevel;
- bool mOverridePlayerType;
- int mOverridePlayerTypeValue;
};
}; // namespace android
SET_VIDEO_SURFACETEXTURE,
SET_PARAMETER,
GET_PARAMETER,
- SET_MEDIA_PLAYER_TYPE,
};
class BpMediaPlayer: public BpInterface<IMediaPlayer>
return remote()->transact(GET_PARAMETER, data, reply);
}
- status_t setMediaPlayerType(int playerType) {
- Parcel data, reply;
- data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor());
- data.writeInt32(playerType);
- remote()->transact(SET_MEDIA_PLAYER_TYPE, data, &reply);
- return reply.readInt32();
- }
};
IMPLEMENT_META_INTERFACE(MediaPlayer, "android.media.IMediaPlayer");
CHECK_INTERFACE(IMediaPlayer, data, reply);
return getParameter(data.readInt32(), reply);
} break;
- case SET_MEDIA_PLAYER_TYPE: {
- CHECK_INTERFACE(IMediaPlayer, data, reply);
- reply->writeInt32(setMediaPlayerType(data.readInt32()));
- return NO_ERROR;
- } break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
mAudioSessionId = AudioSystem::newAudioSessionId();
AudioSystem::acquireAudioSessionId(mAudioSessionId);
mSendLevel = 0;
- mOverridePlayerType = false;
- mOverridePlayerTypeValue = -1;
}
MediaPlayer::~MediaPlayer()
const sp<IMediaPlayerService>& service(getMediaPlayerService());
if (service != 0) {
sp<IMediaPlayer> player(service->create(getpid(), this, mAudioSessionId));
-
- if (mOverridePlayerType) {
- if (NO_ERROR != player->setMediaPlayerType(mOverridePlayerTypeValue)) {
- player.clear();
- }
- }
-
- if (player != 0 && NO_ERROR != player->setDataSource(url, headers)) {
+ if (NO_ERROR != player->setDataSource(url, headers)) {
player.clear();
}
err = attachNewPlayer(player);
const sp<IMediaPlayerService>& service(getMediaPlayerService());
if (service != 0) {
sp<IMediaPlayer> player(service->create(getpid(), this, mAudioSessionId));
-
- if (mOverridePlayerType) {
- if (NO_ERROR != player->setMediaPlayerType(mOverridePlayerTypeValue)) {
- player.clear();
- }
- }
-
- if (player != 0 && NO_ERROR != player->setDataSource(fd, offset, length)) {
+ if (NO_ERROR != player->setDataSource(fd, offset, length)) {
player.clear();
}
err = attachNewPlayer(player);
return INVALID_OPERATION;
}
-status_t MediaPlayer::setMediaPlayerType(int playerType) {
- if (!((mCurrentState & MEDIA_PLAYER_IDLE) ||
- (mCurrentState == MEDIA_PLAYER_STATE_ERROR))) {
- LOGE("attachNewPlayer called in state %d", mCurrentState);
- return INVALID_OPERATION;
- }
-
- mOverridePlayerType = true;
- mOverridePlayerTypeValue = playerType;
-
- return NO_ERROR;
-}
-
void MediaPlayer::notify(int msg, int ext1, int ext2, const Parcel *obj)
{
LOGV("message received msg=%d, ext1=%d, ext2=%d", msg, ext1, ext2);
LOGD("create Antagonizer");
mAntagonizer = new Antagonizer(notify, this);
#endif
-
- mOverridePlayerType = false;
- mOverridePlayerTypeValue = static_cast<player_type>(-1);
}
MediaPlayerService::Client::~Client()
close(fd);
return mStatus;
} else {
- player_type playerType = mOverridePlayerType ?
- mOverridePlayerTypeValue : getPlayerType(url);
+ player_type playerType = getPlayerType(url);
LOGV("player type = %d", playerType);
// create the right type of player
LOGV("calculated length = %lld", length);
}
- player_type playerType = mOverridePlayerType ?
- mOverridePlayerTypeValue : getPlayerType(fd, offset, length);
+ player_type playerType = getPlayerType(fd, offset, length);
LOGV("player type = %d", playerType);
// create the right type of player
return p->getParameter(key, reply);
}
-status_t MediaPlayerService::Client::setMediaPlayerType(int playerType) {
- mOverridePlayerType = true;
- mOverridePlayerTypeValue = static_cast<player_type>(playerType);
-
- return NO_ERROR;
-}
-
void MediaPlayerService::Client::notify(
void* cookie, int msg, int ext1, int ext2, const Parcel *obj)
{
virtual status_t attachAuxEffect(int effectId);
virtual status_t setParameter(int key, const Parcel &request);
virtual status_t getParameter(int key, Parcel *reply);
- virtual status_t setMediaPlayerType(int playerType);
sp<MediaPlayerBase> createPlayer(player_type playerType);
// getMetadata clears this set.
media::Metadata::Filter mMetadataUpdated; // protected by mLock
- bool mOverridePlayerType;
- player_type mOverridePlayerTypeValue;
-
#if CALLBACK_ANTAGONIZER
Antagonizer* mAntagonizer;
#endif