Bug 190674 - [GStreamer][WebRTC] Add webrtcencoder bin to cleanup and refactor the way we set encoders
Summary: [GStreamer][WebRTC] Add webrtcencoder bin to cleanup and refactor the way we ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Thibault Saunier
URL:
Keywords: InRadar
Depends on:
Blocks: 187064 190676
  Show dependency treegraph
 
Reported: 2018-10-17 11:56 PDT by Thibault Saunier
Modified: 2018-11-05 07:11 PST (History)
5 users (show)

See Also:


Attachments
Patch (28.42 KB, patch)
2018-10-17 12:00 PDT, Thibault Saunier
no flags Details | Formatted Diff | Diff
Patch (28.49 KB, patch)
2018-10-31 04:20 PDT, Thibault Saunier
no flags Details | Formatted Diff | Diff
Patch (28.59 KB, patch)
2018-11-05 06:16 PST, Thibault Saunier
no flags Details | Formatted Diff | Diff
Patch for landing (28.67 KB, patch)
2018-11-05 06:32 PST, Thibault Saunier
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thibault Saunier 2018-10-17 11:56:50 PDT
[GStreamer][WebRTC] Add webrtcencoder bin to cleanup and refactor the way we set encoders
Comment 1 Thibault Saunier 2018-10-17 12:00:18 PDT
Created attachment 352603 [details]
Patch
Comment 2 Xabier Rodríguez Calvar 2018-10-18 00:53:38 PDT
Comment on attachment 352603 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=352603&action=review

> Source/WebCore/ChangeLog:12
> +        The added files follow GStreamer coding style as we aim at upstreaming the element
> +        in the future.

In the future is quite vague. I won't block this because of this issue but I really think that coding style can change during the upstreaming process and currently we should respect WebKit's.

> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:52
> +  const char *name;
> +  const char *parser_name;

This is inconsistent. Either use char or gchar.

> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:101
> +     static void gst_webrtc_video_encoder_finalize (GObject * object)

Indentation

> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:140
> +  if (priv->encoder)
> +    encoders[priv->encoderId].setBitrate (G_OBJECT (priv->encoder),
> +        encoders[priv->encoderId].bitrate_propname, priv->bitrate);

Please correct me if I am wrong, but I think GStreamer would recommend { } enclosing what is running after evaluation the if clause.
Comment 3 Philippe Normand 2018-10-18 02:41:59 PDT
Comment on attachment 352603 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=352603&action=review

> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:185
> +        GstPad *tmppad2 = gst_element_get_static_pad (priv->capsfilter, "sink");

This pad leaks, I think.

> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:230
> +  GstPluginFeature *feature =
> +      gst_registry_lookup_feature (gst_registry_get (), name);

Leak? :)
Comment 4 Thibault Saunier 2018-10-31 04:20:20 PDT
Created attachment 353486 [details]
Patch
Comment 5 Thibault Saunier 2018-10-31 04:20:40 PDT
(In reply to Xabier Rodríguez Calvar from comment #2)
> Comment on attachment 352603 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=352603&action=review
> 
> > Source/WebCore/ChangeLog:12
> > +        The added files follow GStreamer coding style as we aim at upstreaming the element
> > +        in the future.
> 
> In the future is quite vague. I won't block this because of this issue but I
> really think that coding style can change during the upstreaming process and
> currently we should respect WebKit's.

We discussed that last week, and I believe you ended up "agreeing" we should do it that way.

> > Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:52
> > +  const char *name;
> > +  const char *parser_name;
> 
> This is inconsistent. Either use char or gchar.

Done, using GLib variants all around now.

> > Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:101
> > +     static void gst_webrtc_video_encoder_finalize (GObject * object)
> 
> Indentation

Fixed.

> > Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:140
> > +  if (priv->encoder)
> > +    encoders[priv->encoderId].setBitrate (G_OBJECT (priv->encoder),
> > +        encoders[priv->encoderId].bitrate_propname, priv->bitrate);
> 
> Please correct me if I am wrong, but I think GStreamer would recommend { }
> enclosing what is running after evaluation the if clause.

Fixed, though it is accepted in GStreamer.

(In reply to Philippe Normand from comment #3)
> Comment on attachment 352603 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=352603&action=review
> 
> > Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:185
> > +        GstPad *tmppad2 = gst_element_get_static_pad (priv->capsfilter, "sink");
> 
> This pad leaks, I think.

Fixed.

> > Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:230
> > +  GstPluginFeature *feature =
> > +      gst_registry_lookup_feature (gst_registry_get (), name);
> 
> Leak? :)

Fixed.
Comment 6 Philippe Normand 2018-10-31 06:19:34 PDT
Comment on attachment 353486 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=353486&action=review

> Source/WebCore/platform/GStreamer.cmake:38
>          platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp
> +        platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp
>          platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp

It's a minor detail but I think those files should move to platform/mediastream/gstreamer/ at some point.

> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:61
> +  ENCODER_NONE,

Might be good to explicitly assign to 0?

> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:77
> +  ENCODER_LAST,
> +} EncoderId;
> +
> +EncoderDefinition encoders[ENCODER_LAST] = {
> +  FALSE,
> +  NULL,
> +  NULL,
> +  NULL,
> +  NULL,
> +  NULL,
> +  NULL,
> +  NULL,
> +};

