Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: talk/app/webrtc/java/src/org/webrtc/RtpSender.java

Issue 1368143002: Java binding for RtpSender/RtpReceiver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Getting rid of updateSenders. Instead, getSenders will update the stored list and dispose of old ob… Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation 11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution. 12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products 13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 package org.webrtc; 28 package org.webrtc;
29 29
30 public class CallSessionFileRotatingLogSink { 30 /** Java wrapper for a C++ RtpSenderInterface. */
31 static { 31 public class RtpSender {
32 System.loadLibrary("jingle_peerconnection_so"); 32 final long nativeRtpSender;
33
34 private MediaStreamTrack cachedTrack;
35
36 public RtpSender(long nativeRtpSender) {
37 this.nativeRtpSender = nativeRtpSender;
38 long track = nativeTrack(nativeRtpSender);
39 cachedTrack = (track == 0) ? null : new MediaStreamTrack(track);
33 } 40 }
34 41
35 private long nativeSink; 42 // NOTE: This should not be called with a track that's already used by
36 43 // another RtpSender, because then it would be double-disposed.
37 public static byte[] getLogData(String dirPath) { 44 public void setTrack(MediaStreamTrack track) {
38 return nativeGetLogData(dirPath); 45 if (cachedTrack != null) {
46 cachedTrack.dispose();
47 }
48 cachedTrack = track;
49 nativeSetTrack(nativeRtpSender, (track == null) ? 0 : track.nativeTrack);
39 } 50 }
40 51
41 public CallSessionFileRotatingLogSink( 52 public MediaStreamTrack track() {
42 String dirPath, int maxFileSize, Logging.Severity severity) { 53 return cachedTrack;
43 nativeSink = nativeAddSink(dirPath, maxFileSize, severity.ordinal()); 54 }
55
56 public String id() {
57 return nativeId(nativeRtpSender);
44 } 58 }
45 59
46 public void dispose() { 60 public void dispose() {
47 if (nativeSink != 0) { 61 if (cachedTrack != null) {
48 nativeDeleteSink(nativeSink); 62 cachedTrack.dispose();
49 nativeSink = 0;
50 } 63 }
64 free(nativeRtpSender);
51 } 65 }
52 66
53 private static native long nativeAddSink( 67 private static native void nativeSetTrack(long nativeRtpSender,
54 String dirPath, int maxFileSize, int severity); 68 long nativeTrack);
55 private static native void nativeDeleteSink(long nativeSink); 69
56 private static native byte[] nativeGetLogData(String dirPath); 70 // This should increment the reference count of the track.
AlexG 2015/10/02 22:44:36 I think it actually decrements refcount - it calls
Taylor Brandstetter 2015/10/03 01:50:10 See other comment
71 // Will be released in dispose() or setTrack().
72 private static native long nativeTrack(long nativeRtpSender);
73
74 private static native String nativeId(long nativeRtpSender);
75
76 private static native void free(long nativeRtpSender);
57 } 77 }
78 ;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698