New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom encryption with aiortc python webRTC #33
Comments
Sorry, this seems to be an aiortc problem. |
you need to make sure you apply the encryption before the frame is split into RTP packets. |
Thanks for the feedback, it works fine when I apply no change on sender side and receiver side(no en/decryption). But still some doubts. I got some progress(that is received distorted video) when I discard first 10 byte from encryption/decryption at sender/receiver. Based on the webrtc example https://github.com/webrtc/samples/blob/gh-pages/src/content/peerconnection/endtoend-encryption/js/worker.js the variable I will make sure whether packet is sending before or after RTP packet split. |
The encryption is done on full media frames, just after the encoder and before the rtp packetization. |
I have done on the same place but receive distorted frame. |
Hey @SourceCodeZone I am also discussing this on #37 It sounds like this will not work unless you implement the GFD extension. The docs aren't public yet, but when I get access to them will share the PR I make to https://github.com/pion/webrtc Right now even if I properly decrypt everything my video fails to play. I ran two streams and compare the buffers (one didn't decode before send, and the other did) and the buffers were exactly the same. |
Thanks for the information, for me the goal was implement custom encryption between two peers, so as a solution I have implemented without insertable stream using aiortc only. Like the sender peer(aiortc-peer) send the frame by encrypting. The receiver(aiortc-peer) peer received the data and decrypted, then decode and displayed in webserver using Flask as described here https://medium.com/datadriveninvestor/video-streaming-using-flask-and-opencv-c464bf8473d6 |
@SourceCodeZone that is very cool! Nice work, I bet you learned a lot building that. I will try my best to help with aiortc after I land my change in Pion's code base. I know enough Python to be dangerous :) |
Thanks man, and all the very best with your Pion's code base work. |
If you are skipping the first bytes of the payload, it should work and most likely you are not doing something correctly. Implementing GFD will most probably not going to solve the problem for you. |
Closing issue as "not requiring any spec change". |
I am tying to use webrtc insertable stream. Right now my sender peer is aiortc https://github.com/aiortc/aiortc python webrtc lib and receiver is normal browser(latest chrome which support insertable stream).
Right now I am adding simple change on the trasnmistted encoded byte, that is subtract 1(at python-webrtc-aiortc). And at receiver side add 1 to reconstruct the frame.
Java script
Python code:
I am editing following file https://github.com/aiortc/aiortc/blob/c0504b6962484ac26ba8ad065191794ac6f607a4/src/aiortc/rtcrtpsender.py#L284 and corresponding code, where the decode frame get
I am getting correct data at js side, but the video not playing.
Few doubts having about python side encryption.
Where should I apply the encryption, just after frame encoded on frame data, before adding header, sequence number and timestamp.
Why the video not playing while the frame send is received correctly when I apply the above changes.
Please give some advice, how I can add encryption at aiortc side decryption at browser side. I have implemented it like above and data received same as sent but video not playing. If I remove the subtract operation(simple-encryption) from both side then it works.
The text was updated successfully, but these errors were encountered: