cordova-rtc / cordova-plugin-iosrtc

Cordova iOS plugin exposing the WebRTC W3C API
MIT License
690 stars 338 forks source link

Apply new Objective-C stuff in libwebrtc #91

Closed ibc closed 7 years ago

ibc commented 8 years ago

The latest version of libwebrtc provides more API. This is the diff with the new stuff in the ObjC public API:

diff -Naur /Users/ibc/eFace2Face/src/cordova-plugin-iosrtc/src/webrtc-headers/RTCDataChannel.h ./RTCDataChannel.h
--- /Users/ibc/eFace2Face/src/cordova-plugin-iosrtc/src/webrtc-headers/RTCDataChannel.h 2015-06-01 20:12:00.000000000 +0200
+++ ./RTCDataChannel.h  2015-11-26 13:40:05.000000000 +0100
@@ -82,6 +82,12 @@
 - (void)channel:(RTCDataChannel*)channel
     didReceiveMessageWithBuffer:(RTCDataBuffer*)buffer;

+@optional
+
+// Called when the buffered amount has changed.
+- (void)channel:(RTCDataChannel*)channel
+    didChangeBufferedAmount:(NSUInteger)amount;
+
 @end

 // ObjectiveC wrapper for a DataChannel object.
diff -Naur /Users/ibc/eFace2Face/src/cordova-plugin-iosrtc/src/webrtc-headers/RTCFileLogger.h ./RTCFileLogger.h
--- /Users/ibc/eFace2Face/src/cordova-plugin-iosrtc/src/webrtc-headers/RTCFileLogger.h  1970-01-01 01:00:00.000000000 +0100
+++ ./RTCFileLogger.h   2015-11-26 13:40:05.000000000 +0100
@@ -0,0 +1,70 @@
+/*
+ * libjingle
+ * Copyright 2015 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Foundation/Foundation.h>
+
+// TODO(tkchin): Move this to a common location.
+#ifndef NS_DESIGNATED_INITIALIZER
+#define NS_DESIGNATED_INITIALIZER
+#endif
+
+typedef NS_ENUM(NSUInteger, RTCFileLoggerSeverity) {
+  kRTCFileLoggerSeverityVerbose,
+  kRTCFileLoggerSeverityInfo,
+  kRTCFileLoggerSeverityWarning,
+  kRTCFileLoggerSeverityError
+};
+
+// This class intercepts WebRTC logs and saves them to a file. The file size
+// will not exceed the given maximum bytesize. When the maximum bytesize is
+// reached logs from the beginning and the end are preserved while the middle
+// section is overwritten instead.
+// This class is not threadsafe.
+@interface RTCFileLogger : NSObject
+
+// The severity level to capture. The default is kRTCFileLoggerSeverityInfo.
+@property(nonatomic, assign) RTCFileLoggerSeverity severity;
+
+// Default constructor provides default settings for dir path and file size.
+- (instancetype)init;
+
+- (instancetype)initWithDirPath:(NSString *)dirPath
+                    maxFileSize:(NSUInteger)maxFileSize
+    NS_DESIGNATED_INITIALIZER;
+
+// Starts writing WebRTC logs to disk if not already started. Overwrites any
+// existing file(s).
+- (void)start;
+
+// Stops writing WebRTC logs to disk. This method is also called on dealloc.
+- (void)stop;
+
+// Returns the current contents of the logs, or nil if start has been called
+// without a stop.
+- (NSData *)logData;
+
+@end
diff -Naur /Users/ibc/eFace2Face/src/cordova-plugin-iosrtc/src/webrtc-headers/RTCLogging.h ./RTCLogging.h
--- /Users/ibc/eFace2Face/src/cordova-plugin-iosrtc/src/webrtc-headers/RTCLogging.h 1970-01-01 01:00:00.000000000 +0100
+++ ./RTCLogging.h  2015-11-26 13:40:05.000000000 +0100
@@ -0,0 +1,92 @@
+/*
+ * libjingle
+ * Copyright 2015 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Foundation/Foundation.h>
+
+// Subset of rtc::LoggingSeverity.
+typedef NS_ENUM(NSInteger, RTCLoggingSeverity) {
+  kRTCLoggingSeverityVerbose,
+  kRTCLoggingSeverityInfo,
+  kRTCLoggingSeverityWarning,
+  kRTCLoggingSeverityError,
+};
+
+#if defined(__cplusplus)
+extern "C" void RTCLogEx(RTCLoggingSeverity severity, NSString* logString);
+extern "C" void RTCSetMinDebugLogLevel(RTCLoggingSeverity severity);
+extern "C" NSString* RTCFileName(const char* filePath);
+#else
+
+// Wrapper for C++ LOG(sev) macros.
+// Logs the log string to the webrtc logstream for the given severity.
+extern void RTCLogEx(RTCLoggingSeverity severity, NSString* logString);
+
+// Wrapper for rtc::LogMessage::LogToDebug.
+// Sets the minimum severity to be logged to console.
+extern void RTCSetMinDebugLogLevel(RTCLoggingSeverity severity);
+
+// Returns the filename with the path prefix removed.
+extern NSString* RTCFileName(const char* filePath);
+
+#endif
+
+// Some convenience macros.
+
+#define RTCLogString(format, ...)                    \
+  [NSString stringWithFormat:@"(%@:%d %s): " format, \
+      RTCFileName(__FILE__),                         \
+      __LINE__,                                      \
+      __FUNCTION__,                                  \
+      ##__VA_ARGS__]
+
+#define RTCLogFormat(severity, format, ...)                    \
+  do {                                                         \
+    NSString *logString = RTCLogString(format, ##__VA_ARGS__); \
+    RTCLogEx(severity, logString);                             \
+  } while (false)
+
+#define RTCLogVerbose(format, ...)                                \
+  RTCLogFormat(kRTCLoggingSeverityVerbose, format, ##__VA_ARGS__) \
+
+#define RTCLogInfo(format, ...)                                   \
+  RTCLogFormat(kRTCLoggingSeverityInfo, format, ##__VA_ARGS__)    \
+
+#define RTCLogWarning(format, ...)                                \
+  RTCLogFormat(kRTCLoggingSeverityWarning, format, ##__VA_ARGS__) \
+
+#define RTCLogError(format, ...)                                  \
+  RTCLogFormat(kRTCLoggingSeverityError, format, ##__VA_ARGS__)   \
+
+#if !defined(NDEBUG)
+#define RTCLogDebug(format, ...) RTCLogInfo(format, ##__VA_ARGS__)
+#else
+#define RTCLogDebug(format, ...) \
+  do {                           \
+  } while (false)
+#endif
+
+#define RTCLog(format, ...) RTCLogInfo(format, ##__VA_ARGS__)
diff -Naur /Users/ibc/eFace2Face/src/cordova-plugin-iosrtc/src/webrtc-headers/RTCPeerConnection.h ./RTCPeerConnection.h
--- /Users/ibc/eFace2Face/src/cordova-plugin-iosrtc/src/webrtc-headers/RTCPeerConnection.h  2015-06-01 20:12:00.000000000 +0200
+++ ./RTCPeerConnection.h   2015-11-26 13:40:05.000000000 +0100
@@ -27,6 +27,7 @@

 #import "RTCPeerConnectionDelegate.h"

+@class RTCConfiguration;
 @class RTCDataChannel;
 @class RTCDataChannelInit;
 @class RTCICECandidate;
@@ -97,10 +98,12 @@
     setRemoteDescriptionWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
                   sessionDescription:(RTCSessionDescription *)sdp;

-// Restarts or updates the ICE Agent process of gathering local candidates
-// and pinging remote candidates.
-- (BOOL)updateICEServers:(NSArray *)servers
-             constraints:(RTCMediaConstraints *)constraints;
+// Sets the PeerConnection's global configuration to |configuration|.
+// Any changes to STUN/TURN servers or ICE candidate policy will affect the
+// next gathering phase, and cause the next call to createOffer to generate
+// new ICE credentials. Note that the BUNDLE and RTCP-multiplexing policies
+// cannot be changed with this method.
+- (BOOL)setConfiguration:(RTCConfiguration *)configuration;

 // Provides a remote candidate to the ICE Agent.
 - (BOOL)addICECandidate:(RTCICECandidate *)candidate;
diff -Naur /Users/ibc/eFace2Face/src/cordova-plugin-iosrtc/src/webrtc-headers/RTCPeerConnectionFactory.h ./RTCPeerConnectionFactory.h
--- /Users/ibc/eFace2Face/src/cordova-plugin-iosrtc/src/webrtc-headers/RTCPeerConnectionFactory.h   2015-06-01 20:12:00.000000000 +0200
+++ ./RTCPeerConnectionFactory.h    2015-11-26 13:40:05.000000000 +0100
@@ -28,6 +28,7 @@
 #import <Foundation/Foundation.h>

 @class RTCAudioTrack;
+@class RTCConfiguration;
 @class RTCMediaConstraints;
 @class RTCMediaStream;
 @class RTCPeerConnection;
@@ -44,7 +45,7 @@
 + (void)initializeSSL;
 + (void)deinitializeSSL;

-// Create an RTCPeerConnection object.   RTCPeerConnectionFactory will create
+// Create an RTCPeerConnection object. RTCPeerConnectionFactory will create
 // required libjingle threads, socket and network manager factory classes for
 // networking.
 - (RTCPeerConnection *)
@@ -52,6 +53,11 @@
                      constraints:(RTCMediaConstraints *)constraints
                         delegate:(id<RTCPeerConnectionDelegate>)delegate;

+// Creates a peer connection using the default port allocator factory and identity service.
+- (RTCPeerConnection *)peerConnectionWithConfiguration:(RTCConfiguration *)configuration
+                                           constraints:(RTCMediaConstraints *)constraints
+                                              delegate:(id<RTCPeerConnectionDelegate>)delegate;
+
 // Create an RTCMediaStream named |label|.
 - (RTCMediaStream *)mediaStreamWithLabel:(NSString *)label;

diff -Naur /Users/ibc/eFace2Face/src/cordova-plugin-iosrtc/src/webrtc-headers/RTCPeerConnectionInterface.h ./RTCPeerConnectionInterface.h
--- /Users/ibc/eFace2Face/src/cordova-plugin-iosrtc/src/webrtc-headers/RTCPeerConnectionInterface.h 1970-01-01 01:00:00.000000000 +0100
+++ ./RTCPeerConnectionInterface.h  2015-11-26 13:40:05.000000000 +0100
@@ -0,0 +1,75 @@
+/*
+ * libjingle
+ * Copyright 2015 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation
+ *     and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// See talk/app/webrtc/peerconnectioninterface.h.
+
+#import <Foundation/Foundation.h>
+
+typedef NS_ENUM(NSInteger, RTCIceTransportsType) {
+  kRTCIceTransportsTypeNone,
+  kRTCIceTransportsTypeRelay,
+  kRTCIceTransportsTypeNoHost,
+  kRTCIceTransportsTypeAll,
+};
+
+// https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-08#section-4.1.1
+typedef NS_ENUM(NSInteger, RTCBundlePolicy) {
+  kRTCBundlePolicyBalanced,
+  kRTCBundlePolicyMaxBundle,
+  kRTCBundlePolicyMaxCompat,
+};
+
+// https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-09#section-4.1.1
+typedef NS_ENUM(NSInteger, RTCRtcpMuxPolicy) {
+  kRTCRtcpMuxPolicyNegotiate,
+  kRTCRtcpMuxPolicyRequire,
+};
+
+typedef NS_ENUM(NSInteger, RTCTcpCandidatePolicy) {
+  kRTCTcpCandidatePolicyEnabled,
+  kRTCTcpCandidatePolicyDisabled,
+};
+
+// Configuration object used for creating a peer connection.
+@interface RTCConfiguration : NSObject
+
+@property(nonatomic, assign) RTCIceTransportsType iceTransportsType;
+@property(nonatomic, copy) NSArray *iceServers;
+@property(nonatomic, assign) RTCBundlePolicy bundlePolicy;
+@property(nonatomic, assign) RTCRtcpMuxPolicy rtcpMuxPolicy;
+@property(nonatomic, assign) RTCTcpCandidatePolicy tcpCandidatePolicy;
+@property(nonatomic, assign) int audioJitterBufferMaxPackets;
+@property(nonatomic, assign) int iceConnectionReceivingTimeout;
+
+- (instancetype)initWithIceTransportsType:(RTCIceTransportsType)iceTransportsType
+                             bundlePolicy:(RTCBundlePolicy)bundlePolicy
+                            rtcpMuxPolicy:(RTCRtcpMuxPolicy)rtcpMuxPolicy
+                       tcpCandidatePolicy:(RTCTcpCandidatePolicy)tcpCandidatePolicy
+              audioJitterBufferMaxPackets:(int)audioJitterBufferMaxPackets
+            iceConnectionReceivingTimeout:(int)iceConnectionReceivingTimeout;
+
+@end
diff -Naur /Users/ibc/eFace2Face/src/cordova-plugin-iosrtc/src/webrtc-headers/RTCTypes.h ./RTCTypes.h
--- /Users/ibc/eFace2Face/src/cordova-plugin-iosrtc/src/webrtc-headers/RTCTypes.h   2015-06-01 20:12:00.000000000 +0200
+++ ./RTCTypes.h    2015-11-26 13:40:05.000000000 +0100
@@ -36,6 +36,7 @@
   RTCICEConnectionFailed,
   RTCICEConnectionDisconnected,
   RTCICEConnectionClosed,
+  RTCICEConnectionMax,
 } RTCICEConnectionState;

 // RTCICEGatheringState the states in webrtc::ICEGatheringState.
Globik commented 8 years ago

And this lib/libwebrtc.a is on C written or on Objective C?

saghul commented 7 years ago

This is issue is too dated to act on in. On the next WebRTC update, new APIs will be considered.