 Chromium Code Reviews
 Chromium Code Reviews Issue 1819553002:
  Added the JNI interface to get and set RtpParameters and the maximum bitrate limits.  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master
    
  
    Issue 1819553002:
  Added the JNI interface to get and set RtpParameters and the maximum bitrate limits.  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 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 #include "webrtc/api/java/jni/jni_helpers.h" | 10 #include "webrtc/api/java/jni/jni_helpers.h" | 
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 // Scope Java local references to the lifetime of this object. Use in all C++ | 265 // Scope Java local references to the lifetime of this object. Use in all C++ | 
| 266 // callbacks (i.e. entry points that don't originate in a Java callstack | 266 // callbacks (i.e. entry points that don't originate in a Java callstack | 
| 267 // through a "native" method call). | 267 // through a "native" method call). | 
| 268 ScopedLocalRefFrame::ScopedLocalRefFrame(JNIEnv* jni) : jni_(jni) { | 268 ScopedLocalRefFrame::ScopedLocalRefFrame(JNIEnv* jni) : jni_(jni) { | 
| 269 RTC_CHECK(!jni_->PushLocalFrame(0)) << "Failed to PushLocalFrame"; | 269 RTC_CHECK(!jni_->PushLocalFrame(0)) << "Failed to PushLocalFrame"; | 
| 270 } | 270 } | 
| 271 ScopedLocalRefFrame::~ScopedLocalRefFrame() { | 271 ScopedLocalRefFrame::~ScopedLocalRefFrame() { | 
| 272 jni_->PopLocalFrame(NULL); | 272 jni_->PopLocalFrame(NULL); | 
| 273 } | 273 } | 
| 274 | 274 | 
| 275 // Creates an iterator representing the end of any collection. | |
| 276 Iterator::Iterator() : iterator_(NULL) {} | |
| 277 | |
| 278 // Creates an iterator pointing to the beginning of the specified collection. | |
| 279 Iterator::Iterator(JNIEnv* jni, jobject iterable) : jni_(jni) { | |
| 280 jclass j_class = GetObjectClass(jni, iterable); | |
| 281 jmethodID iterator_id = | |
| 282 GetMethodID(jni, j_class, "iterator", "()Ljava/util/Iterator;"); | |
| 283 iterator_ = jni->CallObjectMethod(iterable, iterator_id); | |
| 284 CHECK_EXCEPTION(jni) << "error during CallObjectMethod"; | |
| 285 | |
| 286 if (iterator_ == NULL) { | |
| 287 // TODO(skvlad): Should this be an exception instead? | |
| 
Taylor Brandstetter
2016/03/22 01:16:36
That seems reasonable. Just use "RTC_CHECK(iterato
 
skvlad
2016/03/22 02:19:59
Done.
 | |
| 288 return; | |
| 289 } | |
| 290 | |
| 291 jclass iterator_class = GetObjectClass(jni, iterator_); | |
| 292 has_next_id_ = GetMethodID(jni, iterator_class, "hasNext", "()Z"); | |
| 293 next_id_ = GetMethodID(jni, iterator_class, "next", "()Ljava/lang/Object;"); | |
| 294 | |
| 295 // Start at the first element in the collection | |
| 296 ++(*this); | |
| 297 } | |
| 298 | |
| 299 // Move constructor - necessary to be able to return iterator types from | |
| 300 // functions | |
| 301 Iterator::Iterator(Iterator&& other) | |
| 302 : jni_(std::move(other.jni_)), | |
| 303 iterator_(std::move(other.iterator_)), | |
| 304 value_(std::move(other.value_)), | |
| 305 has_next_id_(std::move(other.has_next_id_)), | |
| 306 next_id_(std::move(other.next_id_)){}; | |
| 307 | |
| 308 // Advances the iterator one step | |
| 309 Iterator& Iterator::operator++() { | |
| 310 if (iterator_ == NULL) { | |
| 311 // Can't iterate past the end | |
| 312 return *this; | |
| 313 } | |
| 314 bool has_next = jni_->CallBooleanMethod(iterator_, has_next_id_); | |
| 315 CHECK_EXCEPTION(jni_) << "error during CallBooleanMethod"; | |
| 316 if (!has_next) { | |
| 317 iterator_ = NULL; | |
| 318 return *this; | |
| 319 } | |
| 320 | |
| 321 value_ = jni_->CallObjectMethod(iterator_, next_id_); | |
| 322 CHECK_EXCEPTION(jni_) << "error during CallObjectMethod"; | |
| 323 return *this; | |
| 324 } | |
| 325 | |
| 275 } // namespace webrtc_jni | 326 } // namespace webrtc_jni | 
| OLD | NEW |