Changeset 231091 in webkit


Ignore:
Timestamp:
Apr 27, 2018 3:07:58 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r231089.
https://bugs.webkit.org/show_bug.cgi?id=185071

Broke and made crash some WPE EME tests (Requested by calvaris
on #webkit).

Reverted changeset:

"[EME][GStreamer] Move the decryptor from AppendPipeline to
PlaybackPipeline."
https://bugs.webkit.org/show_bug.cgi?id=181855
https://trac.webkit.org/changeset/231089

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r231089 r231091  
     12018-04-27  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r231089.
     4        https://bugs.webkit.org/show_bug.cgi?id=185071
     5
     6        Broke and made crash some WPE EME tests (Requested by calvaris
     7        on #webkit).
     8
     9        Reverted changeset:
     10
     11        "[EME][GStreamer] Move the decryptor from AppendPipeline to
     12        PlaybackPipeline."
     13        https://bugs.webkit.org/show_bug.cgi?id=181855
     14        https://trac.webkit.org/changeset/231089
     15
    1162018-04-27  Yacine Bandou  <yacine.bandou_ext@softathome.com>
    217
  • trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp

    r231089 r231091  
    300300
    301301    switch (GST_EVENT_TYPE(event)) {
     302    case GST_EVENT_PROTECTION: {
     303        const char* systemId = nullptr;
     304
     305        gst_event_parse_protection(event, &systemId, nullptr, nullptr);
     306        GST_TRACE_OBJECT(self, "received protection event for %s", systemId);
     307
     308        if (!g_strcmp0(systemId, klass->protectionSystemId)) {
     309            GST_DEBUG_OBJECT(self, "sending protection event to the pipeline");
     310            gst_element_post_message(GST_ELEMENT(self),
     311                gst_message_new_element(GST_OBJECT(self),
     312                    gst_structure_new("drm-key-needed", "event", GST_TYPE_EVENT, event, nullptr)));
     313        }
     314
     315        gst_event_unref(event);
     316        result = TRUE;
     317        break;
     318    }
    302319    case GST_EVENT_CUSTOM_DOWNSTREAM_OOB: {
    303320        if (klass->handleKeyResponse(self, event)) {
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp

    r231089 r231091  
    5656    case AppendPipeline::AppendState::Ongoing:
    5757        return "Ongoing";
     58    case AppendPipeline::AppendState::KeyNegotiation:
     59        return "KeyNegotiation";
    5860    case AppendPipeline::AppendState::DataStarve:
    5961        return "DataStarve";
     
    9193    appendPipeline->handleApplicationMessage(message);
    9294}
     95
     96#if ENABLE(ENCRYPTED_MEDIA)
     97static void appendPipelineElementMessageCallback(GstBus*, GstMessage* message, AppendPipeline* appendPipeline)
     98{
     99    appendPipeline->handleElementMessage(message);
     100}
     101#endif
    93102
    94103static void appendPipelineStateChangeMessageCallback(GstBus*, GstMessage* message, AppendPipeline* appendPipeline)
     
    123132    g_signal_connect(m_bus.get(), "sync-message::need-context", G_CALLBACK(appendPipelineNeedContextMessageCallback), this);
    124133    g_signal_connect(m_bus.get(), "message::application", G_CALLBACK(appendPipelineApplicationMessageCallback), this);
     134#if ENABLE(ENCRYPTED_MEDIA)
     135    g_signal_connect(m_bus.get(), "message::element", G_CALLBACK(appendPipelineElementMessageCallback), this);
     136#endif
    125137    g_signal_connect(m_bus.get(), "message::state-changed", G_CALLBACK(appendPipelineStateChangeMessageCallback), this);
    126138
     
    264276    gst_message_parse_context_type(message, &contextType);
    265277    GST_TRACE("context type: %s", contextType);
     278    if (!g_strcmp0(contextType, "drm-preferred-decryption-system-id")
     279        && m_appendState != AppendPipeline::AppendState::KeyNegotiation)
     280        setAppendState(AppendPipeline::AppendState::KeyNegotiation);
    266281
    267282    // MediaPlayerPrivateGStreamerBase will take care of setting up encryption.
     
    314329    ASSERT_NOT_REACHED();
    315330}
     331
     332#if ENABLE(ENCRYPTED_MEDIA)
     333void AppendPipeline::handleElementMessage(GstMessage* message)
     334{
     335    ASSERT(WTF::isMainThread());
     336
     337    const GstStructure* structure = gst_message_get_structure(message);
     338    GST_TRACE("%s message from %s", gst_structure_get_name(structure), GST_MESSAGE_SRC_NAME(message));
     339    if (m_playerPrivate && gst_structure_has_name(structure, "drm-key-needed")) {
     340        if (m_appendState != AppendPipeline::AppendState::KeyNegotiation)
     341            setAppendState(AppendPipeline::AppendState::KeyNegotiation);
     342
     343        GST_DEBUG("sending drm-key-needed message from %s to the player", GST_MESSAGE_SRC_NAME(message));
     344        GRefPtr<GstEvent> event;
     345        gst_structure_get(structure, "event", GST_TYPE_EVENT, &event.outPtr(), nullptr);
     346        m_playerPrivate->handleProtectionEvent(event.get());
     347    }
     348}
     349#endif
    316350
    317351void AppendPipeline::handleStateChangeMessage(GstMessage* message)
     
    340374    }
    341375
    342     ASSERT(m_appendState == AppendState::Ongoing || m_appendState == AppendState::Sampling);
     376    ASSERT(m_appendState == AppendState::KeyNegotiation || m_appendState == AppendState::Ongoing || m_appendState == AppendState::Sampling);
    343377    ASSERT(!m_appsrcNeedDataReceived);
    344378
     
    398432    //           |         |            `->Aborting-->NotStarted
    399433    //           |         `->Sampling-···->Sampling-->LastSample-->NotStarted
    400     //           |                                               `->Aborting-->NotStarted
     434    //           |         |                                     `->Aborting-->NotStarted
     435    //           |         `->KeyNegotiation-->Ongoing-->[...]
    401436    //           `->Aborting-->NotStarted
    402437    AppendState oldAppendState = m_appendState;
     
    434469        }
    435470        break;
     471    case AppendState::KeyNegotiation:
     472        switch (newAppendState) {
     473        case AppendState::Ongoing:
     474        case AppendState::Invalid:
     475            ok = true;
     476            break;
     477        default:
     478            break;
     479        }
     480        break;
    436481    case AppendState::Ongoing:
    437482        switch (newAppendState) {
     483        case AppendState::KeyNegotiation:
    438484        case AppendState::Sampling:
    439485        case AppendState::Invalid:
     
    537583    m_demuxerSrcPadCaps = adoptGRef(demuxerSrcPadCaps);
    538584    m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Unknown;
    539 
     585#if ENABLE(ENCRYPTED_MEDIA)
     586    if (areEncryptedCaps(m_demuxerSrcPadCaps.get())) {
     587        // Any previous decryptor should have been removed from the pipeline by disconnectFromAppSinkFromStreamingThread()
     588        ASSERT(!m_decryptor);
     589        GstStructure* structure = gst_caps_get_structure(m_demuxerSrcPadCaps.get(), 0);
     590        m_decryptor = GStreamerEMEUtilities::createDecryptor(gst_structure_get_string(structure, "protection-system"));
     591        if (!m_decryptor) {
     592            GST_ERROR("decryptor not found for caps: %" GST_PTR_FORMAT, m_demuxerSrcPadCaps.get());
     593            return;
     594        }
     595    }
     596#endif
    540597    const char* originalMediaType = capsMediaType(m_demuxerSrcPadCaps.get());
    541598    if (!MediaPlayerPrivateGStreamerMSE::supportsCodec(originalMediaType)) {
     
    617674        LockHolder locker(m_newSampleLock);
    618675
     676        // If we were in KeyNegotiation but samples are coming, assume we're already OnGoing
     677        if (m_appendState == AppendState::KeyNegotiation)
     678            setAppendState(AppendState::Ongoing);
     679
    619680        // Ignore samples if we're not expecting them. Refuse processing if we're in Invalid state.
    620681        if (m_appendState != AppendState::Ongoing && m_appendState != AppendState::Sampling) {
     
    9491010        }
    9501011
     1012#if ENABLE(ENCRYPTED_MEDIA)
     1013        if (m_decryptor) {
     1014            gst_object_ref(m_decryptor.get());
     1015            gst_bin_add(GST_BIN(m_pipeline.get()), m_decryptor.get());
     1016            gst_element_sync_state_with_parent(m_decryptor.get());
     1017
     1018            GRefPtr<GstPad> decryptorSinkPad = adoptGRef(gst_element_get_static_pad(m_decryptor.get(), "sink"));
     1019            GRefPtr<GstPad> decryptorSrcPad = adoptGRef(gst_element_get_static_pad(m_decryptor.get(), "src"));
     1020
     1021            gst_pad_link(currentSrcPad.get(), decryptorSinkPad.get());
     1022            currentSrcPad = decryptorSrcPad;
     1023        }
     1024#endif
     1025
    9511026        gst_pad_link(currentSrcPad.get(), appsinkSinkPad.get());
    9521027
    9531028        gst_element_sync_state_with_parent(m_appsink.get());
    9541029
     1030#if ENABLE(ENCRYPTED_MEDIA)
     1031        if (m_pendingDecryptionStructure)
     1032            dispatchPendingDecryptionStructure();
     1033#endif
    9551034        gst_element_set_state(m_pipeline.get(), GST_STATE_PAUSED);
    9561035        gst_element_sync_state_with_parent(m_appsink.get());
     
    10311110    GST_DEBUG("Disconnecting appsink");
    10321111
     1112#if ENABLE(ENCRYPTED_MEDIA)
     1113    if (m_decryptor) {
     1114        gst_element_set_state(m_decryptor.get(), GST_STATE_NULL);
     1115        gst_bin_remove(GST_BIN(m_pipeline.get()), m_decryptor.get());
     1116        m_decryptor = nullptr;
     1117    }
     1118#endif
     1119
    10331120    if (m_parser) {
    10341121        gst_element_set_state(m_parser.get(), GST_STATE_NULL);
     
    10391126    GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(m_pipeline.get()), GST_DEBUG_GRAPH_SHOW_ALL, "pad-removed-after");
    10401127}
     1128
     1129#if ENABLE(ENCRYPTED_MEDIA)
     1130void AppendPipeline::dispatchPendingDecryptionStructure()
     1131{
     1132    ASSERT(m_decryptor);
     1133    ASSERT(m_pendingDecryptionStructure);
     1134    ASSERT(m_appendState == AppendState::KeyNegotiation);
     1135    GST_TRACE("dispatching key to append pipeline %p", this);
     1136
     1137    // Release the m_pendingDecryptionStructure object since
     1138    // gst_event_new_custom() takes over ownership of it.
     1139    gst_element_send_event(m_pipeline.get(), gst_event_new_custom(GST_EVENT_CUSTOM_DOWNSTREAM_OOB, m_pendingDecryptionStructure.release()));
     1140
     1141    setAppendState(AppendState::Ongoing);
     1142}
     1143
     1144void AppendPipeline::dispatchDecryptionStructure(GUniquePtr<GstStructure>&& structure)
     1145{
     1146    if (m_appendState == AppendState::KeyNegotiation) {
     1147        GST_TRACE("append pipeline %p in key negotiation", this);
     1148        m_pendingDecryptionStructure = WTFMove(structure);
     1149        if (m_decryptor)
     1150            dispatchPendingDecryptionStructure();
     1151        else
     1152            GST_TRACE("no decryptor yet, waiting for it");
     1153    } else
     1154        GST_TRACE("append pipeline %p not in key negotiation", this);
     1155}
     1156#endif
    10411157
    10421158static void appendPipelineAppsinkCapsChanged(GObject* appsinkPad, GParamSpec*, AppendPipeline* appendPipeline)
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h

    r231089 r231091  
    4343class AppendPipeline : public ThreadSafeRefCounted<AppendPipeline> {
    4444public:
    45     enum class AppendState { Invalid, NotStarted, Ongoing, DataStarve, Sampling, LastSample, Aborting };
     45    enum class AppendState { Invalid, NotStarted, Ongoing, KeyNegotiation, DataStarve, Sampling, LastSample, Aborting };
    4646
    4747    AppendPipeline(Ref<MediaSourceClientGStreamerMSE>, Ref<SourceBufferPrivateGStreamer>, MediaPlayerPrivateGStreamerMSE&);
     
    5151    void handleApplicationMessage(GstMessage*);
    5252    void handleStateChangeMessage(GstMessage*);
     53#if ENABLE(ENCRYPTED_MEDIA)
     54    void handleElementMessage(GstMessage*);
     55#endif
    5356
    5457    gint id();
     
    5861    GstFlowReturn handleNewAppsinkSample(GstElement*);
    5962    GstFlowReturn pushNewBuffer(GstBuffer*);
     63#if ENABLE(ENCRYPTED_MEDIA)
     64    void dispatchDecryptionStructure(GUniquePtr<GstStructure>&&);
     65#endif
    6066
    6167    // Takes ownership of caps.
     
    9399    void removeAppsrcDataLeavingProbe();
    94100    void setAppsrcDataLeavingProbe();
     101#if ENABLE(ENCRYPTED_MEDIA)
     102    void dispatchPendingDecryptionStructure();
     103#endif
    95104
    96105    Ref<MediaSourceClientGStreamerMSE> m_mediaSourceClient;
     
    110119    GRefPtr<GstElement> m_demux;
    111120    GRefPtr<GstElement> m_parser; // Optional.
     121#if ENABLE(ENCRYPTED_MEDIA)
     122    GRefPtr<GstElement> m_decryptor;
     123#endif
    112124    // The demuxer has one src stream only, so only one appsink is needed and linked to it.
    113125    GRefPtr<GstElement> m_appsink;
     
    144156
    145157    GRefPtr<GstBuffer> m_pendingBuffer;
     158#if ENABLE(ENCRYPTED_MEDIA)
     159    GUniquePtr<GstStructure> m_pendingDecryptionStructure;
     160#endif
    146161};
    147162
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp

    r231089 r231091  
    956956        gst_structure_set_value(structure.get(), "key-values", &keyValueList);
    957957
    958         gst_element_send_event(m_playbackPipeline->pipeline(), gst_event_new_custom(GST_EVENT_CUSTOM_DOWNSTREAM_OOB, gst_structure_copy(structure.get())));
     958        for (auto it : m_appendPipelinesMap)
     959            it.value->dispatchDecryptionStructure(GUniquePtr<GstStructure>(gst_structure_copy(structure.get())));
    959960    }
    960961}
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/PlaybackPipeline.cpp

    r231089 r231091  
    181181    GUniquePtr<gchar> parserBinName(g_strdup_printf("streamparser%u", padId));
    182182
    183     if (areEncryptedCaps(caps)) {
    184         GST_DEBUG("It's encrypted content, parsers are not needed before decrypting the content");
    185     } else if (!g_strcmp0(mediaType, "video/x-h264")) {
     183    if (!g_strcmp0(mediaType, "video/x-h264")) {
    186184        GRefPtr<GstCaps> filterCaps = adoptGRef(gst_caps_new_simple("video/x-h264", "alignment", G_TYPE_STRING, "au", nullptr));
    187185        GstElement* capsfilter = gst_element_factory_make("capsfilter", nullptr);
Note: See TracChangeset for help on using the changeset viewer.