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

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

Issue 1360173002: VideoCapturerAndroid: Add custom nativeCreateVideoCapturer() (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
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 28 matching lines...) Expand all
39 int AndroidVideoCapturerJni::SetAndroidObjects(JNIEnv* jni, 39 int AndroidVideoCapturerJni::SetAndroidObjects(JNIEnv* jni,
40 jobject appliction_context) { 40 jobject appliction_context) {
41 if (application_context_) { 41 if (application_context_) {
42 jni->DeleteGlobalRef(application_context_); 42 jni->DeleteGlobalRef(application_context_);
43 } 43 }
44 application_context_ = NewGlobalRef(jni, appliction_context); 44 application_context_ = NewGlobalRef(jni, appliction_context);
45 45
46 return 0; 46 return 0;
47 } 47 }
48 48
49 // static
50 rtc::scoped_refptr<AndroidVideoCapturerJni>
51 AndroidVideoCapturerJni::Create(JNIEnv* jni,
52 jobject j_video_capture,
53 jstring device_name) {
54 LOG(LS_INFO) << "AndroidVideoCapturerJni::Create";
55 rtc::scoped_refptr<AndroidVideoCapturerJni> capturer(
56 new rtc::RefCountedObject<AndroidVideoCapturerJni>(jni, j_video_capture));
57
58 if (capturer->Init(device_name)) {
59 return capturer;
60 }
61 LOG(LS_ERROR) << "AndroidVideoCapturerJni init fails";
62 return nullptr;
63 }
64
65 AndroidVideoCapturerJni::AndroidVideoCapturerJni(JNIEnv* jni, 49 AndroidVideoCapturerJni::AndroidVideoCapturerJni(JNIEnv* jni,
66 jobject j_video_capturer) 50 jobject j_video_capturer)
67 : j_capturer_global_(jni, j_video_capturer), 51 : j_capturer_global_(jni, j_video_capturer),
68 j_video_capturer_class_( 52 j_video_capturer_class_(
69 jni, FindClass(jni, "org/webrtc/VideoCapturerAndroid")), 53 jni, FindClass(jni, "org/webrtc/VideoCapturerAndroid")),
70 j_observer_class_( 54 j_observer_class_(
71 jni, 55 jni,
72 FindClass(jni, 56 FindClass(jni,
73 "org/webrtc/VideoCapturerAndroid$NativeObserver")), 57 "org/webrtc/VideoCapturerAndroid$NativeObserver")),
74 capturer_(nullptr) { 58 capturer_(nullptr) {
75 LOG(LS_INFO) << "AndroidVideoCapturerJni ctor"; 59 LOG(LS_INFO) << "AndroidVideoCapturerJni ctor";
76 thread_checker_.DetachFromThread(); 60 thread_checker_.DetachFromThread();
77 } 61 }
78 62
79 bool AndroidVideoCapturerJni::Init(jstring device_name) {
80 const jmethodID m(GetMethodID(
81 jni(), *j_video_capturer_class_, "init", "(Ljava/lang/String;)Z"));
82 if (!jni()->CallBooleanMethod(*j_capturer_global_, m, device_name)) {
83 return false;
84 }
85 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod";
86 return true;
87 }
88
89 AndroidVideoCapturerJni::~AndroidVideoCapturerJni() { 63 AndroidVideoCapturerJni::~AndroidVideoCapturerJni() {
90 LOG(LS_INFO) << "AndroidVideoCapturerJni dtor"; 64 LOG(LS_INFO) << "AndroidVideoCapturerJni dtor";
91 jni()->CallVoidMethod( 65 jni()->CallVoidMethod(
92 *j_capturer_global_, 66 *j_capturer_global_,
93 GetMethodID(jni(), *j_video_capturer_class_, "release", "()V")); 67 GetMethodID(jni(), *j_video_capturer_class_, "release", "()V"));
94 CHECK_EXCEPTION(jni()) << "error during VideoCapturerAndroid.release()"; 68 CHECK_EXCEPTION(jni()) << "error during VideoCapturerAndroid.release()";
95 } 69 }
96 70
97 void AndroidVideoCapturerJni::Start(int width, int height, int framerate, 71 void AndroidVideoCapturerJni::Start(int width, int height, int framerate,
98 webrtc::AndroidVideoCapturer* capturer) { 72 webrtc::AndroidVideoCapturer* capturer) {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 213 }
240 214
241 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeOnOutputFormatRequest) 215 JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeOnOutputFormatRequest)
242 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height, 216 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height,
243 jint j_fps) { 217 jint j_fps) {
244 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest"; 218 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest";
245 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest( 219 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest(
246 j_width, j_height, j_fps); 220 j_width, j_height, j_fps);
247 } 221 }
248 222
223 JOW(jlong, VideoCapturerAndroid_nativeCreateVideoCapturer)
224 (JNIEnv* jni, jclass, jobject j_video_capturer) {
225 rtc::scoped_refptr<webrtc::AndroidVideoCapturerDelegate> delegate =
226 new rtc::RefCountedObject<AndroidVideoCapturerJni>(jni, j_video_capturer);
227 rtc::scoped_ptr<cricket::VideoCapturer> capturer(
228 new webrtc::AndroidVideoCapturer(delegate));
229 // Caller takes ownership of the cricket::VideoCapturer* pointer.
230 return jlongFromPointer(capturer.release());
231 }
232
249 } // namespace webrtc_jni 233 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « talk/app/webrtc/java/jni/androidvideocapturer_jni.h ('k') | talk/app/webrtc/java/jni/peerconnection_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698