Exemplo n.º 1
0
def onmessage_cb(channel, datatype, data, length, userdata):
    if datatype == RTCDC_DATATYPE_STRING:
        message = ffi.cast("char *", data)
        message = ffi.string(message)
        message = message[:length].decode("UTF-8")
    if datatype == RTCDC_DATATYPE_BINARY:
        message = ffi.cast("char *", data)
        message = ffi.buffer(message, length)[:]
    if userdata:
            ffi.from_handle(userdata)._onMessage(message)
Exemplo n.º 2
0
 def generate_offer_sdp(self):
     offerSDP = lib.rtcdc_generate_offer_sdp(self.peer)
     offerSDP = ffi.string(offerSDP)
     return b64encode(offerSDP)
Exemplo n.º 3
0
def oncandidate_cb(peer, candidate, userdata):
    candidate = ffi.string(candidate)
    ffi.from_handle(userdata)._onCandidate(peer, candidate)
Exemplo n.º 4
0
 def generate_local_candidate(self):
     candidateSDP = lib.rtcdc_generate_local_candidate_sdp(self.peer)
     candidateSDP = ffi.string(candidateSDP)
     return b64encode(candidateSDP)