client.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:disco 作者: b1naryth1ef 项目源码 文件源码
def send_frame(self, frame, sequence=None, timestamp=None):
        # Convert the frame to a bytearray
        frame = bytearray(frame)

        # Pack the rtc header into our buffer
        struct.pack_into('>H', self._buffer, 2, sequence or self.vc.sequence)
        struct.pack_into('>I', self._buffer, 4, timestamp or self.vc.timestamp)
        struct.pack_into('>i', self._buffer, 8, self.vc.ssrc)

        # Now encrypt the payload with the nonce as a header
        raw = self.vc.secret_box.encrypt(bytes(frame), bytes(self._buffer)).ciphertext

        # Send the header (sans nonce padding) plus the payload
        self.send(self._buffer[:12] + raw)

        # Increment our sequence counter
        self.vc.sequence += 1
        if self.vc.sequence >= 65535:
            self.vc.sequence = 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号