• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * libjingle
3  * Copyright 2014 Google Inc.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  *  1. Redistributions of source code must retain the above copyright notice,
9  *     this list of conditions and the following disclaimer.
10  *  2. Redistributions in binary form must reproduce the above copyright notice,
11  *     this list of conditions and the following disclaimer in the documentation
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
14  *     derived from this software without specific prior written permission.
15  *
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
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
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,
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
25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #import <Foundation/Foundation.h>
29 
30 // ObjectiveC wrapper for a DataChannelInit object.
31 @interface RTCDataChannelInit : NSObject
32 
33 // Set to YES if ordered delivery is required
34 @property(nonatomic) BOOL isOrdered;
35 // Max period in milliseconds in which retransmissions will be sent. After this
36 // time, no more retransmissions will be sent. -1 if unset.
37 @property(nonatomic) NSInteger maxRetransmitTimeMs;
38 // The max number of retransmissions. -1 if unset.
39 @property(nonatomic) NSInteger maxRetransmits;
40 // Set to YES if the channel has been externally negotiated and we do not send
41 // an in-band signalling in the form of an "open" message
42 @property(nonatomic) BOOL isNegotiated;
43 // The stream id, or SID, for SCTP data channels. -1 if unset.
44 @property(nonatomic) NSInteger streamId;
45 // Set by the application and opaque to the WebRTC implementation.
46 @property(nonatomic) NSString* protocol;
47 
48 @end
49 
50 // ObjectiveC wrapper for a DataBuffer object.
51 @interface RTCDataBuffer : NSObject
52 
53 @property(nonatomic, readonly) NSData* data;
54 @property(nonatomic, readonly) BOOL isBinary;
55 
56 - (instancetype)initWithData:(NSData*)data isBinary:(BOOL)isBinary;
57 
58 #ifndef DOXYGEN_SHOULD_SKIP_THIS
59 // Disallow init and don't add to documentation
60 - (id)init __attribute__((
61     unavailable("init is not a supported initializer for this class.")));
62 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
63 
64 @end
65 
66 // Keep in sync with webrtc::DataChannelInterface::DataState
67 typedef enum {
68   kRTCDataChannelStateConnecting,
69   kRTCDataChannelStateOpen,
70   kRTCDataChannelStateClosing,
71   kRTCDataChannelStateClosed
72 } RTCDataChannelState;
73 
74 @class RTCDataChannel;
75 // Protocol for receving data channel state and message events.
76 @protocol RTCDataChannelDelegate<NSObject>
77 
78 // Called when the data channel state has changed.
79 - (void)channelDidChangeState:(RTCDataChannel*)channel;
80 
81 // Called when a data buffer was successfully received.
82 - (void)channel:(RTCDataChannel*)channel
83     didReceiveMessageWithBuffer:(RTCDataBuffer*)buffer;
84 
85 @optional
86 
87 // Called when the buffered amount has changed.
88 - (void)channel:(RTCDataChannel*)channel
89     didChangeBufferedAmount:(NSUInteger)amount;
90 
91 @end
92 
93 // ObjectiveC wrapper for a DataChannel object.
94 // See talk/app/webrtc/datachannelinterface.h
95 @interface RTCDataChannel : NSObject
96 
97 @property(nonatomic, readonly) NSString* label;
98 @property(nonatomic, readonly) BOOL isReliable;
99 @property(nonatomic, readonly) BOOL isOrdered;
100 @property(nonatomic, readonly) NSUInteger maxRetransmitTime;
101 @property(nonatomic, readonly) NSUInteger maxRetransmits;
102 @property(nonatomic, readonly) NSString* protocol;
103 @property(nonatomic, readonly) BOOL isNegotiated;
104 @property(nonatomic, readonly) NSInteger streamId;
105 @property(nonatomic, readonly) RTCDataChannelState state;
106 @property(nonatomic, readonly) NSUInteger bufferedAmount;
107 @property(nonatomic, weak) id<RTCDataChannelDelegate> delegate;
108 
109 - (void)close;
110 - (BOOL)sendData:(RTCDataBuffer*)data;
111 
112 #ifndef DOXYGEN_SHOULD_SKIP_THIS
113 // Disallow init and don't add to documentation
114 - (id)init __attribute__((
115     unavailable("init is not a supported initializer for this class.")));
116 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
117 
118 @end
119