OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 // It may be possible for an RtpSender to be created without a track. | 23 // It may be possible for an RtpSender to be created without a track. |
24 cachedTrack = (track == 0) ? null : new MediaStreamTrack(track); | 24 cachedTrack = (track == 0) ? null : new MediaStreamTrack(track); |
25 } | 25 } |
26 | 26 |
27 // If |takeOwnership| is true, the RtpSender takes ownership of the track | 27 // If |takeOwnership| is true, the RtpSender takes ownership of the track |
28 // from the caller, and will auto-dispose of it when no longer needed. | 28 // from the caller, and will auto-dispose of it when no longer needed. |
29 // |takeOwnership| should only be used if the caller owns the track; it is | 29 // |takeOwnership| should only be used if the caller owns the track; it is |
30 // not appropriate when the track is owned by, for example, another RtpSender | 30 // not appropriate when the track is owned by, for example, another RtpSender |
31 // or a MediaStream. | 31 // or a MediaStream. |
32 public boolean setTrack(MediaStreamTrack track, boolean takeOwnership) { | 32 public boolean setTrack(MediaStreamTrack track, boolean takeOwnership) { |
33 if (!nativeSetTrack(nativeRtpSender, | 33 if (!nativeSetTrack(nativeRtpSender, (track == null) ? 0 : track.nativeTrack
)) { |
34 (track == null) ? 0 : track.nativeTrack)) { | 34 return false; |
35 return false; | |
36 } | 35 } |
37 if (cachedTrack != null && ownsTrack) { | 36 if (cachedTrack != null && ownsTrack) { |
38 cachedTrack.dispose(); | 37 cachedTrack.dispose(); |
39 } | 38 } |
40 cachedTrack = track; | 39 cachedTrack = track; |
41 ownsTrack = takeOwnership; | 40 ownsTrack = takeOwnership; |
42 return true; | 41 return true; |
43 } | 42 } |
44 | 43 |
45 public MediaStreamTrack track() { | 44 public MediaStreamTrack track() { |
(...skipping 12 matching lines...) Expand all Loading... |
58 return nativeId(nativeRtpSender); | 57 return nativeId(nativeRtpSender); |
59 } | 58 } |
60 | 59 |
61 public void dispose() { | 60 public void dispose() { |
62 if (cachedTrack != null && ownsTrack) { | 61 if (cachedTrack != null && ownsTrack) { |
63 cachedTrack.dispose(); | 62 cachedTrack.dispose(); |
64 } | 63 } |
65 free(nativeRtpSender); | 64 free(nativeRtpSender); |
66 } | 65 } |
67 | 66 |
68 private static native boolean nativeSetTrack(long nativeRtpSender, | 67 private static native boolean nativeSetTrack(long nativeRtpSender, long native
Track); |
69 long nativeTrack); | |
70 | 68 |
71 // This should increment the reference count of the track. | 69 // This should increment the reference count of the track. |
72 // Will be released in dispose() or setTrack(). | 70 // Will be released in dispose() or setTrack(). |
73 private static native long nativeGetTrack(long nativeRtpSender); | 71 private static native long nativeGetTrack(long nativeRtpSender); |
74 | 72 |
75 private static native boolean nativeSetParameters(long nativeRtpSender, | 73 private static native boolean nativeSetParameters(long nativeRtpSender, RtpPar
ameters parameters); |
76 RtpParameters parameters); | |
77 | 74 |
78 private static native RtpParameters nativeGetParameters(long nativeRtpSender); | 75 private static native RtpParameters nativeGetParameters(long nativeRtpSender); |
79 | 76 |
80 private static native String nativeId(long nativeRtpSender); | 77 private static native String nativeId(long nativeRtpSender); |
81 | 78 |
82 private static native void free(long nativeRtpSender); | 79 private static native void free(long nativeRtpSender); |
83 } | 80 }; |
84 ; | |
OLD | NEW |