Changeset 207879 in webkit


Ignore:
Timestamp:
Oct 26, 2016 1:40:33 AM (8 years ago)
Author:
eocanha@igalia.com
Message:

[GStreamer][MSE] SourceBufferPrivateGStreamer refactoring
https://bugs.webkit.org/show_bug.cgi?id=162898

Reviewed by Xabier Rodriguez-Calvar.

Moved SourceBufferPrivateGStreamer to an mse directory and added unimplemented features (abort, enqueueing and sample flow control).

  • platform/graphics/gstreamer/SourceBufferPrivateGStreamer.cpp: Removed.
  • platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp: Added.

(WebCore::SourceBufferPrivateGStreamer::create):
(WebCore::SourceBufferPrivateGStreamer::SourceBufferPrivateGStreamer):
(WebCore::SourceBufferPrivateGStreamer::~SourceBufferPrivateGStreamer):
(WebCore::SourceBufferPrivateGStreamer::setClient):
(WebCore::SourceBufferPrivateGStreamer::append):
(WebCore::SourceBufferPrivateGStreamer::abort):
(WebCore::SourceBufferPrivateGStreamer::resetParserState):
(WebCore::SourceBufferPrivateGStreamer::removedFromMediaSource):
(WebCore::SourceBufferPrivateGStreamer::readyState):
(WebCore::SourceBufferPrivateGStreamer::setReadyState):
(WebCore::SourceBufferPrivateGStreamer::flushAndEnqueueNonDisplayingSamples):
(WebCore::SourceBufferPrivateGStreamer::enqueueSample):
(WebCore::SourceBufferPrivateGStreamer::isReadyForMoreSamples):
(WebCore::SourceBufferPrivateGStreamer::setReadyForMoreSamples):
(WebCore::SourceBufferPrivateGStreamer::notifyReadyForMoreSamples):
(WebCore::SourceBufferPrivateGStreamer::setActive):
(WebCore::SourceBufferPrivateGStreamer::stopAskingForMoreSamples):
(WebCore::SourceBufferPrivateGStreamer::notifyClientWhenReadyForMoreSamples):
(WebCore::SourceBufferPrivateGStreamer::didReceiveInitializationSegment):
(WebCore::SourceBufferPrivateGStreamer::didReceiveSample):
(WebCore::SourceBufferPrivateGStreamer::didReceiveAllPendingSamples):

  • platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h: Renamed from Source/WebCore/platform/graphics/gstreamer/SourceBufferPrivateGStreamer.h.