So ENCODER_LAST is 4 but encoders's array is bigger. How is this supposed to work? :)

> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:97
> +G_DEFINE_TYPE_WITH_PRIVATE (GstWebrtcVideoEncoder, gst_webrtc_video_encoder,
> +    GST_TYPE_BIN)
> +     enum
> +     {
> +       PROP_0,
> +       PROP_FORMAT,
> +       PROP_ENCODER,
> +       PROP_BITRATE,
> +       N_PROPS
> +     };

The indentation is odd here

> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:101
> +     static void gst_webrtc_video_encoder_finalize (GObject * object)

Useless whitespace here ;)

> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:153
> +  for (i = 1; i < ENCODER_LAST; i++) {

So here you start at 1 because the first item is always FALSE anyway, right?

> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:282
> +  g_object_set (encoder, prop_name, bitrate * 1024, NULL);

Use KBIT_TO_BIT here? Otherwise this macro is unused.
Comment 7 Thibault Saunier 2018-11-05 06:16:21 PST
Created attachment 353856 [details]
Patch
Comment 8 Thibault Saunier 2018-11-05 06:16:30 PST
(In reply to Philippe Normand from comment #6)
> Comment on attachment 353486 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=353486&action=review
> 
> > Source/WebCore/platform/GStreamer.cmake:38
> >          platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp
> > +        platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp
> >          platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp
> 
> It's a minor detail but I think those files should move to
> platform/mediastream/gstreamer/ at some point.
> 
> > Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:61
> > +  ENCODER_NONE,
> 
> Might be good to explicitly assign to 0?

Done.

> > Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:77
> > +  ENCODER_LAST,
> > +} EncoderId;
> > +
> > +EncoderDefinition encoders[ENCODER_LAST] = {
> > +  FALSE,
> > +  NULL,
> > +  NULL,
> > +  NULL,
> > +  NULL,
> > +  NULL,
> > +  NULL,
> > +  NULL,
> > +};
> 
> So ENCODER_LAST is 4 but encoders's array is bigger. How is this supposed to
> work? :)

Those are setting the content of the `EncoderDefinition` structure, not the whole array itself.

> > Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:97
> > +G_DEFINE_TYPE_WITH_PRIVATE (GstWebrtcVideoEncoder, gst_webrtc_video_encoder,
> > +    GST_TYPE_BIN)
> > +     enum
> > +     {
> > +       PROP_0,
> > +       PROP_FORMAT,
> > +       PROP_ENCODER,
> > +       PROP_BITRATE,
> > +       N_PROPS
> > +     };
> 
> The indentation is odd here

`gst-indent`' doing :-) - added necessary `INDENT-OFF/ON`.

> > Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:101
> > +     static void gst_webrtc_video_encoder_finalize (GObject * object)
> 
> Useless whitespace here ;)

Same.

> > Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:153
> > +  for (i = 1; i < ENCODER_LAST; i++) {
> 
> So here you start at 1 because the first item is always FALSE anyway, right?

Right 0 is the NONE encoder :-)

> > Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:282
> > +  g_object_set (encoder, prop_name, bitrate * 1024, NULL);
> 
> Use KBIT_TO_BIT here? Otherwise this macro is unused.
Comment 9 WebKit Commit Bot 2018-11-05 06:27:29 PST
Comment on attachment 353856 [details]
Patch

Rejecting attachment 353856 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-01', 'validate-changelog', '--check-oops', '--non-interactive', 353856, '--port=mac']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

/Volumes/Data/EWS/WebKit/Source/WebCore/ChangeLog neither lists a valid reviewer nor contains the string "Unreviewed" or "Rubber stamp" (case insensitive).

Full output: https://webkit-queues.webkit.org/results/9864724
Comment 10 Thibault Saunier 2018-11-05 06:32:09 PST
Created attachment 353858 [details]
Patch for landing
Comment 11 WebKit Commit Bot 2018-11-05 07:10:03 PST
Comment on attachment 353858 [details]
Patch for landing

Clearing flags on attachment: 353858

Committed r237801: <https://trac.webkit.org/changeset/237801>
Comment 12 WebKit Commit Bot 2018-11-05 07:10:04 PST
All reviewed patches have been landed.  Closing bug.
Comment 13 Radar WebKit Bug Importer 2018-11-05 07:11:21 PST
<rdar://problem/45806634>