RESOLVED FIXED 204686
[GStreamer] Refactor MediaPlayerPrivateGStreamer::notifyPlayerOf*
https://bugs.webkit.org/show_bug.cgi?id=204686
Summary [GStreamer] Refactor MediaPlayerPrivateGStreamer::notifyPlayerOf*
Charlie Turner
Reported 2019-11-28 10:02:10 PST
There is a lot of unnecessary duplication in these methods that can be cleaned up.
Attachments
Patch (16.37 KB, patch)
2021-06-15 03:05 PDT, Enrique Ocaña
no flags
Patch (16.39 KB, patch)
2021-06-15 09:32 PDT, Enrique Ocaña
no flags
Patch (16.35 KB, patch)
2021-06-16 04:04 PDT, Enrique Ocaña
no flags
Patch (16.36 KB, patch)
2021-06-16 09:19 PDT, Enrique Ocaña
no flags
Patch (16.54 KB, patch)
2021-06-17 04:28 PDT, Enrique Ocaña
no flags
Patch (1.74 KB, patch)
2021-06-17 05:33 PDT, Enrique Ocaña
no flags
Enrique Ocaña
Comment 1 2021-06-15 03:05:27 PDT
Philippe Normand
Comment 2 2021-06-15 06:36:01 PDT
Comment on attachment 431418 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=431418&action=review > Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:966 > +static void addTrackToPlayer(MediaPlayer&player, AudioTrackPrivate& track) Missing space after &, also twice below in add methods. > Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:1012 > + if (*hasType) > + m_player->sizeChanged(); This should be done only for video
Enrique Ocaña
Comment 3 2021-06-15 09:32:48 PDT
Philippe Normand
Comment 4 2021-06-15 10:20:39 PDT
Comment on attachment 431448 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=431448&action=review Nice clean-up! > Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:1050 > + addTrackToPlayer(*m_player, track.get()); Nit: I wonder if instead of static funcs we could use a Variant on the enum value here?
Enrique Ocaña
Comment 5 2021-06-16 02:45:23 PDT
Comment on attachment 431448 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=431448&action=review >> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:1050 >> + addTrackToPlayer(*m_player, track.get()); > > Nit: I wonder if instead of static funcs we could use a Variant on the enum value here? Thanks, you've just given me the missing piece I needed to achieve all the needed functionality without function parameters!
Enrique Ocaña
Comment 6 2021-06-16 04:04:31 PDT
Philippe Normand
Comment 7 2021-06-16 04:18:16 PDT
Comment on attachment 431534 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=431534&action=review > Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:1052 > + case 0: m_player->addAudioTrack(get<AudioTrackPrivate&>(variantTrack)); break; > + case 1: m_player->addVideoTrack(get<VideoTrackPrivate&>(variantTrack)); break; > + case 2: m_player->addTextTrack(get<InbandTextTrackPrivate&>(variantTrack)); break; Instead of hard-coding numbers, can you re-use the TrackType enum?
Enrique Ocaña
Comment 8 2021-06-16 04:57:35 PDT
Comment on attachment 431534 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=431534&action=review >> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:1052 >> + case 2: m_player->addTextTrack(get<InbandTextTrackPrivate&>(variantTrack)); break; > > Instead of hard-coding numbers, can you re-use the TrackType enum? Sure. I'm also renaming tracksVariant (at the begining of the method) as variantTracks, to make it consistent with the variantTrack here.
Enrique Ocaña
Comment 9 2021-06-16 09:19:58 PDT
EWS
Comment 10 2021-06-17 02:18:10 PDT
Committed r278978 (238904@main): <https://commits.webkit.org/238904@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 431550 [details].
WebKit Commit Bot
Comment 11 2021-06-17 02:42:15 PDT
Re-opened since this is blocked by bug 227115
Enrique Ocaña
Comment 12 2021-06-17 02:54:47 PDT
I had to revert this patch because the g++ 8 compiler used in the Debian and Ubuntu bots doesn't like the array-based initializations: ../../Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: In instantiation of ‘void WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfTrack() [with TrackPrivateType = WebCore::AudioTrackPrivateGStreamer]’: ../../Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:1097:65: required from here ../../Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:977:65: error: taking address of temporary array auto typeName = (const char*[]) { "audio", "video", "text" }[type]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ ../../Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:978:68: error: taking address of temporary array auto* hasType = (bool*[]) { &m_hasAudio, &m_hasVideo, nullptr }[type]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Also, this warning: In file included from WTF/Headers/wtf/JSONValues.h:35, from ../../Source/WebCore/platform/graphics/IntSize.h:29, from ../../Source/WebCore/platform/graphics/IntPoint.h:28, from ../../Source/WebCore/platform/graphics/FloatSize.h:30, from ../../Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h:23, from ../../Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:29, from ../../Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:27: WTF/Headers/wtf/HashMap.h:480:13: error: ‘bool WTF::HashMap<KeyArg, MappedArg, <template-parameter-1-3>, <template-parameter-1-4>, <template-parameter-1-5>, <template-parameter-1-6> >::removeIf(Functor&&) [with Functor = WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfTrack() [with TrackPrivateType = WebCore::AudioTrackPrivateGStreamer]::<lambda(auto:16&)>; KeyArg = WTF::AtomString; MappedArg = WTF::RefPtr<WebCore::AudioTrackPrivateGStreamer>; HashArg = WTF::DefaultHash<WTF::AtomString>; KeyTraitsArg = WTF::HashTraits<WTF::AtomString>; MappedTraitsArg = WTF::HashTraits<WTF::RefPtr<WebCore::AudioTrackPrivateGStreamer> >; TableTraitsArg = WTF::HashTableTraits]’, declared using local type ‘WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfTrack() [with TrackPrivateType = WebCore::AudioTrackPrivateGStreamer]::<lambda(auto:16&)>’, is used but never defined [-fpermissive] inline bool HashMap<T, U, V, W, X, Y>::removeIf(Functor&& functor) ^~~~~~~~~~~~~~~~~~~~~~~~~ WTF/Headers/wtf/HashMap.h:480:13: error: ‘bool WTF::HashMap<KeyArg, MappedArg, <template-parameter-1-3>, <template-parameter-1-4>, <template-parameter-1-5>, <template-parameter-1-6> >::removeIf(Functor&&) [with Functor = WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfTrack() [with TrackPrivateType = WebCore::InbandTextTrackPrivateGStreamer]::<lambda(auto:16&)>; KeyArg = WTF::AtomString; MappedArg = WTF::RefPtr<WebCore::InbandTextTrackPrivateGStreamer>; HashArg = WTF::DefaultHash<WTF::AtomString>; KeyTraitsArg = WTF::HashTraits<WTF::AtomString>; MappedTraitsArg = WTF::HashTraits<WTF::RefPtr<WebCore::InbandTextTrackPrivateGStreamer> >; TableTraitsArg = WTF::HashTableTraits]’, declared using local type ‘WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfTrack() [with TrackPrivateType = WebCore::InbandTextTrackPrivateGStreamer]::<lambda(auto:16&)>’, is used but never defined [-fpermissive] WTF/Headers/wtf/HashMap.h:480:13: error: ‘bool WTF::HashMap<KeyArg, MappedArg, <template-parameter-1-3>, <template-parameter-1-4>, <template-parameter-1-5>, <template-parameter-1-6> >::removeIf(Functor&&) [with Functor = WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfTrack() [with TrackPrivateType = WebCore::VideoTrackPrivateGStreamer]::<lambda(auto:16&)>; KeyArg = WTF::AtomString; MappedArg = WTF::RefPtr<WebCore::VideoTrackPrivateGStreamer>; HashArg = WTF::DefaultHash<WTF::AtomString>; KeyTraitsArg = WTF::HashTraits<WTF::AtomString>; MappedTraitsArg = WTF::HashTraits<WTF::RefPtr<WebCore::VideoTrackPrivateGStreamer> >; TableTraitsArg = WTF::HashTableTraits]’, declared using local type ‘WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfTrack() [with TrackPrivateType = WebCore::VideoTrackPrivateGStreamer]::<lambda(auto:16&)>’, is used but never defined [-fpermissive]
Enrique Ocaña
Comment 13 2021-06-17 04:28:04 PDT
EWS
Comment 14 2021-06-17 05:00:55 PDT
Committed r278981 (238907@main): <https://commits.webkit.org/238907@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 431652 [details].
Enrique Ocaña
Comment 15 2021-06-17 05:33:10 PDT
Reopening to attach new patch.
Enrique Ocaña
Comment 16 2021-06-17 05:33:14 PDT
EWS
Comment 17 2021-06-17 05:59:10 PDT
Committed r278983 (238909@main): <https://commits.webkit.org/238909@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 431655 [details].
Note You need to log in before you can comment on or make changes to this bug.