Repo created
This commit is contained in:
parent
81b91f4139
commit
f8c34fa5ee
22732 changed files with 4815320 additions and 2 deletions
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* 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/video_source.h"
|
||||
|
||||
#include "sdk/android/src/jni/android_video_track_source.h"
|
||||
#include "sdk/android/src/jni/native_capturer_observer.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,
|
||||
bool align_timestamps)
|
||||
: android_video_track_source_(
|
||||
rtc::make_ref_counted<jni::AndroidVideoTrackSource>(
|
||||
signaling_thread,
|
||||
env,
|
||||
is_screencast,
|
||||
align_timestamps)),
|
||||
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:
|
||||
// Encoded sinks not implemented for JavaVideoTrackSourceImpl.
|
||||
bool SupportsEncodedOutput() const override { return false; }
|
||||
void GenerateKeyFrame() override {}
|
||||
void AddEncodedSink(
|
||||
rtc::VideoSinkInterface<webrtc::RecordableEncodedFrame>* sink) override {}
|
||||
void RemoveEncodedSink(
|
||||
rtc::VideoSinkInterface<webrtc::RecordableEncodedFrame>* sink) override {}
|
||||
|
||||
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,
|
||||
bool align_timestamps) {
|
||||
return rtc::make_ref_counted<JavaVideoTrackSourceImpl>(
|
||||
jni, signaling_thread, is_screencast, align_timestamps);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright 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.
|
||||
*/
|
||||
|
||||
#ifndef SDK_ANDROID_NATIVE_API_VIDEO_VIDEO_SOURCE_H_
|
||||
#define SDK_ANDROID_NATIVE_API_VIDEO_VIDEO_SOURCE_H_
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "api/media_stream_interface.h"
|
||||
#include "rtc_base/thread.h"
|
||||
#include "sdk/android/native_api/jni/scoped_java_ref.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Interface for class that implements VideoTrackSourceInterface and provides a
|
||||
// Java object that can be used to feed frames to the source.
|
||||
class JavaVideoTrackSourceInterface : public VideoTrackSourceInterface {
|
||||
public:
|
||||
// Returns CapturerObserver object that can be used to feed frames to the
|
||||
// video source.
|
||||
virtual ScopedJavaLocalRef<jobject> GetJavaVideoCapturerObserver(
|
||||
JNIEnv* env) = 0;
|
||||
};
|
||||
|
||||
// Creates an instance of JavaVideoTrackSourceInterface,
|
||||
rtc::scoped_refptr<JavaVideoTrackSourceInterface> CreateJavaVideoSource(
|
||||
JNIEnv* env,
|
||||
rtc::Thread* signaling_thread,
|
||||
bool is_screencast,
|
||||
bool align_timestamps);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // SDK_ANDROID_NATIVE_API_VIDEO_VIDEO_SOURCE_H_
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 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/wrapper.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "sdk/android/native_api/jni/scoped_java_ref.h"
|
||||
#include "sdk/android/src/jni/video_frame.h"
|
||||
#include "sdk/android/src/jni/video_sink.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
std::unique_ptr<rtc::VideoSinkInterface<VideoFrame>> JavaToNativeVideoSink(
|
||||
JNIEnv* jni,
|
||||
jobject video_sink) {
|
||||
return std::make_unique<jni::VideoSinkWrapper>(
|
||||
jni, JavaParamRef<jobject>(video_sink));
|
||||
}
|
||||
|
||||
ScopedJavaLocalRef<jobject> NativeToJavaVideoFrame(JNIEnv* jni,
|
||||
const VideoFrame& frame) {
|
||||
return jni::NativeToJavaVideoFrame(jni, frame);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 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.
|
||||
*/
|
||||
|
||||
#ifndef SDK_ANDROID_NATIVE_API_VIDEO_WRAPPER_H_
|
||||
#define SDK_ANDROID_NATIVE_API_VIDEO_WRAPPER_H_
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/media_stream_interface.h"
|
||||
#include "api/video/video_frame.h"
|
||||
#include "sdk/android/native_api/jni/scoped_java_ref.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Creates an instance of rtc::VideoSinkInterface<VideoFrame> from Java
|
||||
// VideoSink.
|
||||
std::unique_ptr<rtc::VideoSinkInterface<VideoFrame>> JavaToNativeVideoSink(
|
||||
JNIEnv* jni,
|
||||
jobject video_sink);
|
||||
|
||||
// Creates a Java VideoFrame object from a native VideoFrame. The returned
|
||||
// object has to be released by calling release.
|
||||
ScopedJavaLocalRef<jobject> NativeToJavaVideoFrame(JNIEnv* jni,
|
||||
const VideoFrame& frame);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // SDK_ANDROID_NATIVE_API_VIDEO_WRAPPER_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue