Files
platform-external-webrtc/sdk/android/api/org/webrtc/VideoSource.java
Sami Kalliomäki ff1de0af6b Add Android native API: CreateJavaVideoSource
Adds Android native API for creating VideoTrackSourceInterface objects
that can be fed frames using VideoCapturer.CapturerObserver.

NativeCapturerObserver is moved out of VideoSource because it will now
be used without a VideoSource. It now takes a pointer to
AndroidVideoTrackSource directly instead of VideoTrackSourceProxy.

VideoSource and NativeCapturerObserver JNI code is moved away from
androidvideotracksource.cc to their own files. This allows using
AndroidVideoTrackSource independently.

Bug: webrtc:8769
Change-Id: Ifb9e1eb27d4c8237597d19d932ca6e863abb4d27
Reviewed-on: https://webrtc-review.googlesource.com/76924
Reviewed-by: Paulina Hensman <phensman@webrtc.org>
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23269}
2018-05-17 07:41:51 +00:00

58 lines
2.0 KiB
Java

/*
* Copyright 2013 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.
*/
package org.webrtc;
import javax.annotation.Nullable;
/**
* Java wrapper of native AndroidVideoTrackSource.
*/
@JNINamespace("webrtc::jni")
public class VideoSource extends MediaSource {
private final NativeCapturerObserver capturerObserver;
public VideoSource(long nativeSource) {
super(nativeSource);
this.capturerObserver = new NativeCapturerObserver(nativeGetInternalSource(nativeSource));
}
// TODO(bugs.webrtc.org/9181): Remove.
VideoSource(long nativeSource, SurfaceTextureHelper surfaceTextureHelper) {
super(nativeSource);
this.capturerObserver =
new NativeCapturerObserver(nativeGetInternalSource(nativeSource), surfaceTextureHelper);
}
/**
* Calling this function will cause frames to be scaled down to the requested resolution. Also,
* frames will be cropped to match the requested aspect ratio, and frames will be dropped to match
* the requested fps. The requested aspect ratio is orientation agnostic and will be adjusted to
* maintain the input orientation, so it doesn't matter if e.g. 1280x720 or 720x1280 is requested.
*/
public void adaptOutputFormat(int width, int height, int fps) {
nativeAdaptOutputFormat(nativeSource, width, height, fps);
}
public VideoCapturer.CapturerObserver getCapturerObserver() {
return capturerObserver;
}
@Override
public void dispose() {
capturerObserver.dispose();
super.dispose();
}
// Returns source->internal() from webrtc::VideoTrackSourceProxy.
private static native long nativeGetInternalSource(long source);
private static native void nativeAdaptOutputFormat(long source, int width, int height, int fps);
}