<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - WebRTC: Add RTCRtpTransceiver interface and RTCPeerConnection.addTransceiver()"
   href="https://bugs.webkit.org/show_bug.cgi?id=158189#c10">Comment # 10</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - WebRTC: Add RTCRtpTransceiver interface and RTCPeerConnection.addTransceiver()"
   href="https://bugs.webkit.org/show_bug.cgi?id=158189">bug 158189</a>
              from <span class="vcard"><a class="email" href="mailto:adam.bergkvist&#64;ericsson.com" title="Adam Bergkvist &lt;adam.bergkvist&#64;ericsson.com&gt;"> <span class="fn">Adam Bergkvist</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=158189#c7">comment #7</a>)
<span class="quote">&gt; Comment on <span class="bz_obsolete"><a href="attachment.cgi?id=280093&amp;action=diff" name="attach_280093" title="Proposed patch">attachment 280093</a> <a href="attachment.cgi?id=280093&amp;action=edit" title="Proposed patch">[details]</a></span>
&gt; Proposed patch
&gt; 
&gt; View in context:
&gt; <a href="https://bugs.webkit.org/attachment.cgi?id=280093&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=280093&amp;action=review</a>
&gt; 
&gt; Noticed a few more things while re-looking at this that we could refine
&gt; later.
&gt; 
&gt; &gt;&gt;&gt; Source/WebCore/Modules/mediastream/RTCPeerConnection.idl:69
&gt; &gt;&gt;&gt; +    [StrictTypeChecking, RaisesException] RTCRtpTransceiver addTransceiver(DOMString kind, optional Dictionary init);
&gt; &gt;&gt; 
&gt; &gt;&gt; New code should never use Dictionary. These dictionaries should defined.
&gt; &gt;&gt; 
&gt; &gt;&gt; dictionary RTCRtpTransceiverInit {
&gt; &gt;&gt;     boolean send = true;
&gt; &gt;&gt;     boolean receive = true;
&gt; &gt;&gt;     sequence&lt;MediaStream&gt; streams;
&gt; &gt;&gt;     sequence&lt;RTCRtpEncodingParameters&gt; sendEncodings;
&gt; &gt;&gt; };
&gt; &gt;&gt; 
&gt; &gt;&gt; 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!
&gt; &gt; 
&gt; &gt; Using dictionary from latest published editor's draft [1]. Not all members are supported yet. Should I add a FIXME+bug# for that?
&gt; &gt; 
&gt; &gt; [1] <a href="https://w3c.github.io/webrtc-pc/archives/20160513/webrtc.html#idl-def-rtcrtptransceiverinit">https://w3c.github.io/webrtc-pc/archives/20160513/webrtc.html#idl-def-rtcrtptransceiverinit</a>
&gt; 
&gt; I don’t think we need a FIXME about each piece that is missing as we
&gt; implement something new like this. Eventually it might have some value. but
&gt; during development it’s probably OK to just do things a bit at a time.
&gt; 
&gt; &gt; Source/WebCore/Modules/mediastream/RTCRtpSender.cpp:58
&gt; &gt; +    if (track)
&gt; &gt; +        setTrack(WTFMove(track));
&gt; 
&gt; Not sure the if here is valuable.</span >

Let's let setTrack() handle track being null

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

Fixed.

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

Fixed.

<span class="quote">&gt; &gt;&gt;&gt; Source/WebCore/Modules/mediastream/RTCRtpTransceiver.cpp:98
&gt; &gt;&gt;&gt; +}
&gt; &gt;&gt; 
&gt; &gt;&gt; Since bindings create functions like this for all enumerations, we should avoid writing this code ourselves if possible. What makes this necessary?
&gt; &gt; 
&gt; &gt; 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?
&gt; 
&gt; Yes, at the moment there is no way to convert an enumeration into the string
&gt; from the bindings, but if this pattern keeps recurring, I suppose we can add
&gt; a way.</span >


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

Agreed. See comments below.

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

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.

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

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.

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

Agreed. Adding comments.

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

Fixed.

<span class="quote">&gt; &gt; Source/WebCore/Modules/mediastream/RTCRtpTransceiver.cpp:80
&gt; &gt; +    return emptyString();
&gt; 
&gt; Maybe return inactiveString() here instead of emptyString()?</span >

Fixed.

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

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

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

Fixed.

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

Fixed.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>