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 Java object, and will be freed from there. | |
AlexG
2015/12/02 00:50:16
nit: extend comment to list what method will free
| |
1773 sender->AddRef(); | |
1774 return j_sender; | |
1775 } | |
1776 | |
1756 JOW(jobject, PeerConnection_nativeGetSenders)(JNIEnv* jni, jobject j_pc) { | 1777 JOW(jobject, PeerConnection_nativeGetSenders)(JNIEnv* jni, jobject j_pc) { |
1757 jclass j_array_list_class = FindClass(jni, "java/util/ArrayList"); | 1778 jclass j_array_list_class = FindClass(jni, "java/util/ArrayList"); |
1758 jmethodID j_array_list_ctor = | 1779 jmethodID j_array_list_ctor = |
1759 GetMethodID(jni, j_array_list_class, "<init>", "()V"); | 1780 GetMethodID(jni, j_array_list_class, "<init>", "()V"); |
1760 jmethodID j_array_list_add = | 1781 jmethodID j_array_list_add = |
1761 GetMethodID(jni, j_array_list_class, "add", "(Ljava/lang/Object;)Z"); | 1782 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); | 1783 jobject j_senders = jni->NewObject(j_array_list_class, j_array_list_ctor); |
1763 CHECK_EXCEPTION(jni) << "error during NewObject"; | 1784 CHECK_EXCEPTION(jni) << "error during NewObject"; |
1764 | 1785 |
1765 jclass j_rtp_sender_class = FindClass(jni, "org/webrtc/RtpSender"); | 1786 jclass j_rtp_sender_class = FindClass(jni, "org/webrtc/RtpSender"); |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2095 return JavaStringFromStdString( | 2116 return JavaStringFromStdString( |
2096 jni, | 2117 jni, |
2097 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); | 2118 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); |
2098 } | 2119 } |
2099 | 2120 |
2100 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { | 2121 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { |
2101 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); | 2122 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); |
2102 } | 2123 } |
2103 | 2124 |
2104 } // namespace webrtc_jni | 2125 } // namespace webrtc_jni |
OLD | NEW |