webrtc - Match source element to transceiver/id/name
Hi! First time posting in this forum, so please let me know if my issue contains all relevant info.
I have a use case where I want to send two (or more) video streams via webrtcbin
to a web client. The video streams are produced by an appsrc
-element. It is important that the different sources can be disambiguated at the client. I have not found a good way to match a particular instance of the appsrc
with the received MediaTrack
s at the client.
Here is how I set up the pipeline:
const VP8_PIPELINE: &str = "
webrtcbin name=webrtcbin bundle-policy=max-bundle
appsrc name=appsrc0 is-live=true min-latency=0 format=time block=true ! queue !
videoconvert !
vp8enc end-usage=vbr target-bitrate=2000000 deadline=1 threads=4 token-partitions=4 static-threshold=100 !
rtpvp8pay pt=96 !
webrtcbin.sink_0
appsrc name=appsrc1 is-live=true min-latency=0 format=time block=true ! queue !
videoconvert !
vp8enc end-usage=vbr target-bitrate=2000000 deadline=1 threads=4 token-partitions=4 static-threshold=100 !
rtpvp8pay pt=96 !
webrtcbin.sink_1
";
Schematically I visualize it as
appsrc0 -> Video Payload -\
sink_0 transceiver index 'a', mid='x'
webrtcbin <
sink_1 transceiver index 'b', mid='y'
appsrc1 -> Video Payload -/
At the web client I get a callback for each MediaTrack
. The MediaTrack
has an id
that seems connected to the transceiver index ('a' or 'b' in the above figure), as an example id webrtctransceiver2
. The problem is, how can I figure out which appsrc
-instance (appsrc0 or appsrc1) is mapped to which transceiver index? I can't assume that it will always be webrtctransceiver0
and webrtctransceiver1
, since refreshing the page (including dropping and recreating the full pipeline on the server) will result in the transceiver indexes increasing (to 2 and 3, then 4 and 5 etc. until the server is restarted). Alternatively I can look at the transceiver instance on the client and get its mid
. This is stable even between refreshes (video0
and video1
), but still I need to be sure which of them map to which apprsc
-instance. Is there a way to specify the mid used by webrtcbin
? Can I walk the "pipeline graph" from each transceiver back to its appsrc? Is there a simpler way of gainin control of which client MediaTrack
that belongs to which appsrc
-instance?