Sami Kalliomäki | 3e77afd | 2018-03-08 16:43:16 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame^] | 11 | #ifndef EXAMPLES_ANDROIDNATIVEAPI_JNI_ANDROID_CALL_CLIENT_H_ |
| 12 | #define EXAMPLES_ANDROIDNATIVEAPI_JNI_ANDROID_CALL_CLIENT_H_ |
Sami Kalliomäki | 3e77afd | 2018-03-08 16:43:16 +0100 | [diff] [blame] | 13 | |
| 14 | #include <jni.h> |
| 15 | |
| 16 | #include <memory> |
| 17 | #include <string> |
| 18 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame^] | 19 | #include "api/peer_connection_interface.h" |
| 20 | #include "rtc_base/critical_section.h" |
Sami Kalliomäki | 3e77afd | 2018-03-08 16:43:16 +0100 | [diff] [blame] | 21 | #include "rtc_base/scoped_ref_ptr.h" |
| 22 | #include "rtc_base/thread_checker.h" |
| 23 | #include "sdk/android/native_api/jni/scoped_java_ref.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame^] | 24 | #include "sdk/android/native_api/video/video_source.h" |
Sami Kalliomäki | 3e77afd | 2018-03-08 16:43:16 +0100 | [diff] [blame] | 25 | |
| 26 | namespace webrtc_examples { |
| 27 | |
| 28 | class AndroidCallClient { |
| 29 | public: |
| 30 | AndroidCallClient(); |
Mirko Bonadei | 94ef424 | 2018-07-20 13:33:06 +0200 | [diff] [blame] | 31 | ~AndroidCallClient(); |
Sami Kalliomäki | 3e77afd | 2018-03-08 16:43:16 +0100 | [diff] [blame] | 32 | |
| 33 | void Call(JNIEnv* env, |
| 34 | const webrtc::JavaRef<jobject>& cls, |
| 35 | const webrtc::JavaRef<jobject>& local_sink, |
| 36 | const webrtc::JavaRef<jobject>& remote_sink); |
| 37 | void Hangup(JNIEnv* env, const webrtc::JavaRef<jobject>& cls); |
| 38 | // A helper method for Java code to delete this object. Calls delete this. |
| 39 | void Delete(JNIEnv* env, const webrtc::JavaRef<jobject>& cls); |
| 40 | |
Sami Kalliomäki | c475ac1 | 2018-05-16 15:49:18 +0200 | [diff] [blame] | 41 | webrtc::ScopedJavaLocalRef<jobject> GetJavaVideoCapturerObserver( |
| 42 | JNIEnv* env, |
| 43 | const webrtc::JavaRef<jobject>& cls); |
| 44 | |
Sami Kalliomäki | 3e77afd | 2018-03-08 16:43:16 +0100 | [diff] [blame] | 45 | private: |
| 46 | class PCObserver; |
| 47 | |
| 48 | void CreatePeerConnectionFactory() RTC_RUN_ON(thread_checker_); |
| 49 | void CreatePeerConnection() RTC_RUN_ON(thread_checker_); |
| 50 | void Connect() RTC_RUN_ON(thread_checker_); |
| 51 | |
| 52 | rtc::ThreadChecker thread_checker_; |
| 53 | |
| 54 | bool call_started_ RTC_GUARDED_BY(thread_checker_); |
| 55 | |
| 56 | const std::unique_ptr<PCObserver> pc_observer_; |
| 57 | |
| 58 | rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pcf_ |
| 59 | RTC_GUARDED_BY(thread_checker_); |
| 60 | std::unique_ptr<rtc::Thread> network_thread_ RTC_GUARDED_BY(thread_checker_); |
| 61 | std::unique_ptr<rtc::Thread> worker_thread_ RTC_GUARDED_BY(thread_checker_); |
| 62 | std::unique_ptr<rtc::Thread> signaling_thread_ |
| 63 | RTC_GUARDED_BY(thread_checker_); |
| 64 | |
| 65 | std::unique_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> local_sink_ |
| 66 | RTC_GUARDED_BY(thread_checker_); |
| 67 | std::unique_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> remote_sink_ |
| 68 | RTC_GUARDED_BY(thread_checker_); |
Sami Kalliomäki | c475ac1 | 2018-05-16 15:49:18 +0200 | [diff] [blame] | 69 | rtc::scoped_refptr<webrtc::JavaVideoTrackSourceInterface> video_source_ |
Sami Kalliomäki | 3e77afd | 2018-03-08 16:43:16 +0100 | [diff] [blame] | 70 | RTC_GUARDED_BY(thread_checker_); |
| 71 | |
| 72 | rtc::CriticalSection pc_mutex_; |
| 73 | rtc::scoped_refptr<webrtc::PeerConnectionInterface> pc_ |
| 74 | RTC_GUARDED_BY(pc_mutex_); |
| 75 | }; |
| 76 | |
| 77 | } // namespace webrtc_examples |
| 78 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame^] | 79 | #endif // EXAMPLES_ANDROIDNATIVEAPI_JNI_ANDROID_CALL_CLIENT_H_ |