| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 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 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 namespace webrtc_jni { | 40 namespace webrtc_jni { |
| 41 | 41 |
| 42 // AndroidVideoCapturerJni implements AndroidVideoCapturerDelegate. | 42 // AndroidVideoCapturerJni implements AndroidVideoCapturerDelegate. |
| 43 // The purpose of the delegate is to hide the JNI specifics from the C++ only | 43 // The purpose of the delegate is to hide the JNI specifics from the C++ only |
| 44 // AndroidVideoCapturer. | 44 // AndroidVideoCapturer. |
| 45 class AndroidVideoCapturerJni : public webrtc::AndroidVideoCapturerDelegate { | 45 class AndroidVideoCapturerJni : public webrtc::AndroidVideoCapturerDelegate { |
| 46 public: | 46 public: |
| 47 static int SetAndroidObjects(JNIEnv* jni, jobject appliction_context); | 47 static int SetAndroidObjects(JNIEnv* jni, jobject appliction_context); |
| 48 | 48 |
| 49 // Creates a new instance of AndroidVideoCapturerJni. Returns a nullptr if | 49 AndroidVideoCapturerJni(JNIEnv* jni, jobject j_video_capturer); |
| 50 // it can't be created. This happens if |device_name| is invalid. | |
| 51 static rtc::scoped_refptr<AndroidVideoCapturerJni> Create( | |
| 52 JNIEnv* jni, | |
| 53 jobject j_video_capture, // Instance of VideoCapturerAndroid | |
| 54 jstring device_name); // Name of the camera to use. | |
| 55 | 50 |
| 56 void Start(int width, int height, int framerate, | 51 void Start(int width, int height, int framerate, |
| 57 webrtc::AndroidVideoCapturer* capturer) override; | 52 webrtc::AndroidVideoCapturer* capturer) override; |
| 58 void Stop() override; | 53 void Stop() override; |
| 59 | 54 |
| 60 std::string GetSupportedFormats() override; | 55 std::string GetSupportedFormats() override; |
| 61 | 56 |
| 62 // Called from VideoCapturerAndroid::NativeObserver on a Java thread. | 57 // Called from VideoCapturerAndroid::NativeObserver on a Java thread. |
| 63 void OnCapturerStarted(bool success); | 58 void OnCapturerStarted(bool success); |
| 64 void OnIncomingFrame(void* video_frame, | 59 void OnIncomingFrame(void* video_frame, |
| 65 int length, | 60 int length, |
| 66 int width, | 61 int width, |
| 67 int height, | 62 int height, |
| 68 int rotation, | 63 int rotation, |
| 69 int64 time_stamp); | 64 int64 time_stamp); |
| 70 void OnOutputFormatRequest(int width, int height, int fps); | 65 void OnOutputFormatRequest(int width, int height, int fps); |
| 71 protected: | 66 |
| 72 AndroidVideoCapturerJni(JNIEnv* jni, jobject j_video_capturer); | 67 protected: |
| 73 ~AndroidVideoCapturerJni(); | 68 ~AndroidVideoCapturerJni(); |
| 74 | 69 |
| 75 private: | 70 private: |
| 76 bool Init(jstring device_name); | |
| 77 void ReturnBuffer(int64 time_stamp); | 71 void ReturnBuffer(int64 time_stamp); |
| 78 JNIEnv* jni(); | 72 JNIEnv* jni(); |
| 79 | 73 |
| 80 // Helper function to make safe asynchronous calls to |capturer_|. The calls | 74 // Helper function to make safe asynchronous calls to |capturer_|. The calls |
| 81 // are not guaranteed to be delivered. | 75 // are not guaranteed to be delivered. |
| 82 template <typename... Args> | 76 template <typename... Args> |
| 83 void AsyncCapturerInvoke( | 77 void AsyncCapturerInvoke( |
| 84 const char* method_name, | 78 const char* method_name, |
| 85 void (webrtc::AndroidVideoCapturer::*method)(Args...), | 79 void (webrtc::AndroidVideoCapturer::*method)(Args...), |
| 86 Args... args); | 80 Args... args); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 101 rtc::scoped_ptr<rtc::GuardedAsyncInvoker> invoker_ GUARDED_BY(capturer_lock_); | 95 rtc::scoped_ptr<rtc::GuardedAsyncInvoker> invoker_ GUARDED_BY(capturer_lock_); |
| 102 | 96 |
| 103 static jobject application_context_; | 97 static jobject application_context_; |
| 104 | 98 |
| 105 RTC_DISALLOW_COPY_AND_ASSIGN(AndroidVideoCapturerJni); | 99 RTC_DISALLOW_COPY_AND_ASSIGN(AndroidVideoCapturerJni); |
| 106 }; | 100 }; |
| 107 | 101 |
| 108 } // namespace webrtc_jni | 102 } // namespace webrtc_jni |
| 109 | 103 |
| 110 #endif // TALK_APP_WEBRTC_JAVA_JNI_ANDROIDVIDEOCAPTURER_JNI_H_ | 104 #endif // TALK_APP_WEBRTC_JAVA_JNI_ANDROIDVIDEOCAPTURER_JNI_H_ |
| OLD | NEW |