| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // the below methods and we only override one of them. | 167 // the below methods and we only override one of them. |
| 168 // TODO(deadbeef): Remove once there's only one version of the methods. | 168 // TODO(deadbeef): Remove once there's only one version of the methods. |
| 169 using PeerConnectionObserver::OnAddStream; | 169 using PeerConnectionObserver::OnAddStream; |
| 170 using PeerConnectionObserver::OnRemoveStream; | 170 using PeerConnectionObserver::OnRemoveStream; |
| 171 using PeerConnectionObserver::OnDataChannel; | 171 using PeerConnectionObserver::OnDataChannel; |
| 172 | 172 |
| 173 PCOJava(JNIEnv* jni, jobject j_observer) | 173 PCOJava(JNIEnv* jni, jobject j_observer) |
| 174 : j_observer_global_(jni, j_observer), | 174 : j_observer_global_(jni, j_observer), |
| 175 j_observer_class_(jni, GetObjectClass(jni, *j_observer_global_)), | 175 j_observer_class_(jni, GetObjectClass(jni, *j_observer_global_)), |
| 176 j_media_stream_class_(jni, FindClass(jni, "org/webrtc/MediaStream")), | 176 j_media_stream_class_(jni, FindClass(jni, "org/webrtc/MediaStream")), |
| 177 j_media_stream_ctor_(GetMethodID( | 177 j_media_stream_ctor_( |
| 178 jni, *j_media_stream_class_, "<init>", "(J)V")), | 178 GetMethodID(jni, *j_media_stream_class_, "<init>", "(J)V")), |
| 179 j_audio_track_class_(jni, FindClass(jni, "org/webrtc/AudioTrack")), | 179 j_audio_track_class_(jni, FindClass(jni, "org/webrtc/AudioTrack")), |
| 180 j_audio_track_ctor_(GetMethodID( | 180 j_audio_track_ctor_( |
| 181 jni, *j_audio_track_class_, "<init>", "(J)V")), | 181 GetMethodID(jni, *j_audio_track_class_, "<init>", "(J)V")), |
| 182 j_video_track_class_(jni, FindClass(jni, "org/webrtc/VideoTrack")), | 182 j_video_track_class_(jni, FindClass(jni, "org/webrtc/VideoTrack")), |
| 183 j_video_track_ctor_(GetMethodID( | 183 j_video_track_ctor_( |
| 184 jni, *j_video_track_class_, "<init>", "(J)V")), | 184 GetMethodID(jni, *j_video_track_class_, "<init>", "(J)V")), |
| 185 j_data_channel_class_(jni, FindClass(jni, "org/webrtc/DataChannel")), | 185 j_data_channel_class_(jni, FindClass(jni, "org/webrtc/DataChannel")), |
| 186 j_data_channel_ctor_(GetMethodID( | 186 j_data_channel_ctor_( |
| 187 jni, *j_data_channel_class_, "<init>", "(J)V")) { | 187 GetMethodID(jni, *j_data_channel_class_, "<init>", "(J)V")), |
| 188 } | 188 j_rtp_receiver_class_(jni, FindClass(jni, "org/webrtc/RtpReceiver")), |
| 189 j_rtp_receiver_ctor_( |
| 190 GetMethodID(jni, *j_rtp_receiver_class_, "<init>", "(J)V")) {} |
| 189 | 191 |
| 190 virtual ~PCOJava() { | 192 virtual ~PCOJava() { |
| 191 ScopedLocalRefFrame local_ref_frame(jni()); | 193 ScopedLocalRefFrame local_ref_frame(jni()); |
| 192 while (!remote_streams_.empty()) | 194 while (!remote_streams_.empty()) |
| 193 DisposeRemoteStream(remote_streams_.begin()); | 195 DisposeRemoteStream(remote_streams_.begin()); |
| 196 while (!rtp_receivers_.empty()) |
| 197 DisposeRtpReceiver(rtp_receivers_.begin()); |
| 194 } | 198 } |
| 195 | 199 |
| 196 void OnIceCandidate(const IceCandidateInterface* candidate) override { | 200 void OnIceCandidate(const IceCandidateInterface* candidate) override { |
| 197 ScopedLocalRefFrame local_ref_frame(jni()); | 201 ScopedLocalRefFrame local_ref_frame(jni()); |
| 198 std::string sdp; | 202 std::string sdp; |
| 199 RTC_CHECK(candidate->ToString(&sdp)) << "got so far: " << sdp; | 203 RTC_CHECK(candidate->ToString(&sdp)) << "got so far: " << sdp; |
| 200 jclass candidate_class = FindClass(jni(), "org/webrtc/IceCandidate"); | 204 jclass candidate_class = FindClass(jni(), "org/webrtc/IceCandidate"); |
| 201 jmethodID ctor = GetMethodID(jni(), candidate_class, | 205 jmethodID ctor = GetMethodID(jni(), candidate_class, |
| 202 "<init>", "(Ljava/lang/String;ILjava/lang/String;)V"); | 206 "<init>", "(Ljava/lang/String;ILjava/lang/String;)V"); |
| 203 jstring j_mid = JavaStringFromStdString(jni(), candidate->sdp_mid()); | 207 jstring j_mid = JavaStringFromStdString(jni(), candidate->sdp_mid()); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 jni(), *j_observer_class_, "onIceGatheringChange", | 265 jni(), *j_observer_class_, "onIceGatheringChange", |
| 262 "(Lorg/webrtc/PeerConnection$IceGatheringState;)V"); | 266 "(Lorg/webrtc/PeerConnection$IceGatheringState;)V"); |
| 263 jobject new_state_enum = JavaEnumFromIndex( | 267 jobject new_state_enum = JavaEnumFromIndex( |
| 264 jni(), "PeerConnection$IceGatheringState", new_state); | 268 jni(), "PeerConnection$IceGatheringState", new_state); |
| 265 jni()->CallVoidMethod(*j_observer_global_, m, new_state_enum); | 269 jni()->CallVoidMethod(*j_observer_global_, m, new_state_enum); |
| 266 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; | 270 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; |
| 267 } | 271 } |
| 268 | 272 |
| 269 void OnAddStream(rtc::scoped_refptr<MediaStreamInterface> stream) override { | 273 void OnAddStream(rtc::scoped_refptr<MediaStreamInterface> stream) override { |
| 270 ScopedLocalRefFrame local_ref_frame(jni()); | 274 ScopedLocalRefFrame local_ref_frame(jni()); |
| 271 // Java MediaStream holds one reference. Corresponding Release() is in | 275 // The stream could be added into the remote_streams_ map when calling |
| 272 // MediaStream_free, triggered by MediaStream.dispose(). | 276 // OnAddTrack. |
| 273 stream->AddRef(); | 277 jobject j_stream = GetOrCreateJavaStream(stream); |
| 274 jobject j_stream = | |
| 275 jni()->NewObject(*j_media_stream_class_, j_media_stream_ctor_, | |
| 276 reinterpret_cast<jlong>(stream.get())); | |
| 277 CHECK_EXCEPTION(jni()) << "error during NewObject"; | |
| 278 | 278 |
| 279 for (const auto& track : stream->GetAudioTracks()) { | 279 for (const auto& track : stream->GetAudioTracks()) { |
| 280 jstring id = JavaStringFromStdString(jni(), track->id()); | 280 jstring id = JavaStringFromStdString(jni(), track->id()); |
| 281 // Java AudioTrack holds one reference. Corresponding Release() is in | 281 // Java AudioTrack holds one reference. Corresponding Release() is in |
| 282 // MediaStreamTrack_free, triggered by AudioTrack.dispose(). | 282 // MediaStreamTrack_free, triggered by AudioTrack.dispose(). |
| 283 track->AddRef(); | 283 track->AddRef(); |
| 284 jobject j_track = | 284 jobject j_track = |
| 285 jni()->NewObject(*j_audio_track_class_, j_audio_track_ctor_, | 285 jni()->NewObject(*j_audio_track_class_, j_audio_track_ctor_, |
| 286 reinterpret_cast<jlong>(track.get()), id); | 286 reinterpret_cast<jlong>(track.get()), id); |
| 287 CHECK_EXCEPTION(jni()) << "error during NewObject"; | 287 CHECK_EXCEPTION(jni()) << "error during NewObject"; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 314 "Ljava/util/LinkedList;"); | 314 "Ljava/util/LinkedList;"); |
| 315 jobject video_tracks = GetObjectField(jni(), j_stream, video_tracks_id); | 315 jobject video_tracks = GetObjectField(jni(), j_stream, video_tracks_id); |
| 316 jmethodID add = GetMethodID(jni(), | 316 jmethodID add = GetMethodID(jni(), |
| 317 GetObjectClass(jni(), video_tracks), | 317 GetObjectClass(jni(), video_tracks), |
| 318 "add", | 318 "add", |
| 319 "(Ljava/lang/Object;)Z"); | 319 "(Ljava/lang/Object;)Z"); |
| 320 jboolean added = jni()->CallBooleanMethod(video_tracks, add, j_track); | 320 jboolean added = jni()->CallBooleanMethod(video_tracks, add, j_track); |
| 321 CHECK_EXCEPTION(jni()) << "error during CallBooleanMethod"; | 321 CHECK_EXCEPTION(jni()) << "error during CallBooleanMethod"; |
| 322 RTC_CHECK(added); | 322 RTC_CHECK(added); |
| 323 } | 323 } |
| 324 remote_streams_[stream] = NewGlobalRef(jni(), j_stream); | |
| 325 | 324 |
| 326 jmethodID m = GetMethodID(jni(), *j_observer_class_, "onAddStream", | 325 jmethodID m = GetMethodID(jni(), *j_observer_class_, "onAddStream", |
| 327 "(Lorg/webrtc/MediaStream;)V"); | 326 "(Lorg/webrtc/MediaStream;)V"); |
| 328 jni()->CallVoidMethod(*j_observer_global_, m, j_stream); | 327 jni()->CallVoidMethod(*j_observer_global_, m, j_stream); |
| 329 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; | 328 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; |
| 330 } | 329 } |
| 331 | 330 |
| 332 void OnRemoveStream( | 331 void OnRemoveStream( |
| 333 rtc::scoped_refptr<MediaStreamInterface> stream) override { | 332 rtc::scoped_refptr<MediaStreamInterface> stream) override { |
| 334 ScopedLocalRefFrame local_ref_frame(jni()); | 333 ScopedLocalRefFrame local_ref_frame(jni()); |
| 335 NativeToJavaStreamsMap::iterator it = remote_streams_.find(stream); | 334 NativeToJavaStreamsMap::iterator it = remote_streams_.find(stream); |
| 336 RTC_CHECK(it != remote_streams_.end()) << "unexpected stream: " << std::hex | 335 RTC_CHECK(it != remote_streams_.end()) << "unexpected stream: " << std::hex |
| 337 << stream; | 336 << stream; |
| 338 jobject j_stream = it->second; | 337 jobject j_stream = it->second; |
| 339 jmethodID m = GetMethodID(jni(), *j_observer_class_, "onRemoveStream", | 338 jmethodID m = GetMethodID(jni(), *j_observer_class_, "onRemoveStream", |
| 340 "(Lorg/webrtc/MediaStream;)V"); | 339 "(Lorg/webrtc/MediaStream;)V"); |
| 341 jni()->CallVoidMethod(*j_observer_global_, m, j_stream); | 340 jni()->CallVoidMethod(*j_observer_global_, m, j_stream); |
| 342 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; | 341 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; |
| 343 // Release the refptr reference so that DisposeRemoteStream can assert | 342 // Release the refptr reference so that DisposeRemoteStream can assert |
| 344 // it removes the final reference. | 343 // it removes the final reference. |
| 345 stream = nullptr; | 344 stream = nullptr; |
| 346 DisposeRemoteStream(it); | 345 DisposeRemoteStream(it); |
| 347 } | 346 } |
| 348 | 347 |
| 349 void OnDataChannel( | 348 void OnDataChannel( |
| 350 rtc::scoped_refptr<DataChannelInterface> channel) override { | 349 rtc::scoped_refptr<DataChannelInterface> channel) override { |
| 351 ScopedLocalRefFrame local_ref_frame(jni()); | 350 ScopedLocalRefFrame local_ref_frame(jni()); |
| 352 jobject j_channel = jni()->NewObject( | 351 jobject j_channel = |
| 353 *j_data_channel_class_, j_data_channel_ctor_, (jlong)channel.get()); | 352 jni()->NewObject(*j_data_channel_class_, j_data_channel_ctor_, |
| 353 jlongFromPointer(channel.get())); |
| 354 CHECK_EXCEPTION(jni()) << "error during NewObject"; | 354 CHECK_EXCEPTION(jni()) << "error during NewObject"; |
| 355 | 355 |
| 356 jmethodID m = GetMethodID(jni(), *j_observer_class_, "onDataChannel", | 356 jmethodID m = GetMethodID(jni(), *j_observer_class_, "onDataChannel", |
| 357 "(Lorg/webrtc/DataChannel;)V"); | 357 "(Lorg/webrtc/DataChannel;)V"); |
| 358 jni()->CallVoidMethod(*j_observer_global_, m, j_channel); | 358 jni()->CallVoidMethod(*j_observer_global_, m, j_channel); |
| 359 | 359 |
| 360 // Channel is now owned by Java object, and will be freed from | 360 // Channel is now owned by Java object, and will be freed from |
| 361 // DataChannel.dispose(). Important that this be done _after_ the | 361 // DataChannel.dispose(). Important that this be done _after_ the |
| 362 // CallVoidMethod above as Java code might call back into native code and be | 362 // CallVoidMethod above as Java code might call back into native code and be |
| 363 // surprised to see a refcount of 2. | 363 // surprised to see a refcount of 2. |
| 364 int bumped_count = channel->AddRef(); | 364 int bumped_count = channel->AddRef(); |
| 365 RTC_CHECK(bumped_count == 2) << "Unexpected refcount OnDataChannel"; | 365 RTC_CHECK(bumped_count == 2) << "Unexpected refcount OnDataChannel"; |
| 366 | 366 |
| 367 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; | 367 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; |
| 368 } | 368 } |
| 369 | 369 |
| 370 void OnRenegotiationNeeded() override { | 370 void OnRenegotiationNeeded() override { |
| 371 ScopedLocalRefFrame local_ref_frame(jni()); | 371 ScopedLocalRefFrame local_ref_frame(jni()); |
| 372 jmethodID m = | 372 jmethodID m = |
| 373 GetMethodID(jni(), *j_observer_class_, "onRenegotiationNeeded", "()V"); | 373 GetMethodID(jni(), *j_observer_class_, "onRenegotiationNeeded", "()V"); |
| 374 jni()->CallVoidMethod(*j_observer_global_, m); | 374 jni()->CallVoidMethod(*j_observer_global_, m); |
| 375 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; | 375 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; |
| 376 } | 376 } |
| 377 | 377 |
| 378 void OnAddTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver, |
| 379 const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& |
| 380 streams) override { |
| 381 ScopedLocalRefFrame local_ref_frame(jni()); |
| 382 jobject j_rtp_receiver = |
| 383 jni()->NewObject(*j_rtp_receiver_class_, j_rtp_receiver_ctor_, |
| 384 jlongFromPointer(receiver.get())); |
| 385 CHECK_EXCEPTION(jni()) << "error during NewObject"; |
| 386 receiver->AddRef(); |
| 387 rtp_receivers_[receiver] = NewGlobalRef(jni(), j_rtp_receiver); |
| 388 |
| 389 jobjectArray j_stream_array = ToJavaMediaStreamArray(jni(), streams); |
| 390 jmethodID m = |
| 391 GetMethodID(jni(), *j_observer_class_, "onAddTrack", |
| 392 "(Lorg/webrtc/RtpReceiver;[Lorg/webrtc/MediaStream;)V"); |
| 393 jni()->CallVoidMethod(*j_observer_global_, m, j_rtp_receiver, |
| 394 j_stream_array); |
| 395 CHECK_EXCEPTION(jni()) << "Error during CallVoidMethod"; |
| 396 } |
| 397 |
| 378 void SetConstraints(ConstraintsWrapper* constraints) { | 398 void SetConstraints(ConstraintsWrapper* constraints) { |
| 379 RTC_CHECK(!constraints_.get()) << "constraints already set!"; | 399 RTC_CHECK(!constraints_.get()) << "constraints already set!"; |
| 380 constraints_.reset(constraints); | 400 constraints_.reset(constraints); |
| 381 } | 401 } |
| 382 | 402 |
| 383 const ConstraintsWrapper* constraints() { return constraints_.get(); } | 403 const ConstraintsWrapper* constraints() { return constraints_.get(); } |
| 384 | 404 |
| 385 private: | 405 private: |
| 386 typedef std::map<MediaStreamInterface*, jobject> NativeToJavaStreamsMap; | 406 typedef std::map<MediaStreamInterface*, jobject> NativeToJavaStreamsMap; |
| 407 typedef std::map<RtpReceiverInterface*, jobject> NativeToJavaRtpReceiverMap; |
| 387 | 408 |
| 388 void DisposeRemoteStream(const NativeToJavaStreamsMap::iterator& it) { | 409 void DisposeRemoteStream(const NativeToJavaStreamsMap::iterator& it) { |
| 389 jobject j_stream = it->second; | 410 jobject j_stream = it->second; |
| 390 remote_streams_.erase(it); | 411 remote_streams_.erase(it); |
| 391 jni()->CallVoidMethod( | 412 jni()->CallVoidMethod( |
| 392 j_stream, GetMethodID(jni(), *j_media_stream_class_, "dispose", "()V")); | 413 j_stream, GetMethodID(jni(), *j_media_stream_class_, "dispose", "()V")); |
| 393 CHECK_EXCEPTION(jni()) << "error during MediaStream.dispose()"; | 414 CHECK_EXCEPTION(jni()) << "error during MediaStream.dispose()"; |
| 394 DeleteGlobalRef(jni(), j_stream); | 415 DeleteGlobalRef(jni(), j_stream); |
| 395 } | 416 } |
| 396 | 417 |
| 418 void DisposeRtpReceiver(const NativeToJavaRtpReceiverMap::iterator& it) { |
| 419 jobject j_rtp_receiver = it->second; |
| 420 rtp_receivers_.erase(it); |
| 421 jni()->CallVoidMethod( |
| 422 j_rtp_receiver, |
| 423 GetMethodID(jni(), *j_rtp_receiver_class_, "dispose", "()V")); |
| 424 CHECK_EXCEPTION(jni()) << "error during RtpReceiver.dispose()"; |
| 425 DeleteGlobalRef(jni(), j_rtp_receiver); |
| 426 } |
| 427 |
| 397 jobject ToJavaCandidate(JNIEnv* jni, | 428 jobject ToJavaCandidate(JNIEnv* jni, |
| 398 jclass* candidate_class, | 429 jclass* candidate_class, |
| 399 const cricket::Candidate& candidate) { | 430 const cricket::Candidate& candidate) { |
| 400 std::string sdp = webrtc::SdpSerializeCandidate(candidate); | 431 std::string sdp = webrtc::SdpSerializeCandidate(candidate); |
| 401 RTC_CHECK(!sdp.empty()) << "got an empty ICE candidate"; | 432 RTC_CHECK(!sdp.empty()) << "got an empty ICE candidate"; |
| 402 jmethodID ctor = GetMethodID(jni, *candidate_class, "<init>", | 433 jmethodID ctor = GetMethodID(jni, *candidate_class, "<init>", |
| 403 "(Ljava/lang/String;ILjava/lang/String;)V"); | 434 "(Ljava/lang/String;ILjava/lang/String;)V"); |
| 404 jstring j_mid = JavaStringFromStdString(jni, candidate.transport_name()); | 435 jstring j_mid = JavaStringFromStdString(jni, candidate.transport_name()); |
| 405 jstring j_sdp = JavaStringFromStdString(jni, sdp); | 436 jstring j_sdp = JavaStringFromStdString(jni, sdp); |
| 406 // sdp_mline_index is not used, pass an invalid value -1. | 437 // sdp_mline_index is not used, pass an invalid value -1. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 417 jobjectArray java_candidates = | 448 jobjectArray java_candidates = |
| 418 jni->NewObjectArray(candidates.size(), candidate_class, NULL); | 449 jni->NewObjectArray(candidates.size(), candidate_class, NULL); |
| 419 int i = 0; | 450 int i = 0; |
| 420 for (const cricket::Candidate& candidate : candidates) { | 451 for (const cricket::Candidate& candidate : candidates) { |
| 421 jobject j_candidate = ToJavaCandidate(jni, &candidate_class, candidate); | 452 jobject j_candidate = ToJavaCandidate(jni, &candidate_class, candidate); |
| 422 jni->SetObjectArrayElement(java_candidates, i++, j_candidate); | 453 jni->SetObjectArrayElement(java_candidates, i++, j_candidate); |
| 423 } | 454 } |
| 424 return java_candidates; | 455 return java_candidates; |
| 425 } | 456 } |
| 426 | 457 |
| 458 jobjectArray ToJavaMediaStreamArray( |
| 459 JNIEnv* jni, |
| 460 const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) { |
| 461 jobjectArray java_streams = |
| 462 jni->NewObjectArray(streams.size(), *j_media_stream_class_, nullptr); |
| 463 CHECK_EXCEPTION(jni) << "error during NewObjectArray"; |
| 464 for (size_t i = 0; i < streams.size(); ++i) { |
| 465 jobject j_stream = GetOrCreateJavaStream(streams[i]); |
| 466 jni->SetObjectArrayElement(java_streams, i, j_stream); |
| 467 } |
| 468 return java_streams; |
| 469 } |
| 470 |
| 471 // If the NativeToJavaStreamsMap contains the stream, return it. |
| 472 // Otherwise, create a new Java MediaStream. |
| 473 jobject GetOrCreateJavaStream( |
| 474 const rtc::scoped_refptr<MediaStreamInterface>& stream) { |
| 475 NativeToJavaStreamsMap::iterator it = remote_streams_.find(stream); |
| 476 if (it != remote_streams_.end()) { |
| 477 return it->second; |
| 478 } |
| 479 |
| 480 // Java MediaStream holds one reference. Corresponding Release() is in |
| 481 // MediaStream_free, triggered by MediaStream.dispose(). |
| 482 stream->AddRef(); |
| 483 jobject j_stream = |
| 484 jni()->NewObject(*j_media_stream_class_, j_media_stream_ctor_, |
| 485 reinterpret_cast<jlong>(stream.get())); |
| 486 CHECK_EXCEPTION(jni()) << "error during NewObject"; |
| 487 |
| 488 remote_streams_[stream] = NewGlobalRef(jni(), j_stream); |
| 489 return j_stream; |
| 490 } |
| 491 |
| 427 JNIEnv* jni() { | 492 JNIEnv* jni() { |
| 428 return AttachCurrentThreadIfNeeded(); | 493 return AttachCurrentThreadIfNeeded(); |
| 429 } | 494 } |
| 430 | 495 |
| 431 const ScopedGlobalRef<jobject> j_observer_global_; | 496 const ScopedGlobalRef<jobject> j_observer_global_; |
| 432 const ScopedGlobalRef<jclass> j_observer_class_; | 497 const ScopedGlobalRef<jclass> j_observer_class_; |
| 433 const ScopedGlobalRef<jclass> j_media_stream_class_; | 498 const ScopedGlobalRef<jclass> j_media_stream_class_; |
| 434 const jmethodID j_media_stream_ctor_; | 499 const jmethodID j_media_stream_ctor_; |
| 435 const ScopedGlobalRef<jclass> j_audio_track_class_; | 500 const ScopedGlobalRef<jclass> j_audio_track_class_; |
| 436 const jmethodID j_audio_track_ctor_; | 501 const jmethodID j_audio_track_ctor_; |
| 437 const ScopedGlobalRef<jclass> j_video_track_class_; | 502 const ScopedGlobalRef<jclass> j_video_track_class_; |
| 438 const jmethodID j_video_track_ctor_; | 503 const jmethodID j_video_track_ctor_; |
| 439 const ScopedGlobalRef<jclass> j_data_channel_class_; | 504 const ScopedGlobalRef<jclass> j_data_channel_class_; |
| 440 const jmethodID j_data_channel_ctor_; | 505 const jmethodID j_data_channel_ctor_; |
| 506 const ScopedGlobalRef<jclass> j_rtp_receiver_class_; |
| 507 const jmethodID j_rtp_receiver_ctor_; |
| 441 // C++ -> Java remote streams. The stored jobects are global refs and must be | 508 // C++ -> Java remote streams. The stored jobects are global refs and must be |
| 442 // manually deleted upon removal. Use DisposeRemoteStream(). | 509 // manually deleted upon removal. Use DisposeRemoteStream(). |
| 443 NativeToJavaStreamsMap remote_streams_; | 510 NativeToJavaStreamsMap remote_streams_; |
| 511 NativeToJavaRtpReceiverMap rtp_receivers_; |
| 444 std::unique_ptr<ConstraintsWrapper> constraints_; | 512 std::unique_ptr<ConstraintsWrapper> constraints_; |
| 445 }; | 513 }; |
| 446 | 514 |
| 447 // Wrapper for a Java MediaConstraints object. Copies all needed data so when | 515 // Wrapper for a Java MediaConstraints object. Copies all needed data so when |
| 448 // the constructor returns the Java object is no longer needed. | 516 // the constructor returns the Java object is no longer needed. |
| 449 class ConstraintsWrapper : public MediaConstraintsInterface { | 517 class ConstraintsWrapper : public MediaConstraintsInterface { |
| 450 public: | 518 public: |
| 451 ConstraintsWrapper(JNIEnv* jni, jobject j_constraints) { | 519 ConstraintsWrapper(JNIEnv* jni, jobject j_constraints) { |
| 452 PopulateConstraintsFromJavaPairList( | 520 PopulateConstraintsFromJavaPairList( |
| 453 jni, j_constraints, "mandatory", &mandatory_); | 521 jni, j_constraints, "mandatory", &mandatory_); |
| (...skipping 2013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2467 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer) | 2535 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer) |
| 2468 ->SetObserver(nullptr); | 2536 ->SetObserver(nullptr); |
| 2469 RtpReceiverObserver* observer = | 2537 RtpReceiverObserver* observer = |
| 2470 reinterpret_cast<RtpReceiverObserver*>(j_observer_pointer); | 2538 reinterpret_cast<RtpReceiverObserver*>(j_observer_pointer); |
| 2471 if (observer) { | 2539 if (observer) { |
| 2472 delete observer; | 2540 delete observer; |
| 2473 } | 2541 } |
| 2474 } | 2542 } |
| 2475 | 2543 |
| 2476 } // namespace webrtc_jni | 2544 } // namespace webrtc_jni |
| OLD | NEW |