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 1833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1844 rtc::scoped_refptr<MediaSourceInterface> p( | 1844 rtc::scoped_refptr<MediaSourceInterface> p( |
1845 reinterpret_cast<MediaSourceInterface*>(j_p)); | 1845 reinterpret_cast<MediaSourceInterface*>(j_p)); |
1846 return JavaEnumFromIndex(jni, "MediaSource$State", p->state()); | 1846 return JavaEnumFromIndex(jni, "MediaSource$State", p->state()); |
1847 } | 1847 } |
1848 | 1848 |
1849 JOW(jobject, VideoCapturer_nativeCreateVideoCapturer)( | 1849 JOW(jobject, VideoCapturer_nativeCreateVideoCapturer)( |
1850 JNIEnv* jni, jclass, jstring j_device_name) { | 1850 JNIEnv* jni, jclass, jstring j_device_name) { |
1851 // Since we can't create platform specific java implementations in Java, we | 1851 // Since we can't create platform specific java implementations in Java, we |
1852 // defer the creation to C land. | 1852 // defer the creation to C land. |
1853 #if defined(ANDROID) | 1853 #if defined(ANDROID) |
| 1854 // TODO(nisse): This case is intended to be deleted. |
1854 jclass j_video_capturer_class( | 1855 jclass j_video_capturer_class( |
1855 FindClass(jni, "org/webrtc/VideoCapturerAndroid")); | 1856 FindClass(jni, "org/webrtc/VideoCapturerAndroid")); |
1856 const int camera_id = jni->CallStaticIntMethod( | 1857 const int camera_id = jni->CallStaticIntMethod( |
1857 j_video_capturer_class, | 1858 j_video_capturer_class, |
1858 GetStaticMethodID(jni, j_video_capturer_class, "lookupDeviceName", | 1859 GetStaticMethodID(jni, j_video_capturer_class, "lookupDeviceName", |
1859 "(Ljava/lang/String;)I"), | 1860 "(Ljava/lang/String;)I"), |
1860 j_device_name); | 1861 j_device_name); |
1861 CHECK_EXCEPTION(jni) << "error during VideoCapturerAndroid.lookupDeviceName"; | 1862 CHECK_EXCEPTION(jni) << "error during VideoCapturerAndroid.lookupDeviceName"; |
1862 if (camera_id == -1) | 1863 if (camera_id == -1) |
1863 return nullptr; | 1864 return nullptr; |
1864 jobject j_video_capturer = jni->NewObject( | 1865 jobject j_video_capturer = jni->NewObject( |
1865 j_video_capturer_class, | 1866 j_video_capturer_class, |
1866 GetMethodID(jni, j_video_capturer_class, "<init>", "(I)V"), camera_id); | 1867 GetMethodID(jni, j_video_capturer_class, "<init>", "(I)V"), camera_id); |
1867 CHECK_EXCEPTION(jni) << "error during creation of VideoCapturerAndroid"; | 1868 CHECK_EXCEPTION(jni) << "error during creation of VideoCapturerAndroid"; |
| 1869 jfieldID helper_fid = GetFieldID(jni, j_video_capturer_class, "surfaceHelper", |
| 1870 "Lorg/webrtc/SurfaceTextureHelper;"); |
| 1871 |
1868 rtc::scoped_refptr<webrtc::AndroidVideoCapturerDelegate> delegate = | 1872 rtc::scoped_refptr<webrtc::AndroidVideoCapturerDelegate> delegate = |
1869 new rtc::RefCountedObject<AndroidVideoCapturerJni>(jni, j_video_capturer); | 1873 new rtc::RefCountedObject<AndroidVideoCapturerJni>( |
| 1874 jni, j_video_capturer, |
| 1875 GetObjectField(jni, j_video_capturer, helper_fid)); |
1870 rtc::scoped_ptr<cricket::VideoCapturer> capturer( | 1876 rtc::scoped_ptr<cricket::VideoCapturer> capturer( |
1871 new webrtc::AndroidVideoCapturer(delegate)); | 1877 new webrtc::AndroidVideoCapturer(delegate)); |
1872 | 1878 |
1873 #else | 1879 #else |
1874 std::string device_name = JavaToStdString(jni, j_device_name); | 1880 std::string device_name = JavaToStdString(jni, j_device_name); |
1875 scoped_ptr<cricket::DeviceManagerInterface> device_manager( | 1881 scoped_ptr<cricket::DeviceManagerInterface> device_manager( |
1876 cricket::DeviceManagerFactory::Create()); | 1882 cricket::DeviceManagerFactory::Create()); |
1877 RTC_CHECK(device_manager->Init()) << "DeviceManager::Init() failed"; | 1883 RTC_CHECK(device_manager->Init()) << "DeviceManager::Init() failed"; |
1878 cricket::Device device; | 1884 cricket::Device device; |
1879 if (!device_manager->GetVideoCaptureDevice(device_name, &device)) { | 1885 if (!device_manager->GetVideoCaptureDevice(device_name, &device)) { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2095 return JavaStringFromStdString( | 2101 return JavaStringFromStdString( |
2096 jni, | 2102 jni, |
2097 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); | 2103 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); |
2098 } | 2104 } |
2099 | 2105 |
2100 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { | 2106 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { |
2101 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); | 2107 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); |
2102 } | 2108 } |
2103 | 2109 |
2104 } // namespace webrtc_jni | 2110 } // namespace webrtc_jni |
OLD | NEW |