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 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 return ExtractNativePC(jni, j_pc)->AddStream( | 1746 return ExtractNativePC(jni, j_pc)->AddStream( |
1747 reinterpret_cast<MediaStreamInterface*>(native_stream)); | 1747 reinterpret_cast<MediaStreamInterface*>(native_stream)); |
1748 } | 1748 } |
1749 | 1749 |
1750 JOW(void, PeerConnection_nativeRemoveLocalStream)( | 1750 JOW(void, PeerConnection_nativeRemoveLocalStream)( |
1751 JNIEnv* jni, jobject j_pc, jlong native_stream) { | 1751 JNIEnv* jni, jobject j_pc, jlong native_stream) { |
1752 ExtractNativePC(jni, j_pc)->RemoveStream( | 1752 ExtractNativePC(jni, j_pc)->RemoveStream( |
1753 reinterpret_cast<MediaStreamInterface*>(native_stream)); | 1753 reinterpret_cast<MediaStreamInterface*>(native_stream)); |
1754 } | 1754 } |
1755 | 1755 |
| 1756 JOW(jobject, PeerConnection_nativeCreateSender)( |
| 1757 JNIEnv* jni, jobject j_pc, jstring j_kind) { |
| 1758 jclass j_rtp_sender_class = FindClass(jni, "org/webrtc/RtpSender"); |
| 1759 jmethodID j_rtp_sender_ctor = |
| 1760 GetMethodID(jni, j_rtp_sender_class, "<init>", "(J)V"); |
| 1761 |
| 1762 std::string kind = JavaToStdString(jni, j_kind); |
| 1763 rtc::scoped_refptr<RtpSenderInterface> sender = |
| 1764 ExtractNativePC(jni, j_pc)->CreateSender(kind); |
| 1765 if (!sender.get()) { |
| 1766 return nullptr; |
| 1767 } |
| 1768 jlong nativeSenderPtr = jlongFromPointer(sender.get()); |
| 1769 jobject j_sender = |
| 1770 jni->NewObject(j_rtp_sender_class, j_rtp_sender_ctor, nativeSenderPtr); |
| 1771 CHECK_EXCEPTION(jni) << "error during NewObject"; |
| 1772 // Sender is now owned by the Java object, and will be freed from |
| 1773 // RtpSender.dispose(), called by PeerConnection.dispose() or getSenders(). |
| 1774 sender->AddRef(); |
| 1775 return j_sender; |
| 1776 } |
| 1777 |
1756 JOW(jobject, PeerConnection_nativeGetSenders)(JNIEnv* jni, jobject j_pc) { | 1778 JOW(jobject, PeerConnection_nativeGetSenders)(JNIEnv* jni, jobject j_pc) { |
1757 jclass j_array_list_class = FindClass(jni, "java/util/ArrayList"); | 1779 jclass j_array_list_class = FindClass(jni, "java/util/ArrayList"); |
1758 jmethodID j_array_list_ctor = | 1780 jmethodID j_array_list_ctor = |
1759 GetMethodID(jni, j_array_list_class, "<init>", "()V"); | 1781 GetMethodID(jni, j_array_list_class, "<init>", "()V"); |
1760 jmethodID j_array_list_add = | 1782 jmethodID j_array_list_add = |
1761 GetMethodID(jni, j_array_list_class, "add", "(Ljava/lang/Object;)Z"); | 1783 GetMethodID(jni, j_array_list_class, "add", "(Ljava/lang/Object;)Z"); |
1762 jobject j_senders = jni->NewObject(j_array_list_class, j_array_list_ctor); | 1784 jobject j_senders = jni->NewObject(j_array_list_class, j_array_list_ctor); |
1763 CHECK_EXCEPTION(jni) << "error during NewObject"; | 1785 CHECK_EXCEPTION(jni) << "error during NewObject"; |
1764 | 1786 |
1765 jclass j_rtp_sender_class = FindClass(jni, "org/webrtc/RtpSender"); | 1787 jclass j_rtp_sender_class = FindClass(jni, "org/webrtc/RtpSender"); |
1766 jmethodID j_rtp_sender_ctor = | 1788 jmethodID j_rtp_sender_ctor = |
1767 GetMethodID(jni, j_rtp_sender_class, "<init>", "(J)V"); | 1789 GetMethodID(jni, j_rtp_sender_class, "<init>", "(J)V"); |
1768 | 1790 |
1769 auto senders = ExtractNativePC(jni, j_pc)->GetSenders(); | 1791 auto senders = ExtractNativePC(jni, j_pc)->GetSenders(); |
1770 for (const auto& sender : senders) { | 1792 for (const auto& sender : senders) { |
1771 jlong nativeSenderPtr = jlongFromPointer(sender.get()); | 1793 jlong nativeSenderPtr = jlongFromPointer(sender.get()); |
1772 jobject j_sender = | 1794 jobject j_sender = |
1773 jni->NewObject(j_rtp_sender_class, j_rtp_sender_ctor, nativeSenderPtr); | 1795 jni->NewObject(j_rtp_sender_class, j_rtp_sender_ctor, nativeSenderPtr); |
1774 CHECK_EXCEPTION(jni) << "error during NewObject"; | 1796 CHECK_EXCEPTION(jni) << "error during NewObject"; |
1775 // Sender is now owned by Java object, and will be freed from there. | 1797 // Sender is now owned by the Java object, and will be freed from |
| 1798 // RtpSender.dispose(), called by PeerConnection.dispose() or getSenders(). |
1776 sender->AddRef(); | 1799 sender->AddRef(); |
1777 jni->CallBooleanMethod(j_senders, j_array_list_add, j_sender); | 1800 jni->CallBooleanMethod(j_senders, j_array_list_add, j_sender); |
1778 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod"; | 1801 CHECK_EXCEPTION(jni) << "error during CallBooleanMethod"; |
1779 } | 1802 } |
1780 return j_senders; | 1803 return j_senders; |
1781 } | 1804 } |
1782 | 1805 |
1783 JOW(jobject, PeerConnection_nativeGetReceivers)(JNIEnv* jni, jobject j_pc) { | 1806 JOW(jobject, PeerConnection_nativeGetReceivers)(JNIEnv* jni, jobject j_pc) { |
1784 jclass j_array_list_class = FindClass(jni, "java/util/ArrayList"); | 1807 jclass j_array_list_class = FindClass(jni, "java/util/ArrayList"); |
1785 jmethodID j_array_list_ctor = | 1808 jmethodID j_array_list_ctor = |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2095 return JavaStringFromStdString( | 2118 return JavaStringFromStdString( |
2096 jni, | 2119 jni, |
2097 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); | 2120 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); |
2098 } | 2121 } |
2099 | 2122 |
2100 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { | 2123 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { |
2101 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); | 2124 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); |
2102 } | 2125 } |
2103 | 2126 |
2104 } // namespace webrtc_jni | 2127 } // namespace webrtc_jni |
OLD | NEW |