Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: webrtc/sdk/android/src/jni/peerconnection_jni.cc

Issue 2651883010: Adding C++ versions of currently spec'd "RtpParameters" structs. (Closed)
Patch Set: Update unit tests (due to switch from special-case values to rtc::Optional) Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 init.maxRetransmitTime = GetIntField(jni, j_init, max_retransmit_time_id); 151 init.maxRetransmitTime = GetIntField(jni, j_init, max_retransmit_time_id);
152 init.maxRetransmits = GetIntField(jni, j_init, max_retransmits_id); 152 init.maxRetransmits = GetIntField(jni, j_init, max_retransmits_id);
153 init.protocol = JavaToStdString( 153 init.protocol = JavaToStdString(
154 jni, GetStringField(jni, j_init, protocol_id)); 154 jni, GetStringField(jni, j_init, protocol_id));
155 init.negotiated = GetBooleanField(jni, j_init, negotiated_id); 155 init.negotiated = GetBooleanField(jni, j_init, negotiated_id);
156 init.id = GetIntField(jni, j_init, id_id); 156 init.id = GetIntField(jni, j_init, id_id);
157 157
158 return init; 158 return init;
159 } 159 }
160 160
161 static cricket::MediaType JavaMediaTypeToJsepMediaType(JNIEnv* jni,
162 jobject j_media_type) {
163 jclass j_media_type_class =
164 FindClass(jni, "org/webrtc/MediaStreamTrack$MediaType");
165 jmethodID j_name_id =
166 GetMethodID(jni, j_media_type_class, "name", "()Ljava/lang/String;");
167 jstring j_type_string =
168 (jstring)jni->CallObjectMethod(j_media_type, j_name_id);
169 CHECK_EXCEPTION(jni) << "error during CallObjectMethod";
170 std::string type_string = JavaToStdString(jni, j_type_string);
171
172 RTC_DCHECK(type_string == "MEDIA_TYPE_AUDIO" ||
173 type_string == "MEDIA_TYPE_VIDEO")
174 << "Media type: " << type_string;
175 return type_string == "MEDIA_TYPE_AUDIO" ? cricket::MEDIA_TYPE_AUDIO
176 : cricket::MEDIA_TYPE_VIDEO;
177 }
178
179 static jobject JsepMediaTypeToJavaMediaType(JNIEnv* jni,
180 cricket::MediaType media_type) {
181 jclass j_media_type_class =
182 FindClass(jni, "org/webrtc/MediaStreamTrack$MediaType");
183
184 const char* media_type_str = nullptr;
185 switch (media_type) {
186 case cricket::MEDIA_TYPE_AUDIO:
187 media_type_str = "MEDIA_TYPE_AUDIO";
188 break;
189 case cricket::MEDIA_TYPE_VIDEO:
190 media_type_str = "MEDIA_TYPE_VIDEO";
191 break;
192 case cricket::MEDIA_TYPE_DATA:
193 RTC_NOTREACHED();
194 break;
195 }
196 jfieldID j_media_type_fid =
197 GetStaticFieldID(jni, j_media_type_class, media_type_str,
198 "Lorg/webrtc/MediaStreamTrack$MediaType;");
199 return GetStaticObjectField(jni, j_media_type_class, j_media_type_fid);
200 }
201
161 class ConstraintsWrapper; 202 class ConstraintsWrapper;
162 203
163 // Adapter between the C++ PeerConnectionObserver interface and the Java 204 // Adapter between the C++ PeerConnectionObserver interface and the Java
164 // PeerConnection.Observer interface. Wraps an instance of the Java interface 205 // PeerConnection.Observer interface. Wraps an instance of the Java interface
165 // and dispatches C++ callbacks to Java. 206 // and dispatches C++ callbacks to Java.
166 class PCOJava : public PeerConnectionObserver { 207 class PCOJava : public PeerConnectionObserver {
167 public: 208 public:
168 // We need these using declarations because there are two versions of each of 209 // We need these using declarations because there are two versions of each of
169 // the below methods and we only override one of them. 210 // the below methods and we only override one of them.
170 // TODO(deadbeef): Remove once there's only one version of the methods. 211 // TODO(deadbeef): Remove once there's only one version of the methods.
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 951
911 ~RtpReceiverObserver() override {} 952 ~RtpReceiverObserver() override {}
912 953
913 void OnFirstPacketReceived(cricket::MediaType media_type) override { 954 void OnFirstPacketReceived(cricket::MediaType media_type) override {
914 JNIEnv* const jni = AttachCurrentThreadIfNeeded(); 955 JNIEnv* const jni = AttachCurrentThreadIfNeeded();
915 956
916 jmethodID j_on_first_packet_received_mid = GetMethodID( 957 jmethodID j_on_first_packet_received_mid = GetMethodID(
917 jni, GetObjectClass(jni, *j_observer_global_), "onFirstPacketReceived", 958 jni, GetObjectClass(jni, *j_observer_global_), "onFirstPacketReceived",
918 "(Lorg/webrtc/MediaStreamTrack$MediaType;)V"); 959 "(Lorg/webrtc/MediaStreamTrack$MediaType;)V");
919 // Get the Java version of media type. 960 // Get the Java version of media type.
920 jclass j_media_type_class = 961 jobject JavaMediaType = JsepMediaTypeToJavaMediaType(jni, media_type);
921 FindClass(jni, "org/webrtc/MediaStreamTrack$MediaType");
922
923 RTC_DCHECK(media_type == cricket::MEDIA_TYPE_AUDIO ||
924 media_type == cricket::MEDIA_TYPE_VIDEO)
925 << "Media type: " << media_type;
926 const char* media_type_str = media_type == cricket::MEDIA_TYPE_AUDIO
927 ? "MEDIA_TYPE_AUDIO"
928 : "MEDIA_TYPE_VIDEO";
929 jfieldID j_media_type_fid =
930 GetStaticFieldID(jni, j_media_type_class, media_type_str,
931 "Lorg/webrtc/MediaStreamTrack$MediaType;");
932 jobject JavaMediaType =
933 GetStaticObjectField(jni, j_media_type_class, j_media_type_fid);
934 // Trigger the callback function. 962 // Trigger the callback function.
935 jni->CallVoidMethod(*j_observer_global_, j_on_first_packet_received_mid, 963 jni->CallVoidMethod(*j_observer_global_, j_on_first_packet_received_mid,
936 JavaMediaType); 964 JavaMediaType);
937 CHECK_EXCEPTION(jni) << "error during CallVoidMethod"; 965 CHECK_EXCEPTION(jni) << "error during CallVoidMethod";
938 } 966 }
939 967
940 private: 968 private:
941 const ScopedGlobalRef<jobject> j_observer_global_; 969 const ScopedGlobalRef<jobject> j_observer_global_;
942 }; 970 };
943 971
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
2393 webrtc::RtpParameters* parameters) { 2421 webrtc::RtpParameters* parameters) {
2394 RTC_CHECK(parameters != nullptr); 2422 RTC_CHECK(parameters != nullptr);
2395 jclass parameters_class = jni->FindClass("org/webrtc/RtpParameters"); 2423 jclass parameters_class = jni->FindClass("org/webrtc/RtpParameters");
2396 jfieldID encodings_id = 2424 jfieldID encodings_id =
2397 GetFieldID(jni, parameters_class, "encodings", "Ljava/util/LinkedList;"); 2425 GetFieldID(jni, parameters_class, "encodings", "Ljava/util/LinkedList;");
2398 jfieldID codecs_id = 2426 jfieldID codecs_id =
2399 GetFieldID(jni, parameters_class, "codecs", "Ljava/util/LinkedList;"); 2427 GetFieldID(jni, parameters_class, "codecs", "Ljava/util/LinkedList;");
2400 2428
2401 // Convert encodings. 2429 // Convert encodings.
2402 jobject j_encodings = GetObjectField(jni, j_parameters, encodings_id); 2430 jobject j_encodings = GetObjectField(jni, j_parameters, encodings_id);
2403 const int kBitrateUnlimited = -1;
2404 jclass j_encoding_parameters_class = 2431 jclass j_encoding_parameters_class =
2405 jni->FindClass("org/webrtc/RtpParameters$Encoding"); 2432 jni->FindClass("org/webrtc/RtpParameters$Encoding");
2406 jfieldID active_id = 2433 jfieldID active_id =
2407 GetFieldID(jni, j_encoding_parameters_class, "active", "Z"); 2434 GetFieldID(jni, j_encoding_parameters_class, "active", "Z");
2408 jfieldID bitrate_id = GetFieldID(jni, j_encoding_parameters_class, 2435 jfieldID bitrate_id = GetFieldID(jni, j_encoding_parameters_class,
2409 "maxBitrateBps", "Ljava/lang/Integer;"); 2436 "maxBitrateBps", "Ljava/lang/Integer;");
2410 jfieldID ssrc_id = 2437 jfieldID ssrc_id =
2411 GetFieldID(jni, j_encoding_parameters_class, "ssrc", "Ljava/lang/Long;"); 2438 GetFieldID(jni, j_encoding_parameters_class, "ssrc", "Ljava/lang/Long;");
2412 jclass j_integer_class = jni->FindClass("java/lang/Integer"); 2439 jclass j_integer_class = jni->FindClass("java/lang/Integer");
2413 jclass j_long_class = jni->FindClass("java/lang/Long"); 2440 jclass j_long_class = jni->FindClass("java/lang/Long");
2414 jmethodID int_value_id = GetMethodID(jni, j_integer_class, "intValue", "()I"); 2441 jmethodID int_value_id = GetMethodID(jni, j_integer_class, "intValue", "()I");
2415 jmethodID long_value_id = GetMethodID(jni, j_long_class, "longValue", "()J"); 2442 jmethodID long_value_id = GetMethodID(jni, j_long_class, "longValue", "()J");
2416 2443
2417 for (jobject j_encoding_parameters : Iterable(jni, j_encodings)) { 2444 for (jobject j_encoding_parameters : Iterable(jni, j_encodings)) {
2418 webrtc::RtpEncodingParameters encoding; 2445 webrtc::RtpEncodingParameters encoding;
2419 encoding.active = GetBooleanField(jni, j_encoding_parameters, active_id); 2446 encoding.active = GetBooleanField(jni, j_encoding_parameters, active_id);
2420 jobject j_bitrate = 2447 jobject j_bitrate =
2421 GetNullableObjectField(jni, j_encoding_parameters, bitrate_id); 2448 GetNullableObjectField(jni, j_encoding_parameters, bitrate_id);
2422 if (!IsNull(jni, j_bitrate)) { 2449 if (!IsNull(jni, j_bitrate)) {
2423 int bitrate_value = jni->CallIntMethod(j_bitrate, int_value_id); 2450 int bitrate_value = jni->CallIntMethod(j_bitrate, int_value_id);
2424 CHECK_EXCEPTION(jni) << "error during CallIntMethod"; 2451 CHECK_EXCEPTION(jni) << "error during CallIntMethod";
2425 encoding.max_bitrate_bps = bitrate_value; 2452 encoding.max_bitrate_bps = rtc::Optional<int>(bitrate_value);
2426 } else {
2427 encoding.max_bitrate_bps = kBitrateUnlimited;
2428 } 2453 }
2429 jobject j_ssrc = 2454 jobject j_ssrc =
2430 GetNullableObjectField(jni, j_encoding_parameters, ssrc_id); 2455 GetNullableObjectField(jni, j_encoding_parameters, ssrc_id);
2431 if (!IsNull(jni, j_ssrc)) { 2456 if (!IsNull(jni, j_ssrc)) {
2432 jlong ssrc_value = jni->CallLongMethod(j_ssrc, long_value_id); 2457 jlong ssrc_value = jni->CallLongMethod(j_ssrc, long_value_id);
2433 CHECK_EXCEPTION(jni) << "error during CallLongMethod"; 2458 CHECK_EXCEPTION(jni) << "error during CallLongMethod";
2434 encoding.ssrc = rtc::Optional<uint32_t>(ssrc_value); 2459 encoding.ssrc = rtc::Optional<uint32_t>(ssrc_value);
2435 } 2460 }
2436 parameters->encodings.push_back(encoding); 2461 parameters->encodings.push_back(encoding);
2437 } 2462 }
2438 2463
2439 // Convert codecs. 2464 // Convert codecs.
2440 jobject j_codecs = GetObjectField(jni, j_parameters, codecs_id); 2465 jobject j_codecs = GetObjectField(jni, j_parameters, codecs_id);
2441 jclass codec_class = jni->FindClass("org/webrtc/RtpParameters$Codec"); 2466 jclass codec_class = jni->FindClass("org/webrtc/RtpParameters$Codec");
2442 jfieldID payload_type_id = GetFieldID(jni, codec_class, "payloadType", "I"); 2467 jfieldID payload_type_id = GetFieldID(jni, codec_class, "payloadType", "I");
2443 jfieldID mime_type_id = 2468 jfieldID name_id = GetFieldID(jni, codec_class, "name", "Ljava/lang/String;");
2444 GetFieldID(jni, codec_class, "mimeType", "Ljava/lang/String;"); 2469 jfieldID kind_id = GetFieldID(jni, codec_class, "kind",
2445 jfieldID clock_rate_id = GetFieldID(jni, codec_class, "clockRate", "I"); 2470 "Lorg/webrtc/MediaStreamTrack$MediaType;");
2446 jfieldID channels_id = GetFieldID(jni, codec_class, "channels", "I"); 2471 jfieldID clock_rate_id =
2472 GetFieldID(jni, codec_class, "clockRate", "Ljava/lang/Integer;");
2473 jfieldID num_channels_id =
2474 GetFieldID(jni, codec_class, "numChannels", "Ljava/lang/Integer;");
2447 2475
2448 for (jobject j_codec : Iterable(jni, j_codecs)) { 2476 for (jobject j_codec : Iterable(jni, j_codecs)) {
2449 webrtc::RtpCodecParameters codec; 2477 webrtc::RtpCodecParameters codec;
2450 codec.payload_type = GetIntField(jni, j_codec, payload_type_id); 2478 codec.payload_type = GetIntField(jni, j_codec, payload_type_id);
2451 codec.mime_type = 2479 codec.name = JavaToStdString(jni, GetStringField(jni, j_codec, name_id));
2452 JavaToStdString(jni, GetStringField(jni, j_codec, mime_type_id)); 2480 codec.kind = JavaMediaTypeToJsepMediaType(
2453 codec.clock_rate = GetIntField(jni, j_codec, clock_rate_id); 2481 jni, GetObjectField(jni, j_codec, kind_id));
2454 codec.channels = GetIntField(jni, j_codec, channels_id); 2482 jobject j_clock_rate = GetNullableObjectField(jni, j_codec, clock_rate_id);
2483 if (!IsNull(jni, j_clock_rate)) {
2484 int clock_rate_value = jni->CallIntMethod(j_clock_rate, int_value_id);
2485 CHECK_EXCEPTION(jni) << "error during CallIntMethod";
2486 codec.clock_rate = rtc::Optional<int>(clock_rate_value);
2487 }
2488 jobject j_num_channels =
2489 GetNullableObjectField(jni, j_codec, num_channels_id);
2490 if (!IsNull(jni, j_num_channels)) {
2491 int num_channels_value = jni->CallIntMethod(j_num_channels, int_value_id);
2492 CHECK_EXCEPTION(jni) << "error during CallIntMethod";
2493 codec.num_channels = rtc::Optional<int>(num_channels_value);
2494 }
2455 parameters->codecs.push_back(codec); 2495 parameters->codecs.push_back(codec);
2456 } 2496 }
2457 } 2497 }
2458 2498
2459 static jobject JsepRtpParametersToJavaRtpParameters( 2499 static jobject JsepRtpParametersToJavaRtpParameters(
2460 JNIEnv* jni, 2500 JNIEnv* jni,
2461 const webrtc::RtpParameters& parameters) { 2501 const webrtc::RtpParameters& parameters) {
2462 jclass parameters_class = jni->FindClass("org/webrtc/RtpParameters"); 2502 jclass parameters_class = jni->FindClass("org/webrtc/RtpParameters");
2463 jmethodID parameters_ctor = 2503 jmethodID parameters_ctor =
2464 GetMethodID(jni, parameters_class, "<init>", "()V"); 2504 GetMethodID(jni, parameters_class, "<init>", "()V");
2465 jobject j_parameters = jni->NewObject(parameters_class, parameters_ctor); 2505 jobject j_parameters = jni->NewObject(parameters_class, parameters_ctor);
2466 CHECK_EXCEPTION(jni) << "error during NewObject"; 2506 CHECK_EXCEPTION(jni) << "error during NewObject";
2467 2507
2468 // Add encodings. 2508 // Add encodings.
2469 jclass encoding_class = jni->FindClass("org/webrtc/RtpParameters$Encoding"); 2509 jclass encoding_class = jni->FindClass("org/webrtc/RtpParameters$Encoding");
2470 jmethodID encoding_ctor = GetMethodID(jni, encoding_class, "<init>", "()V"); 2510 jmethodID encoding_ctor = GetMethodID(jni, encoding_class, "<init>", "()V");
2471 jfieldID encodings_id = 2511 jfieldID encodings_id =
2472 GetFieldID(jni, parameters_class, "encodings", "Ljava/util/LinkedList;"); 2512 GetFieldID(jni, parameters_class, "encodings", "Ljava/util/LinkedList;");
2473 jobject j_encodings = GetObjectField(jni, j_parameters, encodings_id); 2513 jobject j_encodings = GetObjectField(jni, j_parameters, encodings_id);
2474 jmethodID encodings_add = GetMethodID(jni, GetObjectClass(jni, j_encodings), 2514 jmethodID encodings_add = GetMethodID(jni, GetObjectClass(jni, j_encodings),
2475 "add", "(Ljava/lang/Object;)Z"); 2515 "add", "(Ljava/lang/Object;)Z");
2476 jfieldID active_id = 2516 jfieldID active_id = GetFieldID(jni, encoding_class, "active", "Z");
2477 GetFieldID(jni, encoding_class, "active", "Z");
2478 jfieldID bitrate_id = 2517 jfieldID bitrate_id =
2479 GetFieldID(jni, encoding_class, "maxBitrateBps", "Ljava/lang/Integer;"); 2518 GetFieldID(jni, encoding_class, "maxBitrateBps", "Ljava/lang/Integer;");
2480 jfieldID ssrc_id = 2519 jfieldID ssrc_id =
2481 GetFieldID(jni, encoding_class, "ssrc", "Ljava/lang/Long;"); 2520 GetFieldID(jni, encoding_class, "ssrc", "Ljava/lang/Long;");
2482 2521
2483 jclass integer_class = jni->FindClass("java/lang/Integer"); 2522 jclass integer_class = jni->FindClass("java/lang/Integer");
2484 jclass long_class = jni->FindClass("java/lang/Long"); 2523 jclass long_class = jni->FindClass("java/lang/Long");
2485 jmethodID integer_ctor = GetMethodID(jni, integer_class, "<init>", "(I)V"); 2524 jmethodID integer_ctor = GetMethodID(jni, integer_class, "<init>", "(I)V");
2486 jmethodID long_ctor = GetMethodID(jni, long_class, "<init>", "(J)V"); 2525 jmethodID long_ctor = GetMethodID(jni, long_class, "<init>", "(J)V");
2487 2526
2488 for (const webrtc::RtpEncodingParameters& encoding : parameters.encodings) { 2527 for (const webrtc::RtpEncodingParameters& encoding : parameters.encodings) {
2489 jobject j_encoding_parameters = 2528 jobject j_encoding_parameters =
2490 jni->NewObject(encoding_class, encoding_ctor); 2529 jni->NewObject(encoding_class, encoding_ctor);
2491 CHECK_EXCEPTION(jni) << "error during NewObject"; 2530 CHECK_EXCEPTION(jni) << "error during NewObject";
2492 jni->SetBooleanField(j_encoding_parameters, active_id, encoding.active); 2531 jni->SetBooleanField(j_encoding_parameters, active_id, encoding.active);
2493 CHECK_EXCEPTION(jni) << "error during SetBooleanField"; 2532 CHECK_EXCEPTION(jni) << "error during SetBooleanField";
2494 if (encoding.max_bitrate_bps > 0) { 2533 if (encoding.max_bitrate_bps) {
2495 jobject j_bitrate_value = 2534 jobject j_bitrate_value = jni->NewObject(integer_class, integer_ctor,
2496 jni->NewObject(integer_class, integer_ctor, encoding.max_bitrate_bps); 2535 *(encoding.max_bitrate_bps));
2497 CHECK_EXCEPTION(jni) << "error during NewObject"; 2536 CHECK_EXCEPTION(jni) << "error during NewObject";
2498 jni->SetObjectField(j_encoding_parameters, bitrate_id, j_bitrate_value); 2537 jni->SetObjectField(j_encoding_parameters, bitrate_id, j_bitrate_value);
2499 CHECK_EXCEPTION(jni) << "error during SetObjectField"; 2538 CHECK_EXCEPTION(jni) << "error during SetObjectField";
2500 } 2539 }
2501 if (encoding.ssrc) { 2540 if (encoding.ssrc) {
2502 jobject j_ssrc_value = jni->NewObject(long_class, long_ctor, 2541 jobject j_ssrc_value = jni->NewObject(long_class, long_ctor,
2503 static_cast<jlong>(*encoding.ssrc)); 2542 static_cast<jlong>(*encoding.ssrc));
2504 CHECK_EXCEPTION(jni) << "error during NewObject"; 2543 CHECK_EXCEPTION(jni) << "error during NewObject";
2505 jni->SetObjectField(j_encoding_parameters, ssrc_id, j_ssrc_value); 2544 jni->SetObjectField(j_encoding_parameters, ssrc_id, j_ssrc_value);
2506 CHECK_EXCEPTION(jni) << "error during SetObjectField"; 2545 CHECK_EXCEPTION(jni) << "error during SetObjectField";
2507 } 2546 }
2508 jboolean added = jni->CallBooleanMethod(j_encodings, encodings_add, 2547 jboolean added = jni->CallBooleanMethod(j_encodings, encodings_add,
2509 j_encoding_parameters); 2548 j_encoding_parameters);
2510 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod"; 2549 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod";
2511 RTC_CHECK(added); 2550 RTC_CHECK(added);
2512 } 2551 }
2513 2552
2514 // Add codecs. 2553 // Add codecs.
2515 jclass codec_class = jni->FindClass("org/webrtc/RtpParameters$Codec"); 2554 jclass codec_class = jni->FindClass("org/webrtc/RtpParameters$Codec");
2516 jmethodID codec_ctor = GetMethodID(jni, codec_class, "<init>", "()V"); 2555 jmethodID codec_ctor = GetMethodID(jni, codec_class, "<init>", "()V");
2517 jfieldID codecs_id = 2556 jfieldID codecs_id =
2518 GetFieldID(jni, parameters_class, "codecs", "Ljava/util/LinkedList;"); 2557 GetFieldID(jni, parameters_class, "codecs", "Ljava/util/LinkedList;");
2519 jobject j_codecs = GetObjectField(jni, j_parameters, codecs_id); 2558 jobject j_codecs = GetObjectField(jni, j_parameters, codecs_id);
2520 jmethodID codecs_add = GetMethodID(jni, GetObjectClass(jni, j_codecs), 2559 jmethodID codecs_add = GetMethodID(jni, GetObjectClass(jni, j_codecs), "add",
2521 "add", "(Ljava/lang/Object;)Z"); 2560 "(Ljava/lang/Object;)Z");
2522 jfieldID payload_type_id = GetFieldID(jni, codec_class, "payloadType", "I"); 2561 jfieldID payload_type_id = GetFieldID(jni, codec_class, "payloadType", "I");
2523 jfieldID mime_type_id = 2562 jfieldID name_id = GetFieldID(jni, codec_class, "name", "Ljava/lang/String;");
2524 GetFieldID(jni, codec_class, "mimeType", "Ljava/lang/String;"); 2563 jfieldID kind_id = GetFieldID(jni, codec_class, "kind",
2525 jfieldID clock_rate_id = GetFieldID(jni, codec_class, "clockRate", "I"); 2564 "Lorg/webrtc/MediaStreamTrack$MediaType;");
2526 jfieldID channels_id = GetFieldID(jni, codec_class, "channels", "I"); 2565 jfieldID clock_rate_id =
2566 GetFieldID(jni, codec_class, "clockRate", "Ljava/lang/Integer;");
2567 jfieldID num_channels_id =
2568 GetFieldID(jni, codec_class, "numChannels", "Ljava/lang/Integer;");
2527 2569
2528 for (const webrtc::RtpCodecParameters& codec : parameters.codecs) { 2570 for (const webrtc::RtpCodecParameters& codec : parameters.codecs) {
2529 jobject j_codec = jni->NewObject(codec_class, codec_ctor); 2571 jobject j_codec = jni->NewObject(codec_class, codec_ctor);
2530 CHECK_EXCEPTION(jni) << "error during NewObject"; 2572 CHECK_EXCEPTION(jni) << "error during NewObject";
2531 jni->SetIntField(j_codec, payload_type_id, codec.payload_type); 2573 jni->SetIntField(j_codec, payload_type_id, codec.payload_type);
2532 CHECK_EXCEPTION(jni) << "error during SetIntField"; 2574 CHECK_EXCEPTION(jni) << "error during SetIntField";
2533 jni->SetObjectField(j_codec, mime_type_id, 2575 jni->SetObjectField(j_codec, name_id,
2534 JavaStringFromStdString(jni, codec.mime_type)); 2576 JavaStringFromStdString(jni, codec.name));
2535 CHECK_EXCEPTION(jni) << "error during SetObjectField"; 2577 CHECK_EXCEPTION(jni) << "error during SetObjectField";
2536 jni->SetIntField(j_codec, clock_rate_id, codec.clock_rate); 2578 jni->SetObjectField(j_codec, kind_id,
2537 CHECK_EXCEPTION(jni) << "error during SetIntField"; 2579 JsepMediaTypeToJavaMediaType(jni, codec.kind));
2538 jni->SetIntField(j_codec, channels_id, codec.channels); 2580 CHECK_EXCEPTION(jni) << "error during SetObjectField";
2539 CHECK_EXCEPTION(jni) << "error during SetIntField"; 2581 if (codec.clock_rate) {
2582 jobject j_clock_rate_value =
2583 jni->NewObject(integer_class, integer_ctor, *(codec.clock_rate));
2584 CHECK_EXCEPTION(jni) << "error during NewObject";
2585 jni->SetObjectField(j_codec, clock_rate_id, j_clock_rate_value);
2586 CHECK_EXCEPTION(jni) << "error during SetObjectField";
2587 }
2588 if (codec.num_channels) {
2589 jobject j_num_channels_value =
2590 jni->NewObject(integer_class, integer_ctor, *(codec.num_channels));
2591 CHECK_EXCEPTION(jni) << "error during NewObject";
2592 jni->SetObjectField(j_codec, num_channels_id, j_num_channels_value);
2593 CHECK_EXCEPTION(jni) << "error during SetObjectField";
2594 }
2540 jboolean added = jni->CallBooleanMethod(j_codecs, codecs_add, j_codec); 2595 jboolean added = jni->CallBooleanMethod(j_codecs, codecs_add, j_codec);
2541 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod"; 2596 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod";
2542 RTC_CHECK(added); 2597 RTC_CHECK(added);
2543 } 2598 }
2544 2599
2545 return j_parameters; 2600 return j_parameters;
2546 } 2601 }
2547 2602
2548 JOW(jboolean, RtpSender_nativeSetParameters) 2603 JOW(jboolean, RtpSender_nativeSetParameters)
2549 (JNIEnv* jni, jclass, jlong j_rtp_sender_pointer, jobject j_parameters) { 2604 (JNIEnv* jni, jclass, jlong j_rtp_sender_pointer, jobject j_parameters) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2670 return reinterpret_cast<DtmfSenderInterface*>(j_dtmf_sender_pointer) 2725 return reinterpret_cast<DtmfSenderInterface*>(j_dtmf_sender_pointer)
2671 ->inter_tone_gap(); 2726 ->inter_tone_gap();
2672 } 2727 }
2673 2728
2674 JOW(void, DtmfSender_free) 2729 JOW(void, DtmfSender_free)
2675 (JNIEnv* jni, jclass, jlong j_dtmf_sender_pointer) { 2730 (JNIEnv* jni, jclass, jlong j_dtmf_sender_pointer) {
2676 reinterpret_cast<DtmfSenderInterface*>(j_dtmf_sender_pointer)->Release(); 2731 reinterpret_cast<DtmfSenderInterface*>(j_dtmf_sender_pointer)->Release();
2677 } 2732 }
2678 2733
2679 } // namespace webrtc_jni 2734 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « webrtc/sdk/android/api/org/webrtc/RtpParameters.java ('k') | webrtc/sdk/objc/Framework/Classes/RTCRtpCodecParameters.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698