_status_t MagPlayerClient::setDataSource(const sp<IStreamBuffer> &source){
    AGILE_LOGV("setDataSource stream buffer");
    _status_t err = MAG_BAD_VALUE;

    const sp<IMagPlayerService>& service(getMagPlayerService());
    if (service != 0) {
        sp<IMagPlayerClient> player(service->create(getpid(), this));
        if (MAG_NO_ERROR != player->setDataSource(source)) {
            player.clear();
        }
        err = attachNewPlayer(player);
    }
    return err;
}
status_t MediaPlayer::setDataSource(const sp<IStreamSource> &source)
{
    ALOGV("setDataSource");
    status_t err = UNKNOWN_ERROR;
    const sp<IMediaPlayerService>& service(getMediaPlayerService());
    if (service != 0) {
        sp<IMediaPlayer> player(service->create(getpid(), this, mAudioSessionId));
        if (NO_ERROR != player->setDataSource(source)) {
            player.clear();
        }
        err = attachNewPlayer(player);
    }
    return err;
}
status_t MediaPlayer::setDataSource(int fd, int64_t offset, int64_t length)
{
    ALOGV("setDataSource(%d, %lld, %lld)", fd, offset, length);
    status_t err = UNKNOWN_ERROR;
    const sp<IMediaPlayerService>& service(getMediaPlayerService());
    if (service != 0) {
        sp<IMediaPlayer> player(service->create(getpid(), this, mAudioSessionId));
        if (NO_ERROR != player->setDataSource(fd, offset, length)) {
            player.clear();
        }
        err = attachNewPlayer(player);
    }
    return err;
}
_status_t MagPlayerClient::setDataSource(i32 fd, i64 offset, i64 length)
{
    AGILE_LOGV("setDataSource(fd:%d, offset:%lld, length:%lld)", fd, offset, length);
    _status_t err = MAG_BAD_VALUE;
    
    const sp<IMagPlayerService>& service(getMagPlayerService());
    if (service != 0) {
        sp<IMagPlayerClient> player(service->create(getpid(), this));
        if (MAG_NO_ERROR != player->setDataSource(fd, offset, length)) {
            player.clear();
        }
        err = attachNewPlayer(player);
    }
    return err;
}
status_t MediaPlayer::setDataSource(const sp<IDataSource> &source)
{
    ALOGV("setDataSource(IDataSource)");
    status_t err = UNKNOWN_ERROR;
    const sp<IMediaPlayerService>& service(getMediaPlayerService());
    if (service != 0) {
        sp<IMediaPlayer> player(service->create(this, mAudioSessionId));
        if ((NO_ERROR != doSetRetransmitEndpoint(player)) ||
            (NO_ERROR != player->setDataSource(source))) {
            player.clear();
        }
        err = attachNewPlayer(player);
    }
    return err;
}
status_t MediaPlayer::setDataSource(int fd, int64_t offset, int64_t length)
{
    ALOGV("setDataSource(%d, %" PRId64 ", %" PRId64 ")", fd, offset, length);
    status_t err = UNKNOWN_ERROR;
    const sp<IMediaPlayerService>& service(getMediaPlayerService());
    if (service != 0) {
        sp<IMediaPlayer> player(service->create(this, mAudioSessionId));
        if ((NO_ERROR != doSetRetransmitEndpoint(player)) ||
            (NO_ERROR != player->setDataSource(fd, offset, length))) {
            player.clear();
        }
        err = attachNewPlayer(player);
    }
    return err;
}
_status_t MagPlayerClient::setDataSource(const char *url)
{
    AGILE_LOGV("setDataSource(%s)", url);
    _status_t err = MAG_BAD_VALUE;
    
    if (url != NULL) {
        const sp<IMagPlayerService>& service(getMagPlayerService());
        if (service != 0) {
            sp<IMagPlayerClient> player(service->create(getpid(), this));
            if (MAG_NO_ERROR != player->setDataSource(url)) {
                player.clear();
            }
            err = attachNewPlayer(player);
        }
    }
    return err;
}
status_t MediaPlayer::setDataSource(
        const char *url, const KeyedVector<String8, String8> *headers)
{
    ALOGV("setDataSource(%s)", url);
    status_t err = BAD_VALUE;
    if (url != NULL) {
        const sp<IMediaPlayerService>& service(getMediaPlayerService());
        if (service != 0) {
            sp<IMediaPlayer> player(service->create(getpid(), this, mAudioSessionId));
            if (NO_ERROR != player->setDataSource(url, headers)) {
                player.clear();
            }
            err = attachNewPlayer(player);
        }
    }
    return err;
}