webrtc/sdk/android/native_api/video/videosource.cc
Danil Chapovalov 196100efa6 Replace rtc::Optional with absl::optional
This is a no-op change because rtc::Optional is an alias to absl::optional

This CL generated by running script passing top level directories except rtc_base and api

find $@ -type f \( -name \*.h -o -name \*.cc -o -name \*.mm \) \
-exec sed -i 's|rtc::Optional|absl::optional|g' {} \+ \
-exec sed -i 's|rtc::nullopt|absl::nullopt|g' {} \+ \
-exec sed -i 's|#include "api/optional.h"|#include "absl/types/optional.h"|' {} \+

find $@ -type f -name BUILD.gn \
-exec sed -r -i 's|"[\./api]*:optional"|"//third_party/abseil-cpp/absl/types:optional"|' {} \+;

git cl format

Bug: webrtc:9078
Change-Id: I9465c172e65ba6e6ed4e4fdc35b0b265038d6f71
Reviewed-on: https://webrtc-review.googlesource.com/84584
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23697}
2018-06-21 09:32:56 +00:00

104 lines
3.7 KiB
C++

/*
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "sdk/android/native_api/video/videosource.h"
#include "sdk/android/src/jni/androidvideotracksource.h"
#include "sdk/android/src/jni/nativecapturerobserver.h"
namespace webrtc {
namespace {
// Hides full jni::AndroidVideoTrackSource interface and provides an instance of
// NativeCapturerObserver associated with the video source. Does not extend
// AndroidVideoTrackSource to avoid diamond inheritance on
// VideoTrackSourceInterface.
class JavaVideoTrackSourceImpl : public JavaVideoTrackSourceInterface {
public:
JavaVideoTrackSourceImpl(JNIEnv* env,
rtc::Thread* signaling_thread,
bool is_screencast)
: android_video_track_source_(
new rtc::RefCountedObject<jni::AndroidVideoTrackSource>(
signaling_thread,
env,
is_screencast)),
native_capturer_observer_(jni::CreateJavaNativeCapturerObserver(
env,
android_video_track_source_)) {}
ScopedJavaLocalRef<jobject> GetJavaVideoCapturerObserver(
JNIEnv* env) override {
return ScopedJavaLocalRef<jobject>(env, native_capturer_observer_);
}
// Delegate VideoTrackSourceInterface methods to android_video_track_source_.
void RegisterObserver(ObserverInterface* observer) override {
android_video_track_source_->RegisterObserver(observer);
}
void UnregisterObserver(ObserverInterface* observer) override {
android_video_track_source_->UnregisterObserver(observer);
}
SourceState state() const override {
return android_video_track_source_->state();
}
bool remote() const override { return android_video_track_source_->remote(); }
void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
const rtc::VideoSinkWants& wants) override {
// The method is defined private in the implementation so we have to access
// it through the interface...
static_cast<VideoTrackSourceInterface*>(android_video_track_source_.get())
->AddOrUpdateSink(sink, wants);
}
void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override {
// The method is defined private in the implementation so we have to access
// it through the interface...
static_cast<VideoTrackSourceInterface*>(android_video_track_source_.get())
->RemoveSink(sink);
}
bool is_screencast() const override {
return android_video_track_source_->is_screencast();
}
absl::optional<bool> needs_denoising() const override {
return android_video_track_source_->needs_denoising();
}
bool GetStats(Stats* stats) override {
// The method is defined private in the implementation so we have to access
// it through the interface...
return static_cast<VideoTrackSourceInterface*>(
android_video_track_source_.get())
->GetStats(stats);
}
private:
rtc::scoped_refptr<jni::AndroidVideoTrackSource> android_video_track_source_;
ScopedJavaGlobalRef<jobject> native_capturer_observer_;
};
} // namespace
rtc::scoped_refptr<JavaVideoTrackSourceInterface> CreateJavaVideoSource(
JNIEnv* jni,
rtc::Thread* signaling_thread,
bool is_screencast) {
return new rtc::RefCountedObject<JavaVideoTrackSourceImpl>(
jni, signaling_thread, is_screencast);
}
} // namespace webrtc