diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/platform/mock/mediasource | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/platform/mock/mediasource')
10 files changed, 290 insertions, 238 deletions
diff --git a/Source/WebCore/platform/mock/mediasource/MockBox.cpp b/Source/WebCore/platform/mock/mediasource/MockBox.cpp index 286e81b49..c8b134e51 100644 --- a/Source/WebCore/platform/mock/mediasource/MockBox.cpp +++ b/Source/WebCore/platform/mock/mediasource/MockBox.cpp @@ -10,10 +10,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -28,9 +28,13 @@ #if ENABLE(MEDIA_SOURCE) +#include <JavaScriptCore/HeapInlines.h> +#include <JavaScriptCore/JSCJSValueInlines.h> +#include <JavaScriptCore/TypedArrayInlines.h> #include <runtime/ArrayBuffer.h> #include <runtime/DataView.h> #include <runtime/Int8Array.h> +#include <wtf/NeverDestroyed.h> #include <wtf/text/StringBuilder.h> namespace WebCore { @@ -76,7 +80,7 @@ MockTrackBox::MockTrackBox(ArrayBuffer* data) const String& MockTrackBox::type() { - DEFINE_STATIC_LOCAL(String, trak, (ASCIILiteral("trak"))); + static NeverDestroyed<String> trak(ASCIILiteral("trak")); return trak; } @@ -105,14 +109,14 @@ MockInitializationBox::MockInitializationBox(ArrayBuffer* data) const String& MockInitializationBox::type() { - DEFINE_STATIC_LOCAL(String, init, (ASCIILiteral("init"))); + static NeverDestroyed<String> init(ASCIILiteral("init")); return init; } MockSampleBox::MockSampleBox(ArrayBuffer* data) : MockBox(data) { - ASSERT(m_length == 29); + ASSERT(m_length == 30); RefPtr<JSC::DataView> view = JSC::DataView::create(data, 0, data->byteLength()); int32_t timeScale = view->get<int32_t>(8, true); @@ -128,11 +132,12 @@ MockSampleBox::MockSampleBox(ArrayBuffer* data) m_trackID = view->get<int32_t>(24, true); m_flags = view->get<uint8_t>(28, true); + m_generation = view->get<uint8_t>(29, true); } const String& MockSampleBox::type() { - DEFINE_STATIC_LOCAL(String, smpl, (ASCIILiteral("smpl"))); + static NeverDestroyed<String> smpl(ASCIILiteral("smpl")); return smpl; } diff --git a/Source/WebCore/platform/mock/mediasource/MockBox.h b/Source/WebCore/platform/mock/mediasource/MockBox.h index 6ddc21c47..2cc530fe3 100644 --- a/Source/WebCore/platform/mock/mediasource/MockBox.h +++ b/Source/WebCore/platform/mock/mediasource/MockBox.h @@ -10,10 +10,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -117,6 +117,7 @@ protected: // 4 bytes : signed : duration time value // 4 bytes : signed : track ID // 1 byte : unsigned : flags +// 1 byte : unsigned : generation // class MockSampleBox final : public MockBox { public: @@ -128,17 +129,33 @@ public: MediaTime duration() const { return m_duration; } int32_t trackID() const { return m_trackID; } uint8_t flags() const { return m_flags; } + uint8_t generation() const { return m_generation; } + void offsetTimestampsBy(const MediaTime& offset) + { + m_presentationTimestamp += offset; + m_decodeTimestamp += offset; + } + void setTimestamps(const MediaTime& presentationTimestamp, const MediaTime& decodeTimestamp) + { + m_presentationTimestamp = presentationTimestamp; + m_decodeTimestamp = decodeTimestamp; + } + + void clearFlag(uint8_t flag) { m_flags &= ~flag; } + void setFlag(uint8_t flag) { m_flags |= flag; } enum { IsSync = 1 << 0, IsCorrupted = 1 << 1, IsDropped = 1 << 2, IsDelayed = 1 << 3, + IsNonDisplaying = 1 << 4, }; bool isSync() const { return m_flags & IsSync; } bool isCorrupted() const { return m_flags & IsCorrupted; } bool isDropped() const { return m_flags & IsDropped; } bool isDelayed() const { return m_flags & IsDelayed; } + bool isNonDisplaying() const { return m_flags & IsNonDisplaying; } protected: MediaTime m_presentationTimestamp; @@ -146,6 +163,7 @@ protected: MediaTime m_duration; int32_t m_trackID; uint8_t m_flags; + uint8_t m_generation; }; } diff --git a/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp b/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp index e0fc51c9f..4e40c8e73 100644 --- a/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp +++ b/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013-2015 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,10 +10,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -28,12 +28,11 @@ #if ENABLE(MEDIA_SOURCE) -#include "ExceptionCodePlaceholder.h" -#include "HTMLMediaSource.h" #include "MediaPlayer.h" +#include "MediaSourcePrivateClient.h" #include "MockMediaSourcePrivate.h" -#include <wtf/Functional.h> #include <wtf/MainThread.h> +#include <wtf/NeverDestroyed.h> #include <wtf/text/WTFString.h> namespace WebCore { @@ -41,28 +40,25 @@ namespace WebCore { // MediaPlayer Enigne Support void MockMediaPlayerMediaSource::registerMediaEngine(MediaEngineRegistrar registrar) { - registrar(create, getSupportedTypes, supportsType, 0, 0, 0); + registrar([](MediaPlayer* player) { return std::make_unique<MockMediaPlayerMediaSource>(player); }, getSupportedTypes, + supportsType, 0, 0, 0, 0); } -PassOwnPtr<MediaPlayerPrivateInterface> MockMediaPlayerMediaSource::create(MediaPlayer* player) +static const HashSet<String, ASCIICaseInsensitiveHash>& mimeTypeCache() { - return adoptPtr(new MockMediaPlayerMediaSource(player)); -} - -static HashSet<String> mimeTypeCache() -{ - DEFINE_STATIC_LOCAL(HashSet<String>, cache, ()); + static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache; static bool isInitialized = false; if (!isInitialized) { isInitialized = true; - cache.add(ASCIILiteral("video/mock")); + cache.get().add(ASCIILiteral("video/mock")); + cache.get().add(ASCIILiteral("audio/mock")); } return cache; } -void MockMediaPlayerMediaSource::getSupportedTypes(HashSet<String>& supportedTypes) +void MockMediaPlayerMediaSource::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& supportedTypes) { supportedTypes = mimeTypeCache(); } @@ -72,7 +68,7 @@ MediaPlayer::SupportsType MockMediaPlayerMediaSource::supportsType(const MediaEn if (!parameters.isMediaSource) return MediaPlayer::IsNotSupported; - if (!mimeTypeCache().contains(parameters.type)) + if (parameters.type.isEmpty() || !mimeTypeCache().contains(parameters.type)) return MediaPlayer::IsNotSupported; if (parameters.codecs.isEmpty()) @@ -84,10 +80,10 @@ MediaPlayer::SupportsType MockMediaPlayerMediaSource::supportsType(const MediaEn MockMediaPlayerMediaSource::MockMediaPlayerMediaSource(MediaPlayer* player) : m_player(player) , m_currentTime(MediaTime::zeroTime()) - , m_duration(0) , m_readyState(MediaPlayer::HaveNothing) , m_networkState(MediaPlayer::Empty) , m_playing(false) + , m_seekCompleted(true) { } @@ -100,11 +96,9 @@ void MockMediaPlayerMediaSource::load(const String&) ASSERT_NOT_REACHED(); } -void MockMediaPlayerMediaSource::load(const String&, PassRefPtr<HTMLMediaSource> source) +void MockMediaPlayerMediaSource::load(const String&, MediaSourcePrivateClient* source) { - m_mediaSource = source; - m_mediaSourcePrivate = MockMediaSourcePrivate::create(this); - m_mediaSource->setPrivateAndOpen(*m_mediaSourcePrivate); + m_mediaSourcePrivate = MockMediaSourcePrivate::create(this, source); } void MockMediaPlayerMediaSource::cancelLoad() @@ -114,7 +108,9 @@ void MockMediaPlayerMediaSource::cancelLoad() void MockMediaPlayerMediaSource::play() { m_playing = 1; - callOnMainThread(bind(&MockMediaPlayerMediaSource::advanceCurrentTime, this)); + callOnMainThread([this] { + advanceCurrentTime(); + }); } void MockMediaPlayerMediaSource::pause() @@ -122,9 +118,9 @@ void MockMediaPlayerMediaSource::pause() m_playing = 0; } -IntSize MockMediaPlayerMediaSource::naturalSize() const +FloatSize MockMediaPlayerMediaSource::naturalSize() const { - return IntSize(); + return FloatSize(); } bool MockMediaPlayerMediaSource::hasVideo() const @@ -143,7 +139,7 @@ void MockMediaPlayerMediaSource::setVisible(bool) bool MockMediaPlayerMediaSource::seeking() const { - return false; + return !m_seekCompleted; } bool MockMediaPlayerMediaSource::paused() const @@ -161,14 +157,17 @@ MediaPlayer::ReadyState MockMediaPlayerMediaSource::readyState() const return m_readyState; } -double MockMediaPlayerMediaSource::maxTimeSeekableDouble() const +MediaTime MockMediaPlayerMediaSource::maxMediaTimeSeekable() const { return m_duration; } -PassRefPtr<TimeRanges> MockMediaPlayerMediaSource::buffered() const +std::unique_ptr<PlatformTimeRanges> MockMediaPlayerMediaSource::buffered() const { - return m_mediaSource ? m_mediaSource->buffered() : TimeRanges::create(); + if (m_mediaSourcePrivate) + return m_mediaSourcePrivate->buffered(); + + return std::make_unique<PlatformTimeRanges>(); } bool MockMediaPlayerMediaSource::didLoadingProgress() const @@ -180,45 +179,54 @@ void MockMediaPlayerMediaSource::setSize(const IntSize&) { } -void MockMediaPlayerMediaSource::paint(GraphicsContext*, const IntRect&) +void MockMediaPlayerMediaSource::paint(GraphicsContext&, const FloatRect&) { } -double MockMediaPlayerMediaSource::currentTimeDouble() const +MediaTime MockMediaPlayerMediaSource::currentMediaTime() const { - return m_currentTime.toDouble(); + return m_currentTime; } -double MockMediaPlayerMediaSource::durationDouble() const +MediaTime MockMediaPlayerMediaSource::durationMediaTime() const { - return m_duration; + return m_mediaSourcePrivate ? m_mediaSourcePrivate->duration() : MediaTime::zeroTime(); } -void MockMediaPlayerMediaSource::seekWithTolerance(double time, double negativeTolerance, double positiveTolerance) +void MockMediaPlayerMediaSource::seekWithTolerance(const MediaTime& time, const MediaTime& negativeTolerance, const MediaTime& positiveTolerance) { if (!negativeTolerance && !positiveTolerance) { - m_currentTime = MediaTime::createWithDouble(time); - m_mediaSourcePrivate->seekToTime(MediaTime::createWithDouble(time)); + m_currentTime = time; + m_mediaSourcePrivate->seekToTime(time); } else - m_currentTime = m_mediaSourcePrivate->seekToTime(MediaTime::createWithDouble(time), MediaTime::createWithDouble(negativeTolerance), MediaTime::createWithDouble(positiveTolerance)); - m_player->timeChanged(); + m_currentTime = m_mediaSourcePrivate->seekToTime(time, negativeTolerance, positiveTolerance); - if (m_playing) - callOnMainThread(bind(&MockMediaPlayerMediaSource::advanceCurrentTime, this)); + if (m_seekCompleted) { + m_player->timeChanged(); + + if (m_playing) + callOnMainThread([this] { + advanceCurrentTime(); + }); + } } void MockMediaPlayerMediaSource::advanceCurrentTime() { - RefPtr<TimeRanges> buffered = this->buffered(); - size_t pos = buffered->find(m_currentTime.toDouble()); + if (!m_mediaSourcePrivate) + return; + + auto buffered = m_mediaSourcePrivate->buffered(); + size_t pos = buffered->find(m_currentTime); if (pos == notFound) return; - m_currentTime = MediaTime::createWithDouble(std::min(m_duration, buffered->end(pos, IGNORE_EXCEPTION))); + bool ignoreError; + m_currentTime = std::min(m_duration, buffered->end(pos, ignoreError)); m_player->timeChanged(); } -void MockMediaPlayerMediaSource::updateDuration(double duration) +void MockMediaPlayerMediaSource::updateDuration(const MediaTime& duration) { if (m_duration == duration) return; @@ -245,6 +253,25 @@ void MockMediaPlayerMediaSource::setNetworkState(MediaPlayer::NetworkState netwo m_player->networkStateChanged(); } +void MockMediaPlayerMediaSource::waitForSeekCompleted() +{ + m_seekCompleted = false; +} + +void MockMediaPlayerMediaSource::seekCompleted() +{ + if (m_seekCompleted) + return; + m_seekCompleted = true; + + m_player->timeChanged(); + + if (m_playing) + callOnMainThread([this] { + advanceCurrentTime(); + }); +} + unsigned long MockMediaPlayerMediaSource::totalVideoFrames() { return m_mediaSourcePrivate ? m_mediaSourcePrivate->totalVideoFrames() : 0; @@ -260,9 +287,9 @@ unsigned long MockMediaPlayerMediaSource::corruptedVideoFrames() return m_mediaSourcePrivate ? m_mediaSourcePrivate->corruptedVideoFrames() : 0; } -double MockMediaPlayerMediaSource::totalFrameDelay() +MediaTime MockMediaPlayerMediaSource::totalFrameDelay() { - return m_mediaSourcePrivate ? m_mediaSourcePrivate->totalFrameDelay() : 0; + return m_mediaSourcePrivate ? m_mediaSourcePrivate->totalFrameDelay() : MediaTime::zeroTime(); } } diff --git a/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h b/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h index cd8d794ab..d03e4a06e 100644 --- a/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h +++ b/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h @@ -10,10 +10,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -38,59 +38,63 @@ class MockMediaSourcePrivate; class MockMediaPlayerMediaSource : public MediaPlayerPrivateInterface { public: + explicit MockMediaPlayerMediaSource(MediaPlayer*); + // MediaPlayer Engine Support - static void registerMediaEngine(MediaEngineRegistrar); - static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*); - static void getSupportedTypes(HashSet<String>& types); + WEBCORE_EXPORT static void registerMediaEngine(MediaEngineRegistrar); + static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types); static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&); virtual ~MockMediaPlayerMediaSource(); void advanceCurrentTime(); - void updateDuration(double); + void updateDuration(const MediaTime&); - virtual MediaPlayer::ReadyState readyState() const override; + MediaPlayer::ReadyState readyState() const override; void setReadyState(MediaPlayer::ReadyState); void setNetworkState(MediaPlayer::NetworkState); + void waitForSeekCompleted(); + void seekCompleted(); private: - MockMediaPlayerMediaSource(MediaPlayer*); - // MediaPlayerPrivate Overrides - virtual void load(const String& url) override; - virtual void load(const String& url, PassRefPtr<HTMLMediaSource>) override; - virtual void cancelLoad() override; - virtual void play() override; - virtual void pause() override; - virtual IntSize naturalSize() const override; - virtual bool hasVideo() const override; - virtual bool hasAudio() const override; - virtual void setVisible(bool) override; - virtual bool seeking() const override; - virtual bool paused() const override; - virtual MediaPlayer::NetworkState networkState() const override; - virtual double maxTimeSeekableDouble() const override; - virtual PassRefPtr<TimeRanges> buffered() const override; - virtual bool didLoadingProgress() const override; - virtual void setSize(const IntSize&) override; - virtual void paint(GraphicsContext*, const IntRect&) override; - virtual double currentTimeDouble() const override; - virtual double durationDouble() const override; - virtual void seekWithTolerance(double time, double, double) override; - virtual unsigned long totalVideoFrames() override; - virtual unsigned long droppedVideoFrames() override; - virtual unsigned long corruptedVideoFrames() override; - virtual double totalFrameDelay() override; + void load(const String& url) override; + void load(const String& url, MediaSourcePrivateClient*) override; +#if ENABLE(MEDIA_STREAM) + void load(MediaStreamPrivate&) override { } +#endif + void cancelLoad() override; + void play() override; + void pause() override; + FloatSize naturalSize() const override; + bool hasVideo() const override; + bool hasAudio() const override; + void setVisible(bool) override; + bool seeking() const override; + bool paused() const override; + MediaPlayer::NetworkState networkState() const override; + MediaTime maxMediaTimeSeekable() const override; + std::unique_ptr<PlatformTimeRanges> buffered() const override; + bool didLoadingProgress() const override; + void setSize(const IntSize&) override; + void paint(GraphicsContext&, const FloatRect&) override; + MediaTime currentMediaTime() const override; + MediaTime durationMediaTime() const override; + void seekWithTolerance(const MediaTime&, const MediaTime&, const MediaTime&) override; + unsigned long totalVideoFrames() override; + unsigned long droppedVideoFrames() override; + unsigned long corruptedVideoFrames() override; + MediaTime totalFrameDelay() override; MediaPlayer* m_player; - RefPtr<HTMLMediaSource> m_mediaSource; RefPtr<MockMediaSourcePrivate> m_mediaSourcePrivate; MediaTime m_currentTime; - double m_duration; + MediaTime m_duration; MediaPlayer::ReadyState m_readyState; MediaPlayer::NetworkState m_networkState; bool m_playing; + bool m_seekCompleted; }; } diff --git a/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp b/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp index 811173dfa..eb2ff784c 100644 --- a/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp +++ b/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp @@ -10,10 +10,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -29,25 +29,26 @@ #if ENABLE(MEDIA_SOURCE) #include "ContentType.h" -#include "ExceptionCodePlaceholder.h" +#include "MediaSourcePrivateClient.h" #include "MockMediaPlayerMediaSource.h" #include "MockSourceBufferPrivate.h" namespace WebCore { -RefPtr<MockMediaSourcePrivate> MockMediaSourcePrivate::create(MockMediaPlayerMediaSource* parent) +RefPtr<MockMediaSourcePrivate> MockMediaSourcePrivate::create(MockMediaPlayerMediaSource* parent, MediaSourcePrivateClient* client) { - return adoptRef(new MockMediaSourcePrivate(parent)); + RefPtr<MockMediaSourcePrivate> mediaSourcePrivate = adoptRef(new MockMediaSourcePrivate(parent, client)); + client->setPrivateAndOpen(*mediaSourcePrivate); + return mediaSourcePrivate; } -MockMediaSourcePrivate::MockMediaSourcePrivate(MockMediaPlayerMediaSource* parent) +MockMediaSourcePrivate::MockMediaSourcePrivate(MockMediaPlayerMediaSource* parent, MediaSourcePrivateClient* client) : m_player(parent) - , m_duration(std::numeric_limits<float>::quiet_NaN()) + , m_client(client) , m_isEnded(false) , m_totalVideoFrames(0) , m_droppedVideoFrames(0) , m_corruptedVideoFrames(0) - , m_totalFrameDelay(0) { } @@ -84,18 +85,19 @@ void MockMediaSourcePrivate::removeSourceBuffer(SourceBufferPrivate* buffer) m_sourceBuffers.remove(pos); } -double MockMediaSourcePrivate::duration() +MediaTime MockMediaSourcePrivate::duration() { - return m_duration; + return m_client->duration(); } -void MockMediaSourcePrivate::setDuration(double duration) +std::unique_ptr<PlatformTimeRanges> MockMediaSourcePrivate::buffered() { - if (duration == m_duration) - return; + return m_client->buffered(); +} - m_duration = duration; - m_player->updateDuration(duration); +void MockMediaSourcePrivate::durationChanged() +{ + m_player->updateDuration(duration()); } void MockMediaSourcePrivate::markEndOfStream(EndOfStreamStatus status) @@ -120,6 +122,16 @@ void MockMediaSourcePrivate::setReadyState(MediaPlayer::ReadyState readyState) m_player->setReadyState(readyState); } +void MockMediaSourcePrivate::waitForSeekCompleted() +{ + m_player->waitForSeekCompleted(); +} + +void MockMediaSourcePrivate::seekCompleted() +{ + m_player->seekCompleted(); +} + void MockMediaSourcePrivate::sourceBufferPrivateDidChangeActiveState(MockSourceBufferPrivate* buffer, bool active) { if (active && !m_activeSourceBuffers.contains(buffer)) @@ -154,8 +166,7 @@ bool MockMediaSourcePrivate::hasVideo() const void MockMediaSourcePrivate::seekToTime(const MediaTime& time) { - for (auto it = m_activeSourceBuffers.begin(), end = m_activeSourceBuffers.end(); it != end; ++it) - (*it)->seekToTime(time); + m_client->seekToTime(time); } MediaTime MockMediaSourcePrivate::seekToTime(const MediaTime& targetTime, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold) diff --git a/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h b/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h index 9cc3da2eb..8c7169ea0 100644 --- a/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h +++ b/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h @@ -10,10 +10,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -39,7 +39,7 @@ class TimeRanges; class MockMediaSourcePrivate final : public MediaSourcePrivate { public: - static RefPtr<MockMediaSourcePrivate> create(MockMediaPlayerMediaSource*); + static RefPtr<MockMediaSourcePrivate> create(MockMediaPlayerMediaSource*, MediaSourcePrivateClient*); virtual ~MockMediaSourcePrivate(); const Vector<MockSourceBufferPrivate*>& activeSourceBuffers() const { return m_activeSourceBuffers; } @@ -47,6 +47,9 @@ public: bool hasAudio() const; bool hasVideo() const; + MediaTime duration(); + std::unique_ptr<PlatformTimeRanges> buffered(); + MockMediaPlayerMediaSource* player() const { return m_player; } void seekToTime(const MediaTime&); @@ -55,24 +58,25 @@ public: unsigned long totalVideoFrames() const { return m_totalVideoFrames; } unsigned long droppedVideoFrames() const { return m_droppedVideoFrames; } unsigned long corruptedVideoFrames() const { return m_corruptedVideoFrames; } - double totalFrameDelay() const { return m_totalFrameDelay; } + MediaTime totalFrameDelay() const { return m_totalFrameDelay; } void incrementTotalVideoFrames() { ++m_totalVideoFrames; } void incrementDroppedFrames() { ++m_droppedVideoFrames; } void incrementCorruptedFrames() { ++m_corruptedVideoFrames; } - void incrementTotalFrameDelayBy(double delay) { m_totalFrameDelay += delay; } + void incrementTotalFrameDelayBy(const MediaTime& delay) { m_totalFrameDelay += delay; } private: - MockMediaSourcePrivate(MockMediaPlayerMediaSource*); + MockMediaSourcePrivate(MockMediaPlayerMediaSource*, MediaSourcePrivateClient*); // MediaSourcePrivate Overrides - virtual AddStatus addSourceBuffer(const ContentType&, RefPtr<SourceBufferPrivate>&) override; - virtual double duration() override; - virtual void setDuration(double) override; - virtual void markEndOfStream(EndOfStreamStatus) override; - virtual void unmarkEndOfStream() override; - virtual MediaPlayer::ReadyState readyState() const override; - virtual void setReadyState(MediaPlayer::ReadyState) override; + AddStatus addSourceBuffer(const ContentType&, RefPtr<SourceBufferPrivate>&) override; + void durationChanged() override; + void markEndOfStream(EndOfStreamStatus) override; + void unmarkEndOfStream() override; + MediaPlayer::ReadyState readyState() const override; + void setReadyState(MediaPlayer::ReadyState) override; + void waitForSeekCompleted() override; + void seekCompleted() override; void sourceBufferPrivateDidChangeActiveState(MockSourceBufferPrivate*, bool active); void removeSourceBuffer(SourceBufferPrivate*); @@ -80,7 +84,7 @@ private: friend class MockSourceBufferPrivate; MockMediaPlayerMediaSource* m_player; - double m_duration; + RefPtr<MediaSourcePrivateClient> m_client; Vector<RefPtr<MockSourceBufferPrivate>> m_sourceBuffers; Vector<MockSourceBufferPrivate*> m_activeSourceBuffers; bool m_isEnded; @@ -88,7 +92,7 @@ private: unsigned long m_totalVideoFrames; unsigned long m_droppedVideoFrames; unsigned long m_corruptedVideoFrames; - double m_totalFrameDelay; + MediaTime m_totalFrameDelay; }; } diff --git a/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp b/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp index 643ae76cd..e031a9b5d 100644 --- a/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp +++ b/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,17 +10,17 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" @@ -38,29 +38,40 @@ #include "SourceBufferPrivateClient.h" #include <map> #include <runtime/ArrayBuffer.h> +#include <wtf/StringPrintStream.h> namespace WebCore { class MockMediaSample final : public MediaSample { public: - static RefPtr<MockMediaSample> create(const MockSampleBox& box) { return adoptRef(new MockMediaSample(box)); } + static Ref<MockMediaSample> create(const MockSampleBox& box) { return adoptRef(*new MockMediaSample(box)); } virtual ~MockMediaSample() { } - virtual MediaTime presentationTime() const override { return m_box.presentationTimestamp(); } - virtual MediaTime decodeTime() const override { return m_box.decodeTimestamp(); } - virtual MediaTime duration() const override { return m_box.duration(); } - virtual AtomicString trackID() const override { return m_id; } - - virtual SampleFlags flags() const override; - virtual PlatformSample platformSample() override; - -protected: +private: MockMediaSample(const MockSampleBox& box) : m_box(box) , m_id(String::format("%d", box.trackID())) { } + MediaTime presentationTime() const override { return m_box.presentationTimestamp(); } + MediaTime decodeTime() const override { return m_box.decodeTimestamp(); } + MediaTime duration() const override { return m_box.duration(); } + AtomicString trackID() const override { return m_id; } + void setTrackID(const String& id) override { m_id = id; } + size_t sizeInBytes() const override { return sizeof(m_box); } + SampleFlags flags() const override; + PlatformSample platformSample() override; + FloatSize presentationSize() const override { return FloatSize(); } + void dump(PrintStream&) const override; + void offsetTimestampsBy(const MediaTime& offset) override { m_box.offsetTimestampsBy(offset); } + void setTimestamps(const MediaTime& presentationTimestamp, const MediaTime& decodeTimestamp) override { m_box.setTimestamps(presentationTimestamp, decodeTimestamp); } + bool isDivisable() const override { return false; } + std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> divide(const MediaTime&) override { return {nullptr, nullptr}; } + Ref<MediaSample> createNonDisplayingCopy() const override; + + unsigned generation() const { return m_box.generation(); } + MockSampleBox m_box; AtomicString m_id; }; @@ -68,8 +79,10 @@ protected: MediaSample::SampleFlags MockMediaSample::flags() const { unsigned flags = None; - if (m_box.flags() & MockSampleBox::IsSync) + if (m_box.isSync()) flags |= IsSync; + if (m_box.isNonDisplaying()) + flags |= IsNonDisplaying; return SampleFlags(flags); } @@ -79,15 +92,27 @@ PlatformSample MockMediaSample::platformSample() return sample; } +void MockMediaSample::dump(PrintStream& out) const +{ + out.print("{PTS(", presentationTime(), "), DTS(", decodeTime(), "), duration(", duration(), "), flags(", (int)flags(), "), generation(", generation(), ")}"); +} + +Ref<MediaSample> MockMediaSample::createNonDisplayingCopy() const +{ + auto copy = MockMediaSample::create(m_box); + copy->m_box.setFlag(MockSampleBox::IsNonDisplaying); + return WTFMove(copy); +} + class MockMediaDescription final : public MediaDescription { public: static RefPtr<MockMediaDescription> create(const MockTrackBox& box) { return adoptRef(new MockMediaDescription(box)); } virtual ~MockMediaDescription() { } - virtual AtomicString codec() const override { return m_box.codec(); } - virtual bool isVideo() const override { return m_box.kind() == MockTrackBox::Video; } - virtual bool isAudio() const override { return m_box.kind() == MockTrackBox::Audio; } - virtual bool isText() const override { return m_box.kind() == MockTrackBox::Text; } + AtomicString codec() const override { return m_box.codec(); } + bool isVideo() const override { return m_box.kind() == MockTrackBox::Video; } + bool isAudio() const override { return m_box.kind() == MockTrackBox::Audio; } + bool isText() const override { return m_box.kind() == MockTrackBox::Text; } protected: MockMediaDescription(const MockTrackBox& box) : m_box(box) { } @@ -114,12 +139,12 @@ void MockSourceBufferPrivate::setClient(SourceBufferPrivateClient* client) m_client = client; } -SourceBufferPrivate::AppendResult MockSourceBufferPrivate::append(const unsigned char* data, unsigned length) +void MockSourceBufferPrivate::append(const unsigned char* data, unsigned length) { m_inputBuffer.append(data, length); - AppendResult result = AppendSucceeded; + SourceBufferPrivateClient::AppendResult result = SourceBufferPrivateClient::AppendSucceeded; - while (m_inputBuffer.size() && result == AppendSucceeded) { + while (m_inputBuffer.size() && result == SourceBufferPrivateClient::AppendSucceeded) { RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(m_inputBuffer.data(), m_inputBuffer.size()); size_t boxLength = MockBox::peekLength(buffer.get()); if (boxLength > buffer->byteLength()) @@ -133,12 +158,13 @@ SourceBufferPrivate::AppendResult MockSourceBufferPrivate::append(const unsigned MockSampleBox sampleBox = MockSampleBox(buffer.get()); didReceiveSample(sampleBox); } else - result = ParsingFailed; + result = SourceBufferPrivateClient::ParsingFailed; m_inputBuffer.remove(0, boxLength); } - return result; + if (m_client) + m_client->sourceBufferPrivateAppendComplete(result); } void MockSourceBufferPrivate::didReceiveInitializationSegment(const MockInitializationBox& initBox) @@ -169,7 +195,7 @@ void MockSourceBufferPrivate::didReceiveInitializationSegment(const MockInitiali } } - m_client->sourceBufferPrivateDidReceiveInitializationSegment(this, segment); + m_client->sourceBufferPrivateDidReceiveInitializationSegment(segment); } @@ -178,13 +204,17 @@ void MockSourceBufferPrivate::didReceiveSample(const MockSampleBox& sampleBox) if (!m_client) return; - m_client->sourceBufferPrivateDidReceiveSample(this, MockMediaSample::create(sampleBox)); + m_client->sourceBufferPrivateDidReceiveSample(MockMediaSample::create(sampleBox)); } void MockSourceBufferPrivate::abort() { } +void MockSourceBufferPrivate::resetParserState() +{ +} + void MockSourceBufferPrivate::removedFromMediaSource() { if (m_mediaSource) @@ -202,32 +232,27 @@ void MockSourceBufferPrivate::setReadyState(MediaPlayer::ReadyState readyState) m_mediaSource->player()->setReadyState(readyState); } -void MockSourceBufferPrivate::evictCodedFrames() -{ - // No-op. -} - -bool MockSourceBufferPrivate::isFull() -{ - return false; -} - void MockSourceBufferPrivate::setActive(bool isActive) { if (m_mediaSource) m_mediaSource->sourceBufferPrivateDidChangeActiveState(this, isActive); } -void MockSourceBufferPrivate::enqueueSample(PassRefPtr<MediaSample> sample, AtomicString) +Vector<String> MockSourceBufferPrivate::enqueuedSamplesForTrackID(const AtomicString&) +{ + return m_enqueuedSamples; +} + +void MockSourceBufferPrivate::enqueueSample(Ref<MediaSample>&& sample, const AtomicString&) { - if (!m_mediaSource || !sample) + if (!m_mediaSource) return; PlatformSample platformSample = sample->platformSample(); if (platformSample.type != PlatformSample::MockSampleBoxType) return; - MockSampleBox* box = platformSample.sample.mockSampleBox; + auto* box = platformSample.sample.mockSampleBox; if (!box) return; @@ -237,37 +262,32 @@ void MockSourceBufferPrivate::enqueueSample(PassRefPtr<MediaSample> sample, Atom if (box->isDropped()) m_mediaSource->incrementDroppedFrames(); if (box->isDelayed()) - m_mediaSource->incrementTotalFrameDelayBy(1); + m_mediaSource->incrementTotalFrameDelayBy(MediaTime(1, 1)); + + m_enqueuedSamples.append(toString(sample.get())); } bool MockSourceBufferPrivate::hasVideo() const { - if (!m_client) - return false; - - return m_client->sourceBufferPrivateHasVideo(this); + return m_client && m_client->sourceBufferPrivateHasVideo(); } bool MockSourceBufferPrivate::hasAudio() const { - if (!m_client) - return false; - - return m_client->sourceBufferPrivateHasAudio(this); + return m_client && m_client->sourceBufferPrivateHasAudio(); } - MediaTime MockSourceBufferPrivate::fastSeekTimeForMediaTime(const MediaTime& time, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold) { if (m_client) - return m_client->sourceBufferPrivateFastSeekTimeForMediaTime(this, time, negativeThreshold, positiveThreshold); + return m_client->sourceBufferPrivateFastSeekTimeForMediaTime(time, negativeThreshold, positiveThreshold); return time; } void MockSourceBufferPrivate::seekToTime(const MediaTime& time) { if (m_client) - m_client->sourceBufferPrivateSeekToTime(this, time); + m_client->sourceBufferPrivateSeekToTime(time); } } diff --git a/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h b/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h index 109d032db..49650553b 100644 --- a/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h +++ b/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,10 +10,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -23,17 +23,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef MockSourceBufferPrivate_h -#define MockSourceBufferPrivate_h +#pragma once #if ENABLE(MEDIA_SOURCE) #include "SourceBufferPrivate.h" -#include <wtf/HashMap.h> -#include <wtf/MediaTime.h> -#include <wtf/RefPtr.h> -#include <wtf/RetainPtr.h> -#include <wtf/Vector.h> namespace WebCore { @@ -45,7 +39,7 @@ class MockSampleBox; class TimeRanges; class VideoTrackPrivate; -class MockSourceBufferPrivate : public SourceBufferPrivate { +class MockSourceBufferPrivate final : public SourceBufferPrivate { public: static RefPtr<MockSourceBufferPrivate> create(MockMediaSourcePrivate*); virtual ~MockSourceBufferPrivate(); @@ -62,25 +56,27 @@ private: explicit MockSourceBufferPrivate(MockMediaSourcePrivate*); // SourceBufferPrivate overrides - virtual void setClient(SourceBufferPrivateClient*) override; - virtual AppendResult append(const unsigned char* data, unsigned length) override; - virtual void abort() override; - virtual void removedFromMediaSource() override; - virtual MediaPlayer::ReadyState readyState() const override; - virtual void setReadyState(MediaPlayer::ReadyState) override; - virtual void evictCodedFrames() override; - virtual bool isFull() override; - - virtual void flushAndEnqueueNonDisplayingSamples(Vector<RefPtr<MediaSample>>, AtomicString) override { } - virtual void enqueueSample(PassRefPtr<MediaSample>, AtomicString) override; - virtual bool isReadyForMoreSamples(AtomicString) override { return true; } - virtual void setActive(bool) override; + void setClient(SourceBufferPrivateClient*) final; + void append(const unsigned char* data, unsigned length) final; + void abort() final; + void resetParserState() final; + void removedFromMediaSource() final; + MediaPlayer::ReadyState readyState() const final; + void setReadyState(MediaPlayer::ReadyState) final; + + void flush(const AtomicString&) final { m_enqueuedSamples.clear(); } + void enqueueSample(Ref<MediaSample>&&, const AtomicString&) final; + bool isReadyForMoreSamples(const AtomicString&) final { return true; } + void setActive(bool) final; + + Vector<String> enqueuedSamplesForTrackID(const AtomicString&) final; void didReceiveInitializationSegment(const MockInitializationBox&); void didReceiveSample(const MockSampleBox&); MockMediaSourcePrivate* m_mediaSource; SourceBufferPrivateClient* m_client; + Vector<String> m_enqueuedSamples; Vector<char> m_inputBuffer; }; @@ -88,6 +84,3 @@ private: } #endif // ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION) - -#endif - diff --git a/Source/WebCore/platform/mock/mediasource/MockTracks.cpp b/Source/WebCore/platform/mock/mediasource/MockTracks.cpp deleted file mode 100644 index 8f8840d84..000000000 --- a/Source/WebCore/platform/mock/mediasource/MockTracks.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2013 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "MockTracks.h" diff --git a/Source/WebCore/platform/mock/mediasource/MockTracks.h b/Source/WebCore/platform/mock/mediasource/MockTracks.h index 3f8eded74..073f36863 100644 --- a/Source/WebCore/platform/mock/mediasource/MockTracks.h +++ b/Source/WebCore/platform/mock/mediasource/MockTracks.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,10 +10,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -23,8 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef MockTracks_h -#define MockTracks_h +#pragma once #if ENABLE(MEDIA_SOURCE) @@ -37,7 +36,7 @@ namespace WebCore { class MockAudioTrackPrivate : public AudioTrackPrivate { public: - static RefPtr<MockAudioTrackPrivate> create(const MockTrackBox& box) { return adoptRef(new MockAudioTrackPrivate(box)); } + static Ref<MockAudioTrackPrivate> create(const MockTrackBox& box) { return adoptRef(*new MockAudioTrackPrivate(box)); } virtual ~MockAudioTrackPrivate() { } virtual AtomicString id() const { return m_id; } @@ -45,7 +44,7 @@ public: protected: MockAudioTrackPrivate(const MockTrackBox& box) : m_box(box) - , m_id(String::format("%d", box.trackID())) + , m_id(AtomicString::number(box.trackID())) { } MockTrackBox m_box; @@ -63,7 +62,7 @@ protected: MockTextTrackPrivate(const MockTrackBox& box) : InbandTextTrackPrivate(InbandTextTrackPrivate::Generic) , m_box(box) - , m_id(String::format("%d", box.trackID())) + , m_id(AtomicString::number(box.trackID())) { } MockTrackBox m_box; @@ -81,7 +80,7 @@ public: protected: MockVideoTrackPrivate(const MockTrackBox& box) : m_box(box) - , m_id(String::format("%d", box.trackID())) + , m_id(AtomicString::number(box.trackID())) { } MockTrackBox m_box; @@ -91,5 +90,3 @@ protected: } #endif - -#endif |