webrtc-ruby 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.dockerignore +19 -0
  3. data/.rspec +3 -0
  4. data/CHANGELOG.md +12 -0
  5. data/Dockerfile +49 -0
  6. data/LICENSE +201 -0
  7. data/README.md +264 -0
  8. data/Rakefile +42 -0
  9. data/examples/signaling_server/server.rb +200 -0
  10. data/examples/simple_data_channel.rb +81 -0
  11. data/examples/video_call.rb +152 -0
  12. data/ext/webrtc_ruby/CMakeLists.txt +84 -0
  13. data/ext/webrtc_ruby/Makefile +31 -0
  14. data/ext/webrtc_ruby/webrtc_ruby.c +994 -0
  15. data/ext/webrtc_ruby/webrtc_ruby.h +212 -0
  16. data/lib/webrtc/configuration.rb +99 -0
  17. data/lib/webrtc/data_channel.rb +216 -0
  18. data/lib/webrtc/dtls_transport.rb +54 -0
  19. data/lib/webrtc/dtmf_sender.rb +81 -0
  20. data/lib/webrtc/errors.rb +10 -0
  21. data/lib/webrtc/factory.rb +28 -0
  22. data/lib/webrtc/ffi/library.rb +122 -0
  23. data/lib/webrtc/ice_candidate.rb +63 -0
  24. data/lib/webrtc/ice_transport.rb +95 -0
  25. data/lib/webrtc/media_interfaces.rb +101 -0
  26. data/lib/webrtc/media_stream.rb +67 -0
  27. data/lib/webrtc/media_stream_track.rb +83 -0
  28. data/lib/webrtc/observers.rb +51 -0
  29. data/lib/webrtc/parity_types.rb +358 -0
  30. data/lib/webrtc/peer_connection.rb +577 -0
  31. data/lib/webrtc/promise.rb +59 -0
  32. data/lib/webrtc/rtp_receiver.rb +79 -0
  33. data/lib/webrtc/rtp_sender.rb +117 -0
  34. data/lib/webrtc/rtp_transceiver.rb +39 -0
  35. data/lib/webrtc/sctp_transport.rb +31 -0
  36. data/lib/webrtc/session_description.rb +65 -0
  37. data/lib/webrtc/stats_report.rb +199 -0
  38. data/lib/webrtc/version.rb +5 -0
  39. data/lib/webrtc/video_frame.rb +29 -0
  40. data/lib/webrtc.rb +43 -0
  41. data/webrtc-ruby.gemspec +33 -0
  42. metadata +113 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f669ae95db387b78ddd0d490c472154f5cd59d1879fbec7581cbb97f902cfb74
