tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

android_call_client.h (2754B)


      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 
     11 #ifndef EXAMPLES_ANDROIDNATIVEAPI_JNI_ANDROID_CALL_CLIENT_H_
     12 #define EXAMPLES_ANDROIDNATIVEAPI_JNI_ANDROID_CALL_CLIENT_H_
     13 
     14 #include <jni.h>
     15 
     16 #include <memory>
     17 
     18 #include "api/peer_connection_interface.h"
     19 #include "api/scoped_refptr.h"
     20 #include "api/sequence_checker.h"
     21 #include "api/video/video_frame.h"
     22 #include "api/video/video_sink_interface.h"
     23 #include "rtc_base/synchronization/mutex.h"
     24 #include "rtc_base/thread.h"
     25 #include "rtc_base/thread_annotations.h"
     26 #include "sdk/android/native_api/jni/scoped_java_ref.h"
     27 #include "sdk/android/native_api/video/video_source.h"
     28 
     29 namespace webrtc_examples {
     30 
     31 class AndroidCallClient {
     32 public:
     33  AndroidCallClient();
     34  ~AndroidCallClient();
     35 
     36  void Call(JNIEnv* env,
     37            const webrtc::JavaRef<jobject>& local_sink,
     38            const webrtc::JavaRef<jobject>& remote_sink);
     39  void Hangup(JNIEnv* env);
     40  // A helper method for Java code to delete this object. Calls delete this.
     41  void Delete(JNIEnv* env);
     42 
     43  webrtc::ScopedJavaLocalRef<jobject> GetJavaVideoCapturerObserver(JNIEnv* env);
     44 
     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  webrtc::SequenceChecker thread_checker_;
     53 
     54  bool call_started_ RTC_GUARDED_BY(thread_checker_);
     55 
     56  const std::unique_ptr<PCObserver> pc_observer_;
     57 
     58  webrtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pcf_
     59      RTC_GUARDED_BY(thread_checker_);
     60  std::unique_ptr<webrtc::Thread> network_thread_
     61      RTC_GUARDED_BY(thread_checker_);
     62  std::unique_ptr<webrtc::Thread> worker_thread_
     63      RTC_GUARDED_BY(thread_checker_);
     64  std::unique_ptr<webrtc::Thread> signaling_thread_
     65      RTC_GUARDED_BY(thread_checker_);
     66 
     67  std::unique_ptr<webrtc::VideoSinkInterface<webrtc::VideoFrame>> local_sink_
     68      RTC_GUARDED_BY(thread_checker_);
     69  std::unique_ptr<webrtc::VideoSinkInterface<webrtc::VideoFrame>> remote_sink_
     70      RTC_GUARDED_BY(thread_checker_);
     71  webrtc::scoped_refptr<webrtc::JavaVideoTrackSourceInterface> video_source_
     72      RTC_GUARDED_BY(thread_checker_);
     73 
     74  webrtc::Mutex pc_mutex_;
     75  webrtc::scoped_refptr<webrtc::PeerConnectionInterface> pc_
     76      RTC_GUARDED_BY(pc_mutex_);
     77 };
     78 
     79 }  // namespace webrtc_examples
     80 
     81 #endif  // EXAMPLES_ANDROIDNATIVEAPI_JNI_ANDROID_CALL_CLIENT_H_