Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: talk/app/webrtc/java/jni/androidvideocapturer_jni.h

Issue 1530843002: Android VideoCapture : Use NV21 instead of YUV12 and clean up. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 18 matching lines...) Expand all
29 #ifndef TALK_APP_WEBRTC_JAVA_JNI_ANDROIDVIDEOCAPTURER_JNI_H_ 29 #ifndef TALK_APP_WEBRTC_JAVA_JNI_ANDROIDVIDEOCAPTURER_JNI_H_
30 #define TALK_APP_WEBRTC_JAVA_JNI_ANDROIDVIDEOCAPTURER_JNI_H_ 30 #define TALK_APP_WEBRTC_JAVA_JNI_ANDROIDVIDEOCAPTURER_JNI_H_
31 31
32 #include <string> 32 #include <string>
33 33
34 #include "talk/app/webrtc/androidvideocapturer.h" 34 #include "talk/app/webrtc/androidvideocapturer.h"
35 #include "talk/app/webrtc/java/jni/jni_helpers.h" 35 #include "talk/app/webrtc/java/jni/jni_helpers.h"
36 #include "webrtc/base/asyncinvoker.h" 36 #include "webrtc/base/asyncinvoker.h"
37 #include "webrtc/base/criticalsection.h" 37 #include "webrtc/base/criticalsection.h"
38 #include "webrtc/base/thread_checker.h" 38 #include "webrtc/base/thread_checker.h"
39 #include "webrtc/common_video/include/i420_buffer_pool.h"
39 40
40 namespace webrtc_jni { 41 namespace webrtc_jni {
41 42
42 class NativeHandleImpl; 43 class NativeHandleImpl;
44 class SurfaceTextureHelper;
43 45
44 // AndroidVideoCapturerJni implements AndroidVideoCapturerDelegate. 46 // AndroidVideoCapturerJni implements AndroidVideoCapturerDelegate.
45 // The purpose of the delegate is to hide the JNI specifics from the C++ only 47 // The purpose of the delegate is to hide the JNI specifics from the C++ only
46 // AndroidVideoCapturer. 48 // AndroidVideoCapturer.
47 class AndroidVideoCapturerJni : public webrtc::AndroidVideoCapturerDelegate { 49 class AndroidVideoCapturerJni : public webrtc::AndroidVideoCapturerDelegate {
48 public: 50 public:
49 static int SetAndroidObjects(JNIEnv* jni, jobject appliction_context); 51 static int SetAndroidObjects(JNIEnv* jni, jobject appliction_context);
50 52
51 AndroidVideoCapturerJni(JNIEnv* jni, 53 AndroidVideoCapturerJni(JNIEnv* jni,
52 jobject j_video_capturer, 54 jobject j_video_capturer,
(...skipping 10 matching lines...) Expand all
63 void OnMemoryBufferFrame(void* video_frame, int length, int width, 65 void OnMemoryBufferFrame(void* video_frame, int length, int width,
64 int height, int rotation, int64_t timestamp_ns); 66 int height, int rotation, int64_t timestamp_ns);
65 void OnTextureFrame(int width, int height, int rotation, int64_t timestamp_ns, 67 void OnTextureFrame(int width, int height, int rotation, int64_t timestamp_ns,
66 const NativeHandleImpl& handle); 68 const NativeHandleImpl& handle);
67 void OnOutputFormatRequest(int width, int height, int fps); 69 void OnOutputFormatRequest(int width, int height, int fps);
68 70
69 protected: 71 protected:
70 ~AndroidVideoCapturerJni(); 72 ~AndroidVideoCapturerJni();
71 73
72 private: 74 private:
73 void ReturnBuffer(int64_t time_stamp);
74 JNIEnv* jni(); 75 JNIEnv* jni();
75 76
76 // To avoid deducing Args from the 3rd parameter of AsyncCapturerInvoke. 77 // To avoid deducing Args from the 3rd parameter of AsyncCapturerInvoke.
77 template <typename T> 78 template <typename T>
78 struct Identity { 79 struct Identity {
79 typedef T type; 80 typedef T type;
80 }; 81 };
81 82
82 // Helper function to make safe asynchronous calls to |capturer_|. The calls 83 // Helper function to make safe asynchronous calls to |capturer_|. The calls
83 // are not guaranteed to be delivered. 84 // are not guaranteed to be delivered.
84 template <typename... Args> 85 template <typename... Args>
85 void AsyncCapturerInvoke( 86 void AsyncCapturerInvoke(
86 const char* method_name, 87 const char* method_name,
87 void (webrtc::AndroidVideoCapturer::*method)(Args...), 88 void (webrtc::AndroidVideoCapturer::*method)(Args...),
88 typename Identity<Args>::type... args); 89 typename Identity<Args>::type... args);
89 90
90 const ScopedGlobalRef<jobject> j_video_capturer_; 91 const ScopedGlobalRef<jobject> j_video_capturer_;
91 const ScopedGlobalRef<jobject> j_surface_texture_helper_;
92 const ScopedGlobalRef<jclass> j_video_capturer_class_; 92 const ScopedGlobalRef<jclass> j_video_capturer_class_;
93 const ScopedGlobalRef<jclass> j_observer_class_; 93 const ScopedGlobalRef<jclass> j_observer_class_;
94 94
95 // Used on the Java thread running the camera.
96 webrtc::I420BufferPool buffer_pool_;
97 rtc::scoped_refptr<SurfaceTextureHelper> surface_texture_helper_;
95 rtc::ThreadChecker thread_checker_; 98 rtc::ThreadChecker thread_checker_;
96 99
97 // |capturer| is a guaranteed to be a valid pointer between a call to 100 // |capturer| is a guaranteed to be a valid pointer between a call to
98 // AndroidVideoCapturerDelegate::Start 101 // AndroidVideoCapturerDelegate::Start
99 // until AndroidVideoCapturerDelegate::Stop. 102 // until AndroidVideoCapturerDelegate::Stop.
100 rtc::CriticalSection capturer_lock_; 103 rtc::CriticalSection capturer_lock_;
101 webrtc::AndroidVideoCapturer* capturer_ GUARDED_BY(capturer_lock_); 104 webrtc::AndroidVideoCapturer* capturer_ GUARDED_BY(capturer_lock_);
102 // |invoker_| is used to communicate with |capturer_| on the thread Start() is 105 // |invoker_| is used to communicate with |capturer_| on the thread Start() is
103 // called on. 106 // called on.
104 rtc::scoped_ptr<rtc::GuardedAsyncInvoker> invoker_ GUARDED_BY(capturer_lock_); 107 rtc::scoped_ptr<rtc::GuardedAsyncInvoker> invoker_ GUARDED_BY(capturer_lock_);
105 108
106 static jobject application_context_; 109 static jobject application_context_;
107 110
108 RTC_DISALLOW_COPY_AND_ASSIGN(AndroidVideoCapturerJni); 111 RTC_DISALLOW_COPY_AND_ASSIGN(AndroidVideoCapturerJni);
109 }; 112 };
110 113
111 } // namespace webrtc_jni 114 } // namespace webrtc_jni
112 115
113 #endif // TALK_APP_WEBRTC_JAVA_JNI_ANDROIDVIDEOCAPTURER_JNI_H_ 116 #endif // TALK_APP_WEBRTC_JAVA_JNI_ANDROIDVIDEOCAPTURER_JNI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698