[Webkit-unassigned] [Bug 158189] WebRTC: Add RTCRtpTransceiver interface and RTCPeerConnection.addTransceiver()

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jun 1 01:36:46 PDT 2016


https://bugs.webkit.org/show_bug.cgi?id=158189

--- Comment #10 from Adam Bergkvist <adam.bergkvist at ericsson.com> ---
(In reply to comment #7)
> Comment on attachment 280093 [details]
> Proposed patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=280093&action=review
> 
> Noticed a few more things while re-looking at this that we could refine
> later.
> 
> >>> Source/WebCore/Modules/mediastream/RTCPeerConnection.idl:69
> >>> +    [StrictTypeChecking, RaisesException] RTCRtpTransceiver addTransceiver(DOMString kind, optional Dictionary init);
> >> 
> >> New code should never use Dictionary. These dictionaries should defined.
> >> 
> >> dictionary RTCRtpTransceiverInit {
> >>     boolean send = true;
> >>     boolean receive = true;
> >>     sequence<MediaStream> streams;
> >>     sequence<RTCRtpEncodingParameters> sendEncodings;
> >> };
> >> 
> >> If the bindings generator can’t handle this dictionary, we should fix it so it can handle it. Every single time we instead use the deprecated Dictionary, we add code we will need to later delete!
> > 
> > Using dictionary from latest published editor's draft [1]. Not all members are supported yet. Should I add a FIXME+bug# for that?
> > 
> > [1] https://w3c.github.io/webrtc-pc/archives/20160513/webrtc.html#idl-def-rtcrtptransceiverinit
> 
> I don’t think we need a FIXME about each piece that is missing as we
> implement something new like this. Eventually it might have some value. but
> during development it’s probably OK to just do things a bit at a time.
> 
> > Source/WebCore/Modules/mediastream/RTCRtpSender.cpp:58
> > +    if (track)
> > +        setTrack(WTFMove(track));
> 
> Not sure the if here is valuable.

Let's let setTrack() handle track being null

> > Source/WebCore/Modules/mediastream/RTCRtpSenderReceiverBase.h:47
> >      virtual ~RTCRtpSenderReceiverBase() { }
> 
> It’s probably more elegant to write "= default" here instead of writing out
> an empty body.

Fixed.

> > Source/WebCore/Modules/mediastream/RTCRtpSenderReceiverBase.h:53
> > +    RTCRtpSenderReceiverBase()
> > +    { }
> 
> It’s probably more elegant to write "= default" here instead of writing out
> an empty body.

Fixed.

> >>> Source/WebCore/Modules/mediastream/RTCRtpTransceiver.cpp:98
> >>> +}
> >> 
> >> Since bindings create functions like this for all enumerations, we should avoid writing this code ourselves if possible. What makes this necessary?
> > 
> > Removed parseDirectionString() as part of moving to properly defined dictionary in idl. directionString() is used when the direction value is added to a PeerMediaDescription (which represents direction as a string). I guess there's no nice way to use the generated version from the binding?
> 
> Yes, at the moment there is no way to convert an enumeration into the string
> from the bindings, but if this pattern keeps recurring, I suppose we can add
> a way.


(In reply to comment #8)
> Comment on attachment 280145 [details]
> Updated patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=280145&action=review
> 
> > Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp:195
> > +    transceiver->setDirection(static_cast<RTCRtpTransceiver::Direction>(init.direction));
> 
> This typecast should not be needed. It’s currently only needed because we
> are defining the enum twice (see my other comments).

Agreed. See comments below.

> > Source/WebCore/Modules/mediastream/RTCPeerConnection.h:67
> >      Vector<RefPtr<RTCRtpSender>> getSenders() const override { return m_senderSet; }
> >      Vector<RefPtr<RTCRtpReceiver>> getReceivers() const { return m_receiverSet; }
> 
> It’s expensive to have functions that return an existing Vector by copying
> it. We should not do that unless we have to.

The separate fields for storing senders and receivers will be removed shortly since an RTCRtpTransceiver wraps these. They're kept for now to keep the size of this change smaller. The new versions will look into the m_transceiverSet to create the sender and receiver lists so there might be some optimizations to do there as well. These normally contain only a few elements. Sending and receiving 10 streams is quite a lot.

> > Source/WebCore/Modules/mediastream/RTCPeerConnection.h:78
> > +    enum class RtpTransceiverDirection {
> > +        Sendrecv,
> > +        Sendonly,
> > +        Recvonly,
> > +        Inactive
> > +    };
> 
> Instead of re-defining this here, we should write this:
> 
>     using RtpTransceiverDirection = RTCRtpTransceiver::Direction;

This would be much nicer. However, applying this change makes the bindings generator generate duplicate conversion functions (jsStringWithCache, parse, convert) for the RTCRtpTransceiverDirection enum with the same C++ enum. I'll leave as is and file a new bug.

> > Source/WebCore/Modules/mediastream/RTCPeerConnection.h:82
> > +    struct RtpTransceiverInit {
> > +        RtpTransceiverDirection direction;
> > +    };
> 
> Eventually, we probably also want to define this in RTCRtpTransceiver and
> use "using" to pull it in here with the appropriate name.
> 
> > Source/WebCore/Modules/mediastream/RTCPeerConnection.idl:125
> > +enum RTCRtpTransceiverDirection {
> > +    "sendrecv",
> > +    "sendonly",
> > +    "recvonly",
> > +    "inactive"
> > +};
> 
> Eventually we will make the bindings script smarter so we don’t have to
> repeat this in multiple IDL files. In the mean time we might want to comment
> so anyone modifying one knows they should modify the other.

Agreed. Adding comments.

> > Source/WebCore/Modules/mediastream/RTCRtpSender.h:60
> > +    bool isStopped() const { return m_client == nullptr; }
> 
> WebKit coding style says we write this !m_client rather than m_client ==
> nullptr.

Fixed.

> > Source/WebCore/Modules/mediastream/RTCRtpTransceiver.cpp:80
> > +    return emptyString();
> 
> Maybe return inactiveString() here instead of emptyString()?

Fixed.

> > Source/WebCore/Modules/mediastream/RTCRtpTransceiver.h:52
> > +    enum class Direction {
> > +        Sendrecv,
> > +        Sendonly,
> > +        Recvonly,
> > +        Inactive
> > +    };
> 
> I find short enumerations like this really nice when writing out all on one
> line.

The direction enums will likely never be extended so let's make them a one-liner.

> > Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp:50
> > +    Ref<MockRealtimeAudioSource> source = adoptRef(*new MockRealtimeAudioSource(name));
> 
> I think auto works better here than writing the type a second time. I’d also
> omit the empty line below.

Fixed.

> > Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp:59
> > +    Ref<MockRealtimeVideoSource> source = adoptRef(*new MockRealtimeVideoSource(name));
> 
> I think auto works better here than writing the type a second time. I’d also
> omit the empty line below.

Fixed.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160601/80538338/attachment-0001.html>


More information about the webkit-unassigned mailing list