⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276493 in webkit


Ignore:
Timestamp:
Apr 23, 2021, 2:46:01 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

[Media] Allow access to MediaElement id from MediaPlayerPrivate
https://bugs.webkit.org/show_bug.cgi?id=224818

Patch by Philippe Normand <pnormand@igalia.com> on 2021-04-23
Reviewed by Xabier Rodriguez-Calvar.

A new method is added in the MediaPlayer allowing to query the client media element for its
identifier. That could be useful for accurate naming of the internal player/pipeline in the
MediaPlayerPrivate. If no specific id was set on the media element then the id is empty
string and the MediaPlayerPrivate needs to handle that by forging a unique id.

This also lead me to simplify pipeline-related code in the GStreamer player. The player can
handle only one pipeline in its entire life-time so the code handling pipeline "re-loading"
was actually never hit.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::parseAttribute):

  • html/HTMLMediaElement.h:
  • platform/graphics/MediaPlayer.cpp:

(WebCore::MediaPlayer::elementId const):

  • platform/graphics/MediaPlayer.h:

(WebCore::MediaPlayerClient::mediaPlayerElementId const):

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:

(WebCore::MediaPlayerPrivateGStreamer::load):
(WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin):
(WebCore::MediaPlayerPrivateGStreamer::loadFull): Deleted.
(WebCore::MediaPlayerPrivateGStreamer::setPipeline): Deleted.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r276492 r276493  
     12021-04-23  Philippe Normand  <pnormand@igalia.com>
     2
     3        [Media] Allow access to MediaElement id from MediaPlayerPrivate
     4        https://bugs.webkit.org/show_bug.cgi?id=224818
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        A new method is added in the MediaPlayer allowing to query the client media element for its
     9        identifier. That could be useful for accurate naming of the internal player/pipeline in the
     10        MediaPlayerPrivate. If no specific id was set on the media element then the id is empty
     11        string and the MediaPlayerPrivate needs to handle that by forging a unique id.
     12
     13        This also lead me to simplify pipeline-related code in the GStreamer player. The player can
     14        handle only one pipeline in its entire life-time so the code handling pipeline "re-loading"
     15        was actually never hit.
     16
     17        * html/HTMLMediaElement.cpp:
     18        (WebCore::HTMLMediaElement::parseAttribute):
     19        * html/HTMLMediaElement.h:
     20        * platform/graphics/MediaPlayer.cpp:
     21        (WebCore::MediaPlayer::elementId const):
     22        * platform/graphics/MediaPlayer.h:
     23        (WebCore::MediaPlayerClient::mediaPlayerElementId const):
     24        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
     25        (WebCore::MediaPlayerPrivateGStreamer::load):
     26        (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin):
     27        (WebCore::MediaPlayerPrivateGStreamer::loadFull): Deleted.
     28        (WebCore::MediaPlayerPrivateGStreamer::setPipeline): Deleted.
     29        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
     30
    1312021-04-22  Sergio Villar Senin  <svillar@igalia.com>
    232
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r276389 r276493  
    713713void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomString& value)
    714714{
     715    if (name == idAttr)
     716        m_id = value;
     717
    715718    if (name == srcAttr) {
    716719        // https://html.spec.whatwg.org/multipage/embedded-content.html#location-of-the-media-resource
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r276389 r276493  
    726726    Vector<String> mediaPlayerPreferredAudioCharacteristics() const override;
    727727
     728    String mediaPlayerElementId() const override { return m_id; }
     729
    728730#if PLATFORM(IOS_FAMILY)
    729731    String mediaPlayerNetworkInterfaceName() const override;
     
    12001202    String m_audioOutputHashedDeviceId;
    12011203#endif
     1204    String m_id;
    12021205};
    12031206
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r276267 r276493  
    16701670}
    16711671
     1672String MediaPlayer::elementId() const
     1673{
     1674    return client().mediaPlayerElementId();
     1675}
     1676
    16721677#if !RELEASE_LOG_DISABLED
    16731678const Logger& MediaPlayer::mediaPlayerLogger()
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r274021 r276493  
    259259    virtual String mediaPlayerSourceApplicationIdentifier() const { return emptyString(); }
    260260
     261    virtual String mediaPlayerElementId() const { return emptyString(); }
     262
    261263    virtual void mediaPlayerEngineFailedToLoad() const { }
    262264
     
    549551    String engineDescription() const;
    550552    long platformErrorCode() const;
     553
     554    String elementId() const;
    551555
    552556    CachedResourceLoader* cachedResourceLoader();
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r276198 r276493  
    303303}
    304304
    305 void MediaPlayerPrivateGStreamer::loadFull(const String& urlString, const String& pipelineName)
     305void MediaPlayerPrivateGStreamer::load(const String& urlString)
    306306{
    307307    URL url(URL(), urlString);
     
    319319
    320320    if (!m_pipeline)
    321         createGSTPlayBin(url, pipelineName);
     321        createGSTPlayBin(url);
    322322    syncOnClock(true);
    323323    if (m_fillTimer.isActive())
     
    347347}
    348348
    349 void MediaPlayerPrivateGStreamer::load(const String& urlString)
    350 {
    351     loadFull(urlString, String());
    352 }
    353 
    354349#if ENABLE(MEDIA_SOURCE)
    355350void MediaPlayerPrivateGStreamer::load(const URL&, const ContentType&, MediaSourcePrivateClient*)
     
    365360{
    366361    m_streamPrivate = &stream;
    367     static Atomic<uint32_t> pipelineId;
    368     auto pipelineName = makeString("mediastream-", pipelineId.exchangeAdd(1));
    369 
    370     loadFull(String("mediastream://") + stream.id(), pipelineName);
     362    load(String("mediastream://") + stream.id());
    371363    syncOnClock(false);
    372364
     
    15421534        player->notifyPlayerOfVideo();
    15431535    });
    1544 }
    1545 
    1546 void MediaPlayerPrivateGStreamer::setPipeline(GstElement* pipeline)
    1547 {
    1548     if (!pipeline) {
    1549         GST_WARNING("Playbin not found, make sure to install gst-plugins-base");
    1550         loadingFailed(MediaPlayer::NetworkState::FormatError, MediaPlayer::ReadyState::HaveNothing, true);
    1551         return;
    1552     }
    1553 
    1554     m_pipeline = pipeline;
    15551536}
    15561537
     
    26962677}
    26972678
    2698 void MediaPlayerPrivateGStreamer::createGSTPlayBin(const URL& url, const String& pipelineName)
     2679void MediaPlayerPrivateGStreamer::createGSTPlayBin(const URL& url)
    26992680{
    27002681    GST_INFO("Creating pipeline for %s player", m_player->isVideoPlayer() ? "video" : "audio");
     
    27082689        playbinName = "playbin3";
    27092690
    2710     if (m_pipeline) {
    2711         if (!g_strcmp0(GST_OBJECT_NAME(gst_element_get_factory(m_pipeline.get())), playbinName)) {
    2712             GST_INFO_OBJECT(pipeline(), "Already using %s", playbinName);
    2713             return;
    2714         }
    2715 
    2716         GST_INFO_OBJECT(pipeline(), "Tearing down as we need to use %s now.", playbinName);
    2717         changePipelineState(GST_STATE_NULL);
    2718         m_pipeline = nullptr;
    2719         m_audioSink = nullptr;
    2720     }
    2721 
    27222691    ASSERT(!m_pipeline);
    27232692
     2693    auto elementId = m_player->elementId();
     2694    if (elementId.isEmpty())
     2695        elementId = "media-player";
     2696
     2697    const char* type = isMediaSource() ? "MSE-" : url.protocolIs("mediastream") ? "mediastream-" : "";
     2698
    27242699    m_isLegacyPlaybin = !g_strcmp0(playbinName, "playbin");
    27252700
    27262701    static Atomic<uint32_t> pipelineId;
    2727     setPipeline(gst_element_factory_make(playbinName,
    2728         (pipelineName.isEmpty() ? makeString("media-player-", pipelineId.exchangeAdd(1)) : pipelineName).utf8().data()));
     2702
     2703    m_pipeline = adoptGRef(gst_element_factory_make(playbinName, makeString(type, elementId, '-', pipelineId.exchangeAdd(1)).ascii().data()));
     2704    if (!m_pipeline) {
     2705        GST_WARNING("%s not found, make sure to install gst-plugins-base", playbinName);
     2706        loadingFailed(MediaPlayer::NetworkState::FormatError, MediaPlayer::ReadyState::HaveNothing, true);
     2707        return;
     2708    }
     2709
    27292710    setStreamVolumeElement(GST_STREAM_VOLUME(m_pipeline.get()));
    27302711
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h

    r276197 r276493  
    281281    void setStreamVolumeElement(GstStreamVolume*);
    282282
    283     void setPipeline(GstElement*);
    284283    GstElement* pipeline() const { return m_pipeline.get(); }
    285284
     
    412411    virtual void asyncStateChangeDone();
    413412
    414     void createGSTPlayBin(const URL&, const String& pipelineName);
     413    void createGSTPlayBin(const URL&);
    415414
    416415    bool loadNextLocation();
     
    444443
    445444    void setPlaybinURL(const URL& urlString);
    446     void loadFull(const String& url, const String& pipelineName);
    447445
    448446    void updateTracks(const GRefPtr<GstStreamCollection>&);
Note: See TracChangeset for help on using the changeset viewer.