OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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. | |
9 */ | |
10 | |
11 package org.webrtc; | |
12 | |
13 import java.util.LinkedList; | |
14 | |
15 /** Java version of VideoTrackInterface. */ | |
16 public class VideoTrack extends MediaStreamTrack { | |
17 private final LinkedList<VideoRenderer> renderers = | |
18 new LinkedList<VideoRenderer>(); | |
19 | |
20 public VideoTrack(long nativeTrack) { | |
21 super(nativeTrack); | |
22 } | |
23 | |
24 public void addRenderer(VideoRenderer renderer) { | |
25 renderers.add(renderer); | |
26 nativeAddRenderer(nativeTrack, renderer.nativeVideoRenderer); | |
27 } | |
28 | |
29 public void removeRenderer(VideoRenderer renderer) { | |
30 if (!renderers.remove(renderer)) { | |
31 return; | |
32 } | |
33 nativeRemoveRenderer(nativeTrack, renderer.nativeVideoRenderer); | |
34 renderer.dispose(); | |
35 } | |
36 | |
37 public void dispose() { | |
38 while (!renderers.isEmpty()) { | |
39 removeRenderer(renderers.getFirst()); | |
40 } | |
41 super.dispose(); | |
42 } | |
43 | |
44 private static native void free(long nativeTrack); | |
45 | |
46 private static native void nativeAddRenderer( | |
47 long nativeTrack, long nativeRenderer); | |
48 | |
49 private static native void nativeRemoveRenderer( | |
50 long nativeTrack, long nativeRenderer); | |
51 } | |
OLD | NEW |