Changeset 207886 in webkit


Ignore:
Timestamp:
Oct 26, 2016 1:45:15 AM (7 years ago)
Author:
eocanha@igalia.com
Message:

[GStreamer][EME] Utility function to create decryptor
https://bugs.webkit.org/show_bug.cgi?id=162914

Reviewed by Xabier Rodriguez-Calvar.

Add a utility function to find a suitable GStreamer decryptor element.

This patch is authored by Philippe Normand <philn@igalia.com>.

  • platform/graphics/gstreamer/GStreamerUtilities.cpp:

(WebCore::createGstDecryptor):
(WebCore::gstRegistryHasElementForMediaType): Deleted.

  • platform/graphics/gstreamer/GStreamerUtilities.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207885 r207886  
     12016-10-26  Enrique Ocaña González  <eocanha@igalia.com>
     2
     3        [GStreamer][EME] Utility function to create decryptor
     4        https://bugs.webkit.org/show_bug.cgi?id=162914
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        Add a utility function to find a suitable GStreamer decryptor element.
     9
     10        This patch is authored by Philippe Normand <philn@igalia.com>.
     11
     12        * platform/graphics/gstreamer/GStreamerUtilities.cpp:
     13        (WebCore::createGstDecryptor):
     14        (WebCore::gstRegistryHasElementForMediaType): Deleted.
     15        * platform/graphics/gstreamer/GStreamerUtilities.h:
     16
    1172016-10-26  Enrique Ocaña González  <eocanha@igalia.com>
    218
  • trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp

    r202558 r207886  
    11/*
    2  *  Copyright (C) 2012 Igalia S.L
     2 *  Copyright (C) 2012, 2015, 2016 Igalia S.L
     3 *  Copyright (C) 2015, 2016 Metrological Group B.V.
    34 *
    45 *  This library is free software; you can redistribute it and/or
     
    197198}
    198199
     200#if GST_CHECK_VERSION(1, 5, 3) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
     201GstElement* createGstDecryptor(const gchar* protectionSystem)
     202{
     203    GstElement* decryptor = nullptr;
     204    GList* decryptors = gst_element_factory_list_get_elements(GST_ELEMENT_FACTORY_TYPE_DECRYPTOR, GST_RANK_MARGINAL);
     205
     206    GST_TRACE("looking for decryptor for %s", protectionSystem);
     207
     208    for (GList* walk = decryptors; !decryptor && walk; walk = g_list_next(walk)) {
     209        GstElementFactory* factory = reinterpret_cast<GstElementFactory*>(walk->data);
     210
     211        GST_TRACE("checking factory %s", GST_OBJECT_NAME(factory));
     212
     213        for (const GList* current = gst_element_factory_get_static_pad_templates(factory); current && !decryptor; current = g_list_next(current)) {
     214            GstStaticPadTemplate* staticPadTemplate = static_cast<GstStaticPadTemplate*>(current->data);
     215            GRefPtr<GstCaps> caps = adoptGRef(gst_static_pad_template_get_caps(staticPadTemplate));
     216            unsigned length = gst_caps_get_size(caps.get());
     217
     218            GST_TRACE("factory %s caps has size %u", GST_OBJECT_NAME(factory), length);
     219            for (unsigned i = 0; !decryptor && i < length; ++i) {
     220                GstStructure* structure = gst_caps_get_structure(caps.get(), i);
     221                GST_TRACE("checking structure %s", gst_structure_get_name(structure));
     222                if (gst_structure_has_field_typed(structure, GST_PROTECTION_SYSTEM_ID_CAPS_FIELD, G_TYPE_STRING)) {
     223                    const gchar* sysId = gst_structure_get_string(structure, GST_PROTECTION_SYSTEM_ID_CAPS_FIELD);
     224                    GST_TRACE("structure %s has protection system %s", gst_structure_get_name(structure), sysId);
     225                    if (!g_ascii_strcasecmp(protectionSystem, sysId)) {
     226                        GST_DEBUG("found decryptor %s for %s", GST_OBJECT_NAME(factory), protectionSystem);
     227                        decryptor = gst_element_factory_create(factory, nullptr);
     228                        break;
     229                    }
     230                }
     231            }
     232        }
     233    }
     234    gst_plugin_feature_list_free(decryptors);
     235    GST_TRACE("returning decryptor %p", decryptor);
     236    return decryptor;
     237}
     238#endif
     239
    199240}
    200241
  • trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h

    r203058 r207886  
    11/*
    2  *  Copyright (C) 2012 Igalia S.L
     2 *  Copyright (C) 2012, 2015, 2016 Igalia S.L
     3 *  Copyright (C) 2015, 2016 Metrological Group B.V.
    34 *
    45 *  This library is free software; you can redistribute it and/or
     
    1617 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
    1718 */
     19
     20#pragma once
    1821
    1922#include "Logging.h"
     
    6265GstClockTime toGstClockTime(float time);
    6366bool gstRegistryHasElementForMediaType(GList* elementFactories, const char* capsString);
     67
     68#if GST_CHECK_VERSION(1, 5, 3) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
     69GstElement* createGstDecryptor(const gchar* protectionSystem);
     70#endif
    6471}
Note: See TracChangeset for help on using the changeset viewer.