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

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

Issue 1397373002: Reland of Android: Put common native VideoFrameBuffer implementation in androidvideocapturer_jni (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 2 months 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
« no previous file with comments | « no previous file | talk/app/webrtc/java/jni/native_handle_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 16 matching lines...) Expand all
27 */ 27 */
28 28
29 #include "talk/app/webrtc/java/jni/androidvideocapturer_jni.h" 29 #include "talk/app/webrtc/java/jni/androidvideocapturer_jni.h"
30 #include "talk/app/webrtc/java/jni/classreferenceholder.h" 30 #include "talk/app/webrtc/java/jni/classreferenceholder.h"
31 #include "talk/app/webrtc/java/jni/native_handle_impl.h" 31 #include "talk/app/webrtc/java/jni/native_handle_impl.h"
32 #include "webrtc/base/bind.h" 32 #include "webrtc/base/bind.h"
33 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 33 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
34 34
35 namespace webrtc_jni { 35 namespace webrtc_jni {
36 36
37 namespace {
38
39 class CameraTextureBuffer : public webrtc::NativeHandleBuffer {
40 public:
41 CameraTextureBuffer(int width, int height,
42 const NativeHandleImpl& native_handle,
43 const rtc::Callback0<void>& no_longer_used)
44 : webrtc::NativeHandleBuffer(&native_handle_, width, height),
45 native_handle_(native_handle),
46 no_longer_used_cb_(no_longer_used) {}
47
48 ~CameraTextureBuffer() {
49 no_longer_used_cb_();
50 }
51
52 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override {
53 RTC_NOTREACHED()
54 << "CameraTextureBuffer::NativeToI420Buffer not implemented.";
55 return nullptr;
56 }
57
58 private:
59 NativeHandleImpl native_handle_;
60 rtc::Callback0<void> no_longer_used_cb_;
61 };
62
63 } // anonymous namespace
64
65 jobject AndroidVideoCapturerJni::application_context_ = nullptr; 37 jobject AndroidVideoCapturerJni::application_context_ = nullptr;
66 38
67 // static 39 // static
68 int AndroidVideoCapturerJni::SetAndroidObjects(JNIEnv* jni, 40 int AndroidVideoCapturerJni::SetAndroidObjects(JNIEnv* jni,
69 jobject appliction_context) { 41 jobject appliction_context) {
70 if (application_context_) { 42 if (application_context_) {
71 jni->DeleteGlobalRef(application_context_); 43 jni->DeleteGlobalRef(application_context_);
72 } 44 }
73 application_context_ = NewGlobalRef(jni, appliction_context); 45 application_context_ = NewGlobalRef(jni, appliction_context);
74 46
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 AsyncCapturerInvoke("OnIncomingFrame", 178 AsyncCapturerInvoke("OnIncomingFrame",
207 &webrtc::AndroidVideoCapturer::OnIncomingFrame, 179 &webrtc::AndroidVideoCapturer::OnIncomingFrame,
208 buffer, rotation, timestamp_ns); 180 buffer, rotation, timestamp_ns);
209 } 181 }
210 182
211 void AndroidVideoCapturerJni::OnTextureFrame(int width, 183 void AndroidVideoCapturerJni::OnTextureFrame(int width,
212 int height, 184 int height,
213 int64_t timestamp_ns, 185 int64_t timestamp_ns,
214 const NativeHandleImpl& handle) { 186 const NativeHandleImpl& handle) {
215 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer( 187 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer(
216 new rtc::RefCountedObject<CameraTextureBuffer>( 188 new rtc::RefCountedObject<AndroidTextureBuffer>(
217 width, height, handle, 189 width, height, handle,
218 rtc::Bind(&AndroidVideoCapturerJni::ReturnBuffer, this, 190 rtc::Bind(&AndroidVideoCapturerJni::ReturnBuffer, this,
219 timestamp_ns))); 191 timestamp_ns)));
220 AsyncCapturerInvoke("OnIncomingFrame", 192 AsyncCapturerInvoke("OnIncomingFrame",
221 &webrtc::AndroidVideoCapturer::OnIncomingFrame, 193 &webrtc::AndroidVideoCapturer::OnIncomingFrame,
222 buffer, 0, timestamp_ns); 194 buffer, 0, timestamp_ns);
223 } 195 }
224 196
225 void AndroidVideoCapturerJni::OnOutputFormatRequest(int width, 197 void AndroidVideoCapturerJni::OnOutputFormatRequest(int width,
226 int height, 198 int height,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 (JNIEnv* jni, jclass, jobject j_video_capturer) { 251 (JNIEnv* jni, jclass, jobject j_video_capturer) {
280 rtc::scoped_refptr<webrtc::AndroidVideoCapturerDelegate> delegate = 252 rtc::scoped_refptr<webrtc::AndroidVideoCapturerDelegate> delegate =
281 new rtc::RefCountedObject<AndroidVideoCapturerJni>(jni, j_video_capturer); 253 new rtc::RefCountedObject<AndroidVideoCapturerJni>(jni, j_video_capturer);
282 rtc::scoped_ptr<cricket::VideoCapturer> capturer( 254 rtc::scoped_ptr<cricket::VideoCapturer> capturer(
283 new webrtc::AndroidVideoCapturer(delegate)); 255 new webrtc::AndroidVideoCapturer(delegate));
284 // Caller takes ownership of the cricket::VideoCapturer* pointer. 256 // Caller takes ownership of the cricket::VideoCapturer* pointer.
285 return jlongFromPointer(capturer.release()); 257 return jlongFromPointer(capturer.release());
286 } 258 }
287 259
288 } // namespace webrtc_jni 260 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « no previous file | talk/app/webrtc/java/jni/native_handle_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698