| 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 2015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2026 .release()); | 2026 .release()); |
| 2027 } | 2027 } |
| 2028 | 2028 |
| 2029 static bool JavaEncodingToJsepRtpEncodingParameters( | 2029 static bool JavaEncodingToJsepRtpEncodingParameters( |
| 2030 JNIEnv* jni, | 2030 JNIEnv* jni, |
| 2031 jobject j_encodings, | 2031 jobject j_encodings, |
| 2032 std::vector<webrtc::RtpEncodingParameters>* encodings) { | 2032 std::vector<webrtc::RtpEncodingParameters>* encodings) { |
| 2033 const int kBitrateUnlimited = -1; | 2033 const int kBitrateUnlimited = -1; |
| 2034 jclass j_encoding_parameters_class = | 2034 jclass j_encoding_parameters_class = |
| 2035 jni->FindClass("org/webrtc/RtpParameters$Encoding"); | 2035 jni->FindClass("org/webrtc/RtpParameters$Encoding"); |
| 2036 jfieldID active_id = |
| 2037 GetFieldID(jni, j_encoding_parameters_class, "active", "Z"); |
| 2036 jfieldID bitrate_id = GetFieldID(jni, j_encoding_parameters_class, | 2038 jfieldID bitrate_id = GetFieldID(jni, j_encoding_parameters_class, |
| 2037 "maxBitrateBps", "Ljava/lang/Integer;"); | 2039 "maxBitrateBps", "Ljava/lang/Integer;"); |
| 2038 jclass j_integer_class = jni->FindClass("java/lang/Integer"); | 2040 jclass j_integer_class = jni->FindClass("java/lang/Integer"); |
| 2039 jmethodID int_value_id = GetMethodID(jni, j_integer_class, "intValue", "()I"); | 2041 jmethodID int_value_id = GetMethodID(jni, j_integer_class, "intValue", "()I"); |
| 2040 | 2042 |
| 2041 for (jobject j_encoding_parameters : Iterable(jni, j_encodings)) { | 2043 for (jobject j_encoding_parameters : Iterable(jni, j_encodings)) { |
| 2042 webrtc::RtpEncodingParameters encoding; | 2044 webrtc::RtpEncodingParameters encoding; |
| 2045 encoding.active = GetBooleanField(jni, j_encoding_parameters, active_id); |
| 2043 jobject j_bitrate = GetObjectField(jni, j_encoding_parameters, bitrate_id); | 2046 jobject j_bitrate = GetObjectField(jni, j_encoding_parameters, bitrate_id); |
| 2044 if (!IsNull(jni, j_bitrate)) { | 2047 if (!IsNull(jni, j_bitrate)) { |
| 2045 int bitrate_value = jni->CallIntMethod(j_bitrate, int_value_id); | 2048 int bitrate_value = jni->CallIntMethod(j_bitrate, int_value_id); |
| 2046 CHECK_EXCEPTION(jni) << "error during CallIntMethod"; | 2049 CHECK_EXCEPTION(jni) << "error during CallIntMethod"; |
| 2047 encoding.max_bitrate_bps = bitrate_value; | 2050 encoding.max_bitrate_bps = bitrate_value; |
| 2048 } else { | 2051 } else { |
| 2049 encoding.max_bitrate_bps = kBitrateUnlimited; | 2052 encoding.max_bitrate_bps = kBitrateUnlimited; |
| 2050 } | 2053 } |
| 2051 encodings->push_back(encoding); | 2054 encodings->push_back(encoding); |
| 2052 } | 2055 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2083 jobject j_parameters = jni->NewObject(parameters_class, parameters_ctor); | 2086 jobject j_parameters = jni->NewObject(parameters_class, parameters_ctor); |
| 2084 CHECK_EXCEPTION(jni) << "error during NewObject"; | 2087 CHECK_EXCEPTION(jni) << "error during NewObject"; |
| 2085 | 2088 |
| 2086 jclass encoding_class = jni->FindClass("org/webrtc/RtpParameters$Encoding"); | 2089 jclass encoding_class = jni->FindClass("org/webrtc/RtpParameters$Encoding"); |
| 2087 jmethodID encoding_ctor = GetMethodID(jni, encoding_class, "<init>", "()V"); | 2090 jmethodID encoding_ctor = GetMethodID(jni, encoding_class, "<init>", "()V"); |
| 2088 jfieldID encodings_id = | 2091 jfieldID encodings_id = |
| 2089 GetFieldID(jni, parameters_class, "encodings", "Ljava/util/LinkedList;"); | 2092 GetFieldID(jni, parameters_class, "encodings", "Ljava/util/LinkedList;"); |
| 2090 jobject j_encodings = GetObjectField(jni, j_parameters, encodings_id); | 2093 jobject j_encodings = GetObjectField(jni, j_parameters, encodings_id); |
| 2091 jmethodID add = GetMethodID(jni, GetObjectClass(jni, j_encodings), "add", | 2094 jmethodID add = GetMethodID(jni, GetObjectClass(jni, j_encodings), "add", |
| 2092 "(Ljava/lang/Object;)Z"); | 2095 "(Ljava/lang/Object;)Z"); |
| 2096 jfieldID active_id = |
| 2097 GetFieldID(jni, encoding_class, "active", "Z"); |
| 2093 jfieldID bitrate_id = | 2098 jfieldID bitrate_id = |
| 2094 GetFieldID(jni, encoding_class, "maxBitrateBps", "Ljava/lang/Integer;"); | 2099 GetFieldID(jni, encoding_class, "maxBitrateBps", "Ljava/lang/Integer;"); |
| 2095 | 2100 |
| 2096 jclass integer_class = jni->FindClass("java/lang/Integer"); | 2101 jclass integer_class = jni->FindClass("java/lang/Integer"); |
| 2097 jmethodID integer_ctor = GetMethodID(jni, integer_class, "<init>", "(I)V"); | 2102 jmethodID integer_ctor = GetMethodID(jni, integer_class, "<init>", "(I)V"); |
| 2098 | 2103 |
| 2099 for (webrtc::RtpEncodingParameters encoding : parameters.encodings) { | 2104 for (const webrtc::RtpEncodingParameters& encoding : parameters.encodings) { |
| 2100 jobject j_encoding_parameters = | 2105 jobject j_encoding_parameters = |
| 2101 jni->NewObject(encoding_class, encoding_ctor); | 2106 jni->NewObject(encoding_class, encoding_ctor); |
| 2102 CHECK_EXCEPTION(jni) << "error during NewObject"; | 2107 CHECK_EXCEPTION(jni) << "error during NewObject"; |
| 2108 jni->SetBooleanField(j_encoding_parameters, active_id, encoding.active); |
| 2109 CHECK_EXCEPTION(jni) << "error during SetBooleanField"; |
| 2103 if (encoding.max_bitrate_bps > 0) { | 2110 if (encoding.max_bitrate_bps > 0) { |
| 2104 jobject j_bitrate_value = | 2111 jobject j_bitrate_value = |
| 2105 jni->NewObject(integer_class, integer_ctor, encoding.max_bitrate_bps); | 2112 jni->NewObject(integer_class, integer_ctor, encoding.max_bitrate_bps); |
| 2106 CHECK_EXCEPTION(jni) << "error during NewObject"; | 2113 CHECK_EXCEPTION(jni) << "error during NewObject"; |
| 2107 jni->SetObjectField(j_encoding_parameters, bitrate_id, j_bitrate_value); | 2114 jni->SetObjectField(j_encoding_parameters, bitrate_id, j_bitrate_value); |
| 2108 CHECK_EXCEPTION(jni) << "error during SetObjectField"; | 2115 CHECK_EXCEPTION(jni) << "error during SetObjectField"; |
| 2109 } | 2116 } |
| 2110 jboolean added = | 2117 jboolean added = |
| 2111 jni->CallBooleanMethod(j_encodings, add, j_encoding_parameters); | 2118 jni->CallBooleanMethod(j_encodings, add, j_encoding_parameters); |
| 2112 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod"; | 2119 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod"; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2139 return JavaStringFromStdString( | 2146 return JavaStringFromStdString( |
| 2140 jni, | 2147 jni, |
| 2141 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); | 2148 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); |
| 2142 } | 2149 } |
| 2143 | 2150 |
| 2144 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { | 2151 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { |
| 2145 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); | 2152 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); |
| 2146 } | 2153 } |
| 2147 | 2154 |
| 2148 } // namespace webrtc_jni | 2155 } // namespace webrtc_jni |
| OLD | NEW |