| Index: examples/unityplugin/simple_peer_connection.cc
|
| diff --git a/examples/unityplugin/simple_peer_connection.cc b/examples/unityplugin/simple_peer_connection.cc
|
| index fe59d53a6f5728517762300d0f2a60ff546f398e..80f8ee7af7698a7d1c9fc1776614fe475053a371 100644
|
| --- a/examples/unityplugin/simple_peer_connection.cc
|
| +++ b/examples/unityplugin/simple_peer_connection.cc
|
| @@ -74,6 +74,23 @@ class DummySetSessionDescriptionObserver
|
| ~DummySetSessionDescriptionObserver() {}
|
| };
|
|
|
| +class DummyCapturer : public cricket::VideoCapturer {
|
| + public:
|
| + cricket::CaptureState Start(
|
| + const cricket::VideoFormat& capture_format) override {
|
| + return cricket::CS_RUNNING;
|
| + }
|
| + void Stop() override {}
|
| + void AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink,
|
| + const rtc::VideoSinkWants& wants) override {}
|
| +
|
| + bool IsRunning() override { return true; }
|
| + bool IsScreencast() const override { return false; }
|
| + bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) override {
|
| + return true;
|
| + }
|
| +};
|
| +
|
| } // namespace
|
|
|
| bool SimplePeerConnection::InitializePeerConnection(const char** turn_urls,
|
| @@ -211,7 +228,6 @@ void SimplePeerConnection::OnSuccess(
|
|
|
| std::string sdp;
|
| desc->ToString(&sdp);
|
| -
|
| if (OnLocalSdpReady)
|
| OnLocalSdpReady(desc->type().c_str(), sdp.c_str());
|
| }
|
| @@ -407,7 +423,6 @@ void SimplePeerConnection::AddStreams(bool audio_only) {
|
| std::string id = audio_track->id();
|
| stream->AddTrack(audio_track);
|
|
|
| - if (!audio_only) {
|
| #if defined(WEBRTC_ANDROID)
|
| JNIEnv* env = webrtc::jni::GetEnv();
|
| jclass pc_factory_class =
|
| @@ -421,43 +436,50 @@ void SimplePeerConnection::AddStreams(bool audio_only) {
|
| RTC_DCHECK(texture_helper != nullptr)
|
| << "Cannot get the Surface Texture Helper.";
|
|
|
| - rtc::scoped_refptr<AndroidVideoTrackSource> source(
|
| - new rtc::RefCountedObject<AndroidVideoTrackSource>(
|
| + rtc::scoped_refptr<webrtc::jni::AndroidVideoTrackSource> source(
|
| + new rtc::RefCountedObject<webrtc::jni::AndroidVideoTrackSource>(
|
| g_signaling_thread.get(), env, texture_helper, false));
|
| rtc::scoped_refptr<webrtc::VideoTrackSourceProxy> proxy_source =
|
| webrtc::VideoTrackSourceProxy::Create(g_signaling_thread.get(),
|
| g_worker_thread.get(), source);
|
|
|
| - // link with VideoCapturer (Camera);
|
| - jmethodID link_camera_method = webrtc::jni::GetStaticMethodID(
|
| - env, pc_factory_class, "LinkCamera",
|
| - "(JLorg/webrtc/SurfaceTextureHelper;)Lorg/webrtc/VideoCapturer;");
|
| - jobject camera_tmp =
|
| - env->CallStaticObjectMethod(pc_factory_class, link_camera_method,
|
| - (jlong)proxy_source.get(), texture_helper);
|
| - CHECK_EXCEPTION(env);
|
| - g_camera = (jobject)env->NewGlobalRef(camera_tmp);
|
| + if (!audio_only) {
|
| + // link with VideoCapturer (Camera);
|
| + jmethodID link_camera_method = webrtc::jni::GetStaticMethodID(
|
| + env, pc_factory_class, "LinkCamera",
|
| + "(JLorg/webrtc/SurfaceTextureHelper;)Lorg/webrtc/VideoCapturer;");
|
| + jobject camera_tmp = env->CallStaticObjectMethod(
|
| + pc_factory_class, link_camera_method, (jlong)proxy_source.get(),
|
| + texture_helper);
|
| + CHECK_EXCEPTION(env);
|
| + g_camera = (jobject)env->NewGlobalRef(camera_tmp);
|
| + }
|
|
|
| rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track(
|
| g_peer_connection_factory->CreateVideoTrack(kVideoLabel,
|
| proxy_source.release()));
|
| stream->AddTrack(video_track);
|
| #else
|
| - std::unique_ptr<cricket::VideoCapturer> capture = OpenVideoCaptureDevice();
|
| - if (capture) {
|
| - rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track(
|
| - g_peer_connection_factory->CreateVideoTrack(
|
| - kVideoLabel, g_peer_connection_factory->CreateVideoSource(
|
| - std::move(capture), nullptr)));
|
| -
|
| - stream->AddTrack(video_track);
|
| - }
|
| + std::unique_ptr<cricket::VideoCapturer> capture;
|
| + if (!audio_only) {
|
| + capture = OpenVideoCaptureDevice();
|
| + } else {
|
| + capture.reset(new DummyCapturer());
|
| + }
|
| + if (capture) {
|
| + rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track(
|
| + g_peer_connection_factory->CreateVideoTrack(
|
| + kVideoLabel, g_peer_connection_factory->CreateVideoSource(
|
| + std::move(capture), nullptr)));
|
| +
|
| + stream->AddTrack(video_track);
|
| + }
|
| +
|
| #endif
|
| if (local_video_observer_ && !stream->GetVideoTracks().empty()) {
|
| stream->GetVideoTracks()[0]->AddOrUpdateSink(local_video_observer_.get(),
|
| rtc::VideoSinkWants());
|
| }
|
| - }
|
|
|
| if (!peer_connection_->AddStream(stream)) {
|
| LOG(LS_ERROR) << "Adding stream to PeerConnection failed";
|
|
|