{"_id":"@badnintendo/webrtc2030","name":"@badnintendo/webrtc2030","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.1":{"name":"@badnintendo/webrtc2030","version":"1.0.1","description":"A powerful and versatile npm package designed to handle WebRTC functionalities for front-end to back-end communication.","main":"lib/2030xwebRTC.js","scripts":{"test":"node test/2030xwebRTC.test.js"},"repository":{"type":"git","url":"git+https://github.com/BadNintendo/2030xwebRTC.git"},"keywords":["webrtc","peer-to-peer","media","datachannel","sdp","ice","rtc"],"author":{"name":"BadNintendo"},"license":"MIT","dependencies":{"node-pre-gyp":"^0.16.0"},"devDependencies":{},"gitHead":"d7f6e3f929dcda512c82847c9b0ee081d532fbd9","bugs":{"url":"https://github.com/BadNintendo/2030xwebRTC/issues"},"homepage":"https://github.com/BadNintendo/2030xwebRTC#readme","_id":"@badnintendo/webrtc2030@1.0.1","_nodeVersion":"16.20.1","_npmVersion":"8.19.4","dist":{"integrity":"sha512-OwHK9/YuXo9U1aRXvzSLtuYxUhsW74phRohKWkRmPwsJ56OMNNkXz9OzJO5teF06eDfV+HhecTYqA40bCjGQCA==","shasum":"6d5fabdc51024bfaf2a3aa40fadd8eeaea0b5101","tarball":"https://registry.npmjs.org/@badnintendo/webrtc2030/-/webrtc2030-1.0.1.tgz","fileCount":3,"unpackedSize":14590,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGIoLBOMi3OcSnPIMpEvA5Xs1JVR5zWzLxoCnzgFm2xeAiEA3Q0xoh3sSdGsT4OiWOE2jlggdAOsOBSPELE842mHIu8="}]},"_npmUser":{"name":"badnintendo","email":"nintendotats@gmail.com"},"directories":{},"maintainers":[{"name":"badnintendo","email":"nintendotats@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/webrtc2030_1.0.1_1715990007106_0.7333074611208621"},"_hasShrinkwrap":false}},"time":{"created":"2024-05-17T23:53:26.999Z","1.0.1":"2024-05-17T23:53:27.252Z","modified":"2024-05-17T23:53:27.551Z"},"maintainers":[{"name":"badnintendo","email":"nintendotats@gmail.com"}],"description":"A powerful and versatile npm package designed to handle WebRTC functionalities for front-end to back-end communication.","homepage":"https://github.com/BadNintendo/2030xwebRTC#readme","keywords":["webrtc","peer-to-peer","media","datachannel","sdp","ice","rtc"],"repository":{"type":"git","url":"git+https://github.com/BadNintendo/2030xwebRTC.git"},"author":{"name":"BadNintendo"},"bugs":{"url":"https://github.com/BadNintendo/2030xwebRTC/issues"},"license":"MIT","readme":"# 2030xwebRTC\n\n![npm](https://img.shields.io/npm/v/2030xwebRTC)\n![license](https://img.shields.io/github/license/BadNintendo/2030xwebRTC)\n\n2030xwebRTC is a powerful and versatile npm package designed to handle WebRTC (Web Real-Time Communication) functionalities for front-end to back-end communication. This package provides an extensive set of features to enable peer-to-peer connections, data channels, media streaming, and more. Developed by BadNintendo, 2030xwebRTC aims to simplify the integration and usage of WebRTC in your projects.\n\n## Installation\n\nTo install the 2030xwebRTC package, use the following command:\n\n```bash\nnpm install 2030xwebRTC\n```\n\n## Usage\n\n### Basic Example\n\nHere is a basic example demonstrating how to create a peer connection, generate an SDP offer, and handle ICE candidates:\n\n```javascript\nconst { RTCPeerConnection, RTCSessionDescription, RTCIceCandidate } = require('2030xwebRTC');\n\nconst pc = new RTCPeerConnection();\n\npc.on('icecandidate', ({ candidate }) => {\n  if (candidate) {\n    console.log('New ICE candidate: ', candidate);\n  } else {\n    console.log('All ICE candidates have been sent');\n  }\n});\n\nconst offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };\n\npc.createOffer(offerOptions)\n  .then((offer) => pc.setLocalDescription(offer))\n  .then(() => console.log('Local description set:', pc.localDescription))\n  .catch((error) => console.error('Failed to create offer:', error));\n```\n\n### Advanced Features\n\n2030xwebRTC provides advanced functionalities, including handling media devices, nonstandard WebRTC interfaces, and custom error handling. Below are some examples:\n\n#### Handling Media Devices\n\n```javascript\nconst { mediaDevices } = require('2030xwebRTC');\n\n// Get user media with specified constraints\nconst constraints = { video: true, audio: true };\n\nmediaDevices.getUserMedia(constraints)\n  .then((stream) => {\n    console.log('Got media stream:', stream);\n  })\n  .catch((error) => {\n    console.error('Failed to get user media:', error);\n  });\n```\n\n#### Using Nonstandard Interfaces\n\n```javascript\nconst { nonstandard } = require('2030xwebRTC');\n\nconst videoSource = new nonstandard.RTCVideoSource();\nconst videoSink = new nonstandard.RTCVideoSink(videoSource);\n\n// Example: Convert I420 to RGBA\nconst i420Frame = getI420Frame(); // Assuming this function provides an I420 frame\nconst rgbaFrame = nonstandard.i420ToRgba(i420Frame);\n\nconsole.log('Converted RGBA frame:', rgbaFrame);\n```\n\n### Error Handling\n\n2030xwebRTC includes custom error classes for handling RTC-related errors:\n\n```javascript\nconst { RTCError } = require('2030xwebRTC');\n\ntry {\n  // Some operation that may throw an error\n  throw new RTCError(1, 'Invalid constraints type');\n} catch (error) {\n  console.error('RTC Error:', error);\n}\n```\n\n## API Documentation\n\n### Exports\n\n- **RTCDataChannel**\n  - Corresponds to the original RTCDataChannel.\n  - Handles data channels for peer-to-peer communication.\n\n- **RTCDataChannelEvent**\n  - Corresponds to the original RTCDataChannelEvent.\n  - Handles events related to data channels.\n\n- **RTCIceCandidate**\n  - Corresponds to the original RTCIceCandidate.\n  - Represents ICE candidates used in the connection process.\n\n- **RTCPeerConnection**\n  - Corresponds to the original RTCPeerConnection.\n  - Manages the connection between peers.\n\n- **RTCPeerConnectionIceEvent**\n  - Corresponds to the original RTCPeerConnectionIceEvent.\n  - Handles ICE events during the connection process.\n\n- **RTCRtpReceiver**\n  - Corresponds to the original RTCRtpReceiver.\n  - Manages the receipt of RTP media.\n\n- **RTCRtpSender**\n  - Corresponds to the original RTCRtpSender.\n  - Manages the sending of RTP media.\n\n- **RTCRtpTransceiver**\n  - Corresponds to the original RTCRtpTransceiver.\n  - Manages both sending and receiving of RTP media.\n\n- **RTCSctpTransport**\n  - Corresponds to the original RTCSctpTransport.\n  - Manages SCTP transport for data channels.\n\n- **RTCSessionDescription**\n  - Corresponds to the original RTCSessionDescription.\n  - Represents the configuration of a connection.\n\n- **getUserMedia**\n  - Corresponds to the original getUserMedia.\n  - Allows access to media devices such as cameras and microphones.\n\n- **mediaDevices**\n  - Corresponds to the original mediaDevices.\n  - Provides access to media device functionalities.\n\n- **nonstandard**\n  - Corresponds to the original nonstandard.\n  - Includes nonstandard WebRTC functionalities like `i420ToRgba`, `RTCAudioSink`, `RTCAudioSource`, `RTCVideoSink`, `RTCVideoSource`, and `rgbaToI420`.\n\n- **RTCDataChannelMessageEvent**\n  - New class for handling RTCDataChannel messages.\n  - Represents a message event in an RTCDataChannel.\n\n- **RTCError**\n  - New class for handling RTC-related errors.\n  - Custom error class for RTC-related operations.\n\n- **RTCPeerConnectionIceErrorEvent**\n  - New class for handling ICE candidate errors.\n  - Represents an ICE candidate error event.\n\n## Testing\n\nTo test the functionality of 2030xwebRTC, you can use the provided example in the usage section. Here's a simple script to verify the installation and basic operations:\n\n```bash\nnode test/2030xwebRTC.test.js\n```\n\n### Example Test Script: test/2030xwebRTC.test.js\n\n```javascript\nconst { RTCPeerConnection } = require('2030xwebRTC');\n\nconst pc = new RTCPeerConnection();\n\npc.on('icecandidate', ({ candidate }) => {\n  if (candidate) {\n    console.log('New ICE candidate: ', candidate);\n  } else {\n    console.log('All ICE candidates have been sent');\n  }\n});\n\nconst offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };\n\npc.createOffer(offerOptions)\n  .then((offer) => pc.setLocalDescription(offer))\n  .then(() => console.log('Local description set:', pc.localDescription))\n  .catch((error) => console.error('Failed to create offer:', error));\n```\n\n## Conclusion\n\n2030xwebRTC is a comprehensive WebRTC package designed to handle a wide range of WebRTC functionalities, from peer connections to media handling. With its robust API and extensive features, 2030xwebRTC simplifies the process of integrating WebRTC into your projects.\n\nFor more information, visit the [2030xwebRTC GitHub repository](https://github.com/BadNintendo).\n","readmeFilename":"README.md"}