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

Side by Side Diff: webrtc/examples/unityplugin/simple_peer_connection.cc

Issue 3009613002: Android: Replace webrtc_jni namespace with nested jni namespace (Closed)
Patch Set: Rebase Created 3 years, 3 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 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 config_, &constraints, nullptr, nullptr, this); 157 config_, &constraints, nullptr, nullptr, this);
158 158
159 return peer_connection_.get() != nullptr; 159 return peer_connection_.get() != nullptr;
160 } 160 }
161 161
162 void SimplePeerConnection::DeletePeerConnection() { 162 void SimplePeerConnection::DeletePeerConnection() {
163 g_peer_count--; 163 g_peer_count--;
164 164
165 #if defined(WEBRTC_ANDROID) 165 #if defined(WEBRTC_ANDROID)
166 if (g_camera) { 166 if (g_camera) {
167 JNIEnv* env = webrtc_jni::GetEnv(); 167 JNIEnv* env = webrtc::jni::GetEnv();
168 jclass pc_factory_class = 168 jclass pc_factory_class =
169 unity_plugin::FindClass(env, "org/webrtc/UnityUtility"); 169 unity_plugin::FindClass(env, "org/webrtc/UnityUtility");
170 jmethodID stop_camera_method = webrtc_jni::GetStaticMethodID( 170 jmethodID stop_camera_method = webrtc::jni::GetStaticMethodID(
171 env, pc_factory_class, "StopCamera", "(Lorg/webrtc/VideoCapturer;)V"); 171 env, pc_factory_class, "StopCamera", "(Lorg/webrtc/VideoCapturer;)V");
172 172
173 env->CallStaticVoidMethod(pc_factory_class, stop_camera_method, g_camera); 173 env->CallStaticVoidMethod(pc_factory_class, stop_camera_method, g_camera);
174 CHECK_EXCEPTION(env); 174 CHECK_EXCEPTION(env);
175 175
176 g_camera = nullptr; 176 g_camera = nullptr;
177 } 177 }
178 #endif 178 #endif
179 179
180 CloseDataChannel(); 180 CloseDataChannel();
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 g_peer_connection_factory->CreateLocalMediaStream(kStreamLabel); 402 g_peer_connection_factory->CreateLocalMediaStream(kStreamLabel);
403 403
404 rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track( 404 rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track(
405 g_peer_connection_factory->CreateAudioTrack( 405 g_peer_connection_factory->CreateAudioTrack(
406 kAudioLabel, g_peer_connection_factory->CreateAudioSource(nullptr))); 406 kAudioLabel, g_peer_connection_factory->CreateAudioSource(nullptr)));
407 std::string id = audio_track->id(); 407 std::string id = audio_track->id();
408 stream->AddTrack(audio_track); 408 stream->AddTrack(audio_track);
409 409
410 if (!audio_only) { 410 if (!audio_only) {
411 #if defined(WEBRTC_ANDROID) 411 #if defined(WEBRTC_ANDROID)
412 JNIEnv* env = webrtc_jni::GetEnv(); 412 JNIEnv* env = webrtc::jni::GetEnv();
413 jclass pc_factory_class = 413 jclass pc_factory_class =
414 unity_plugin::FindClass(env, "org/webrtc/UnityUtility"); 414 unity_plugin::FindClass(env, "org/webrtc/UnityUtility");
415 jmethodID load_texture_helper_method = webrtc_jni::GetStaticMethodID( 415 jmethodID load_texture_helper_method = webrtc::jni::GetStaticMethodID(
416 env, pc_factory_class, "LoadSurfaceTextureHelper", 416 env, pc_factory_class, "LoadSurfaceTextureHelper",
417 "()Lorg/webrtc/SurfaceTextureHelper;"); 417 "()Lorg/webrtc/SurfaceTextureHelper;");
418 jobject texture_helper = env->CallStaticObjectMethod( 418 jobject texture_helper = env->CallStaticObjectMethod(
419 pc_factory_class, load_texture_helper_method); 419 pc_factory_class, load_texture_helper_method);
420 CHECK_EXCEPTION(env); 420 CHECK_EXCEPTION(env);
421 RTC_DCHECK(texture_helper != nullptr) 421 RTC_DCHECK(texture_helper != nullptr)
422 << "Cannot get the Surface Texture Helper."; 422 << "Cannot get the Surface Texture Helper.";
423 423
424 rtc::scoped_refptr<webrtc::AndroidVideoTrackSource> source( 424 rtc::scoped_refptr<AndroidVideoTrackSource> source(
425 new rtc::RefCountedObject<webrtc::AndroidVideoTrackSource>( 425 new rtc::RefCountedObject<AndroidVideoTrackSource>(
426 g_signaling_thread.get(), env, texture_helper, false)); 426 g_signaling_thread.get(), env, texture_helper, false));
427 rtc::scoped_refptr<webrtc::VideoTrackSourceProxy> proxy_source = 427 rtc::scoped_refptr<webrtc::VideoTrackSourceProxy> proxy_source =
428 webrtc::VideoTrackSourceProxy::Create(g_signaling_thread.get(), 428 webrtc::VideoTrackSourceProxy::Create(g_signaling_thread.get(),
429 g_worker_thread.get(), source); 429 g_worker_thread.get(), source);
430 430
431 // link with VideoCapturer (Camera); 431 // link with VideoCapturer (Camera);
432 jmethodID link_camera_method = webrtc_jni::GetStaticMethodID( 432 jmethodID link_camera_method = webrtc::jni::GetStaticMethodID(
433 env, pc_factory_class, "LinkCamera", 433 env, pc_factory_class, "LinkCamera",
434 "(JLorg/webrtc/SurfaceTextureHelper;)Lorg/webrtc/VideoCapturer;"); 434 "(JLorg/webrtc/SurfaceTextureHelper;)Lorg/webrtc/VideoCapturer;");
435 jobject camera_tmp = 435 jobject camera_tmp =
436 env->CallStaticObjectMethod(pc_factory_class, link_camera_method, 436 env->CallStaticObjectMethod(pc_factory_class, link_camera_method,
437 (jlong)proxy_source.get(), texture_helper); 437 (jlong)proxy_source.get(), texture_helper);
438 CHECK_EXCEPTION(env); 438 CHECK_EXCEPTION(env);
439 g_camera = (jobject)env->NewGlobalRef(camera_tmp); 439 g_camera = (jobject)env->NewGlobalRef(camera_tmp);
440 440
441 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( 441 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track(
442 g_peer_connection_factory->CreateVideoTrack(kVideoLabel, 442 g_peer_connection_factory->CreateVideoTrack(kVideoLabel,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 556
557 for (const auto& param : params) { 557 for (const auto& param : params) {
558 uint32_t ssrc = param.ssrc.value_or(0); 558 uint32_t ssrc = param.ssrc.value_or(0);
559 if (ssrc > 0) 559 if (ssrc > 0)
560 ssrcs.push_back(ssrc); 560 ssrcs.push_back(ssrc);
561 } 561 }
562 } 562 }
563 563
564 return ssrcs; 564 return ssrcs;
565 } 565 }
OLDNEW
« no previous file with comments | « webrtc/examples/unityplugin/jni_onload.cc ('k') | webrtc/modules/video_coding/codecs/test/android_test_initializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698