Esempio n. 1
0
static jint setConstraintFields(JNIEnv * env, jobject constraint, T_DRM_Constraint_Info * pConstraint)
{
    /* if no this permission */
    if (pConstraint->indicator == (uint8_t)DRM_NO_RIGHTS) {
        if (JNI_DRM_FAILURE == setObjectIntField(env, constraint, "count", 0))
            return JNI_DRM_FAILURE;

        return JNI_DRM_SUCCESS;
    }

    /* set count field */
    if (pConstraint->indicator & DRM_COUNT_CONSTRAINT) {
        if (JNI_DRM_FAILURE == setObjectIntField(env, constraint, "count", pConstraint->count))
            return JNI_DRM_FAILURE;
    }

    /* set start time field */
    if (pConstraint->indicator & DRM_START_TIME_CONSTRAINT) {
        int64_t startTime;

        startTime = computeTime(pConstraint->startDate, pConstraint->startTime);

        if (JNI_DRM_FAILURE == setObjectLongField(env, constraint, "startDate", startTime))
            return JNI_DRM_FAILURE;
    }

    /* set end time field */
    if (pConstraint->indicator & DRM_END_TIME_CONSTRAINT) {
        int64_t endTime;

        endTime = computeTime(pConstraint->endDate, pConstraint->endTime);

        if (JNI_DRM_FAILURE == setObjectLongField(env, constraint, "endDate", endTime))
            return JNI_DRM_FAILURE;
    }

    /* set interval field */
    if (pConstraint->indicator & DRM_INTERVAL_CONSTRAINT) {
        int64_t interval;

        interval = computeInterval(pConstraint->intervalDate, pConstraint->intervalTime);

        if (JNI_DRM_FAILURE == setObjectLongField(env, constraint, "interval", interval))
            return JNI_DRM_FAILURE;
    }

    return JNI_DRM_SUCCESS;
}
Esempio n. 2
0
void Listener::pushVideoPacket(UInt32 time,PacketReader& packet) {
	if(!receiveVideo) {
		_firstKeyFrame=false;
		return;
	}
	if(!_pVideoWriter) {
		ERROR("Listener %u must be initialized before to be used",id);
		return;
	}
	// key frame ?
	if(((*packet.current())&0xF0) == 0x10)
		_firstKeyFrame=true;

	if(!_firstKeyFrame) {
		DEBUG("Video frame dropped for listener %u to wait first key frame",id);
		++(UInt32&)_pVideoWriter->qos.droppedFrames;
		return;
	}

	if(_pVideoWriter->reseted) {
		_pVideoWriter->reseted=false;
		writeBounds();
	}

	_pVideoWriter->write(computeTime(time),packet,_unbuffered);
}
Esempio n. 3
0
void Listener::pushAudioPacket(UInt32 time,PacketReader& packet) {
	if(!_pAudioWriter) {
		ERROR("Listener %u must be initialized before to be used",id);
		return;
	}
	if(_pAudioWriter->reseted) {
		_pAudioWriter->reseted=false;
		writeBounds();
	}
	_pAudioWriter->write(computeTime(time),packet,_unbuffered);
}
GTreeGeometry::GTreeGeometry(TypeTree *t, double min, double max)
{
    tree = t;
    time = NULL;
    inf = NULL;
    sup = NULL;
    setMinMaxTime(min, max);
    if(tree != NULL && tree->size > 0) {
        computeTime();
        start = new QPointF[tree->size];
    } else
        start = NULL;
}
Esempio n. 5
0
/**
 * Recompute the time and update the status fields isTimeSet
 * and areFieldsSet.  Callers should check isTimeSet and only
 * call this method if isTimeSet is false.
 */
