blob: 8e6da176cf381ecfe4513b1a38c2e1c275b2f53b [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellanderb24317b2016-02-10 07:54:43 -08002 * Copyright 2013 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellanderb24317b2016-02-10 07:54:43 -08004 * 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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00009 */
10
henrike@webrtc.org28e20752013-07-10 00:45:36 +000011package org.webrtc;
12
13/** Java wrapper for a C++ MediaSourceInterface. */
Magnus Jedvert84d8ae52017-12-20 15:12:10 +010014@JNINamespace("webrtc::jni")
henrike@webrtc.org28e20752013-07-10 00:45:36 +000015public class MediaSource {
16 /** Tracks MediaSourceInterface.SourceState */
Magnus Jedvert9060eb12017-12-12 12:52:54 +010017 public enum State {
18 INITIALIZING,
19 LIVE,
20 ENDED,
21 MUTED;
22
23 @CalledByNative("State")
24 static State fromNativeIndex(int nativeIndex) {
25 return values()[nativeIndex];
26 }
27 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +000028
sakalb6760f92016-09-29 04:12:44 -070029 final long nativeSource; // Package-protected for PeerConnectionFactory.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000030
31 public MediaSource(long nativeSource) {
32 this.nativeSource = nativeSource;
33 }
34
35 public State state() {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +010036 return nativeGetState(nativeSource);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000037 }
38
fischman@webrtc.org32001ef2013-08-12 23:26:21 +000039 public void dispose() {
magjedb1c74532017-08-27 13:47:20 -070040 JniCommon.nativeReleaseRef(nativeSource);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000041 }
42
Magnus Jedvert84d8ae52017-12-20 15:12:10 +010043 private static native State nativeGetState(long pointer);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000044}