Changeset 228680 in webkit


Ignore:
Timestamp:
Feb 19, 2018 7:16:21 AM (6 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r228316 - [EME][GStreamer] Add support for encrypted caps in GStreamerUtilities
https://bugs.webkit.org/show_bug.cgi?id=181990

Patch by Yacine Bandou <yacine.bandou_ext@softathome.com> on 2018-02-09
Reviewed by Xabier Rodriguez-Calvar.

Add the support of encrypted caps in GStreamerUtilities.
Refactor the manner that the caps are handled, such as how to extract the resolution
from the video caps or how to check if the caps are encrypted.

The attachTrack function in PlaybackPipeline doesn't need the "structure" parameter,
it is already included in the "caps" parameter.

Replace the "mediaType" parameter by the "caps" parameter in reattachTrack function,
it allows to use the new functions that handle the caps in GStreamerUtilities.

Tests:

media/encrypted-media/clearKey/clearKey-cenc-audio-playback-mse.html
media/encrypted-media/clearKey/clearKey-cenc-video-playback-mse.html

  • platform/graphics/gstreamer/GStreamerUtilities.cpp:

(WebCore::getVideoSizeAndFormatFromCaps): Add the support of video encrypted caps.
(WebCore::getVideoResolutionFromCaps):
(WebCore::capsMediaType):
(WebCore::doCapsHaveType):
(WebCore::areEncryptedCaps): Add a new functions in order to handle the caps properly.

  • platform/graphics/gstreamer/GStreamerUtilities.h:
  • platform/graphics/gstreamer/mse/AppendPipeline.cpp:

(WebCore::AppendPipeline::parseDemuxerSrcPadCaps):

  • platform/graphics/gstreamer/mse/GStreamerMediaDescription.cpp:

(WebCore::GStreamerMediaDescription::codec const):
(WebCore::GStreamerMediaDescription::isVideo const):
(WebCore::GStreamerMediaDescription::isAudio const):

  • platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:

(WebCore::MediaPlayerPrivateGStreamerMSE::trackDetected):

  • platform/graphics/gstreamer/mse/PlaybackPipeline.cpp:

(WebCore::PlaybackPipeline::attachTrack):
(WebCore::PlaybackPipeline::reattachTrack):

  • platform/graphics/gstreamer/mse/PlaybackPipeline.h:
  • platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:

(webKitMediaSrcUpdatePresentationSize): Refactor some parts by using the new added functions.

Location:
releases/WebKitGTK/webkit-2.20/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/ChangeLog

    r228679 r228680  
     12018-02-09  Yacine Bandou  <yacine.bandou_ext@softathome.com>
     2
     3        [EME][GStreamer] Add support for encrypted caps in GStreamerUtilities
     4        https://bugs.webkit.org/show_bug.cgi?id=181990
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        Add the support of encrypted caps in GStreamerUtilities.
     9        Refactor the manner that the caps are handled, such as how to extract the resolution
     10        from the video caps or how to check if the caps are encrypted.
     11
     12        The attachTrack function in PlaybackPipeline doesn't need the "structure" parameter,
     13        it is already included in the "caps" parameter.
     14
     15        Replace the "mediaType" parameter by the "caps" parameter in reattachTrack function,
     16        it allows to use the new functions that handle the caps in GStreamerUtilities.
     17
     18        Tests:
     19            media/encrypted-media/clearKey/clearKey-cenc-audio-playback-mse.html
     20            media/encrypted-media/clearKey/clearKey-cenc-video-playback-mse.html
     21
     22        * platform/graphics/gstreamer/GStreamerUtilities.cpp:
     23        (WebCore::getVideoSizeAndFormatFromCaps): Add the support of video encrypted caps.
     24        (WebCore::getVideoResolutionFromCaps):
     25        (WebCore::capsMediaType):
     26        (WebCore::doCapsHaveType):
     27        (WebCore::areEncryptedCaps): Add a new functions in order to handle the caps properly.
     28        * platform/graphics/gstreamer/GStreamerUtilities.h:
     29        * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
     30        (WebCore::AppendPipeline::parseDemuxerSrcPadCaps):
     31        * platform/graphics/gstreamer/mse/GStreamerMediaDescription.cpp:
     32        (WebCore::GStreamerMediaDescription::codec const):
     33        (WebCore::GStreamerMediaDescription::isVideo const):
     34        (WebCore::GStreamerMediaDescription::isAudio const):
     35        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
     36        (WebCore::MediaPlayerPrivateGStreamerMSE::trackDetected):
     37        * platform/graphics/gstreamer/mse/PlaybackPipeline.cpp:
     38        (WebCore::PlaybackPipeline::attachTrack):
     39        (WebCore::PlaybackPipeline::reattachTrack):
     40        * platform/graphics/gstreamer/mse/PlaybackPipeline.h:
     41        * platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:
     42        (webKitMediaSrcUpdatePresentationSize): Refactor some parts by using the new added functions.
     43
    1442018-02-09  Philippe Normand  <pnormand@igalia.com>
    245
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp

    r226504 r228680  
    6060bool getVideoSizeAndFormatFromCaps(GstCaps* caps, WebCore::IntSize& size, GstVideoFormat& format, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride)
    6161{
    62     GstVideoInfo info;
    63 
    64     gst_video_info_init(&info);
    65     if (!gst_video_info_from_caps(&info, caps))
    66         return false;
    67 
    68     format = GST_VIDEO_INFO_FORMAT(&info);
    69     size.setWidth(GST_VIDEO_INFO_WIDTH(&info));
    70     size.setHeight(GST_VIDEO_INFO_HEIGHT(&info));
    71     pixelAspectRatioNumerator = GST_VIDEO_INFO_PAR_N(&info);
    72     pixelAspectRatioDenominator = GST_VIDEO_INFO_PAR_D(&info);
    73     stride = GST_VIDEO_INFO_PLANE_STRIDE(&info, 0);
     62    if (!doCapsHaveType(caps, GST_VIDEO_CAPS_TYPE_PREFIX)) {
     63        GST_WARNING("Failed to get the video size and format, these are not a video caps");
     64        return false;
     65    }
     66
     67    if (areEncryptedCaps(caps)) {
     68        GstStructure* structure = gst_caps_get_structure(caps, 0);
     69        format = GST_VIDEO_FORMAT_ENCODED;
     70        stride = 0;
     71        int width = 0, height = 0;
     72        gst_structure_get_int(structure, "width", &width);
     73        gst_structure_get_int(structure, "height", &height);
     74        if (!gst_structure_get_fraction(structure, "pixel-aspect-ratio", &pixelAspectRatioNumerator, &pixelAspectRatioDenominator)) {
     75            pixelAspectRatioNumerator = 1;
     76            pixelAspectRatioDenominator = 1;
     77        }
     78
     79        size.setWidth(width);
     80        size.setHeight(height);
     81    } else {
     82        GstVideoInfo info;
     83        gst_video_info_init(&info);
     84        if (!gst_video_info_from_caps(&info, caps))
     85            return false;
     86
     87        format = GST_VIDEO_INFO_FORMAT(&info);
     88        size.setWidth(GST_VIDEO_INFO_WIDTH(&info));
     89        size.setHeight(GST_VIDEO_INFO_HEIGHT(&info));
     90        pixelAspectRatioNumerator = GST_VIDEO_INFO_PAR_N(&info);
     91        pixelAspectRatioDenominator = GST_VIDEO_INFO_PAR_D(&info);
     92        stride = GST_VIDEO_INFO_PLANE_STRIDE(&info, 0);
     93    }
    7494
    7595    return true;
     96}
     97
     98std::optional<FloatSize> getVideoResolutionFromCaps(const GstCaps* caps)
     99{
     100    if (!doCapsHaveType(caps, GST_VIDEO_CAPS_TYPE_PREFIX)) {
     101        GST_WARNING("Failed to get the video resolution, these are not a video caps");
     102        return std::nullopt;
     103    }
     104
     105    int width = 0, height = 0;
     106    int pixelAspectRatioNumerator = 1, pixelAspectRatioDenominator = 1;
     107
     108    if (areEncryptedCaps(caps)) {
     109        GstStructure* structure = gst_caps_get_structure(caps, 0);
     110        gst_structure_get_int(structure, "width", &width);
     111        gst_structure_get_int(structure, "height", &height);
     112        gst_structure_get_fraction(structure, "pixel-aspect-ratio", &pixelAspectRatioNumerator, &pixelAspectRatioDenominator);
     113    } else {
     114        GstVideoInfo info;
     115        gst_video_info_init(&info);
     116        if (!gst_video_info_from_caps(&info, caps))
     117            return std::nullopt;
     118
     119        width = GST_VIDEO_INFO_WIDTH(&info);
     120        height = GST_VIDEO_INFO_HEIGHT(&info);
     121        pixelAspectRatioNumerator = GST_VIDEO_INFO_PAR_N(&info);
     122        pixelAspectRatioDenominator = GST_VIDEO_INFO_PAR_D(&info);
     123    }
     124
     125    return std::make_optional(FloatSize(width, height * (static_cast<float>(pixelAspectRatioNumerator) / static_cast<float>(pixelAspectRatioDenominator))));
    76126}
    77127
     
    112162
    113163    return buffer;
     164}
     165
     166const char* capsMediaType(const GstCaps* caps)
     167{
     168    ASSERT(caps);
     169    GstStructure* structure = gst_caps_get_structure(caps, 0);
     170    if (!structure) {
     171        GST_WARNING("caps are empty");
     172        return nullptr;
     173    }
     174#if ENABLE(ENCRYPTED_MEDIA)
     175    if (gst_structure_has_name(structure, "application/x-cenc"))
     176        return gst_structure_get_string(structure, "original-media-type");
     177#endif
     178    return gst_structure_get_name(structure);
     179}
     180
     181bool doCapsHaveType(const GstCaps* caps, const char* type)
     182{
     183    const char* mediaType = capsMediaType(caps);
     184    if (!mediaType) {
     185        GST_WARNING("Failed to get MediaType");
     186        return false;
     187    }
     188    return g_str_has_prefix(mediaType, type);
     189}
     190
     191bool areEncryptedCaps(const GstCaps* caps)
     192{
     193    ASSERT(caps);
     194#if ENABLE(ENCRYPTED_MEDIA)
     195    GstStructure* structure = gst_caps_get_structure(caps, 0);
     196    if (!structure) {
     197        GST_WARNING("caps are empty");
     198        return false;
     199    }
     200    return gst_structure_has_name(structure, "application/x-cenc");
     201#else
     202    UNUSED_PARAM(caps);
     203    return false;
     204#endif
    114205}
    115206
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h

    r226402 r228680  
    2121
    2222
     23#include "FloatSize.h"
    2324#include <gst/gst.h>
    2425#include <gst/video/video-format.h>
     
    5152}
    5253
     54#define GST_VIDEO_CAPS_TYPE_PREFIX  "video/"
     55#define GST_AUDIO_CAPS_TYPE_PREFIX  "audio/"
     56#define GST_TEXT_CAPS_TYPE_PREFIX   "text/"
     57
    5358GstPad* webkitGstGhostPadFromStaticTemplate(GstStaticPadTemplate*, const gchar* name, GstPad* target);
    5459#if ENABLE(VIDEO)
    5560bool getVideoSizeAndFormatFromCaps(GstCaps*, WebCore::IntSize&, GstVideoFormat&, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride);
     61std::optional<FloatSize> getVideoResolutionFromCaps(const GstCaps*);
    5662bool getSampleVideoInfo(GstSample*, GstVideoInfo&);
    5763#endif
     
    5965GstBuffer* createGstBufferForData(const char* data, int length);
    6066char* getGstBufferDataPointer(GstBuffer*);
     67const char* capsMediaType(const GstCaps*);
     68bool doCapsHaveType(const GstCaps*, const char*);
     69bool areEncryptedCaps(const GstCaps*);
    6170void mapGstBuffer(GstBuffer*, uint32_t);
    6271void unmapGstBuffer(GstBuffer*);
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp

    r226357 r228680  
    2828#include "GStreamerEMEUtilities.h"
    2929#include "GStreamerMediaDescription.h"
     30#include "GStreamerUtilities.h"
    3031#include "MediaSampleGStreamer.h"
    3132#include "InbandTextTrackPrivateGStreamer.h"
     
    583584    m_demuxerSrcPadCaps = adoptGRef(demuxerSrcPadCaps);
    584585    m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Unknown;
    585 
    586     GstStructure* structure = gst_caps_get_structure(m_demuxerSrcPadCaps.get(), 0);
    587     bool sizeConfigured = false;
    588 
    589 #if GST_CHECK_VERSION(1, 5, 3) && ENABLE(ENCRYPTED_MEDIA)
    590     if (gst_structure_has_name(structure, "application/x-cenc")) {
     586#if ENABLE(ENCRYPTED_MEDIA)
     587    if (areEncryptedCaps(m_demuxerSrcPadCaps.get())) {
    591588        // Any previous decryptor should have been removed from the pipeline by disconnectFromAppSinkFromStreamingThread()
    592589        ASSERT(!m_decryptor);
    593 
     590        GstStructure* structure = gst_caps_get_structure(m_demuxerSrcPadCaps.get(), 0);
    594591        m_decryptor = GStreamerEMEUtilities::createDecryptor(gst_structure_get_string(structure, "protection-system"));
    595592        if (!m_decryptor) {
     
    597594            return;
    598595        }
    599 
    600         const gchar* originalMediaType = gst_structure_get_string(structure, "original-media-type");
    601 
    602         if (!MediaPlayerPrivateGStreamerMSE::supportsCodec(originalMediaType)) {
     596    }
     597#endif
     598    const char* originalMediaType = capsMediaType(m_demuxerSrcPadCaps.get());
     599    if (!MediaPlayerPrivateGStreamerMSE::supportsCodec(originalMediaType)) {
    603600            m_presentationSize = WebCore::FloatSize();
    604601            m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Invalid;
    605         } else if (g_str_has_prefix(originalMediaType, "video/")) {
    606             int width = 0;
    607             int height = 0;
    608             float finalHeight = 0;
    609 
    610             if (gst_structure_get_int(structure, "width", &width) && gst_structure_get_int(structure, "height", &height)) {
    611                 int ratioNumerator = 1;
    612                 int ratioDenominator = 1;
    613 
    614                 gst_structure_get_fraction(structure, "pixel-aspect-ratio", &ratioNumerator, &ratioDenominator);
    615                 finalHeight = height * ((float) ratioDenominator / (float) ratioNumerator);
    616             }
    617 
    618             m_presentationSize = WebCore::FloatSize(width, finalHeight);
    619             m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Video;
    620         } else {
     602    } else if (doCapsHaveType(m_demuxerSrcPadCaps.get(), GST_VIDEO_CAPS_TYPE_PREFIX)) {
     603        std::optional<FloatSize> size = getVideoResolutionFromCaps(m_demuxerSrcPadCaps.get());
     604        if (size.has_value())
     605            m_presentationSize = size.value();
     606        else
    621607            m_presentationSize = WebCore::FloatSize();
    622             if (g_str_has_prefix(originalMediaType, "audio/"))
    623                 m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Audio;
    624             else if (g_str_has_prefix(originalMediaType, "text/"))
    625                 m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Text;
    626         }
    627         sizeConfigured = true;
    628     }
    629 #endif
    630 
    631     if (!sizeConfigured) {
    632         const char* structureName = gst_structure_get_name(structure);
    633         GstVideoInfo info;
    634 
    635         if (!MediaPlayerPrivateGStreamerMSE::supportsCodec(structureName)) {
    636             m_presentationSize = WebCore::FloatSize();
    637             m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Invalid;
    638         } else if (g_str_has_prefix(structureName, "video/") && gst_video_info_from_caps(&info, demuxerSrcPadCaps)) {
    639             float width, height;
    640 
    641             width = info.width;
    642             height = info.height * ((float) info.par_d / (float) info.par_n);
    643 
    644             m_presentationSize = WebCore::FloatSize(width, height);
    645             m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Video;
    646         } else {
    647             m_presentationSize = WebCore::FloatSize();
    648             if (g_str_has_prefix(structureName, "audio/"))
    649                 m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Audio;
    650             else if (g_str_has_prefix(structureName, "text/"))
    651                 m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Text;
    652         }
     608
     609        m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Video;
     610    } else {
     611        m_presentationSize = WebCore::FloatSize();
     612        if (doCapsHaveType(m_demuxerSrcPadCaps.get(), GST_AUDIO_CAPS_TYPE_PREFIX))
     613            m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Audio;
     614        else if (doCapsHaveType(m_demuxerSrcPadCaps.get(), GST_TEXT_CAPS_TYPE_PREFIX))
     615            m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Text;
    653616    }
    654617}
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/platform/graphics/gstreamer/mse/GStreamerMediaDescription.cpp

    r207876 r228680  
    2121#include "config.h"
    2222#include "GStreamerMediaDescription.h"
    23 
     23#include "GStreamerUtilities.h"
    2424#include "GUniquePtrGStreamer.h"
    2525
     
    3434AtomicString GStreamerMediaDescription::codec() const
    3535{
    36     GUniquePtr<gchar> description(gst_pb_utils_get_codec_description(m_caps.get()));
     36    return m_codecName;
     37}
     38
     39bool GStreamerMediaDescription::isVideo() const
     40{
     41    return doCapsHaveType(m_caps.get(), GST_VIDEO_CAPS_TYPE_PREFIX);
     42}
     43
     44bool GStreamerMediaDescription::isAudio() const
     45{
     46    return doCapsHaveType(m_caps.get(), GST_AUDIO_CAPS_TYPE_PREFIX);
     47}
     48
     49bool GStreamerMediaDescription::isText() const
     50{
     51    // FIXME: Implement proper text track support.
     52    return false;
     53}
     54
     55AtomicString GStreamerMediaDescription::extractCodecName()
     56{
     57    GRefPtr<GstCaps> originalCaps = m_caps;
     58
     59    if (areEncryptedCaps(originalCaps.get())) {
     60        originalCaps = adoptGRef(gst_caps_copy(originalCaps.get()));
     61        GstStructure* structure = gst_caps_get_structure(originalCaps.get(), 0);
     62
     63        if (!gst_structure_has_field(structure, "original-media-type"))
     64            return AtomicString();
     65
     66        gst_structure_set_name(structure, gst_structure_get_string(structure, "original-media-type"));
     67        // Remove the DRM related fields from the caps.
     68        for (int j = 0; j < gst_structure_n_fields(structure); ++j) {
     69            const char* fieldName = gst_structure_nth_field_name(structure, j);
     70
     71            if (g_str_has_prefix(fieldName, "protection-system")
     72                || g_str_has_prefix(fieldName, "original-media-type"))
     73                gst_structure_remove_field(structure, fieldName);
     74        }
     75    }
     76
     77    GUniquePtr<gchar> description(gst_pb_utils_get_codec_description(originalCaps.get()));
    3778    String codecName(description.get());
    3879
     
    4384        size_t braceEnd = codecName.find(")");
    4485        if (braceStart != notFound && braceEnd != notFound)
    45             codecName.remove(braceStart, braceEnd-braceStart);
     86            codecName.remove(braceStart, braceEnd - braceStart);
    4687    }
    4788
     
    4990}
    5091
    51 bool GStreamerMediaDescription::isVideo() const
    52 {
    53     GstStructure* structure = gst_caps_get_structure(m_caps.get(), 0);
    54     const gchar* name = gst_structure_get_name(structure);
    55 
    56     return g_str_has_prefix(name, "video/");
    57 }
    58 
    59 bool GStreamerMediaDescription::isAudio() const
    60 {
    61     GstStructure* structure = gst_caps_get_structure(m_caps.get(), 0);
    62     const gchar* name = gst_structure_get_name(structure);
    63 
    64     return g_str_has_prefix(name, "audio/");
    65 }
    66 
    67 bool GStreamerMediaDescription::isText() const
    68 {
    69     // FIXME: Implement proper text track support.
    70     return false;
    71 }
    72 
    7392} // namespace WebCore.
    7493
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/platform/graphics/gstreamer/mse/GStreamerMediaDescription.h

    r207876 r228680  
    2727
    2828#include <gst/gst.h>
     29#include <wtf/text/AtomicString.h>
    2930
    3031namespace WebCore {
     
    4950        , m_caps(caps)
    5051    {
     52        m_codecName = extractCodecName();
    5153    }
    5254
     55    AtomicString extractCodecName();
    5356    GRefPtr<GstCaps> m_caps;
     57    AtomicString m_codecName;
    5458};
    5559
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp

    r225594 r228680  
    740740    GST_DEBUG("track ID: %s, caps: %" GST_PTR_FORMAT, newTrack->id().string().latin1().data(), caps);
    741741
    742     GstStructure* structure = gst_caps_get_structure(caps, 0);
    743     const gchar* mediaType = gst_structure_get_name(structure);
    744     GstVideoInfo info;
    745 
    746     if (g_str_has_prefix(mediaType, "video/") && gst_video_info_from_caps(&info, caps)) {
    747         float width, height;
    748 
    749         width = info.width;
    750         height = info.height * ((float) info.par_d / (float) info.par_n);
    751         m_videoSize.setWidth(width);
    752         m_videoSize.setHeight(height);
     742    if (doCapsHaveType(caps, GST_VIDEO_CAPS_TYPE_PREFIX)) {
     743        std::optional<FloatSize> size = getVideoResolutionFromCaps(caps);
     744        if (size.has_value())
     745            m_videoSize = size.value();
    753746    }
    754747
    755748    if (firstTrackDetected)
    756         m_playbackPipeline->attachTrack(appendPipeline->sourceBufferPrivate(), newTrack, structure, caps);
     749        m_playbackPipeline->attachTrack(appendPipeline->sourceBufferPrivate(), newTrack, caps);
    757750    else
    758         m_playbackPipeline->reattachTrack(appendPipeline->sourceBufferPrivate(), newTrack, mediaType);
     751        m_playbackPipeline->reattachTrack(appendPipeline->sourceBufferPrivate(), newTrack, caps);
    759752}
    760753
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/platform/graphics/gstreamer/mse/PlaybackPipeline.cpp

    r226357 r228680  
    163163}
    164164
    165 void PlaybackPipeline::attachTrack(RefPtr<SourceBufferPrivateGStreamer> sourceBufferPrivate, RefPtr<TrackPrivateBase> trackPrivate, GstStructure* structure, GstCaps* caps)
     165void PlaybackPipeline::attachTrack(RefPtr<SourceBufferPrivateGStreamer> sourceBufferPrivate, RefPtr<TrackPrivateBase> trackPrivate, GstCaps* caps)
    166166{
    167167    WebKitMediaSrc* webKitMediaSrc = m_webKitMediaSrc.get();
     
    178178    GST_OBJECT_UNLOCK(webKitMediaSrc);
    179179
    180     const gchar* mediaType = gst_structure_get_name(structure);
    181 
     180    const char* mediaType = capsMediaType(caps);
    182181    GST_DEBUG_OBJECT(webKitMediaSrc, "Configured track %s: appsrc=%s, padId=%u, mediaType=%s", trackPrivate->id().string().utf8().data(), GST_ELEMENT_NAME(stream->appsrc), padId, mediaType);
    183182
     
    218217    } else if (!g_strcmp0(mediaType, "audio/mpeg")) {
    219218        gint mpegversion = -1;
     219        GstStructure* structure = gst_caps_get_structure(caps, 0);
    220220        gst_structure_get_int(structure, "mpegversion", &mpegversion);
    221221
     
    273273
    274274    GST_OBJECT_LOCK(webKitMediaSrc);
    275     if (g_str_has_prefix(mediaType, "audio")) {
     275    if (doCapsHaveType(caps, GST_AUDIO_CAPS_TYPE_PREFIX)) {
    276276        stream->type = Audio;
    277277        stream->parent->priv->numberOfAudioStreams++;
    278278        signal = SIGNAL_AUDIO_CHANGED;
    279279        stream->audioTrack = RefPtr<WebCore::AudioTrackPrivateGStreamer>(static_cast<WebCore::AudioTrackPrivateGStreamer*>(trackPrivate.get()));
    280     } else if (g_str_has_prefix(mediaType, "video")) {
     280    } else if (doCapsHaveType(caps, GST_VIDEO_CAPS_TYPE_PREFIX)) {
    281281        stream->type = Video;
    282282        stream->parent->priv->numberOfVideoStreams++;
    283283        signal = SIGNAL_VIDEO_CHANGED;
    284284        stream->videoTrack = RefPtr<WebCore::VideoTrackPrivateGStreamer>(static_cast<WebCore::VideoTrackPrivateGStreamer*>(trackPrivate.get()));
    285     } else if (g_str_has_prefix(mediaType, "text")) {
     285    } else if (doCapsHaveType(caps, GST_TEXT_CAPS_TYPE_PREFIX)) {
    286286        stream->type = Text;
    287287        stream->parent->priv->numberOfTextStreams++;
     
    296296}
    297297
    298 void PlaybackPipeline::reattachTrack(RefPtr<SourceBufferPrivateGStreamer> sourceBufferPrivate, RefPtr<TrackPrivateBase> trackPrivate, const char* mediaType)
     298void PlaybackPipeline::reattachTrack(RefPtr<SourceBufferPrivateGStreamer> sourceBufferPrivate, RefPtr<TrackPrivateBase> trackPrivate, GstCaps* caps)
    299299{
    300300    GST_DEBUG("Re-attaching track");
     
    314314
    315315    GST_OBJECT_LOCK(webKitMediaSrc);
    316     if (g_str_has_prefix(mediaType, "audio")) {
     316    if (doCapsHaveType(caps, GST_AUDIO_CAPS_TYPE_PREFIX)) {
    317317        ASSERT(stream->type == Audio);
    318318        signal = SIGNAL_AUDIO_CHANGED;
    319319        stream->audioTrack = RefPtr<WebCore::AudioTrackPrivateGStreamer>(static_cast<WebCore::AudioTrackPrivateGStreamer*>(trackPrivate.get()));
    320     } else if (g_str_has_prefix(mediaType, "video")) {
     320    } else if (doCapsHaveType(caps, GST_VIDEO_CAPS_TYPE_PREFIX)) {
    321321        ASSERT(stream->type == Video);
    322322        signal = SIGNAL_VIDEO_CHANGED;
    323323        stream->videoTrack = RefPtr<WebCore::VideoTrackPrivateGStreamer>(static_cast<WebCore::VideoTrackPrivateGStreamer*>(trackPrivate.get()));
    324     } else if (g_str_has_prefix(mediaType, "text")) {
     324    } else if (doCapsHaveType(caps, GST_TEXT_CAPS_TYPE_PREFIX)) {
    325325        ASSERT(stream->type == Text);
    326326        signal = SIGNAL_TEXT_CHANGED;
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/platform/graphics/gstreamer/mse/PlaybackPipeline.h

    r222388 r228680  
    5858    MediaSourcePrivate::AddStatus addSourceBuffer(RefPtr<SourceBufferPrivateGStreamer>);
    5959    void removeSourceBuffer(RefPtr<SourceBufferPrivateGStreamer>);
    60     void attachTrack(RefPtr<SourceBufferPrivateGStreamer>, RefPtr<TrackPrivateBase>, GstStructure*, GstCaps*);
    61     void reattachTrack(RefPtr<SourceBufferPrivateGStreamer>, RefPtr<TrackPrivateBase>, const char*);
     60    void attachTrack(RefPtr<SourceBufferPrivateGStreamer>, RefPtr<TrackPrivateBase>, GstCaps*);
     61    void reattachTrack(RefPtr<SourceBufferPrivateGStreamer>, RefPtr<TrackPrivateBase>, GstCaps*);
    6262    void notifyDurationChanged();
    6363
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp

    r222972 r228680  
    453453void webKitMediaSrcUpdatePresentationSize(GstCaps* caps, Stream* stream)
    454454{
    455     GstStructure* structure = gst_caps_get_structure(caps, 0);
    456     const gchar* structureName = gst_structure_get_name(structure);
    457     GstVideoInfo info;
    458 
    459455    GST_OBJECT_LOCK(stream->parent);
    460     if (g_str_has_prefix(structureName, "video/") && gst_video_info_from_caps(&info, caps)) {
    461         float width, height;
    462 
    463         // FIXME: Correct?.
    464         width = info.width;
    465         height = info.height * ((float) info.par_d / (float) info.par_n);
    466         stream->presentationSize = WebCore::FloatSize(width, height);
     456    if (WebCore::doCapsHaveType(caps, GST_VIDEO_CAPS_TYPE_PREFIX)) {
     457        std::optional<WebCore::FloatSize> size = WebCore::getVideoResolutionFromCaps(caps);
     458        if (size.has_value())
     459            stream->presentationSize = size.value();
     460        else
     461            stream->presentationSize = WebCore::FloatSize();
    467462    } else
    468463        stream->presentationSize = WebCore::FloatSize();
Note: See TracChangeset for help on using the changeset viewer.