void 
Calendar::updateTime(UErrorCode& status) 
{
    computeTime(status);
    if(U_FAILURE(status))
        return;
        
    // If we are lenient, we need to recompute the fields to normalize
    // the values.  Also, if we haven't set all the fields yet (i.e.,
    // in a newly-created object), we need to fill in the fields. [LIU]
    if (isLenient() || ! fAreAllFieldsSet) 
        fAreFieldsSet = FALSE;
    
    fIsTimeSet = TRUE;
}
Esempio n. 6
0
int
main(int argc, char *argv[])
{
    int c, fd;
    long ret;
    extern int optind;
    const char *optlet = "v";
    char *endptr;
    int verbose = 0;
    char * file;
    long size = 1 << 20;
    long nb_pages;
    long i;
    
    while ((c = getopt(argc, argv, optlet)) != EOF) {
	switch (c) {
	case 'v':
	    verbose = 1;
	    break;
	case '?':
	default:
	    usage(argv[0]);
	    return (1);
	}
    }

    if (optind == argc) {
	fprintf(stderr, "%s: No file given\n", argv[0]);
	usage(argv[0]);
	return (1);
    }
    file = argv[optind++];
    if (optind < argc) { // one more argument
	size = strtol(argv[optind], &endptr , 0);
	if (*endptr!= '\0') {
	    fprintf(stderr, "%s: invalid argument for request size %s\n", argv[0], argv[optind]);
	    usage(argv[0]);
	    return 1;
	}
	if (size % 0x1000 != 0) {
	    fprintf(stderr, "%s: invalid argument for request size %s: should be MULTIPLE OF 4K\n",
		    argv[0], argv[optind]);
	    usage(argv[0]);
	    return 1;
	}
    }
    nb_pages = size / 0x1000;

    fd = open (file, O_CREAT |O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR);
    if (fd == -1) {
	fprintf(stderr, "%s: open(%s) failed with %s\n",
		argv[0], file, strerror(errno));
	return 1;
    }

    char *buffer = (char*) malloc(0x1000); // allocate 4k
    if (buffer == NULL) {
	fprintf(stderr, "%s: malloc failed\n", argv[0]);
	return 1;
    }
    memset(buffer, 1, 0x1000);
    
    printf("%s: Writing %ld pages (%ld MB) to file %s\n", argv[0], nb_pages, nb_pages/256, file);

    struct timeval before;
    if (gettimeofday(&before, NULL) != 0) {
	fprintf(stderr, "%s: gettimeofday failed (%s)\n", argv[0], strerror(errno));
	return 1;
    }
    
    for (i = 0; i < nb_pages; i++) {
	ret = write(fd, buffer, 0x1000);
	if (ret == -1) {
	    fprintf(stderr, "%s: write for %s failed with %s\n",
		    argv[0], file, strerror(errno));
	    return 1;
	}    
	if (ret != 0x1000) {
	    fprintf(stderr, "%s: write returned %ld\n", argv[0], ret);
	    return 1;
	}
    }

    struct timeval afterWrite;
    if (gettimeofday(&afterWrite, NULL) != 0) {
	fprintf(stderr, "%s: gettimeofday failed (%s)\n", argv[0], strerror(errno));
	return 1;
    }

    ret = fsync(fd);
    if (ret == -1) {
	fprintf(stderr, "%s: fsync failed (%s)\n", argv[0], strerror(errno));
	return 1;
    }
	
    struct timeval afterFsync;
    if (gettimeofday(&afterFsync, NULL) != 0) {
	fprintf(stderr, "%s: gettimeofday failed (%s)\n", argv[0], strerror(errno));
	return 1;
    }

    struct timeval t1, t2;
    computeTime(&before, &afterWrite, &t1);
    computeTime(&afterWrite, &afterFsync, &t2);
    printf("%s:\n\tTime for writing: %ld sec %ld usec\n", argv[0], t1.tv_sec, t1.tv_usec);
    printf("\tTime for fsync:   %ld sec %ld usec\n", t2.tv_sec, t2.tv_usec);

    return 0;
}
void GTreeGeometry::setTree(TypeTree *t) {
    tree = t;
    computeTime();
}