Location:
trunk/Source/WebCore
Files:
1 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207878 r207879  
     12016-10-26  Enrique Ocaña González  <eocanha@igalia.com>
     2
     3        [GStreamer][MSE] SourceBufferPrivateGStreamer refactoring
     4        https://bugs.webkit.org/show_bug.cgi?id=162898
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        Moved SourceBufferPrivateGStreamer to an mse directory and added unimplemented features (abort, enqueueing and sample flow control).
     9
     10        * platform/graphics/gstreamer/SourceBufferPrivateGStreamer.cpp: Removed.
     11        * platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp: Added.
     12        (WebCore::SourceBufferPrivateGStreamer::create):
     13        (WebCore::SourceBufferPrivateGStreamer::SourceBufferPrivateGStreamer):
     14        (WebCore::SourceBufferPrivateGStreamer::~SourceBufferPrivateGStreamer):
     15        (WebCore::SourceBufferPrivateGStreamer::setClient):
     16        (WebCore::SourceBufferPrivateGStreamer::append):
     17        (WebCore::SourceBufferPrivateGStreamer::abort):
     18        (WebCore::SourceBufferPrivateGStreamer::resetParserState):
     19        (WebCore::SourceBufferPrivateGStreamer::removedFromMediaSource):
     20        (WebCore::SourceBufferPrivateGStreamer::readyState):
     21        (WebCore::SourceBufferPrivateGStreamer::setReadyState):
     22        (WebCore::SourceBufferPrivateGStreamer::flushAndEnqueueNonDisplayingSamples):
     23        (WebCore::SourceBufferPrivateGStreamer::enqueueSample):
     24        (WebCore::SourceBufferPrivateGStreamer::isReadyForMoreSamples):
     25        (WebCore::SourceBufferPrivateGStreamer::setReadyForMoreSamples):
     26        (WebCore::SourceBufferPrivateGStreamer::notifyReadyForMoreSamples):
     27        (WebCore::SourceBufferPrivateGStreamer::setActive):
     28        (WebCore::SourceBufferPrivateGStreamer::stopAskingForMoreSamples):
     29        (WebCore::SourceBufferPrivateGStreamer::notifyClientWhenReadyForMoreSamples):
     30        (WebCore::SourceBufferPrivateGStreamer::didReceiveInitializationSegment):
     31        (WebCore::SourceBufferPrivateGStreamer::didReceiveSample):
     32        (WebCore::SourceBufferPrivateGStreamer::didReceiveAllPendingSamples):
     33        * platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h: Renamed from Source/WebCore/platform/graphics/gstreamer/SourceBufferPrivateGStreamer.h.
     34
    1352016-10-26  Enrique Ocaña González  <eocanha@igalia.com>
    236
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp

    r207878 r207879  
    33 * Copyright (C) 2013 Orange
    44 * Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
     5 * Copyright (C) 2015, 2016 Metrological Group B.V.
     6 * Copyright (C) 2015, 2016 Igalia, S.L
    57 *
    68 * Redistribution and use in source and binary forms, with or without
     
    3739
    3840#include "ContentType.h"
     41#include "GStreamerUtilities.h"
     42#include "MediaPlayerPrivateGStreamerMSE.h"
     43#include "MediaSample.h"
     44#include "MediaSourceClientGStreamerMSE.h"
     45#include "MediaSourceGStreamer.h"
    3946#include "NotImplemented.h"
     47#include "WebKitMediaSourceGStreamer.h"
    4048
    4149namespace WebCore {
    4250
    43 Ref<SourceBufferPrivateGStreamer> SourceBufferPrivateGStreamer::create(MediaSourceClientGStreamer& client, const ContentType& contentType)
     51Ref<SourceBufferPrivateGStreamer> SourceBufferPrivateGStreamer::create(MediaSourceGStreamer* mediaSource, Ref<MediaSourceClientGStreamerMSE> client, const ContentType& contentType)
    4452{
    45     return adoptRef(*new SourceBufferPrivateGStreamer(client, contentType));
     53    return adoptRef(*new SourceBufferPrivateGStreamer(mediaSource, client.get(), contentType));
    4654}
    4755
    48 SourceBufferPrivateGStreamer::SourceBufferPrivateGStreamer(MediaSourceClientGStreamer& client, const ContentType& contentType)
    49     : m_type(contentType)
    50     , m_client(&client)
    51     , m_readyState(MediaPlayer::HaveNothing)
    52 {
    53 }
    54 
    55 SourceBufferPrivateGStreamer::~SourceBufferPrivateGStreamer()
     56SourceBufferPrivateGStreamer::SourceBufferPrivateGStreamer(MediaSourceGStreamer* mediaSource, Ref<MediaSourceClientGStreamerMSE> client, const ContentType& contentType)
     57    : SourceBufferPrivate()
     58    , m_mediaSource(mediaSource)
     59    , m_type(contentType)
     60    , m_client(client.get())
    5661{
    5762}
     
    6469void SourceBufferPrivateGStreamer::append(const unsigned char* data, unsigned length)
    6570{
    66     ASSERT(m_client);
    67     ASSERT(m_sourceBufferPrivateClient);
     71    ASSERT(m_mediaSource);
    6872
    69     SourceBufferPrivateClient::AppendResult result = m_client->append(this, data, length);
    70     m_sourceBufferPrivateClient->sourceBufferPrivateAppendComplete(this, result);
     73    if (!m_sourceBufferPrivateClient)
     74        return;
     75
     76    if (m_client->append(this, data, length))
     77        return;
     78
     79    m_sourceBufferPrivateClient->sourceBufferPrivateAppendComplete(this, SourceBufferPrivateClient::ReadStreamFailed);
    7180}
    7281
    7382void SourceBufferPrivateGStreamer::abort()
    7483{
    75     notImplemented();
     84    m_client->abort(this);
    7685}
    7786
     
    8392void SourceBufferPrivateGStreamer::removedFromMediaSource()
    8493{
     94    if (m_mediaSource)
     95        m_mediaSource->removeSourceBuffer(this);
    8596    m_client->removedFromMediaSource(this);
    8697}
     
    8899MediaPlayer::ReadyState SourceBufferPrivateGStreamer::readyState() const
    89100{
    90     return m_readyState;
     101    return m_mediaSource->readyState();
    91102}
    92103
    93104void SourceBufferPrivateGStreamer::setReadyState(MediaPlayer::ReadyState state)
    94105{
    95     m_readyState = state;
     106    m_mediaSource->setReadyState(state);
    96107}
    97108
    98 // TODO: Implement these
    99 void SourceBufferPrivateGStreamer::flushAndEnqueueNonDisplayingSamples(Vector<RefPtr<MediaSample>>, AtomicString)
     109void SourceBufferPrivateGStreamer::flush(AtomicString trackId)
    100110{
    101     notImplemented();
     111    m_client->flush(trackId);
    102112}
    103113
    104 void SourceBufferPrivateGStreamer::enqueueSample(PassRefPtr<MediaSample>, AtomicString)
     114void SourceBufferPrivateGStreamer::enqueueSample(PassRefPtr<MediaSample> prpSample, AtomicString)
    105115{
    106     notImplemented();
     116    m_notifyWhenReadyForMoreSamples = false;
     117
     118    RefPtr<MediaSample> protectedPrpSample = prpSample;
     119    m_client->enqueueSample(protectedPrpSample);
    107120}
    108121
    109122bool SourceBufferPrivateGStreamer::isReadyForMoreSamples(AtomicString)
    110123{
    111     notImplemented();
    112 
    113     return false;
     124    return m_isReadyForMoreSamples;
    114125}
    115126
    116 void SourceBufferPrivateGStreamer::setActive(bool)
     127void SourceBufferPrivateGStreamer::setReadyForMoreSamples(bool isReady)
    117128{
    118     notImplemented();
     129    ASSERT(WTF::isMainThread());
     130    m_isReadyForMoreSamples = isReady;
     131}
     132
     133void SourceBufferPrivateGStreamer::notifyReadyForMoreSamples()
     134{
     135    ASSERT(WTF::isMainThread());
     136    setReadyForMoreSamples(true);
     137    if (m_notifyWhenReadyForMoreSamples)
     138        m_sourceBufferPrivateClient->sourceBufferPrivateDidBecomeReadyForMoreSamples(this, m_trackId);
     139}
     140
     141void SourceBufferPrivateGStreamer::setActive(bool isActive)
     142{
     143    if (m_mediaSource)
     144        m_mediaSource->sourceBufferPrivateDidChangeActiveState(this, isActive);
    119145}
    120146
     
    124150}
    125151
    126 void SourceBufferPrivateGStreamer::notifyClientWhenReadyForMoreSamples(AtomicString)
     152void SourceBufferPrivateGStreamer::notifyClientWhenReadyForMoreSamples(AtomicString trackId)
    127153{
    128     notImplemented();
     154    ASSERT(WTF::isMainThread());
     155    m_notifyWhenReadyForMoreSamples = true;
     156    m_trackId = trackId;
     157}
     158
     159void SourceBufferPrivateGStreamer::didReceiveInitializationSegment(const SourceBufferPrivateClient::InitializationSegment& initializationSegment)
     160{
     161    if (m_sourceBufferPrivateClient)
     162        m_sourceBufferPrivateClient->sourceBufferPrivateDidReceiveInitializationSegment(this, initializationSegment);
     163}
     164
     165void SourceBufferPrivateGStreamer::didReceiveSample(PassRefPtr<MediaSample> prpSample)
     166{
     167    RefPtr<MediaSample> protectedPrpSample = prpSample;
     168    if (m_sourceBufferPrivateClient)
     169        m_sourceBufferPrivateClient->sourceBufferPrivateDidReceiveSample(this, *protectedPrpSample);
     170}
     171
     172void SourceBufferPrivateGStreamer::didReceiveAllPendingSamples()
     173{
     174    if (m_sourceBufferPrivateClient)
     175        m_sourceBufferPrivateClient->sourceBufferPrivateAppendComplete(this, SourceBufferPrivateClient::AppendSucceeded);
    129176}
    130177
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h

    r207878 r207879  
    33 * Copyright (C) 2013 Orange
    44 * Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
     5 * Copyright (C) 2015, 2016 Metrological Group B.V.
     6 * Copyright (C) 2015, 2016 Igalia, S.L
    57 *
    68 * Redistribution and use in source and binary forms, with or without
     
    3133 */
    3234
    33 #ifndef SourceBufferPrivateGStreamer_h
    34 #define SourceBufferPrivateGStreamer_h
     35#pragma once
    3536
    3637#if ENABLE(MEDIA_SOURCE) && USE(GSTREAMER)
    3738
    3839#include "ContentType.h"
     40#include "MediaPlayerPrivateGStreamerMSE.h"
    3941#include "SourceBufferPrivate.h"
     42#include "SourceBufferPrivateClient.h"
    4043#include "WebKitMediaSourceGStreamer.h"
    4144
    4245namespace WebCore {
    4346
     47class MediaSourceGStreamer;
     48
    4449class SourceBufferPrivateGStreamer final : public SourceBufferPrivate {
     50
    4551public:
    46     static Ref<SourceBufferPrivateGStreamer> create(MediaSourceClientGStreamer&, const ContentType&);
    47     virtual ~SourceBufferPrivateGStreamer();
     52    static Ref<SourceBufferPrivateGStreamer> create(MediaSourceGStreamer*, Ref<MediaSourceClientGStreamerMSE>, const ContentType&);
     53    virtual ~SourceBufferPrivateGStreamer() = default;
    4854
    49     virtual void setClient(SourceBufferPrivateClient*);
     55    void clearMediaSource() { m_mediaSource = nullptr; }
    5056
    51     virtual void append(const unsigned char* data, unsigned length);
    52     virtual void abort();
    53     virtual void resetParserState();
    54     virtual void removedFromMediaSource();
     57    void setClient(SourceBufferPrivateClient*) override;
     58    void append(const unsigned char*, unsigned) override;
     59    void abort() override;
     60    void resetParserState() override;
     61    void removedFromMediaSource() override;
     62    MediaPlayer::ReadyState readyState() const override;
     63    void setReadyState(MediaPlayer::ReadyState) override;
    5564
    56     virtual MediaPlayer::ReadyState readyState() const;
    57     virtual void setReadyState(MediaPlayer::ReadyState);
     65    void flush(AtomicString) override;
     66    void enqueueSample(PassRefPtr<MediaSample>, AtomicString) override;
     67    bool isReadyForMoreSamples(AtomicString) override;
     68    void setActive(bool) override;
     69    void stopAskingForMoreSamples(AtomicString) override;
     70    void notifyClientWhenReadyForMoreSamples(AtomicString) override;
    5871
    59     virtual void flushAndEnqueueNonDisplayingSamples(Vector<RefPtr<MediaSample>>, AtomicString);
    60     virtual void enqueueSample(PassRefPtr<MediaSample>, AtomicString);
    61     virtual bool isReadyForMoreSamples(AtomicString);
    62     virtual void setActive(bool);
    63     virtual void stopAskingForMoreSamples(AtomicString);
    64     virtual void notifyClientWhenReadyForMoreSamples(AtomicString);
     72    void setReadyForMoreSamples(bool);
     73    void notifyReadyForMoreSamples();
     74
     75    void didReceiveInitializationSegment(const SourceBufferPrivateClient::InitializationSegment&);
     76    void didReceiveSample(PassRefPtr<MediaSample>);
     77    void didReceiveAllPendingSamples();
    6578
    6679private:
    67     SourceBufferPrivateGStreamer(MediaSourceClientGStreamer&, const ContentType&);
     80    SourceBufferPrivateGStreamer(MediaSourceGStreamer*, Ref<MediaSourceClientGStreamerMSE>, const ContentType&);
     81    friend class MediaSourceClientGStreamerMSE;
    6882
     83    MediaSourceGStreamer* m_mediaSource;
    6984    ContentType m_type;
    70     RefPtr<MediaSourceClientGStreamer> m_client;
     85    Ref<MediaSourceClientGStreamerMSE> m_client;
    7186    SourceBufferPrivateClient* m_sourceBufferPrivateClient;
    72     MediaPlayer::ReadyState m_readyState;
     87    bool m_isReadyForMoreSamples = true;
     88    bool m_notifyWhenReadyForMoreSamples = false;
     89    AtomicString m_trackId;
    7390};
    7491
     
    7693
    7794#endif
    78 #endif
Note: See TracChangeset for help on using the changeset viewer.