henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 4 | * 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.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | package org.webrtc; |
| 12 | |
| 13 | /** Java wrapper for a C++ MediaStreamTrackInterface. */ |
| 14 | public class MediaStreamTrack { |
| 15 | /** Tracks MediaStreamTrackInterface.TrackState */ |
perkj | c8f952d | 2016-03-23 00:33:56 -0700 | [diff] [blame] | 16 | public enum State { LIVE, ENDED } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 17 | |
zhihuang | c4adabf | 2016-12-07 10:36:40 -0800 | [diff] [blame] | 18 | public enum MediaType { |
| 19 | MEDIA_TYPE_AUDIO, |
| 20 | MEDIA_TYPE_VIDEO, |
| 21 | } |
| 22 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 23 | final long nativeTrack; |
| 24 | |
| 25 | public MediaStreamTrack(long nativeTrack) { |
| 26 | this.nativeTrack = nativeTrack; |
| 27 | } |
| 28 | |
| 29 | public String id() { |
| 30 | return nativeId(nativeTrack); |
| 31 | } |
| 32 | |
| 33 | public String kind() { |
| 34 | return nativeKind(nativeTrack); |
| 35 | } |
| 36 | |
| 37 | public boolean enabled() { |
| 38 | return nativeEnabled(nativeTrack); |
| 39 | } |
| 40 | |
| 41 | public boolean setEnabled(boolean enable) { |
| 42 | return nativeSetEnabled(nativeTrack, enable); |
| 43 | } |
| 44 | |
| 45 | public State state() { |
| 46 | return nativeState(nativeTrack); |
| 47 | } |
| 48 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 49 | public void dispose() { |
magjed | b1c7453 | 2017-08-27 13:47:20 -0700 | [diff] [blame] | 50 | JniCommon.nativeReleaseRef(nativeTrack); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | private static native String nativeId(long nativeTrack); |
| 54 | |
| 55 | private static native String nativeKind(long nativeTrack); |
| 56 | |
| 57 | private static native boolean nativeEnabled(long nativeTrack); |
| 58 | |
sakal | b6760f9 | 2016-09-29 04:12:44 -0700 | [diff] [blame] | 59 | private static native boolean nativeSetEnabled(long nativeTrack, boolean enabled); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 60 | |
| 61 | private static native State nativeState(long nativeTrack); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 62 | } |