Index: talk/app/webrtc/java/src/org/webrtc/RtpSender.java |
diff --git a/talk/app/webrtc/java/src/org/webrtc/CallSessionFileRotatingLogSink.java b/talk/app/webrtc/java/src/org/webrtc/RtpSender.java |
similarity index 51% |
copy from talk/app/webrtc/java/src/org/webrtc/CallSessionFileRotatingLogSink.java |
copy to talk/app/webrtc/java/src/org/webrtc/RtpSender.java |
index f7032a739bdbb24ac93dc000b9a42fb11223cc40..37357c0657d0c77e93e9b6124b67a89fb1a1ddbf 100644 |
--- a/talk/app/webrtc/java/src/org/webrtc/CallSessionFileRotatingLogSink.java |
+++ b/talk/app/webrtc/java/src/org/webrtc/RtpSender.java |
@@ -27,31 +27,53 @@ |
package org.webrtc; |
-public class CallSessionFileRotatingLogSink { |
- static { |
- System.loadLibrary("jingle_peerconnection_so"); |
+/** Java wrapper for a C++ RtpSenderInterface. */ |
+public class RtpSender { |
+ final long nativeRtpSender; |
+ |
+ private MediaStreamTrack cachedTrack; |
+ |
+ public RtpSender(long nativeRtpSender) { |
+ this.nativeRtpSender = nativeRtpSender; |
+ long track = nativeGetTrack(nativeRtpSender); |
+ // It may be possible for an RtpSender to be created without a track. |
+ cachedTrack = (track == 0) ? null : new MediaStreamTrack(track); |
} |
- private long nativeSink; |
+ // NOTE: This should not be called with a track that's already used by |
+ // another RtpSender, because then it would be double-disposed. |
+ public void setTrack(MediaStreamTrack track) { |
+ if (cachedTrack != null) { |
+ cachedTrack.dispose(); |
+ } |
+ cachedTrack = track; |
+ nativeSetTrack(nativeRtpSender, (track == null) ? 0 : track.nativeTrack); |
+ } |
- public static byte[] getLogData(String dirPath) { |
- return nativeGetLogData(dirPath); |
+ public MediaStreamTrack track() { |
+ return cachedTrack; |
} |
- public CallSessionFileRotatingLogSink( |
- String dirPath, int maxFileSize, Logging.Severity severity) { |
- nativeSink = nativeAddSink(dirPath, maxFileSize, severity.ordinal()); |
+ public String id() { |
+ return nativeId(nativeRtpSender); |
} |
public void dispose() { |
- if (nativeSink != 0) { |
- nativeDeleteSink(nativeSink); |
- nativeSink = 0; |
+ if (cachedTrack != null) { |
+ cachedTrack.dispose(); |
} |
+ free(nativeRtpSender); |
} |
- private static native long nativeAddSink( |
- String dirPath, int maxFileSize, int severity); |
- private static native void nativeDeleteSink(long nativeSink); |
- private static native byte[] nativeGetLogData(String dirPath); |
+ private static native void nativeSetTrack(long nativeRtpSender, |
+ long nativeTrack); |
+ |
+ // This should increment the reference count of the track. |
+ // Will be released in dispose() or setTrack(). |
+ private static native long nativeGetTrack(long nativeRtpSender); |
+ |
+ private static native String nativeId(long nativeRtpSender); |
+ |
+ private static native void free(long nativeRtpSender); |
} |
+; |