summaryrefslogtreecommitdiff
path: root/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h')
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h238
1 files changed, 144 insertions, 94 deletions
diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
index 1990bb20b..953239b58 100644
--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
@@ -2,7 +2,9 @@
* Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2007 Collabora Ltd. All rights reserved.
* Copyright (C) 2007 Alp Toker <alp@atoker.com>
- * Copyright (C) 2009, 2010 Igalia S.L
+ * Copyright (C) 2009, 2010, 2011, 2012, 2013, 2015, 2016 Igalia S.L
+ * Copyright (C) 2014 Cable Television Laboratories, Inc.
+ * Copyright (C) 2015, 2016 Metrological Group B.V.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -32,185 +34,233 @@
#include <gst/gst.h>
#include <gst/pbutils/install-plugins.h>
#include <wtf/Forward.h>
+#include <wtf/RunLoop.h>
+#include <wtf/WeakPtr.h>
-#if ENABLE(MEDIA_SOURCE)
-#include "MediaSourceGStreamer.h"
+#if ENABLE(VIDEO_TRACK) && USE(GSTREAMER_MPEGTS)
+#include <wtf/text/AtomicStringHash.h>
#endif
typedef struct _GstBuffer GstBuffer;
typedef struct _GstMessage GstMessage;
typedef struct _GstElement GstElement;
+typedef struct _GstMpegtsSection GstMpegtsSection;
namespace WebCore {
+#if ENABLE(WEB_AUDIO)
+class AudioSourceProvider;
+class AudioSourceProviderGStreamer;
+#endif
+
class AudioTrackPrivateGStreamer;
+class InbandMetadataTextTrackPrivateGStreamer;
class InbandTextTrackPrivateGStreamer;
+class MediaPlayerRequestInstallMissingPluginsCallback;
class VideoTrackPrivateGStreamer;
+#if ENABLE(MEDIA_SOURCE)
+class MediaSourcePrivateClient;
+#endif
+
class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateGStreamerBase {
public:
- ~MediaPlayerPrivateGStreamer();
+ explicit MediaPlayerPrivateGStreamer(MediaPlayer*);
+ virtual ~MediaPlayerPrivateGStreamer();
+
static void registerMediaEngine(MediaEngineRegistrar);
- gboolean handleMessage(GstMessage*);
+ void handleMessage(GstMessage*);
void handlePluginInstallerResult(GstInstallPluginsReturn);
- bool hasVideo() const { return m_hasVideo; }
- bool hasAudio() const { return m_hasAudio; }
+ bool hasVideo() const override { return m_hasVideo; }
+ bool hasAudio() const override { return m_hasAudio; }
- void load(const String &url);
+ void load(const String &url) override;
#if ENABLE(MEDIA_SOURCE)
- void load(const String& url, PassRefPtr<HTMLMediaSource>);
+ void load(const String& url, MediaSourcePrivateClient*) override;
+#endif
+#if ENABLE(MEDIA_STREAM)
+ void load(MediaStreamPrivate&) override;
#endif
void commitLoad();
- void cancelLoad();
+ void cancelLoad() override;
- void prepareToPlay();
- void play();
- void pause();
+ void prepareToPlay() override;
+ void play() override;
+ void pause() override;
- bool paused() const;
- bool seeking() const;
+ bool paused() const override;
+ bool seeking() const override;
- float duration() const;
- float currentTime() const;
- void seek(float);
+ MediaTime durationMediaTime() const override;
+ MediaTime currentMediaTime() const override;
+ void seek(float) override;
- void setRate(float);
- void setPreservesPitch(bool);
+ void setRate(float) override;
+ double rate() const override;
+ void setPreservesPitch(bool) override;
- void setPreload(MediaPlayer::Preload);
- void fillTimerFired(Timer<MediaPlayerPrivateGStreamer>*);
+ void setPreload(MediaPlayer::Preload) override;
+ void fillTimerFired();
- PassRefPtr<TimeRanges> buffered() const;
- float maxTimeSeekable() const;
- bool didLoadingProgress() const;
- unsigned totalBytes() const;
- float maxTimeLoaded() const;
+ std::unique_ptr<PlatformTimeRanges> buffered() const override;
+ float maxTimeSeekable() const override;
+ bool didLoadingProgress() const override;
+ unsigned long long totalBytes() const override;
+ float maxTimeLoaded() const override;
+
+ bool hasSingleSecurityOrigin() const override;
void loadStateChanged();
void timeChanged();
void didEnd();
- void durationChanged();
+ virtual void durationChanged();
void loadingFailed(MediaPlayer::NetworkState);
- void videoChanged();
- void videoCapsChanged();
- void audioChanged();
- void notifyPlayerOfVideo();
- void notifyPlayerOfVideoCaps();
- void notifyPlayerOfAudio();
+ virtual void sourceChanged();
-#if ENABLE(VIDEO_TRACK)
- void textChanged();
- void notifyPlayerOfText();
+ GstElement* audioSink() const override;
+ virtual void configurePlaySink() { }
- void newTextSample();
- void notifyPlayerOfNewTextSample();
-#endif
+ void simulateAudioInterruption() override;
- void sourceChanged();
- GstElement* audioSink() const;
+ virtual bool changePipelineState(GstState);
- void setAudioStreamProperties(GObject*);
+#if ENABLE(WEB_AUDIO)
+ AudioSourceProvider* audioSourceProvider() override;
+#endif
- void simulateAudioInterruption();
+ bool isLiveStream() const override { return m_isStreaming; }
- bool changePipelineState(GstState);
+ bool handleSyncMessage(GstMessage*) override;
private:
- MediaPlayerPrivateGStreamer(MediaPlayer*);
-
- static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*);
-
- static void getSupportedTypes(HashSet<String>&);
+ static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>&);
static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
static bool isAvailable();
- GstElement* createAudioSink();
+ WeakPtr<MediaPlayerPrivateGStreamer> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
- float playbackPosition() const;
+ GstElement* createAudioSink() override;
- void cacheDuration();
- void updateStates();
- void asyncStateChangeDone();
+ double playbackPosition() const;
+
+ virtual void updateStates();
+ virtual void asyncStateChangeDone();
void createGSTPlayBin();
bool loadNextLocation();
void mediaLocationChanged(GstMessage*);
- void setDownloadBuffering();
+ virtual void setDownloadBuffering();
void processBufferingStats(GstMessage*);
+#if ENABLE(VIDEO_TRACK) && USE(GSTREAMER_MPEGTS)
+ void processMpegTsSection(GstMpegtsSection*);
+#endif
#if ENABLE(VIDEO_TRACK)
void processTableOfContents(GstMessage*);
- void processTableOfContentsEntry(GstTocEntry*, GstTocEntry* parent);
+ void processTableOfContentsEntry(GstTocEntry*);
#endif
- bool doSeek(gint64 position, float rate, GstSeekFlags seekType);
- void updatePlaybackRate();
+ virtual bool doSeek(gint64 position, float rate, GstSeekFlags seekType);
+ virtual void updatePlaybackRate();
+ String engineDescription() const override { return "GStreamer"; }
+ bool didPassCORSAccessCheck() const override;
+ bool canSaveMediaData() const override;
- virtual String engineDescription() const { return "GStreamer"; }
- virtual bool isLiveStream() const { return m_isStreaming; }
- virtual bool didPassCORSAccessCheck() const;
+ void purgeOldDownloadFiles(const char*);
+ static void uriDecodeBinElementAddedCallback(GstBin*, GstElement*, MediaPlayerPrivateGStreamer*);
+ static void downloadBufferFileCreatedCallback(MediaPlayerPrivateGStreamer*);
-private:
- GRefPtr<GstElement> m_playBin;
+protected:
+ void cacheDuration();
+
+ bool m_buffering;
+ int m_bufferingPercentage;
+ mutable float m_cachedPosition;
+ bool m_canFallBackToLastFinishedSeekPosition;
+ bool m_changingRate;
+ bool m_downloadFinished;
+ bool m_errorOccured;
+ mutable bool m_isEndReached;
+ mutable bool m_isStreaming;
+ mutable gdouble m_durationAtEOS;
+ bool m_paused;
+ float m_playbackRate;
+ GstState m_requestedState;
+ bool m_resetPipeline;
+ bool m_seeking;
+ bool m_seekIsPending;
+ float m_seekTime;
GRefPtr<GstElement> m_source;
+ bool m_volumeAndMuteInitialized;
+
+ void readyTimerFired();
+
+ void notifyPlayerOfVideo();
+ void notifyPlayerOfVideoCaps();
+ void notifyPlayerOfAudio();
+
+#if ENABLE(VIDEO_TRACK)
+ void notifyPlayerOfText();
+ void newTextSample();
+#endif
+
+ void ensureAudioSourceProvider();
+ void setAudioStreamProperties(GObject*);
+
+ static void setAudioStreamPropertiesCallback(MediaPlayerPrivateGStreamer*, GObject*);
+
+ static void sourceChangedCallback(MediaPlayerPrivateGStreamer*);
+ static void videoChangedCallback(MediaPlayerPrivateGStreamer*);
+ static void videoSinkCapsChangedCallback(MediaPlayerPrivateGStreamer*);
+ static void audioChangedCallback(MediaPlayerPrivateGStreamer*);
+#if ENABLE(VIDEO_TRACK)
+ static void textChangedCallback(MediaPlayerPrivateGStreamer*);
+ static GstFlowReturn newTextSampleCallback(MediaPlayerPrivateGStreamer*);
+#endif
+
+private:
+ WeakPtrFactory<MediaPlayerPrivateGStreamer> m_weakPtrFactory;
+
#if ENABLE(VIDEO_TRACK)
GRefPtr<GstElement> m_textAppSink;
GRefPtr<GstPad> m_textAppSinkPad;
#endif
- float m_seekTime;
- bool m_changingRate;
- float m_endTime;
- bool m_isEndReached;
- mutable bool m_isStreaming;
GstStructure* m_mediaLocations;
int m_mediaLocationCurrentIndex;
- bool m_resetPipeline;
- bool m_paused;
bool m_playbackRatePause;
- bool m_seeking;
- bool m_seekIsPending;
float m_timeOfOverlappingSeek;
- bool m_canFallBackToLastFinishedSeekPositon;
- bool m_buffering;
- float m_playbackRate;
float m_lastPlaybackRate;
- bool m_errorOccured;
- mutable gfloat m_mediaDuration;
- bool m_downloadFinished;
- Timer<MediaPlayerPrivateGStreamer> m_fillTimer;
+ Timer m_fillTimer;
float m_maxTimeLoaded;
- int m_bufferingPercentage;
MediaPlayer::Preload m_preload;
bool m_delayingLoad;
- bool m_mediaDurationKnown;
mutable float m_maxTimeLoadedAtLastDidLoadingProgress;
- bool m_volumeAndMuteInitialized;
bool m_hasVideo;
bool m_hasAudio;
- guint m_audioTimerHandler;
- guint m_textTimerHandler;
- guint m_videoTimerHandler;
- guint m_videoCapsTimerHandler;
- guint m_readyTimerHandler;
- mutable long m_totalBytes;
+ RunLoop::Timer<MediaPlayerPrivateGStreamer> m_readyTimerHandler;
+ mutable unsigned long long m_totalBytes;
URL m_url;
bool m_preservesPitch;
- GstState m_requestedState;
+#if ENABLE(WEB_AUDIO)
+ std::unique_ptr<AudioSourceProviderGStreamer> m_audioSourceProvider;
+#endif
GRefPtr<GstElement> m_autoAudioSink;
- bool m_missingPlugins;
+ GRefPtr<GstElement> m_downloadBuffer;
+ RefPtr<MediaPlayerRequestInstallMissingPluginsCallback> m_missingPluginsCallback;
#if ENABLE(VIDEO_TRACK)
Vector<RefPtr<AudioTrackPrivateGStreamer>> m_audioTracks;
Vector<RefPtr<InbandTextTrackPrivateGStreamer>> m_textTracks;
Vector<RefPtr<VideoTrackPrivateGStreamer>> m_videoTracks;
- RefPtr<InbandTextTrackPrivate> m_chaptersTrack;
+ RefPtr<InbandMetadataTextTrackPrivateGStreamer> m_chaptersTrack;
#endif
-#if ENABLE(MEDIA_SOURCE)
- RefPtr<HTMLMediaSource> m_mediaSource;
+#if ENABLE(VIDEO_TRACK) && USE(GSTREAMER_MPEGTS)
+ HashMap<AtomicString, RefPtr<InbandMetadataTextTrackPrivateGStreamer>> m_metadataTracks;
#endif
+ virtual bool isMediaSource() const { return false; }
};
}