No webrtcbin data channel on 1.20.1?

Florian Echtler floe at butterbrot.org
Sat Apr 30 07:45:45 UTC 2022


OK, I've obivously been a bit boneheaded, I've always implicitly assumed the 
data channel is full-duplex. So I've probably been triggering some undefined 
behaviour in 1.16 that sort of worked by accident.

FTR, the correct pattern to have a data channel in both directions is:

--------------------------------------------------------------------------------

    def __init__(...):
    [...]
         # create the outgoing data channel
         self.data_channel = self.wrb.emit("create-data-channel", "events", None)
         self.data_channel.connect("on-open", self.on_channel_open)

     # outgoing data channel is open
     def on_channel_open(self, channel):
         hi = "Hi from "+self.name
         self.data_channel.emit("send-data",GLib.Bytes.new(hi.encode("utf-8")))
         self.data_channel.emit("send-string",hi)

     # message incoming on WebRTC data channel
     def on_dc_message(self, channel, message):
         logging.debug("New data channel message: "+str(message))

     # new incoming data channel created
     def on_data_channel(self, wrb, data_channel):
         logging.info("New incoming data channel created.")
         data_channel.connect("on-message-string", self.on_dc_message)
         data_channel.connect("on-message-data",   self.on_dc_message)

--------------------------------------------------------------------------------

Best, Florian


On 29.04.22 14:00, Florian Echtler via gstreamer-devel wrote:
> Hi everyone,
> 
> I've been testing my GStreamer webrtc application with 1.16.2 and more recently 
> with 1.20.1. Here's a code snippet of the datachannel setup:
> 
>          self.wrb = self.bin.get_by_name("webrtcbin")
>          self.wrb.connect("on-data-channel",self.on_data_channel)
> 
>          # create the data channel
>          self.wrb.emit("create-data-channel", "events", None)
> 
>      # message on WebRTC data channel
>      def on_dc_message(self, wrb, message):
>          logging.debug("New data channel message: "+message)
> 
>      # new data channel created
>      def on_data_channel(self, wrb, data_channel):
>          logging.info("New data channel created.")
>          self.datachannel = data_channel
>          self.datachannel.connect("on-message-string", self.on_dc_message)
>          self.datachannel.connect("on-message-data",   self.on_dc_message)
>          hello = "Hi from "+self.name
>          self.datachannel.emit("send-data",GLib.Bytes.new(hello.encode("utf-8")))
>          self.datachannel.emit("send-string",hello)
> 
> However, on 1.20.1, I'm never getting the on-data-channel signal, while it seems 
> to work on 1.16.2. What should I change, is this a timing issue? This also had 
> me wondering what the second parameter to create-data-channel is supposed to be, 
> couldn't find any documentation?
> 
> Thanks and best, Florian


-- 
SENT FROM MY DEC VT50 TERMINAL
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 203 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20220430/e77ad858/attachment.sig>


More information about the gstreamer-devel mailing list