4
+ data.tar.gz: 8b991089f2a4d8c559dfa3a8c8bad9e26583354712f22c4ae5c9e9662b9356db
5
+ SHA512:
6
+ metadata.gz: e863ef46eea8a0e372619c6fb6d22951fe3b38f59e1f6757308dbd3c90d4c1124f1ad3f8981535ce9da06d575c93293c442b043886d1ab35312585029e860060
7
+ data.tar.gz: ad1df4b5f2d5f1e626cac7a63fe09bc94890b565d678aa85e16c917f02cd80648271d5f3995ca17e2da0d10dc55978231cc3cdfac4a95b3fed15a3767675b90b
data/.dockerignore ADDED
@@ -0,0 +1,19 @@
1
+ # Build directories
2
+ ext/webrtc_ruby/build/
3
+ vendor/libdatachannel/
4
+
5
+ # Git
6
+ .git/
7
+
8
+ # Ruby
9
+ *.gem
10
+ .bundle/
11
+ tmp/
12
+ coverage/
13
+
14
+ # IDE
15
+ .vscode/
16
+ .idea/
17
+
18
+ # Logs
19
+ *.log
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --require spec_helper
2
+ --format documentation
3
+ --color
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## Unreleased
9
+
10
+ ## 1.0.0 - 2026-02-15
11
+
12
+ - Initial release
data/Dockerfile ADDED
@@ -0,0 +1,49 @@
1
+ FROM ruby:3.3-slim
2
+
3
+ # Install build dependencies
4
+ RUN apt-get update && apt-get install -y \
5
+ build-essential \
6
+ cmake \
7
+ git \
8
+ libssl-dev \
9
+ pkg-config \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ WORKDIR /app
13
+
14
+ # Copy gemfiles first for better caching
15
+ COPY Gemfile Gemfile.lock* webrtc-ruby.gemspec ./
16
+ COPY lib/webrtc/version.rb ./lib/webrtc/
17
+
18
+ # Install Ruby dependencies
19
+ RUN bundle install
20
+
21
+ # Clone and build libdatachannel
22
+ RUN git clone --depth 1 --recurse-submodules https://github.com/paullouisageneau/libdatachannel.git /tmp/libdatachannel \
23
+ && cd /tmp/libdatachannel \
24
+ && mkdir build && cd build \
25
+ && cmake -DUSE_GNUTLS=0 -DUSE_NICE=0 -DNO_WEBSOCKET=1 -DNO_EXAMPLES=1 -DNO_TESTS=1 -DCMAKE_BUILD_TYPE=Release .. \
26
+ && make -j$(nproc) \
27
+ && mkdir -p /app/vendor/libdatachannel/build \
28
+ && mkdir -p /app/vendor/libdatachannel/include \
29
+ && cp -r /tmp/libdatachannel/include/* /app/vendor/libdatachannel/include/ \
30
+ && cp /tmp/libdatachannel/build/libdatachannel.so* /app/vendor/libdatachannel/build/ \
31
+ && rm -rf /tmp/libdatachannel
32
+
33
+ # Copy extension source
34
+ COPY ext/ ./ext/
35
+
36
+ # Build webrtc_ruby extension
37
+ RUN cd ext/webrtc_ruby \
38
+ && mkdir -p build && cd build \
39
+ && cmake .. \
40
+ && make -j$(nproc)
41
+
42
+ # Copy the rest of the application
43
+ COPY . .
44
+
45
+ # Set library path
46
+ ENV LD_LIBRARY_PATH=/app/ext/webrtc_ruby/build:/app/vendor/libdatachannel/build
47
+
48
+ # Run tests by default
49
+ CMD ["bundle", "exec", "rspec", "--format", "documentation"]
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2026] [Yudai Takada]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,264 @@
1
+ # WebRTC Ruby
2
+
3
+ WebRTC bindings for Ruby, providing real-time audio, video, and data channel capabilities.
4
+
5
+ ## Status
6
+
7
+ This project provides a practical, `webrtc-rs`-compatible API surface in Ruby, with a mix of:
8
+
9
+ - native-backed features through `libdatachannel` C API
10
+ - Ruby compatibility/typing layers for API parity
11
+
12
+ ### Native-backed (current)
13
+
14
+ - `WebRTC.init` / `WebRTC.cleanup`
15
+ - `RTCPeerConnection`
16
+ - offer/answer
17
+ - local/remote description
18
+ - ICE candidate add
19
+ - connection/ICE/signaling/gathering states + callbacks
20
+ - data channel callbacks
21
+ - track callbacks
22
+ - add/remove track path (via native track ID)
23
+ - `RTCDataChannel`
24
+ - create/close/send
25
+ - open/message/close callbacks
26
+ - buffered amount
27
+ - `RTCSessionDescription`
28
+ - `RTCIceCandidate`
29
+
30
+ ### Compatibility and typed layer (current)
31
+
32
+ - Factory API
33
+ - `CurrentTaskQueueFactory`
34
+ - `PeerConnectionFactory`
35
+ - `WebRTC.create_modular_peer_connection_factory`
36
+ - Observer API
37
+ - `CreateSessionDescriptionObserver`
38
+ - `SetLocalDescriptionObserver`
39
+ - `SetRemoteDescriptionObserver`
40
+ - `AddIceCandidateObserver`
41
+ - `DataChannelObserver`
42
+ - `RTCStatsCollectorCallback`
43
+ - Typed parity classes
44
+ - `CreateOfferOptions`, `CreateAnswerOptions`
45
+ - `DataChannelInit`, `DataChannelMessage`
46
+ - RTP parameter/capability classes
47
+ - `RTCError` and enum modules
48
+ - media interface classes
49
+ - `VideoFrame`, `I420Buffer`
50
+
51
+ ### Stats note
52
+
53
+ - `RTCStatsCollectorCallback` and `RTCStatsResponse` are wired.
54
+ - DataChannel message/byte counters are measured from actual send/receive events.
55
+ - Low-level RTP/ICE transport metrics remain limited by `libdatachannel` C API exposure.
56
+
57
+ ## Requirements
58
+
59
+ - Ruby 3.1+
60
+ - CMake
61
+ - OpenSSL development libraries
62
+
63
+ ## Installation
64
+
65
+ Add this line to your application's Gemfile:
66
+
67
+ ```ruby
68
+ gem 'webrtc-ruby'
69
+ ```
70
+
71
+ Then run:
72
+
73
+ ```bash
74
+ bundle install
75
+ ```
76
+
77
+ ## Building Native Extension
78
+
79
+ The gem requires a native extension (`ext/webrtc_ruby`) and `libdatachannel`.
80
+
81
+ ### macOS
82
+
83
+ ```bash
84
+ brew install cmake openssl
85
+
86
+ # Clone and build libdatachannel
87
+ git clone --depth 1 --recurse-submodules https://github.com/paullouisageneau/libdatachannel.git vendor/libdatachannel
88
+ cd vendor/libdatachannel
89
+ mkdir build && cd build
90
+ cmake -DUSE_GNUTLS=0 -DUSE_NICE=0 -DNO_WEBSOCKET=1 -DNO_EXAMPLES=1 -DNO_TESTS=1 ..
91
+ make -j$(sysctl -n hw.ncpu)
92
+ cd ../../..
93
+
94
+ # Build extension
95
+ cd ext/webrtc_ruby
96
+ mkdir -p build && cd build
97
+ cmake ..
98
+ make
99
+ ```
100
+
101
+ ### Linux (Ubuntu/Debian)
102
+
103
+ ```bash
104
+ sudo apt install build-essential cmake git libssl-dev pkg-config
105
+
106
+ # Clone and build libdatachannel
107
+ git clone --depth 1 --recurse-submodules https://github.com/paullouisageneau/libdatachannel.git vendor/libdatachannel
108
+ cd vendor/libdatachannel
109
+ mkdir build && cd build
110
+ cmake -DUSE_GNUTLS=0 -DUSE_NICE=0 -DNO_WEBSOCKET=1 -DNO_EXAMPLES=1 -DNO_TESTS=1 ..
111
+ make -j$(nproc)
112
+ cd ../../..
113
+
114
+ # Build extension
115
+ cd ext/webrtc_ruby
116
+ mkdir -p build && cd build
117
+ cmake ..
118
+ make
119
+ ```
120
+
121
+ ## Quick Start
122
+
123
+ ```ruby
124
+ require 'webrtc'
125
+
126
+ WebRTC.init
127
+
128
+ pc1 = WebRTC::RTCPeerConnection.new
129
+ pc2 = WebRTC::RTCPeerConnection.new
130
+
131
+ pc1_candidates = []
132
+ pc2_candidates = []
133
+
134
+ pc1.on_ice_candidate { |c| pc1_candidates << c if c }
135
+ pc2.on_ice_candidate { |c| pc2_candidates << c if c }
136
+
137
+ pc2.on_data_channel do |dc|
138
+ dc.on_message { |msg| puts "pc2 recv: #{msg.data}" }
139
+ end
140
+
141
+ dc1 = pc1.create_data_channel('chat')
142
+ dc1.on_open { puts 'pc1 data channel open' }
143
+ dc1.on_message { |msg| puts "pc1 recv: #{msg.data}" }
144
+
145
+ offer = pc1.create_offer.await
146
+ pc1.set_local_description(offer).await
147
+ pc2.set_remote_description(offer).await
148
+
149
+ answer = pc2.create_answer.await
150
+ pc2.set_local_description(answer).await
151
+ pc1.set_remote_description(answer).await
152
+
153
+ pc1_candidates.each { |c| pc2.add_ice_candidate(c).await rescue nil }
154
+ pc2_candidates.each { |c| pc1.add_ice_candidate(c).await rescue nil }
155
+
156
+ pc1.close
157
+ pc2.close
158
+ WebRTC.cleanup
159
+ ```
160
+
161
+ ## Factory Example
162
+
163
+ ```ruby
164
+ factory = WebRTC.create_modular_peer_connection_factory
165
+ pc = factory.create_peer_connection(
166
+ ice_servers: [{ urls: 'stun:stun.l.google.com:19302' }]
167
+ )
168
+ ```
169
+
170
+ ## Observer Example
171
+
172
+ ```ruby
173
+ observer = WebRTC::CreateSessionDescriptionObserver.new(
174
+ on_success: ->(desc) { puts "created: #{desc.type}" },
175
+ on_failure: ->(err) { warn err.message }
176
+ )
177
+
178
+ pc.create_offer(observer: observer).await
179
+ ```
180
+
181
+ ## Stats Example
182
+
183
+ ```ruby
184
+ report = pc.get_stats.await
185
+
186
+ report.each do |_id, stat|
187
+ case stat
188
+ when WebRTC::RTCDataChannelStats
189
+ puts "dc bytes sent=#{stat.bytes_sent} recv=#{stat.bytes_received}"
190
+ when WebRTC::RTCTransportStats
191
+ puts "transport bytes sent=#{stat.bytes_sent} recv=#{stat.bytes_received}"
192
+ end
193
+ end
194
+ ```
195
+
196
+ ## API Coverage (`shiguredo/webrtc-rs` parity)
197
+
198
+ | Area | Status | Notes |
199
+ | --- | --- | --- |
200
+ | PeerConnection core | Implemented | state callbacks, data channel callbacks, track callbacks |
201
+ | Factory API | Implemented | `CurrentTaskQueueFactory`, `PeerConnectionFactory`, `create_modular_peer_connection_factory` |
202
+ | SDP Observer API | Implemented | create/set description observers and option classes |
203
+ | ICE Candidate Observer API | Implemented | `RTCIceCandidateInit`, `AddIceCandidateObserver` |
204
+ | DataChannel typed API | Implemented | `DataChannelInit`, `DataChannelObserver`, `DataChannelMessage`, state constants |
205
+ | RTP Sender/Receiver/Transceiver | Implemented | native add/remove track path + typed parameter classes |
206
+ | Media interfaces | Implemented | audio/video track/source/sink interfaces |
207
+ | Video frame API | Implemented | `VideoFrame`, `I420Buffer` |
208
+ | Error and helper types | Implemented | `RTCError`, `RTCCertificate`, `RTCEncodedImage`, enum modules |
209
+ | Stats callback API | Partial | DataChannel bytes/messages are measured; low-level RTP/ICE metrics are constrained by `libdatachannel` C API |
210
+
211
+ ## Development
212
+
213
+ After checking out the repo, install dependencies:
214
+
215
+ ```bash
216
+ bundle install
217
+ ```
218
+
219
+ ### Important note about `libdatachannel`
220
+
221
+ - Building the native extension and running tests require `libdatachannel`.
222
+ - You must use one of these approaches before testing:
223
+
224
+ ```bash
225
+ # Option A (recommended): keep a local vendor copy
226
+ git clone --depth 1 --recurse-submodules https://github.com/paullouisageneau/libdatachannel.git vendor/libdatachannel
227
+ cd vendor/libdatachannel
228
+ mkdir -p build && cd build
229
+ cmake .. -DCMAKE_BUILD_TYPE=Release -DNO_EXAMPLES=ON -DNO_TESTS=ON
230
+ cmake --build .
231
+ cd ../../..
232
+ ```
233
+
234
+ ```bash
235
+ # Option B: install libdatachannel system-wide (pkg-config discoverable)
236
+ # In this case CMake falls back to pkg-config when vendor/libdatachannel is absent.
237
+ ```
238
+
239
+ ### Run tests
240
+
241
+ ```bash
242
+ # Build native extension first
243
+ cd ext/webrtc_ruby
244
+ mkdir -p build && cd build
245
+ cmake ..
246
+ cmake --build .
247
+ cd ../../..
248
+
249
+ # Run test suite (macOS)
250
+ DYLD_LIBRARY_PATH="ext/webrtc_ruby/build:vendor/libdatachannel/build" bundle exec rspec
251
+
252
+ # Run test suite (Linux)
253
+ LD_LIBRARY_PATH="ext/webrtc_ruby/build:vendor/libdatachannel/build" bundle exec rspec
254
+ ```
255
+
256
+ ## License
257
+
258
+ This project is available under the [Apache License 2.0](LICENSE).
259
+
260
+ ## Contributing
261
+
262
+ Bug reports and pull requests are welcome at:
263
+
264
+ - https://github.com/ydah/webrtc-ruby
data/Rakefile ADDED
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ namespace :native do
9
+ desc 'Build native library'
10
+ task :build do
11
+ ext_dir = File.join(__dir__, 'ext', 'webrtc_ruby')
12
+ build_dir = File.join(ext_dir, 'build')
13
+
14
+ Dir.mkdir(build_dir) unless Dir.exist?(build_dir)
15
+
16
+ case RbConfig::CONFIG['host_os']
17
+ when /darwin/
18
+ lib_name = 'libwebrtc_ruby.dylib'
19
+ flags = '-dynamiclib'
20
+ when /mswin|mingw/
21
+ lib_name = 'webrtc_ruby.dll'
22
+ flags = '-shared'
23
+ else
24
+ lib_name = 'libwebrtc_ruby.so'
25
+ flags = '-shared'
26
+ end
27
+
28
+ cmd = "cc -Wall -Wextra -fPIC -O2 -DWEBRTC_RUBY_BUILDING #{flags} " \
29
+ "-o #{File.join(build_dir, lib_name)} " \
30
+ "#{File.join(ext_dir, 'webrtc_ruby.c')}"
31
+
32
+ system(cmd) || abort('Native build failed')
33
+ end
34
+
35
+ desc 'Clean native build'
36
+ task :clean do
37
+ build_dir = File.join(__dir__, 'ext', 'webrtc_ruby', 'build')
38
+ FileUtils.rm_rf(build_dir)
39
+ end
40
+ end
41
+
42
+ task default: %i[native:build spec]