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

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

Issue 1460703002: Implement AndroidTextureBuffer::NativeToI420. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Get a shared ref to the java SurfaceTectureHelper. 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 30 matching lines...) Expand all
41 41
42 class NativeHandleImpl; 42 class NativeHandleImpl;
43 43
44 // AndroidVideoCapturerJni implements AndroidVideoCapturerDelegate. 44 // AndroidVideoCapturerJni implements AndroidVideoCapturerDelegate.
45 // The purpose of the delegate is to hide the JNI specifics from the C++ only 45 // The purpose of the delegate is to hide the JNI specifics from the C++ only
46 // AndroidVideoCapturer. 46 // AndroidVideoCapturer.
47 class AndroidVideoCapturerJni : public webrtc::AndroidVideoCapturerDelegate { 47 class AndroidVideoCapturerJni : public webrtc::AndroidVideoCapturerDelegate {
48 public: 48 public:
49 static int SetAndroidObjects(JNIEnv* jni, jobject appliction_context); 49 static int SetAndroidObjects(JNIEnv* jni, jobject appliction_context);
50 50
51 AndroidVideoCapturerJni(JNIEnv* jni, jobject j_video_capturer); 51 AndroidVideoCapturerJni(JNIEnv* jni,
52 jobject j_video_capturer,
53 jobject j_surface_texture_helper);
52 54
53 void Start(int width, int height, int framerate, 55 void Start(int width, int height, int framerate,
54 webrtc::AndroidVideoCapturer* capturer) override; 56 webrtc::AndroidVideoCapturer* capturer) override;
55 void Stop() override; 57 void Stop() override;
56 58
57 std::string GetSupportedFormats() override; 59 std::string GetSupportedFormats() override;
58 60
59 // Called from VideoCapturerAndroid::NativeObserver on a Java thread. 61 // Called from VideoCapturerAndroid::NativeObserver on a Java thread.
60 void OnCapturerStarted(bool success); 62 void OnCapturerStarted(bool success);
61 void OnMemoryBufferFrame(void* video_frame, int length, int width, 63 void OnMemoryBufferFrame(void* video_frame, int length, int width,
62 int height, int rotation, int64_t timestamp_ns); 64 int height, int rotation, int64_t timestamp_ns);
63 void OnTextureFrame(int width, int height, int64_t timestamp_ns, 65 void OnTextureFrame(int width, int height, int64_t timestamp_ns,
64 const NativeHandleImpl& handle); 66 const NativeHandleImpl& handle);
65 void OnOutputFormatRequest(int width, int height, int fps); 67 void OnOutputFormatRequest(int width, int height, int fps);
66 68
69 jobject GetSurfaceHelper() { return *j_surface_texture_helper_; }
67 protected: 70 protected:
68 ~AndroidVideoCapturerJni(); 71 ~AndroidVideoCapturerJni();
69 72
70 private: 73 private:
71 void ReturnBuffer(int64_t time_stamp); 74 void ReturnBuffer(int64_t time_stamp);
72 JNIEnv* jni(); 75 JNIEnv* jni();
73 76
74 // To avoid deducing Args from the 3rd parameter of AsyncCapturerInvoke. 77 // To avoid deducing Args from the 3rd parameter of AsyncCapturerInvoke.
75 template <typename T> 78 template <typename T>
76 struct Identity { 79 struct Identity {
77 typedef T type; 80 typedef T type;
78 }; 81 };
79 82
80 // Helper function to make safe asynchronous calls to |capturer_|. The calls 83 // Helper function to make safe asynchronous calls to |capturer_|. The calls
81 // are not guaranteed to be delivered. 84 // are not guaranteed to be delivered.
82 template <typename... Args> 85 template <typename... Args>
83 void AsyncCapturerInvoke( 86 void AsyncCapturerInvoke(
84 const char* method_name, 87 const char* method_name,
85 void (webrtc::AndroidVideoCapturer::*method)(Args...), 88 void (webrtc::AndroidVideoCapturer::*method)(Args...),
86 typename Identity<Args>::type... args); 89 typename Identity<Args>::type... args);
87 90
88 const ScopedGlobalRef<jobject> j_capturer_global_; 91 const ScopedGlobalRef<jobject> j_video_capturer_;
92 const ScopedGlobalRef<jobject> j_surface_texture_helper_;
89 const ScopedGlobalRef<jclass> j_video_capturer_class_; 93 const ScopedGlobalRef<jclass> j_video_capturer_class_;
90 const ScopedGlobalRef<jclass> j_observer_class_; 94 const ScopedGlobalRef<jclass> j_observer_class_;
91 95
92 rtc::ThreadChecker thread_checker_; 96 rtc::ThreadChecker thread_checker_;
93 97
94 // |capturer| is a guaranteed to be a valid pointer between a call to 98 // |capturer| is a guaranteed to be a valid pointer between a call to
95 // AndroidVideoCapturerDelegate::Start 99 // AndroidVideoCapturerDelegate::Start
96 // until AndroidVideoCapturerDelegate::Stop. 100 // until AndroidVideoCapturerDelegate::Stop.
97 rtc::CriticalSection capturer_lock_; 101 rtc::CriticalSection capturer_lock_;
98 webrtc::AndroidVideoCapturer* capturer_ GUARDED_BY(capturer_lock_); 102 webrtc::AndroidVideoCapturer* capturer_ GUARDED_BY(capturer_lock_);
99 // |invoker_| is used to communicate with |capturer_| on the thread Start() is 103 // |invoker_| is used to communicate with |capturer_| on the thread Start() is
100 // called on. 104 // called on.
101 rtc::scoped_ptr<rtc::GuardedAsyncInvoker> invoker_ GUARDED_BY(capturer_lock_); 105 rtc::scoped_ptr<rtc::GuardedAsyncInvoker> invoker_ GUARDED_BY(capturer_lock_);
102 106
103 static jobject application_context_; 107 static jobject application_context_;
104 108
105 RTC_DISALLOW_COPY_AND_ASSIGN(AndroidVideoCapturerJni); 109 RTC_DISALLOW_COPY_AND_ASSIGN(AndroidVideoCapturerJni);
106 }; 110 };
107 111
108 } // namespace webrtc_jni 112 } // namespace webrtc_jni
109 113
110 #endif // TALK_APP_WEBRTC_JAVA_JNI_ANDROIDVIDEOCAPTURER_JNI_H_ 114 #endif // TALK_APP_WEBRTC_JAVA_JNI_ANDROIDVIDEOCAPTURER_JNI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698