OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 jni(), *j_observer_class_, "onCreateSuccess", | 540 jni(), *j_observer_class_, "onCreateSuccess", |
541 "(Lorg/webrtc/SessionDescription;)V"); | 541 "(Lorg/webrtc/SessionDescription;)V"); |
542 jobject j_sdp = JavaSdpFromNativeSdp(jni(), desc); | 542 jobject j_sdp = JavaSdpFromNativeSdp(jni(), desc); |
543 jni()->CallVoidMethod(*j_observer_global_, m, j_sdp); | 543 jni()->CallVoidMethod(*j_observer_global_, m, j_sdp); |
544 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; | 544 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; |
545 } | 545 } |
546 | 546 |
547 protected: | 547 protected: |
548 // Common implementation for failure of Set & Create types, distinguished by | 548 // Common implementation for failure of Set & Create types, distinguished by |
549 // |op| being "Set" or "Create". | 549 // |op| being "Set" or "Create". |
550 void OnFailure(const std::string& op, const std::string& error) { | 550 void DoOnFailure(const std::string& op, const std::string& error) { |
551 jmethodID m = GetMethodID(jni(), *j_observer_class_, "on" + op + "Failure", | 551 jmethodID m = GetMethodID(jni(), *j_observer_class_, "on" + op + "Failure", |
552 "(Ljava/lang/String;)V"); | 552 "(Ljava/lang/String;)V"); |
553 jstring j_error_string = JavaStringFromStdString(jni(), error); | 553 jstring j_error_string = JavaStringFromStdString(jni(), error); |
554 jni()->CallVoidMethod(*j_observer_global_, m, j_error_string); | 554 jni()->CallVoidMethod(*j_observer_global_, m, j_error_string); |
555 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; | 555 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; |
556 } | 556 } |
557 | 557 |
558 JNIEnv* jni() { | 558 JNIEnv* jni() { |
559 return AttachCurrentThreadIfNeeded(); | 559 return AttachCurrentThreadIfNeeded(); |
560 } | 560 } |
561 | 561 |
562 private: | 562 private: |
563 scoped_ptr<ConstraintsWrapper> constraints_; | 563 scoped_ptr<ConstraintsWrapper> constraints_; |
564 const ScopedGlobalRef<jobject> j_observer_global_; | 564 const ScopedGlobalRef<jobject> j_observer_global_; |
565 const ScopedGlobalRef<jclass> j_observer_class_; | 565 const ScopedGlobalRef<jclass> j_observer_class_; |
566 }; | 566 }; |
567 | 567 |
568 class CreateSdpObserverWrapper | 568 class CreateSdpObserverWrapper |
569 : public SdpObserverWrapper<CreateSessionDescriptionObserver> { | 569 : public SdpObserverWrapper<CreateSessionDescriptionObserver> { |
570 public: | 570 public: |
571 CreateSdpObserverWrapper(JNIEnv* jni, jobject j_observer, | 571 CreateSdpObserverWrapper(JNIEnv* jni, jobject j_observer, |
572 ConstraintsWrapper* constraints) | 572 ConstraintsWrapper* constraints) |
573 : SdpObserverWrapper(jni, j_observer, constraints) {} | 573 : SdpObserverWrapper(jni, j_observer, constraints) {} |
574 | 574 |
575 void OnFailure(const std::string& error) override { | 575 void OnFailure(const std::string& error) override { |
576 ScopedLocalRefFrame local_ref_frame(jni()); | 576 ScopedLocalRefFrame local_ref_frame(jni()); |
577 SdpObserverWrapper::OnFailure(std::string("Create"), error); | 577 SdpObserverWrapper::DoOnFailure(std::string("Create"), error); |
578 } | 578 } |
579 }; | 579 }; |
580 | 580 |
581 class SetSdpObserverWrapper | 581 class SetSdpObserverWrapper |
582 : public SdpObserverWrapper<SetSessionDescriptionObserver> { | 582 : public SdpObserverWrapper<SetSessionDescriptionObserver> { |
583 public: | 583 public: |
584 SetSdpObserverWrapper(JNIEnv* jni, jobject j_observer, | 584 SetSdpObserverWrapper(JNIEnv* jni, jobject j_observer, |
585 ConstraintsWrapper* constraints) | 585 ConstraintsWrapper* constraints) |
586 : SdpObserverWrapper(jni, j_observer, constraints) {} | 586 : SdpObserverWrapper(jni, j_observer, constraints) {} |
587 | 587 |
588 void OnFailure(const std::string& error) override { | 588 void OnFailure(const std::string& error) override { |
589 ScopedLocalRefFrame local_ref_frame(jni()); | 589 ScopedLocalRefFrame local_ref_frame(jni()); |
590 SdpObserverWrapper::OnFailure(std::string("Set"), error); | 590 SdpObserverWrapper::DoOnFailure(std::string("Set"), error); |
591 } | 591 } |
592 }; | 592 }; |
593 | 593 |
594 // Adapter for a Java DataChannel$Observer presenting a C++ DataChannelObserver | 594 // Adapter for a Java DataChannel$Observer presenting a C++ DataChannelObserver |
595 // and dispatching the callback from C++ back to Java. | 595 // and dispatching the callback from C++ back to Java. |
596 class DataChannelObserverWrapper : public DataChannelObserver { | 596 class DataChannelObserverWrapper : public DataChannelObserver { |
597 public: | 597 public: |
598 DataChannelObserverWrapper(JNIEnv* jni, jobject j_observer) | 598 DataChannelObserverWrapper(JNIEnv* jni, jobject j_observer) |
599 : j_observer_global_(jni, j_observer), | 599 : j_observer_global_(jni, j_observer), |
600 j_observer_class_(jni, GetObjectClass(jni, j_observer)), | 600 j_observer_class_(jni, GetObjectClass(jni, j_observer)), |
(...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2163 return JavaStringFromStdString( | 2163 return JavaStringFromStdString( |
2164 jni, | 2164 jni, |
2165 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); | 2165 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); |
2166 } | 2166 } |
2167 | 2167 |
2168 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { | 2168 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { |
2169 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); | 2169 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); |
2170 } | 2170 } |
2171 | 2171 |
2172 } // namespace webrtc_jni | 2172 } // namespace webrtc_jni |
OLD | NEW |