/** analyze arp header **/ int analyze_arp(JNIEnv *env,jobject packet,u_char *data){ /** XXX assume Ethernet ARP**/ struct ether_arp *arp=(struct ether_arp *)data; jbyteArray sha,spa,tha,tpa; u_char hl,pl; #ifdef DEBUG puts ("analyze arp"); #endif hl=arp->arp_hln; pl=arp->arp_pln; sha=(*env)->NewByteArray(env,hl); (*env)->SetByteArrayRegion(env,sha,0,hl,(char *)(data+sizeof(struct arphdr))); spa=(*env)->NewByteArray(env,pl); (*env)->SetByteArrayRegion(env,spa,0,pl,(char *)(data+sizeof(struct arphdr)+hl)); tha=(*env)->NewByteArray(env,hl); (*env)->SetByteArrayRegion(env,tha,0,hl,(char *)(data+sizeof(struct arphdr)+hl+pl)); tpa=(*env)->NewByteArray(env,pl); (*env)->SetByteArrayRegion(env,tpa,0,pl,(char *)(data+sizeof(struct arphdr)+hl+pl+hl)); (*env)->CallVoidMethod(env,packet,setARPValueMID, (jshort)ntohs(arp->arp_hrd), (jshort)ntohs(arp->arp_pro), (jshort)hl,(jshort)pl, (jshort)ntohs(arp->arp_op), sha,spa,tha,tpa); DeleteLocalRef(sha); DeleteLocalRef(spa); DeleteLocalRef(tha); DeleteLocalRef(tpa); return sizeof(struct arphdr)+hl*2+pl*2; }
/** analyze datalink layer (ethernet) **/ jobject analyze_datalink(JNIEnv *env,u_char *data,int linktype){ struct ether_header *ether_hdr; jobject packet; jbyteArray src_addr,dst_addr; #ifdef DEBUG puts("analyze datalink"); #endif switch(linktype){ case DLT_EN10MB: packet=AllocObject(EthernetPacket); src_addr=(*env)->NewByteArray(env,6); dst_addr=(*env)->NewByteArray(env,6); ether_hdr=(struct ether_header *)data; (*env)->SetByteArrayRegion(env,src_addr,0,6,ether_hdr->ether_src); (*env)->SetByteArrayRegion(env,dst_addr,0,6,ether_hdr->ether_dest); (*env)->CallVoidMethod(env,packet,setEthernetValueMID,dst_addr,src_addr, (jchar)ntohs(ether_hdr->ether_type)); DeleteLocalRef(src_addr); DeleteLocalRef(dst_addr); break; default: packet=AllocObject(DatalinkPacket); break; } return packet; }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------ JavaStaticClass::JavaStaticClass(const JavaStaticClassDef& in_javaStaticClassDef) { auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment(); //Get the class m_className = in_javaStaticClassDef.GetClassName(); jclass jClass = environment->FindClass(m_className.c_str()); CS_ASSERT(jClass != nullptr, "Could not find Java class: '" + m_className + "'"); m_javaClass = static_cast<jclass>(environment->NewGlobalRef(jClass)); environment->DeleteLocalRef(jClass); //setup the method references for (const auto& method : in_javaStaticClassDef.GetMethods()) { CS_ASSERT(m_methods.find(method.first) == m_methods.end(), "Method '" + method.first + "' has already been added to Java static class '" + m_className + "'"); MethodInfo info; info.m_returnType = JavaMethodSignature::CalcReturnType(method.second); info.m_numArguments = JavaMethodSignature::CalcNumArguments(method.second); info.m_methodId = environment->GetStaticMethodID(m_javaClass, method.first.c_str(), method.second.c_str()); CS_ASSERT(info.m_methodId != nullptr, "Could not find method '" + method.first + "' in Java static class '" + m_className + "'"); m_methods.emplace(method.first, info); } }
NS_IMETHODIMP nsPluggableJVM::GetJavaWrapper(jint obj, jobject *wrapper) { struct Java_CallInfo* call; nsresult rv = NS_OK; *wrapper = NULL; if (!m_extID) return NS_ERROR_FAILURE; nsWFSecureEnv::CreateJavaCallInfo(&call, NULL); call->type = Java_WrapJSObject; call->jException = NULL; call->data.__wrapJSObject.jsObject = obj; call->data.__wrapJSObject.jstid = (jint)PR_GetCurrentThread(); rv = ExtensionCall(1, PTR_TO_JLONG(call)); if (!NS_FAILED(rv)) { // XXX: do smth meaningful with possible Java exception if (call->jException) { DeleteLocalRef(call->jException); rv = NS_ERROR_FAILURE; } else { // global ref already created *wrapper = call->data.__wrapJSObject.jObject; } } nsWFSecureEnv::CleanupJavaCallInfo(call, NULL); return rv; }
JNIEXPORT jint JNICALL Java_com_pbi_dvb_dvbinterface_NativePlayer_DVBPlayerPvrPlayGetFileInfo( JNIEnv *env, jobject obj, jobject jFileInfoObj) { jclass jCls = NULL; DVBPlayer_PVR_FILE_ATTR_t tPvrFileAttr; jCls = env->GetObjectClass(jFileInfoObj); if (NULL == jCls) { return -1; } memset(&tPvrFileAttr, 0, sizeof(DVBPlayer_PVR_FILE_ATTR_t)); DVBPlayer_Set_Attr(eDVBPLAYER_ATTR_PVR_GET_FILE_INFO, (void *) &tPvrFileAttr); SetIntCtoJava(env, jFileInfoObj, jCls, "eIndxType", tPvrFileAttr.u32IdxType); SetIntCtoJava(env, jFileInfoObj, jCls, "u32FrameNum", tPvrFileAttr.u32FrameNum); SetIntCtoJava(env, jFileInfoObj, jCls, "u32StartTimeInMs", tPvrFileAttr.u32StartTimeInMs); SetIntCtoJava(env, jFileInfoObj, jCls, "u32EndTimeInMs", tPvrFileAttr.u32EndTimeInMs); SetDoubleCtoJava(env, jFileInfoObj, jCls, "u64ValidSizeInByte", tPvrFileAttr.u64ValidSizeInByte); DeleteLocalRef(env, jCls); return 0; }
JNIEXPORT jint JNICALL Java_com_pbi_dvb_dvbinterface_NativePlayer_DVBPlayerPvrPlayGetStatus( JNIEnv *env, jobject obj, jobject jPlayStautsObj) { jclass jCls = NULL; DVBPlayer_PVR_PLAY_STATUS_t tPvrStatusInfo; jCls = env->GetObjectClass(jPlayStautsObj); if (NULL == jCls) { return -1; } memset(&tPvrStatusInfo, 0, sizeof(DVBPlayer_PVR_PLAY_STATUS_t)); DVBPlayer_Set_Attr(eDVBPLAYER_ATTR_PVR_GET_STATUS, (void *) &tPvrStatusInfo); SetIntCtoJava(env, jPlayStautsObj, jCls, "eState", tPvrStatusInfo.u32State); SetIntCtoJava(env, jPlayStautsObj, jCls, "eSpeed", tPvrStatusInfo.u32Speed); SetIntCtoJava(env, jPlayStautsObj, jCls, "u32CurPlayFrame", tPvrStatusInfo.u32CurPlayFrame); SetIntCtoJava(env, jPlayStautsObj, jCls, "u32CurPlayTimeInMs", tPvrStatusInfo.u32CurPlayTimeInMs); SetDoubleCtoJava(env, jPlayStautsObj, jCls, "u64CurPlayPos", tPvrStatusInfo.u64CurPlayPos); DeleteLocalRef(env, jCls); return 0; }
NS_IMETHODIMP nsPluggableJVM::UnwrapJavaWrapper(jobject jobj, jint *jsobj) { struct Java_CallInfo* call; nsresult rv = NS_OK; if (jsobj == NULL || !m_extID) return NS_ERROR_FAILURE; if (jobj == NULL) { *jsobj = 0; return NS_OK; } *jsobj = 0; nsWFSecureEnv::CreateJavaCallInfo(&call, NULL); call->type = Java_UnwrapJObject; call->jException = NULL; call->data.__unwrapJObject.jObject = jobj; call->data.__unwrapJObject.jstid = (jint)PR_GetCurrentThread(); rv = ExtensionCall(1, PTR_TO_JLONG(call)); if (!NS_FAILED(rv)) { // XXX: do smth meaningful with possible Java exception if (call->jException) { DeleteLocalRef(call->jException); rv = NS_ERROR_FAILURE; } else { *jsobj = call->data.__unwrapJObject.jsObject; } } nsWFSecureEnv::CleanupJavaCallInfo(call, NULL); return rv; }
WMIService* WMIService::GetFromObject(JNIEnv* pJavaEnv, jobject javaObject) { jclass objectClass = pJavaEnv->GetObjectClass(javaObject); jfieldID fid = pJavaEnv->GetFieldID(objectClass, "serviceHandle", "J"); DeleteLocalRef(pJavaEnv, objectClass); _ASSERT(fid != NULL); if (fid == NULL) { return NULL; } return (WMIService*)pJavaEnv->GetLongField(javaObject, fid); }
void _copyString(const std::string &value) { auto env = spjni::getJniEnv(); auto clipboard = spjni::getService(spjni::Service::Clipboard, env); auto clipboardClass = env->GetObjectClass(clipboard); auto method = spjni::getMethodID(env, clipboardClass, "copyStringToClipboard", "(Ljava/lang/String;)V"); if (method) { auto str = env->NewStringUTF(value.c_str()); env->CallVoidMethod(clipboard, method, str); env->DeleteLocalRef(str); } }
/** analyze tcp header **/ u_short analyze_tcp(JNIEnv *env,jobject packet,u_char *data){ struct tcphdr *tcp_pkt=(struct tcphdr *)data; u_short hdrlen; #ifdef DEBUG puts("analze tcp"); #endif // updated by Damien Daspit 5/7/01 (*env)->CallVoidMethod(env,packet,setTCPValueMID, (jint)ntohs(tcp_pkt->th_sport), (jint)ntohs(tcp_pkt->th_dport), (jlong)ntohl(tcp_pkt->th_seq), (jlong)ntohl(tcp_pkt->th_ack), (jboolean)(((tcp_pkt->th_flags&TH_URG)>0)?JNI_TRUE:JNI_FALSE), (jboolean)(((tcp_pkt->th_flags&TH_ACK)>0)?JNI_TRUE:JNI_FALSE), (jboolean)(((tcp_pkt->th_flags&TH_PUSH)>0)?JNI_TRUE:JNI_FALSE), (jboolean)(((tcp_pkt->th_flags&TH_RST)>0)?JNI_TRUE:JNI_FALSE), (jboolean)(((tcp_pkt->th_flags&TH_SYN)>0)?JNI_TRUE:JNI_FALSE), (jboolean)(((tcp_pkt->th_flags&TH_FIN)>0)?JNI_TRUE:JNI_FALSE), (jboolean)(((tcp_pkt->th_flags&TH_RSV1)>0)?JNI_TRUE:JNI_FALSE), (jboolean)(((tcp_pkt->th_flags&TH_RSV2)>0)?JNI_TRUE:JNI_FALSE), (jint)ntohs(tcp_pkt->th_win), (jshort)ntohs(tcp_pkt->th_urp)); // ******************************* hdrlen=tcp_pkt->th_off*4; /** Handle options **/ if(hdrlen>TCPHDRLEN){ jbyteArray dataArray=(*env)->NewByteArray(env,hdrlen-TCPHDRLEN); (*env)->SetByteArrayRegion(env,dataArray,0,hdrlen-TCPHDRLEN,data+TCPHDRLEN); (*env)->CallVoidMethod(env,packet,setTCPOptionMID,dataArray); DeleteLocalRef(dataArray); } /*if(caplen>hdrlen){ jbyteArray dataArray=(*env)->NewByteArray(env,caplen-hdrlen); (*env)->SetByteArrayRegion(env,dataArray,0, caplen-hdrlen,data+hdrlen); (*env)->CallVoidMethod(env,packet,setPacketDataMID,dataArray); DeleteLocalRef(dataArray); }else{ (*env)->CallVoidMethod(env,packet,setPacketDataMID, (*env)->NewByteArray(env,0)); }*/ return hdrlen; }
unsigned int ActivityState::getAPILevel() { auto env = Thread::getCurrentJavaEnv(); if (!env) { JOP_DEBUG_ERROR("No current java environment, function \"" << __func__ << "\""); return 0; } static unsigned int api = 0; if (!api) { jclass versionClass = env->FindClass("android/os/Build$VERSION"); if (!versionClass) { JOP_DEBUG_ERROR("Failed to get Android API level"); return 0; } jfieldID IDField = env->GetStaticFieldID(versionClass, "SDK_INT", "I"); if (!IDField) { JOP_DEBUG_ERROR("Failed to get Android API level"); env->DeleteLocalRef(versionClass); return 0; } api = static_cast<unsigned int>(env->GetStaticIntField(versionClass, IDField)); env->DeleteLocalRef(versionClass); } return api; }
ActivityState* ActivityState::create(ANativeActivity* activity) { JOP_ASSERT(ns_instance == nullptr, "There must only be one ActivityState!"); ns_instance.reset(new ActivityState); ns_instance->nativeActivity = activity; ANativeActivity_setWindowFlags(activity, AWINDOW_FLAG_KEEP_SCREEN_ON, AWINDOW_FLAG_KEEP_SCREEN_ON); Thread::attachJavaThread(activity->vm, activity->env); // Get the screen size { auto env = Thread::getCurrentJavaEnv(); if (!env) { JOP_DEBUG_ERROR("No current java environment, function \"" << __func__ << "\""); return get(); } jclass activityClass = env->GetObjectClass(activity->clazz); jclass displayMetricsClass = env->FindClass("android/util/DisplayMetrics"); jmethodID displayMetricsInit = env->GetMethodID(displayMetricsClass, "<init>", "()V"); jobject displayMetricsObject = env->NewObject(displayMetricsClass, displayMetricsInit); jmethodID getWindowManagerMethod = env->GetMethodID(activityClass, "getWindowManager", "()Landroid/view/WindowManager;"); jobject windowManagerObject = env->CallObjectMethod(activity->clazz, getWindowManagerMethod); jclass windowManagerClass = env->FindClass("android/view/WindowManager"); jmethodID getDefaultDisplayMethod = env->GetMethodID(windowManagerClass, "getDefaultDisplay", "()Landroid/view/Display;"); jobject displayObject = env->CallObjectMethod(windowManagerObject, getDefaultDisplayMethod); jclass displayClass = env->FindClass("android/view/Display"); jmethodID getMetricsMethod = env->GetMethodID(displayClass, "getMetrics", "(Landroid/util/DisplayMetrics;)V"); env->CallVoidMethod(displayObject, getMetricsMethod, displayMetricsObject); jfieldID pixelsWidth = env->GetFieldID(displayMetricsClass, "widthPixels", "I"); jfieldID pixelsHeight = env->GetFieldID(displayMetricsClass, "heightPixels", "I"); ns_instance->screenSize.x = env->GetIntField(displayMetricsObject, pixelsWidth); ns_instance->screenSize.y = env->GetIntField(displayMetricsObject, pixelsHeight); //jmethodID getRefreshRateMethod = env->GetMethodID(displayClass, "getRefreshRate", "(Landroid/view/Display;)F"); ns_instance->screenRefreshRate = 60;//env->CallFloatMethod(displayObject, getRefreshRateMethod); env->DeleteLocalRef(activityClass); env->DeleteLocalRef(displayMetricsObject); env->DeleteLocalRef(windowManagerObject); env->DeleteLocalRef(windowManagerClass); env->DeleteLocalRef(displayObject); env->DeleteLocalRef(displayClass); } return get(); }
/* * Class: com_pbi_dvb_dvbinterface_NativePlayer * Method: DVBPlayerAVCtrlSetWindows * Signature: (Lcom/pbi/dvb/dvbinterface/NativePlayer/DRV_AVCtrl_VidWindow_t;)I */ JNIEXPORT jint JNICALL Java_com_pbi_dvb_dvbinterface_NativePlayer_DVBPlayerAVCtrlSetWindows( JNIEnv *env, jobject obj, jobject jSetWinObj, jint isCheak) { jclass jObjCls = NULL; int iRet = 0; DRV_AVCtrl_VidWindow_t tVidOut_Window; DRV_AVCtrl_VidWindow_t tGetVidOut_Window; memset(&tVidOut_Window, 0, sizeof(DRV_AVCtrl_VidWindow_t)); memset(&tGetVidOut_Window, 0, sizeof(DRV_AVCtrl_VidWindow_t)); if(isCheak) { iRet = DVBPlayer_Get_Attr( eDVBPLAYER_ATTR_VID_WINDWOS, (void *)&tGetVidOut_Window ); if( 0 != iRet ) { return -1; } } else { tGetVidOut_Window.uBaseWidth = 0; tGetVidOut_Window.uBaseHeight = 0; } jObjCls = env->GetObjectClass(jSetWinObj); if (NULL == jObjCls) { return -1; } tVidOut_Window.uX_Axis = GetIntJavaToC(env, jSetWinObj, jObjCls, "uX_Axis"); tVidOut_Window.uY_Axis = GetIntJavaToC(env, jSetWinObj, jObjCls, "uY_Axis"); tVidOut_Window.uWidth = GetIntJavaToC(env, jSetWinObj, jObjCls, "uWidth"); tVidOut_Window.uHeight = GetIntJavaToC(env, jSetWinObj, jObjCls, "uHeight"); tVidOut_Window.uX_Axis = tVidOut_Window.uX_Axis; // * tGetVidOut_Window.uWidth / 1920; tVidOut_Window.uY_Axis = tVidOut_Window.uY_Axis; // * tGetVidOut_Window.uHeight / 1080; tVidOut_Window.uWidth = tVidOut_Window.uWidth; // * tGetVidOut_Window.uWidth / 1920; tVidOut_Window.uHeight = tVidOut_Window.uHeight; // * tGetVidOut_Window.uHeight / 1080; tVidOut_Window.uBaseWidth = tGetVidOut_Window.uWidth; tVidOut_Window.uBaseHeight = tGetVidOut_Window.uHeight; iRet = DVBPlayer_Set_Attr(eDVBPLAYER_ATTR_VID_WINDWOS, (void *) &tVidOut_Window); DeleteLocalRef(env, jObjCls); return iRet; }
jobject WMIService::MakeWMIObject(JNIEnv* pJavaEnv, IWbemClassObject *pClassObject) { // Create instance JNIMetaData& jniMeta = JNIMetaData::GetMetaData(pJavaEnv); jobject pWmiObject = pJavaEnv->NewObject(jniMeta.wmiObjectClass, jniMeta.wmiObjectConstructor); if (pWmiObject == NULL) { return NULL; } WMIObject* pObject = new WMIObject(pJavaEnv, pWmiObject, pClassObject); if (pJavaEnv->ExceptionCheck()) { DeleteLocalRef(pJavaEnv, pWmiObject); return NULL; } else { return pWmiObject; } }
JNIEXPORT jint JNICALL Java_com_pbi_dvb_dvbinterface_NativePlayer_DVBPlayerSwitchAudio( JNIEnv *env, jobject obj, jobject audioobj) { jclass jObjCls = NULL; int iRet = 0; DVBPlayer_SWITCH_AUDIOPID_t t; jObjCls = env->GetObjectClass(audioobj); if (NULL == jObjCls) { return -1; } t.u16AudioPid = GetIntJavaToC(env, audioobj, jObjCls, "u16AudioPid"); t.u16audiotype = GetIntJavaToC(env, audioobj, jObjCls, "u8AudeoFmt"); iRet = DVBPlayer_Set_Attr(eDVBPLAYER_ATTR_SWITCH_AUDIOPID, (void *) &t); DEBUG_MSG3(-1,T("%s++++++++++++%d=ret%d"),__FUNCTION__,__LINE__,iRet); DeleteLocalRef(env, jObjCls); return iRet; }
jobject JPJavaEnv::NewObject(jclass a0, jmethodID a1) { jobject res; JNIEnv* env = getJNIEnv(); void* _save = JPEnv::getHost()->gotoExternal(); res = env->functions->AllocObject(env, a0); JAVA_CHECK("NewObject"); env->functions->CallVoidMethod(env, res, a1); if (ExceptionCheck()) { DeleteLocalRef(res); } JPEnv::getHost()->returnExternal(_save); JAVA_CHECK("NewObject"); return res; }
/* * Class: com_pbi_dvb_dvbinterface_NativePlayer * Method: DVBPlayer_Get_Info * Signature: (Lcom/pbi/dvb/dvbinterface/NativePlayer/DVBPlayer_Info_t;)I */ JNIEXPORT jint JNICALL Java_com_pbi_dvb_dvbinterface_NativePlayer_DVBPlayerGetInfo( JNIEnv *env, jobject obj, jobject jInfoObj) { jint jRet = 0; jclass jCls = NULL; DVBPlayer_Info_t tInfo; memset(&tInfo, 0, sizeof(DVBPlayer_Info_t)); jRet = DVBPlayer_Get_Info(&tInfo); DEBUG_MSG2(-1,T("LinKang:: tInfo.u16VideoPid = %d, tInfo.u16AudioPid = %d"),tInfo.u16VideoPid ,tInfo.u16AudioPid); if (0 != jRet) { return jRet; } jCls = env->GetObjectClass(jInfoObj); if (NULL == jCls) { DEBUG_MSG2(-1,T("LinKang:: jCls = env->GetObjectClass( jInfoObj ) return null...%s%d"),__FUNCTION__,__LINE__); return -1; } SetIntCtoJava(env, jInfoObj, jCls, "eRunningStatus", tInfo.eRunningStatus); SetIntCtoJava(env, jInfoObj, jCls, "eTunerStatus", tInfo.eTunerStatus); SetIntCtoJava(env, jInfoObj, jCls, "eProgType", tInfo.eProgType); SetIntCtoJava(env, jInfoObj, jCls, "u16ServiceId", tInfo.u16ServiceId); SetIntCtoJava(env, jInfoObj, jCls, "u16PMTPid", tInfo.ePMTStatus); SetIntCtoJava(env, jInfoObj, jCls, "u16VideoPid", tInfo.u16VideoPid); SetIntCtoJava(env, jInfoObj, jCls, "u16AudioPid", tInfo.u16AudioPid); SetIntCtoJava(env, jInfoObj, jCls, "u16AudioPid", tInfo.u16AudioPid); SetIntCtoJava(env, jInfoObj, jCls, "u16PCRPid", tInfo.u16PCRPid); DEBUG_MSG2(-1,T("LinKang:: tInfo.u16VideoPid = %d, tInfo.u16AudioPid = %d"),tInfo.u16VideoPid ,tInfo.u16AudioPid); DeleteLocalRef(env, jCls); return jRet; }
JNIEXPORT jint JNICALL Java_com_pbi_dvb_dvbinterface_NativePlayer_DVBPlayerPvrRecStart( JNIEnv *env, jobject obj, jobject RecObj) { jclass RecCls = NULL; jobject TunerObj = NULL; jstring jName = NULL; jfieldID jFidTemp = NULL; DVBPlayer_PVR_REC_t tPvrRecParam; int iTemp = 0; bool bRet = TRUE; RecCls = env->GetObjectClass(RecObj); if (NULL == RecCls) { DEBUG_MSG2(-1, "[%s %d] class is NULL !!!", __FUNCTION__, __LINE__ ); return -1; } memset(&tPvrRecParam, 0, sizeof(DVBPlayer_PVR_REC_t)); tPvrRecParam.u8RecFlag = GetIntJavaToC(env, RecObj, RecCls, "u8RecFlag"); tPvrRecParam.u16LogicNum = GetIntJavaToC(env, RecObj, RecCls, "u16LogicNum"); tPvrRecParam.u16ServId = GetIntJavaToC(env, RecObj, RecCls, "u16ServId"); tPvrRecParam.u16PmtPid = GetIntJavaToC(env, RecObj, RecCls, "u16PmtPid"); tPvrRecParam.u64MaxFileLength = GetDoubleJavaToC(env, RecObj, RecCls, "u64MaxFileLength"); jName = GetStringJavaToC(env, RecObj, RecCls, "sName"); Jstringtoc_UTF8(env, jName, tPvrRecParam.FileName); DEBUG_MSG2(-1, "FileName =%s...Namelength=%d..\n", tPvrRecParam.FileName,strlen(tPvrRecParam.FileName) ); tPvrRecParam.FileName[strlen(tPvrRecParam.FileName)] = '\0'; if (0 == tPvrRecParam.u8RecFlag) { iTemp = GetIntJavaToC(env, RecObj, RecCls, "eTunerType"); switch (iTemp) { case eDVBCORE_SIGNAL_SOURCE_DVBC: { jFidTemp = env->GetFieldID(RecCls, "tCableInfo", "Lcom/pbi/dvb/dvbinterface/Tuner$DVBCore_Cab_Desc_t;"); if (NULL == jFidTemp) { DEBUG_MSG(-1,T("DVBPlayerPvrRecStart DVBCore_Cab_Desc_t error!")); DeleteLocalRef(env, RecCls); return -1; } TunerObj = env->GetObjectField(RecObj, jFidTemp); bRet = GetDvbCroeCableDescClass(env, TunerObj, &tPvrRecParam.tBackRec.uTunerDesc.tCable); if (FALSE == bRet) { DEBUG_MSG(-1,T("DVBPlayerPvrRecStart DvbCroeCableDescClass error!")); DeleteLocalRef(env, RecCls); DeleteLocalRef(env, TunerObj); return -1; } DeleteLocalRef(env, TunerObj); } break; default: { } } } else { } DeleteLocalRef(env, RecCls); return DVBPlayer_REC_Play(&tPvrRecParam); }
/* * Class: com_pbi_dvb_dvbinterface_NativePlayer * Method: DVBPlayer_Play_Program * Signature: (Lcom/pbi/dvb/dvbinterface/NativePlayer/DVBPlayer_Play_Param_t;)I */ JNIEXPORT jint JNICALL Java_com_pbi_dvb_dvbinterface_NativePlayer_DVBPlayerPlayProgram( JNIEnv *env, jobject obj, jobject jPlayProgObj) { jclass jObjCls = NULL; jclass jClsTemp = NULL; jfieldID jFidTemp = NULL; jobject jObjTemp = NULL; jint jRet = 0; int iTunerType = 0; int iProgType = 0; bool bRet = TRUE; DVBPlayer_Play_Param_t tParam; memset(&tParam, 0, sizeof(DVBPlayer_Play_Param_t)); jObjCls = env->GetObjectClass(jPlayProgObj); if (NULL == jObjCls) { return -1; } iTunerType = GetIntJavaToC(env, jPlayProgObj, jObjCls, "eSignalSource"); iProgType = GetIntJavaToC(env, jPlayProgObj, jObjCls, "eProgType"); switch (iTunerType) { case eDVBCORE_SIGNAL_SOURCE_DVBC: { jFidTemp = env->GetFieldID(jObjCls, "tCable", "Lcom/pbi/dvb/dvbinterface/Tuner$DVBCore_Cab_Desc_t;"); if (jFidTemp == NULL) { DEBUG_MSG2(-1,T("+++++++++++++%s=====obj is null=====%d-------"),__FUNCTION__,__LINE__); return -1; } jObjTemp = env->GetObjectField(jPlayProgObj, jFidTemp); if (jObjTemp == NULL) { DEBUG_MSG2(-1,T("+++++++++++++%s=====obj is null=====%d-------"),__FUNCTION__,__LINE__); return -1; } bRet = GetDvbCroeCableDescClass(env, jObjTemp, &tParam.uTunerParam.tCable); if (TRUE != bRet) { DeleteLocalRef(env, jObjCls); DeleteLocalRef(env, jObjTemp); return -1; } } break; default: { } break; } DeleteLocalRef(env, jObjTemp); switch (iProgType) { case 0: { jFidTemp = env->GetFieldID(jObjCls, "tServParam", "Lcom/pbi/dvb/dvbinterface/NativePlayer$DVBPlayer_Serv_Param_t;"); if (jFidTemp == NULL) { DEBUG_MSG2(-1,T("%s++++++++++++%d="),__FUNCTION__,__LINE__); return -1; } jObjTemp = env->GetObjectField(jPlayProgObj, jFidTemp); if (jObjTemp == NULL) { DEBUG_MSG2(-1,T("%s++++++++++++%d="),__FUNCTION__,__LINE__); return -1; } jClsTemp = env->GetObjectClass(jObjTemp); if (jClsTemp == NULL) { DEBUG_MSG2(-1,T("%s++++++++++++%d="),__FUNCTION__,__LINE__); return -1; } tParam.uProgParam.tServParam.eProgType = (DVBPlayer_Prog_Type_e) iProgType; //DVBPLAYER_PROG_TYPE_SERVICE; tParam.uProgParam.tServParam.eServLockFlag = (DVBPlayer_Serv_Lock_e) GetIntJavaToC(env, jObjTemp, jClsTemp, "eServLockFlag"); tParam.uProgParam.tServParam.u16ServId = GetIntJavaToC(env, jObjTemp, jClsTemp, "u16ServId"); tParam.uProgParam.tServParam.u16PMTPid = GetIntJavaToC(env, jObjTemp, jClsTemp, "u16PMTPid"); tParam.uProgParam.tServParam.u16LogicNum = GetIntJavaToC(env, jObjTemp, jClsTemp, "u16LogicNum"); tParam.uProgParam.tServParam.u16TsId = GetIntJavaToC(env, jObjTemp, jClsTemp, "u16TS_Id"); tParam.uProgParam.tServParam.u16NetId = GetIntJavaToC(env, jObjTemp, jClsTemp, "u16NetId"); tParam.uProgParam.tServParam.u16historyAudioPid = GetIntJavaToC(env, jObjTemp, jClsTemp, "u16AudioPID"); DEBUG_MSG3(-1,T("+++++++++++++%d==========%d-------audioPID%d"),tParam.uProgParam.tServParam.u16ServId,tParam.uProgParam.tServParam.u16PMTPid, tParam.uProgParam.tServParam.u16historyAudioPid); /*Start:add avinfo by zshang 20140403 */ jFidTemp = env->GetFieldID(jObjCls, "tAVPids", "Lcom/pbi/dvb/dvbinterface/NativePlayer$DVBPlayer_AVPid_t;"); if (jFidTemp == NULL) { DEBUG_MSG2(-1,T("%s++++++++++++%d="),__FUNCTION__,__LINE__); return -1; } jObjTemp = env->GetObjectField(jPlayProgObj, jFidTemp); if (jObjTemp == NULL) { DEBUG_MSG2(-1,T("%s++++++++++++%d="),__FUNCTION__,__LINE__); return -1; } jClsTemp = env->GetObjectClass(jObjTemp); if (jClsTemp == NULL) { DEBUG_MSG2(-1,T("%s++++++++++++%d="),__FUNCTION__,__LINE__); return -1; } tParam.uProgParam.tServParam.u16VideoPid = GetIntJavaToC(env, jObjTemp, jClsTemp, "u16VideoPid"); tParam.uProgParam.tServParam.u16AudioPid = GetIntJavaToC(env, jObjTemp, jClsTemp, "u16AudioPid"); tParam.uProgParam.tServParam.u16PCRPid = GetIntJavaToC(env, jObjTemp, jClsTemp, "u16PCRPid"); tParam.uProgParam.tServParam.u8AudioFmt = GetByteJavaToC(env, jObjTemp, jClsTemp, "u8AudioFmt"); tParam.uProgParam.tServParam.u8VideoFmt = GetByteJavaToC(env, jObjTemp, jClsTemp, "u8VideoFmt"); /*End:add avinfo by zshang 20140403 */ } break; case 1: { jFidTemp = env->GetFieldID(jObjCls, "tAVPids", "Lcom/pbi/dvb/dvbinterface/NativePlayer$DVBPlayer_AVPid_t;"); jObjTemp = env->GetObjectField(jPlayProgObj, jFidTemp); jClsTemp = env->GetObjectClass(jObjTemp); tParam.uProgParam.tAVPids.eProgType = (DVBPlayer_Prog_Type_e) iProgType; //DVBPLAYER_PROG_TYPE_AVPID; tParam.uProgParam.tAVPids.u16AudioPid = GetIntJavaToC(env, jObjTemp, jClsTemp, "u16AudioPid"); tParam.uProgParam.tAVPids.u16VideoPid = GetIntJavaToC(env, jObjTemp, jClsTemp, "u16VideoPid"); tParam.uProgParam.tAVPids.u16AudioPid = GetIntJavaToC(env, jObjTemp, jClsTemp, "u16AudioPid"); tParam.uProgParam.tAVPids.u16PCRPid = GetIntJavaToC(env, jObjTemp, jClsTemp, "u16PCRPid"); tParam.uProgParam.tAVPids.u8AudioFmt = GetByteJavaToC(env, jObjTemp, jClsTemp, "u8AudioFmt"); tParam.uProgParam.tAVPids.u8VideoFmt = GetByteJavaToC(env, jObjTemp, jClsTemp, "u8VideoFmt"); } break; default: { } break; } Front_Panel_Dispaly(env, tParam.uProgParam.tServParam.u16LogicNum); jRet = DVBPlayer_Play_Program(&tParam); DeleteLocalRef(env, jObjCls); DeleteLocalRef(env, jClsTemp); DeleteLocalRef(env, jObjTemp); DEBUG_MSG2(-1,T("+++++++++++++%s== END ===%d-------"),__FUNCTION__,__LINE__); return jRet; }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void DeleteLocalRef(jobject in_localReference) { auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment(); environment->DeleteLocalRef(in_localReference); }