Chromium Code Reviews| 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 53% |
| copy from talk/app/webrtc/java/src/org/webrtc/CallSessionFileRotatingLogSink.java |
| copy to talk/app/webrtc/java/src/org/webrtc/RtpSender.java |
| index f7032a739bdbb24ac93dc000b9a42fb11223cc40..b063534729d51f96deca7013f02b8fd8f9d95c09 100644 |
| --- a/talk/app/webrtc/java/src/org/webrtc/CallSessionFileRotatingLogSink.java |
| +++ b/talk/app/webrtc/java/src/org/webrtc/RtpSender.java |
| @@ -27,31 +27,52 @@ |
| 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 = nativeTrack(nativeRtpSender); |
| + 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. |
|
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
|
| + // Will be released in dispose() or setTrack(). |
| + private static native long nativeTrack(long nativeRtpSender); |
| + |
| + private static native String nativeId(long nativeRtpSender); |
| + |
| + private static native void free(long nativeRtpSender); |
| } |
| +; |