aiortc | WebRTC and ORTC implementation for Python using asyncio | Reactive Programming library

 by   aiortc Python Version: 1.9.0 License: BSD-3-Clause

kandi X-RAY | aiortc Summary

kandi X-RAY | aiortc Summary

aiortc is a Python library typically used in Programming Style, Reactive Programming applications. aiortc has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can install using 'pip install aiortc' or download it from GitHub, PyPI.

WebRTC and ORTC implementation for Python using asyncio
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              aiortc has a highly active ecosystem.
              It has 3418 star(s) with 669 fork(s). There are 87 watchers for this library.
              There were 1 major release(s) in the last 12 months.
              There are 38 open issues and 578 have been closed. On average issues are closed in 175 days. There are 10 open pull requests and 0 closed requests.
              OutlinedDot
              It has a negative sentiment in the developer community.
              The latest version of aiortc is 1.9.0

            kandi-Quality Quality

              aiortc has 0 bugs and 0 code smells.

            kandi-Security Security

              aiortc has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              aiortc code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              aiortc is licensed under the BSD-3-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              aiortc releases are not available. You will need to build from source code and install.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              It has 21238 lines of code, 1253 functions and 75 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed aiortc and discovered the below as its top functions. This is intended to give you an instant insight into aiortc implemented functionality, and help decide if they suit your requirements.
            • Parse an SBTP session
            • Create an RTCIceCandidate from an SDP string
            • Return the IP address from an SDP address
            • Split a text file into a list of media and media
            • Encode a video frame
            • Raise an exception
            • Convert from_base to timebase
            • Convert buffer into a list of bytes
            • Handle incoming packet data
            • Open a data channel
            • Returns the RTCStats for this connection
            • Receive data from the stream
            • Send an answer to the receiver
            • Add a packet
            • Create the SSL context
            • Worker function for decoding frames
            • Start the stream
            • Run an offer
            • Encode a single frame
            • Handle an RTCP packet
            • Create a new RPC session
            • Update the rate control state
            • Handle an RTP packet
            • Start the receiver
            • Demultiplexer
            • Update the filter
            Get all kandi verified functions for this library.

            aiortc Key Features

            No Key Features are available at this moment for aiortc.

            aiortc Examples and Code Snippets

            peerjs-python,Dependencies
            Pythondot img1Lines of Code : 2dot img1License : Permissive (Apache-2.0)
            copy iconCopy
            apt install libavdevice-dev libavfilter-dev libopus-dev libvpx-dev pkg-config libsrtp2-dev
            
            brew install ffmpeg opus libvpx pkg-config
              
            RTC Tunnel,Install
            Pythondot img2Lines of Code : 1dot img2License : Permissive (MIT)
            copy iconCopy
            pip install -r requirements.txt
              
            Python-asyncio - using timers/threading to terminate async
            Pythondot img3Lines of Code : 16dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
                if args.timeout:
                    print("Timer started")
                    timer = threading.Timer(
                        args.timeout,
                        asyncio.run_coroutine_threadsafe,
                        args=(client.close(), loop),
                    )
                    timer.start()
            
            How to set an answer as LocalDescription in aiortc (python)?
            Pythondot img4Lines of Code : 6dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            {'sdp': 'v=0\r\no=- 3841969261 3841969261 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=msid-semantic:WMS *\r\nm=video 34067 UDP/TLS/RTP/SAVPF 97 98 99 100 101 102\r\nc=IN \na=sendrecv\r\na=extmap:1 urn:ietf:params:rtp-hdrext:sde
            Coudl not find video device with name [integrated camera]amoung source devices of type video
            Pythondot img5Lines of Code : 4dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            ffmpeg -list_devices true -f dshow -i dummy
            
            v4l2-ctl --list-devices
            
            How to know when a browser peer is disconnected in aiortc?
            Pythondot img6Lines of Code : 13dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from aiortc import RTCPeerConnection
            
            
            pc = RTCPeerConnection()
            
            
            @pc.on("iceconnectionstatechange")
            async def on_iceconnectionstatechange():
                print(f"ICE connection state is {pc.iceConnectionState}")
            
                if pc.iceConnectionState == "f
            Decorator with async function
            Pythondot img7Lines of Code : 22dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            decorator = pc.on("iceconnectionstatechange")
            
            async def on_iceconnectionstatechange():
                log_info("ICE connection state is %s", pc.iceConnectionState)
                if pc.iceConnectionState == "failed":
                    await pc.close()
                    pcs.discar
            Is it possible to use methods on decorators?
            Pythondot img8Lines of Code : 27dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            @foo
            def bar(): ...
            
            def bar(): ...
            bar = foo(bar)
            
            @pc.on('datachannel')
            def on_datachannel(channel): ...
            
            def on_datachannel(channel): ...
            on_datachannel = pc.on('da
            How can stream video on web browser/HTML page by aiohttp
            Pythondot img9Lines of Code : 21dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            @routes.get('/video')
            async def video_feed(request):
                response = web.StreamResponse()
                response.content_type = 'multipart/x-mixed-replace; boundary=frame'
                await response.prepare(request)
            
                for frame in frames('/dev/video0'):
             
            Is there a way to set a global variable to be used with aiortc?
            Pythondot img10Lines of Code : 22dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import argparse
            import asyncio
            import logging
            import time
            
            from aiortc import RTCIceCandidate, RTCPeerConnection, RTCSessionDescription
            from aiortc.contrib.signaling import add_signaling_arguments, create_signaling
            
            pc = None
            channel = Non

            Community Discussions

            QUESTION

            Python-asyncio - using timers/threading to terminate async
            Asked 2022-Jan-12 at 11:07

            I have an async coroutine that I want to terminate using a timer/thread. The coroutine is based of this example from aiortc.

            ...

            ANSWER

            Answered 2022-Jan-12 at 00:48

            This isn't the general solution that I was looking for, I added a timeout variable to the client constructor, and within client.run() I added asyncio.sleep(timeout) which would exit the loop. This is enough for my purposes.

            Source https://stackoverflow.com/questions/70674877

            QUESTION

            Webrtc on Python failing to change ICE connection state between peers
            Asked 2021-Dec-10 at 15:13

            First, I want to mention that I am very new to WebRTC, so any advice would be very helpful.

            Currently I am using aiortc library to build my own WebRTC app. Here is what I am trying to do.

            I have 2 peers, one is web browser, which is written in javascript, and another one is python script, which is working as signaling server and peer at the same time. So If you access to my web page, you will send video frame to server and then the server will make modification of that then send it back.

            So I finished testing my app on LAN environment and everything worked as I expected. But once I deployed my app to remote server (Google cloud run) , I encountered Ice connection state failing issue. And gets this log on remote server.

            enter image description here

            (I think it is due to disconnection between peers, not low memory problem. I tried with 16GB RAM and 4 cpus and still didn't work)

            Then, I dig into more information, and found that TURN/STUN server is necessary to build WebRTC app over Internet. So I added google STUN server to my RTCPeerConnection like this. [{'urls': 'stun:stun.l.google.com:19302'}, {'urls': 'stun:stun1.l.google.com:19302'}, {'urls': 'stun:stun2.l.google.com:19302'}] (I added both side on javascript and python because both side is working as peer) Unfortunately, it still didn't work.

            Now, I am planning to build my own TURN server, but I am afraid if TURN server wouldn't solve this problem. So I would like to have any advice from you since I am quite stuck within my situation.

            p.s I have done SSL encryption.(So GetUserMedia is working fine)

            Sdp details(Offer/Answer):

            SDP

            Offer

            ...

            ANSWER

            Answered 2021-Dec-10 at 15:13

            If everything work on local, and this ice server are set, verify that your gcloud server have the correct firewall for webrtc port (not only your signaling port, check the sdp/ice you exchange). also this Webrtc page allow you to check is a stun/turn work on your client

            You will not need stun on your python side, as it's a server his ip may be public (unless you don't want to). Stun allow to find your public ip and allow the port to remain open.

            On your server you need to open your signaling port (certainly the WS where you exchange the sdp) and the P2P port (candidate lines in the sdp), the media/data will go through this one. For each media (sdp m line) there are usually one used port.

            Source https://stackoverflow.com/questions/70300816

            QUESTION

            Can I remember instance of object in Django?
            Asked 2021-Nov-19 at 05:49

            I'm using django-channels and aiortc, I want to create server to peer connection as WebRTC.

            In my case, if client send the new-peer action, then server send the offer.

            And after client receive the offer, client send the answer as new-answer action.

            But server can't remember peer, so can't setRemoteDescription.

            Of course I know server don't remember, but how do I deal with situations where server need to remember instances like mine?

            I also looked for session variables, but it seems that only simple values ​​can be stored, and it doesn't seem to have anything to do with the instance.

            Please provide helpful documents or solutions related to this.

            consumers.receive method:

            ...

            ANSWER

            Answered 2021-Nov-19 at 05:49

            Solved: django session support saving instance to their session.

            Source https://stackoverflow.com/questions/70019098

            QUESTION

            How to set an answer as LocalDescription in aiortc (python)?
            Asked 2021-Sep-30 at 05:52

            I'm trying to perform signaling using python websocket, then create peer2peer connection using aiortc, to achieve webRTC-based video streaming using pure python.

            I have managed to send an offer from a peer to another and setRemoteDescription successfully.

            ...

            ANSWER

            Answered 2021-Sep-30 at 05:51

            I have resolved the issue. Since the initiative peer sends an offer which is json string like:

            Source https://stackoverflow.com/questions/69372082

            QUESTION

            Sending video stream from NodeJS to python in real time
            Asked 2021-Jun-17 at 10:13

            I'm using a NodeJS server to catch a video stream through a WebRTC PeerConnection and I need to send it to a python script.

            I use NodeJS mainly because it's easy to use WebRTC in it and the package 'wrtc' supports RTCVideoSink and python's aiortc doesn't.

            I was thinking of using a named pipe with ffmpeg to stream the video stream but 3 questions arose :

            • Should I use python instead of NodeJS and completely avoid the stream through a named pipe part ? (This means there is a way to extract individual frames from a MediaStreamTrack in python)

            • If I stick with the "NodeJS - Python" approach, how do I send the stream from one script to the other ? Named pipe ? Unix domain sockets ? And with FFMpeg ?

            • Finally, for performance purpose I think that sending a stream and not each individual frames is better and simpler but is this true ?

            Thanks all !

            ...

            ANSWER

            Answered 2021-Jun-17 at 10:13

            Finally, I found that the MediaStreamTrack API of Python's aiortc has recv().

            It's a Coroutine that returns the next frame. So I will just port my NodeJS script to python using this coroutine to replace RTCVideoSink. No piping or whatsoever !

            Source https://stackoverflow.com/questions/68014505

            QUESTION

            Coudl not find video device with name [integrated camera]amoung source devices of type video
            Asked 2021-Apr-21 at 12:52

            Im testing aiortc becouse i wanna stream webcam audio and video to browser but when im trying to run webcam.py i get I/O error I/O error: 'video=Integrated Camera'

            CODE IS HERE on github

            ...

            ANSWER

            Answered 2021-Apr-21 at 12:52

            Okey if you get this error you need to check names of your devices with ffmpeg windows

            Source https://stackoverflow.com/questions/67195250

            QUESTION

            How to know when a browser peer is disconnected in aiortc?
            Asked 2021-Mar-02 at 08:11
            from aiortc import RTCPeerConnection
            
            pc = RTCPeerConnection()
            print(pc.connectionState)
            
            ...

            ANSWER

            Answered 2021-Feb-27 at 16:26

            aiortc uses pyee for making aiortc event-driven and as you can see in the official GitHub example (webcam/webcam.py), you must put an event listener on an event named iceconnectionstatechange.

            Checkout the code snippet below:

            Source https://stackoverflow.com/questions/66400853

            QUESTION

            Python websocket client close connection
            Asked 2020-Dec-14 at 18:26

            websocket_client.py

            ...

            ANSWER

            Answered 2020-Dec-14 at 18:26

            This post helps you.

            The reason program couldn't stop is that sub threads continue to run even if main thread catches an exception and stop. Note that asyncio is implemented by thread (I pursued codes). There are two kinds of thread in Python, normal thread and daemon thread. The former continues to run if parent thread dies, the latter stops. asyncio is implemented with the former, therefore such this problem happens.

            Source https://stackoverflow.com/questions/65293716

            QUESTION

            Decorator with async function
            Asked 2020-Sep-07 at 10:29

            I am trying to implement a real-time webcam service in python so I am looking to aiortc. Looking at examples on the GitHub page, I have found a stranger thing and I can't understand how it works.

            On server/server.py on the examples folder, there is an async function with a decorator. The function is never called so I can't understand how the decorator can work.

            ...

            ANSWER

            Answered 2020-Sep-07 at 10:29

            RTCPeerConnection inherits from AsyncIOEventEmitter (link) from the pyee module. pyee is an event system module. This AsyncIOEventEmitter class is where the on decorator method comes from.

            The on_iceconnectionstatechange function is never directly called, but the decorator registers it as an event listener, so it will be called whenever that event is emmited, for example here.

            Because of how decorators work, the code snippet in the question is roughly equivalent to:

            Source https://stackoverflow.com/questions/63769395

            QUESTION

            Is it possible to use methods on decorators?
            Asked 2020-Aug-06 at 10:37

            I was looking around the aiortc examples when I notice a decorator that has a method on it:

            ...

            ANSWER

            Answered 2020-Aug-06 at 10:37

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install aiortc

            You can install using 'pip install aiortc' or download it from GitHub, PyPI.
            You can use aiortc like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install aiortc

          • CLONE
          • HTTPS

            https://github.com/aiortc/aiortc.git

          • CLI

            gh repo clone aiortc/aiortc

          • sshUrl

            git@github.com:aiortc/aiortc.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular Reactive Programming Libraries

            axios

            by axios

            RxJava

            by ReactiveX

            async

            by caolan

            rxjs

            by ReactiveX

            fetch

            by github

            Try Top Libraries by aiortc

            aioquic

            by aiortcPython

            aioice

            by aiortcPython

            pylibsrtp

            by aiortcPython

            pylsqpack

            by aiortcC

            aioquic-openssl

            by aiortcPython