Get<type>Field Routines - GetShortField
NativeType Get<type>Field
(JNIEnv *env, jobject obj,
jfieldID fieldID);
This family of accessor routines returns the value of an instance (nonstatic) field of an object. The field to access is specified by a field ID obtained by calling
GetFieldID()
. (GetShortField)
The following table describes the Get<type>Field routine name and result type. You should replace type in Get<type>Field with the Java type of the field, or use one of the actual routine names from the table, and replace NativeType with the corresponding native type for that routine.
Table 4-1a Get<type>Field Family of Accessor Routines
LINKAGE:
Indices in the JNIEnv interface function table:
Table 4-1b Get<type>Field Family of Accessor Routines
PARAMETERS:
env
: the JNI interface pointer.obj
: a Java object (must not be NULL
).fieldID
: a valid field ID.RETURNS:
Returns the content of the field.
Example - GetShortField
JNIEXPORT jint JNICALL Java_org_cablelabs_impl_manager_timeshift_TimeShiftBufferImpl_nTSBBufferingStart (JNIEnv *env, jobject obj, jint tunerID, jint tsbHandle, jobject listenerObj, jobject pidMapTable, jint bitrate) { mpe_Error err; mpe_DvrBuffering tsbBufferingHandle; uint32_t pidCount = 0; mpe_DvrPidInfo *dvrPids = NULL; mpe_EdEventInfo *edHandle; jobjectArray pidMapEntryArray; uint32_t p; jobject pidMapEntry; if(pidMapTable == 0 ) { MPE_LOG(MPE_LOG_ERROR, MPE_MOD_JNI, "JNI(TSB): nTSBBufferingStart: ERROR - NULL PidMapTable\n"); return MPE_DVR_ERR_INVALID_PARAM; } MPE_LOG( MPE_LOG_DEBUG, MPE_MOD_JNI, "JNI(TSB): nTSBBufferingStart(tuner %d, tsb %d, bitrate %d)\n", tunerID, tsbHandle, bitrate ); // get the array of pid entries pidMapEntryArray = (*env)->GetObjectField(env, pidMapTable, jniutil_CachedIds.PidMapTable_pidMapEntryArray); pidCount = (*env)->GetIntField(env, pidMapTable, jniutil_CachedIds.PidMapTable_pidTableSize); MPE_LOG(MPE_LOG_DEBUG, MPE_MOD_JNI, "JNI(TSB): nTSBBufferingStart: number of pids is %d\n", pidCount); if(pidCount == 0 ) { MPE_LOG(MPE_LOG_ERROR, MPE_MOD_JNI, "JNI(TSB): nTSBBufferingStart: ERROR - number of pids is %d\n", pidCount); return MPE_DVR_ERR_INVALID_PARAM; } // allocate dvr pidInfo table err = mpe_memAllocP(MPE_MEM_TEMP, sizeof(mpe_DvrPidInfo) * pidCount, (void**)&dvrPids); if (err != MPE_SUCCESS) { MPE_LOG(MPE_LOG_ERROR, MPE_MOD_JNI, "JNI(TSB): nTSBBufferingStart: ERROR - failed to allocate pid table\n"); return err; } // Create the ed handle to pass into the DVR APIs mpe_edCreateHandle( listenerObj, MPE_ED_QUEUE_NORMAL, NULL, MPE_ED_TERMINATION_EVCODE, MPE_DVR_EVT_SESSION_CLOSED, &edHandle ); // walk through the pidEntryArray to create the DVR PidInfo table for(p=0; p < pidCount; p++) { // get pidMapEntryArray[p] (a PidMapEntry object) pidMapEntry = (*env)->GetObjectArrayElement(env,pidMapEntryArray, p); // get the PidmapEntry fields if (pidMapEntry != NULL) { dvrPids[p].srcPid = (uint16_t)(*env)->GetIntField(env, pidMapEntry, jniutil_CachedIds.PidMapEntry_srcPID); dvrPids[p].srcEltStreamType = (*env)->GetShortField(env, pidMapEntry, jniutil_CachedIds.PidMapEntry_srcElementaryStreamType); dvrPids[p].recPid = (uint16_t)(*env)->GetIntField(env, pidMapEntry, jniutil_CachedIds.PidMapEntry_recPID); dvrPids[p].recEltStreamType = (*env)->GetShortField(env, pidMapEntry, jniutil_CachedIds.PidMapEntry_recElementaryStreamType);; dvrPids[p].streamType = (*env)->GetShortField(env, pidMapEntry, jniutil_CachedIds.PidMapEntry_streamType); MPE_LOG( MPE_LOG_DEBUG, MPE_MOD_JNI, "JNI(TSB): nTSBBufferingStart: dvrPidInfo[%d]: type %d, src_pid %d(0x%x), src_elem %d(0x%x)\n", p, dvrPids[p].streamType, dvrPids[p].srcPid,dvrPids[p].srcPid, dvrPids[p].srcEltStreamType,dvrPids[p].srcEltStreamType ); } } err = mpe_dvrTsbBufferingStart( tunerID, (mpe_DvrTsb)tsbHandle, bitrate, edHandle->eventQ, (void *)edHandle, pidCount, dvrPids, &tsbBufferingHandle ); if (err == MPE_SUCCESS) { // Store the resulting TSB buffering handle (*env)->SetIntField( env, obj, jniutil_CachedIds.TimeShiftBufferImpl_bufferingHandle, (int)tsbBufferingHandle ); // update the PidMapTable with buffered pids jniutil_updatePidMapTable(env, pidCount, dvrPids, pidMapEntryArray); } // Free DVR PIDs if (dvrPids != NULL) { MPE_LOG(MPE_LOG_DEBUG, MPE_MOD_JNI, "JNI(TSB): nTSBBufferingStart: calling mpe_memFreeP...\n", err); mpe_memFreeP(MPE_MEM_TEMP, dvrPids); } return err; }