OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1927 rtc::scoped_refptr<MediaSourceInterface> p( | 1927 rtc::scoped_refptr<MediaSourceInterface> p( |
1928 reinterpret_cast<MediaSourceInterface*>(j_p)); | 1928 reinterpret_cast<MediaSourceInterface*>(j_p)); |
1929 return JavaEnumFromIndex(jni, "MediaSource$State", p->state()); | 1929 return JavaEnumFromIndex(jni, "MediaSource$State", p->state()); |
1930 } | 1930 } |
1931 | 1931 |
1932 JOW(jobject, VideoCapturer_nativeCreateVideoCapturer)( | 1932 JOW(jobject, VideoCapturer_nativeCreateVideoCapturer)( |
1933 JNIEnv* jni, jclass, jstring j_device_name) { | 1933 JNIEnv* jni, jclass, jstring j_device_name) { |
1934 // Since we can't create platform specific java implementations in Java, we | 1934 // Since we can't create platform specific java implementations in Java, we |
1935 // defer the creation to C land. | 1935 // defer the creation to C land. |
1936 #if defined(ANDROID) | 1936 #if defined(ANDROID) |
| 1937 // TODO(nisse): This case is intended to be deleted. |
1937 jclass j_video_capturer_class( | 1938 jclass j_video_capturer_class( |
1938 FindClass(jni, "org/webrtc/VideoCapturerAndroid")); | 1939 FindClass(jni, "org/webrtc/VideoCapturerAndroid")); |
1939 const int camera_id = jni->CallStaticIntMethod( | 1940 const int camera_id = jni->CallStaticIntMethod( |
1940 j_video_capturer_class, | 1941 j_video_capturer_class, |
1941 GetStaticMethodID(jni, j_video_capturer_class, "lookupDeviceName", | 1942 GetStaticMethodID(jni, j_video_capturer_class, "lookupDeviceName", |
1942 "(Ljava/lang/String;)I"), | 1943 "(Ljava/lang/String;)I"), |
1943 j_device_name); | 1944 j_device_name); |
1944 CHECK_EXCEPTION(jni) << "error during VideoCapturerAndroid.lookupDeviceName"; | 1945 CHECK_EXCEPTION(jni) << "error during VideoCapturerAndroid.lookupDeviceName"; |
1945 if (camera_id == -1) | 1946 if (camera_id == -1) |
1946 return nullptr; | 1947 return nullptr; |
1947 jobject j_video_capturer = jni->NewObject( | 1948 jobject j_video_capturer = jni->NewObject( |
1948 j_video_capturer_class, | 1949 j_video_capturer_class, |
1949 GetMethodID(jni, j_video_capturer_class, "<init>", "(I)V"), camera_id); | 1950 GetMethodID(jni, j_video_capturer_class, "<init>", "(I)V"), camera_id); |
1950 CHECK_EXCEPTION(jni) << "error during creation of VideoCapturerAndroid"; | 1951 CHECK_EXCEPTION(jni) << "error during creation of VideoCapturerAndroid"; |
| 1952 jfieldID helper_fid = GetFieldID(jni, j_video_capturer_class, "surfaceHelper", |
| 1953 "Lorg/webrtc/SurfaceTextureHelper;"); |
| 1954 |
1951 rtc::scoped_refptr<webrtc::AndroidVideoCapturerDelegate> delegate = | 1955 rtc::scoped_refptr<webrtc::AndroidVideoCapturerDelegate> delegate = |
1952 new rtc::RefCountedObject<AndroidVideoCapturerJni>(jni, j_video_capturer); | 1956 new rtc::RefCountedObject<AndroidVideoCapturerJni>( |
| 1957 jni, j_video_capturer, |
| 1958 GetObjectField(jni, j_video_capturer, helper_fid)); |
1953 rtc::scoped_ptr<cricket::VideoCapturer> capturer( | 1959 rtc::scoped_ptr<cricket::VideoCapturer> capturer( |
1954 new webrtc::AndroidVideoCapturer(delegate)); | 1960 new webrtc::AndroidVideoCapturer(delegate)); |
1955 | 1961 |
1956 #else | 1962 #else |
1957 std::string device_name = JavaToStdString(jni, j_device_name); | 1963 std::string device_name = JavaToStdString(jni, j_device_name); |
1958 scoped_ptr<cricket::DeviceManagerInterface> device_manager( | 1964 scoped_ptr<cricket::DeviceManagerInterface> device_manager( |
1959 cricket::DeviceManagerFactory::Create()); | 1965 cricket::DeviceManagerFactory::Create()); |
1960 RTC_CHECK(device_manager->Init()) << "DeviceManager::Init() failed"; | 1966 RTC_CHECK(device_manager->Init()) << "DeviceManager::Init() failed"; |
1961 cricket::Device device; | 1967 cricket::Device device; |
1962 if (!device_manager->GetVideoCaptureDevice(device_name, &device)) { | 1968 if (!device_manager->GetVideoCaptureDevice(device_name, &device)) { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 return JavaStringFromStdString( | 2184 return JavaStringFromStdString( |
2179 jni, | 2185 jni, |
2180 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); | 2186 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); |
2181 } | 2187 } |
2182 | 2188 |
2183 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { | 2189 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { |
2184 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); | 2190 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); |
2185 } | 2191 } |
2186 | 2192 |
2187 } // namespace webrtc_jni | 2193 } // namespace webrtc_jni |
OLD | NEW |