Changeset 85 for trunk/sources/androidapplestreaming/src/jniwrapper.cpp
- Timestamp:
- 08/20/10 04:21:17 (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/androidapplestreaming/src/jniwrapper.cpp
r77 r85 23 23 24 24 extern "C" void Java_com_rtmpd_CommandsInterface_EnvRun( 25 JNIEnv* pEnv, jobject thiz, jstring host, jint port) { 26 EnvRun(pEnv->GetStringUTFChars(host, NULL), (uint16_t) port); 25 JNIEnv* pEnv, jobject thiz, jobject pInterface, jstring host, jint port) { 26 CallBackInfo ci; 27 ci.pEnv = pEnv; 28 ci.pInterface = pInterface; 29 EnvRun(pEnv->GetStringUTFChars(host, NULL), (uint16_t) port, ci); 27 30 } 28 31 … … 130 133 return VariantToJObject(result, pEnv); 131 134 } 132 133 jobject VariantToJObject(Variant &value, JNIEnv* pEnv) {134 switch ((VariantType) value) {135 case V_NULL:136 case V_UNDEFINED:137 {138 return NULL;139 }140 case V_BOOL:141 {142 jclass clazz = pEnv->FindClass("java/lang/Boolean");143 jmethodID constructor = pEnv->GetMethodID(clazz, "<init>", "(Z)V");144 return pEnv->NewObject(clazz, constructor, (bool)value);145 }146 case V_INT8:147 case V_INT16:148 case V_INT32:149 case V_UINT8:150 case V_UINT16:151 {152 jclass clazz = pEnv->FindClass("java/lang/Integer");153 jmethodID constructor = pEnv->GetMethodID(clazz, "<init>", "(I)V");154 return pEnv->NewObject(clazz, constructor, (int32_t) value);155 }156 case V_INT64:157 case V_UINT32:158 {159 jclass clazz = pEnv->FindClass("java/lang/Long");160 jmethodID constructor = pEnv->GetMethodID(clazz, "<init>", "(J)V");161 return pEnv->NewObject(clazz, constructor, (int64_t) value);162 }163 case V_UINT64:164 {165 NYI;166 return NULL;167 }168 case V_DOUBLE:169 {170 jclass clazz = pEnv->FindClass("java/lang/Double");171 jmethodID constructor = pEnv->GetMethodID(clazz, "<init>", "(D)V");172 return pEnv->NewObject(clazz, constructor, (double) value);173 }174 case V_TIMESTAMP:175 case V_DATE:176 case V_TIME:177 {178 NYI;179 return NULL;180 }181 case V_BYTEARRAY:182 {183 NYI;184 return NULL;185 }186 case V_STRING:187 {188 return pEnv->NewStringUTF(STR(value));189 }190 case V_TYPED_MAP:191 {192 NYI;193 return NULL;194 }195 case V_MAP:196 {197 jclass mapClazz = pEnv->FindClass("java/util/HashMap");198 jmethodID mapConstructor = pEnv->GetMethodID(mapClazz, "<init>", "()V");199 jmethodID mapPut = pEnv->GetMethodID(mapClazz, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");200 201 jclass longClazz = pEnv->FindClass("java/lang/Long");202 jmethodID longConstructor = pEnv->GetMethodID(longClazz, "<init>", "(J)V");203 204 jobject result = pEnv->NewObject(mapClazz, mapConstructor);205 206 FOR_MAP(value, string, Variant, i) {207 jobject key = NULL;208 if (MAP_KEY(i).find("__index__value__") == 0) {209 key = pEnv->NewObject(longClazz, longConstructor,210 (int64_t) atol(STR(MAP_KEY(i).substr(16))));211 } else {212 key = pEnv->NewStringUTF(STR(MAP_KEY(i)));213 }214 jobject value = VariantToJObject(MAP_VAL(i), pEnv);215 pEnv->CallObjectMethod(result, mapPut, key, value);216 }217 218 return result;219 }220 default:221 {222 FATAL("Invalid variant type: %d", (VariantType) value);223 return NULL;224 }225 }226 }
Note: See TracChangeset
for help on using the changeset viewer.
