OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2260 | 2260 |
2261 // Convert encodings. | 2261 // Convert encodings. |
2262 jobject j_encodings = GetObjectField(jni, j_parameters, encodings_id); | 2262 jobject j_encodings = GetObjectField(jni, j_parameters, encodings_id); |
2263 const int kBitrateUnlimited = -1; | 2263 const int kBitrateUnlimited = -1; |
2264 jclass j_encoding_parameters_class = | 2264 jclass j_encoding_parameters_class = |
2265 jni->FindClass("org/webrtc/RtpParameters$Encoding"); | 2265 jni->FindClass("org/webrtc/RtpParameters$Encoding"); |
2266 jfieldID active_id = | 2266 jfieldID active_id = |
2267 GetFieldID(jni, j_encoding_parameters_class, "active", "Z"); | 2267 GetFieldID(jni, j_encoding_parameters_class, "active", "Z"); |
2268 jfieldID bitrate_id = GetFieldID(jni, j_encoding_parameters_class, | 2268 jfieldID bitrate_id = GetFieldID(jni, j_encoding_parameters_class, |
2269 "maxBitrateBps", "Ljava/lang/Integer;"); | 2269 "maxBitrateBps", "Ljava/lang/Integer;"); |
| 2270 jfieldID ssrc_id = |
| 2271 GetFieldID(jni, j_encoding_parameters_class, "ssrc", "Ljava/lang/Long;"); |
2270 jclass j_integer_class = jni->FindClass("java/lang/Integer"); | 2272 jclass j_integer_class = jni->FindClass("java/lang/Integer"); |
| 2273 jclass j_long_class = jni->FindClass("java/lang/Long"); |
2271 jmethodID int_value_id = GetMethodID(jni, j_integer_class, "intValue", "()I"); | 2274 jmethodID int_value_id = GetMethodID(jni, j_integer_class, "intValue", "()I"); |
| 2275 jmethodID long_value_id = GetMethodID(jni, j_long_class, "longValue", "()J"); |
2272 | 2276 |
2273 for (jobject j_encoding_parameters : Iterable(jni, j_encodings)) { | 2277 for (jobject j_encoding_parameters : Iterable(jni, j_encodings)) { |
2274 webrtc::RtpEncodingParameters encoding; | 2278 webrtc::RtpEncodingParameters encoding; |
2275 encoding.active = GetBooleanField(jni, j_encoding_parameters, active_id); | 2279 encoding.active = GetBooleanField(jni, j_encoding_parameters, active_id); |
2276 jobject j_bitrate = | 2280 jobject j_bitrate = |
2277 GetNullableObjectField(jni, j_encoding_parameters, bitrate_id); | 2281 GetNullableObjectField(jni, j_encoding_parameters, bitrate_id); |
2278 if (!IsNull(jni, j_bitrate)) { | 2282 if (!IsNull(jni, j_bitrate)) { |
2279 int bitrate_value = jni->CallIntMethod(j_bitrate, int_value_id); | 2283 int bitrate_value = jni->CallIntMethod(j_bitrate, int_value_id); |
2280 CHECK_EXCEPTION(jni) << "error during CallIntMethod"; | 2284 CHECK_EXCEPTION(jni) << "error during CallIntMethod"; |
2281 encoding.max_bitrate_bps = bitrate_value; | 2285 encoding.max_bitrate_bps = bitrate_value; |
2282 } else { | 2286 } else { |
2283 encoding.max_bitrate_bps = kBitrateUnlimited; | 2287 encoding.max_bitrate_bps = kBitrateUnlimited; |
2284 } | 2288 } |
| 2289 jobject j_ssrc = |
| 2290 GetNullableObjectField(jni, j_encoding_parameters, ssrc_id); |
| 2291 if (!IsNull(jni, j_ssrc)) { |
| 2292 jlong ssrc_value = jni->CallLongMethod(j_ssrc, long_value_id); |
| 2293 CHECK_EXCEPTION(jni) << "error during CallLongMethod"; |
| 2294 encoding.ssrc = rtc::Optional<uint32_t>(ssrc_value); |
| 2295 } |
2285 parameters->encodings.push_back(encoding); | 2296 parameters->encodings.push_back(encoding); |
2286 } | 2297 } |
2287 | 2298 |
2288 // Convert codecs. | 2299 // Convert codecs. |
2289 jobject j_codecs = GetObjectField(jni, j_parameters, codecs_id); | 2300 jobject j_codecs = GetObjectField(jni, j_parameters, codecs_id); |
2290 jclass codec_class = jni->FindClass("org/webrtc/RtpParameters$Codec"); | 2301 jclass codec_class = jni->FindClass("org/webrtc/RtpParameters$Codec"); |
2291 jfieldID payload_type_id = GetFieldID(jni, codec_class, "payloadType", "I"); | 2302 jfieldID payload_type_id = GetFieldID(jni, codec_class, "payloadType", "I"); |
2292 jfieldID mime_type_id = | 2303 jfieldID mime_type_id = |
2293 GetFieldID(jni, codec_class, "mimeType", "Ljava/lang/String;"); | 2304 GetFieldID(jni, codec_class, "mimeType", "Ljava/lang/String;"); |
2294 jfieldID clock_rate_id = GetFieldID(jni, codec_class, "clockRate", "I"); | 2305 jfieldID clock_rate_id = GetFieldID(jni, codec_class, "clockRate", "I"); |
(...skipping 24 matching lines...) Expand all Loading... |
2319 jmethodID encoding_ctor = GetMethodID(jni, encoding_class, "<init>", "()V"); | 2330 jmethodID encoding_ctor = GetMethodID(jni, encoding_class, "<init>", "()V"); |
2320 jfieldID encodings_id = | 2331 jfieldID encodings_id = |
2321 GetFieldID(jni, parameters_class, "encodings", "Ljava/util/LinkedList;"); | 2332 GetFieldID(jni, parameters_class, "encodings", "Ljava/util/LinkedList;"); |
2322 jobject j_encodings = GetObjectField(jni, j_parameters, encodings_id); | 2333 jobject j_encodings = GetObjectField(jni, j_parameters, encodings_id); |
2323 jmethodID encodings_add = GetMethodID(jni, GetObjectClass(jni, j_encodings), | 2334 jmethodID encodings_add = GetMethodID(jni, GetObjectClass(jni, j_encodings), |
2324 "add", "(Ljava/lang/Object;)Z"); | 2335 "add", "(Ljava/lang/Object;)Z"); |
2325 jfieldID active_id = | 2336 jfieldID active_id = |
2326 GetFieldID(jni, encoding_class, "active", "Z"); | 2337 GetFieldID(jni, encoding_class, "active", "Z"); |
2327 jfieldID bitrate_id = | 2338 jfieldID bitrate_id = |
2328 GetFieldID(jni, encoding_class, "maxBitrateBps", "Ljava/lang/Integer;"); | 2339 GetFieldID(jni, encoding_class, "maxBitrateBps", "Ljava/lang/Integer;"); |
| 2340 jfieldID ssrc_id = |
| 2341 GetFieldID(jni, encoding_class, "ssrc", "Ljava/lang/Long;"); |
2329 | 2342 |
2330 jclass integer_class = jni->FindClass("java/lang/Integer"); | 2343 jclass integer_class = jni->FindClass("java/lang/Integer"); |
| 2344 jclass long_class = jni->FindClass("java/lang/Long"); |
2331 jmethodID integer_ctor = GetMethodID(jni, integer_class, "<init>", "(I)V"); | 2345 jmethodID integer_ctor = GetMethodID(jni, integer_class, "<init>", "(I)V"); |
| 2346 jmethodID long_ctor = GetMethodID(jni, long_class, "<init>", "(J)V"); |
2332 | 2347 |
2333 for (const webrtc::RtpEncodingParameters& encoding : parameters.encodings) { | 2348 for (const webrtc::RtpEncodingParameters& encoding : parameters.encodings) { |
2334 jobject j_encoding_parameters = | 2349 jobject j_encoding_parameters = |
2335 jni->NewObject(encoding_class, encoding_ctor); | 2350 jni->NewObject(encoding_class, encoding_ctor); |
2336 CHECK_EXCEPTION(jni) << "error during NewObject"; | 2351 CHECK_EXCEPTION(jni) << "error during NewObject"; |
2337 jni->SetBooleanField(j_encoding_parameters, active_id, encoding.active); | 2352 jni->SetBooleanField(j_encoding_parameters, active_id, encoding.active); |
2338 CHECK_EXCEPTION(jni) << "error during SetBooleanField"; | 2353 CHECK_EXCEPTION(jni) << "error during SetBooleanField"; |
2339 if (encoding.max_bitrate_bps > 0) { | 2354 if (encoding.max_bitrate_bps > 0) { |
2340 jobject j_bitrate_value = | 2355 jobject j_bitrate_value = |
2341 jni->NewObject(integer_class, integer_ctor, encoding.max_bitrate_bps); | 2356 jni->NewObject(integer_class, integer_ctor, encoding.max_bitrate_bps); |
2342 CHECK_EXCEPTION(jni) << "error during NewObject"; | 2357 CHECK_EXCEPTION(jni) << "error during NewObject"; |
2343 jni->SetObjectField(j_encoding_parameters, bitrate_id, j_bitrate_value); | 2358 jni->SetObjectField(j_encoding_parameters, bitrate_id, j_bitrate_value); |
2344 CHECK_EXCEPTION(jni) << "error during SetObjectField"; | 2359 CHECK_EXCEPTION(jni) << "error during SetObjectField"; |
2345 } | 2360 } |
| 2361 if (encoding.ssrc) { |
| 2362 jobject j_ssrc_value = jni->NewObject(long_class, long_ctor, |
| 2363 static_cast<jlong>(*encoding.ssrc)); |
| 2364 CHECK_EXCEPTION(jni) << "error during NewObject"; |
| 2365 jni->SetObjectField(j_encoding_parameters, ssrc_id, j_ssrc_value); |
| 2366 CHECK_EXCEPTION(jni) << "error during SetObjectField"; |
| 2367 } |
2346 jboolean added = jni->CallBooleanMethod(j_encodings, encodings_add, | 2368 jboolean added = jni->CallBooleanMethod(j_encodings, encodings_add, |
2347 j_encoding_parameters); | 2369 j_encoding_parameters); |
2348 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod"; | 2370 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod"; |
2349 RTC_CHECK(added); | 2371 RTC_CHECK(added); |
2350 } | 2372 } |
2351 | 2373 |
2352 // Add codecs. | 2374 // Add codecs. |
2353 jclass codec_class = jni->FindClass("org/webrtc/RtpParameters$Codec"); | 2375 jclass codec_class = jni->FindClass("org/webrtc/RtpParameters$Codec"); |
2354 jmethodID codec_ctor = GetMethodID(jni, codec_class, "<init>", "()V"); | 2376 jmethodID codec_ctor = GetMethodID(jni, codec_class, "<init>", "()V"); |
2355 jfieldID codecs_id = | 2377 jfieldID codecs_id = |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2467 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer) | 2489 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer) |
2468 ->SetObserver(nullptr); | 2490 ->SetObserver(nullptr); |
2469 RtpReceiverObserver* observer = | 2491 RtpReceiverObserver* observer = |
2470 reinterpret_cast<RtpReceiverObserver*>(j_observer_pointer); | 2492 reinterpret_cast<RtpReceiverObserver*>(j_observer_pointer); |
2471 if (observer) { | 2493 if (observer) { |
2472 delete observer; | 2494 delete observer; |
2473 } | 2495 } |
2474 } | 2496 } |
2475 | 2497 |
2476 } // namespace webrtc_jni | 2498 } // namespace webrtc_jni |
OLD | NEW |