gecko-dev/dom/media/mediasource/SourceBufferContentManager.h
Nathan Froyd 01583602a9 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout.  The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.

CLOSED TREE makes big refactorings like this a piece of cake.

 # The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    xargs perl -p -i -e '
 s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
 s/nsRefPtr ?</RefPtr</g;   # handle declarations and variables
'

 # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h

 # Handle nsRefPtr.h itself, a couple places that define constructors
 # from nsRefPtr, and code generators specially.  We do this here, rather
 # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
 # things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
     mfbt/nsRefPtr.h \
     xpcom/glue/nsCOMPtr.h \
     xpcom/base/OwningNonNull.h \
     ipc/ipdl/ipdl/lower.py \
     ipc/ipdl/ipdl/builtin.py \
     dom/bindings/Codegen.py \
     python/lldbutils/lldbutils/utils.py

 # In our indiscriminate substitution above, we renamed
 # nsRefPtrGetterAddRefs, the class behind getter_AddRefs.  Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
    xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'

if [ -d .git ]; then
    git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
    hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi

--HG--
rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 01:24:48 -04:00

122 lines
3.8 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MOZILLA_SOURCEBUFFERCONTENTMANAGER_H_
#define MOZILLA_SOURCEBUFFERCONTENTMANAGER_H_
#include "mozilla/MozPromise.h"
#include "MediaData.h"
#include "MediaSourceDecoder.h"
#include "TimeUnits.h"
#include "nsString.h"
namespace mozilla {
namespace dom {
class SourceBuffer;
class SourceBufferAttributes;
}
class SourceBufferContentManager {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SourceBufferContentManager);
typedef MozPromise<bool, nsresult, /* IsExclusive = */ true> AppendPromise;
typedef AppendPromise RangeRemovalPromise;
static already_AddRefed<SourceBufferContentManager>
CreateManager(dom::SourceBufferAttributes* aAttributes,
MediaSourceDecoder* aParentDecoder,
const nsACString& aType);
// Add data to the end of the input buffer.
// Returns false if the append failed.
virtual bool
AppendData(MediaByteBuffer* aData, media::TimeUnit aTimestampOffset) = 0;
// Run MSE Buffer Append Algorithm
// 3.5.5 Buffer Append Algorithm.
// http://w3c.github.io/media-source/index.html#sourcebuffer-buffer-append
virtual RefPtr<AppendPromise> BufferAppend() = 0;
// Abort any pending AppendData.
virtual void AbortAppendData() = 0;
// Run MSE Reset Parser State Algorithm.
// 3.5.2 Reset Parser State
// http://w3c.github.io/media-source/#sourcebuffer-reset-parser-state
virtual void ResetParserState() = 0;
// Runs MSE range removal algorithm.
// http://w3c.github.io/media-source/#sourcebuffer-coded-frame-removal
virtual RefPtr<RangeRemovalPromise> RangeRemoval(media::TimeUnit aStart,
media::TimeUnit aEnd) = 0;
enum class EvictDataResult : int8_t
{
NO_DATA_EVICTED,
DATA_EVICTED,
CANT_EVICT,
BUFFER_FULL,
};
// Evicts data up to aPlaybackTime. aThreshold is used to
// bound the data being evicted. It will not evict more than aThreshold
// bytes. aBufferStartTime contains the new start time of the data after the
// eviction.
virtual EvictDataResult
EvictData(media::TimeUnit aPlaybackTime,
uint32_t aThreshold,
media::TimeUnit* aBufferStartTime) = 0;
// Evicts data up to aTime.
virtual void EvictBefore(media::TimeUnit aTime) = 0;
// Returns the buffered range currently managed.
// This may be called on any thread.
// Buffered must conform to http://w3c.github.io/media-source/index.html#widl-SourceBuffer-buffered
virtual media::TimeIntervals Buffered() = 0;
// Return the size of the data managed by this SourceBufferContentManager.
virtual int64_t GetSize() = 0;
// Indicate that the MediaSource parent object got into "ended" state.
virtual void Ended() = 0;
// The parent SourceBuffer is about to be destroyed.
virtual void Detach() = 0;
// Current state as per Segment Parser Loop Algorithm
// http://w3c.github.io/media-source/index.html#sourcebuffer-segment-parser-loop
enum class AppendState : int32_t
{
WAITING_FOR_SEGMENT,
PARSING_INIT_SEGMENT,
PARSING_MEDIA_SEGMENT,
};
virtual AppendState GetAppendState()
{
return AppendState::WAITING_FOR_SEGMENT;
}
virtual void SetGroupStartTimestamp(const media::TimeUnit& aGroupStartTimestamp) {}
virtual void RestartGroupStartTimestamp() {}
virtual media::TimeUnit GroupEndTimestamp() = 0;
#if defined(DEBUG)
virtual void Dump(const char* aPath) { }
#endif
protected:
virtual ~SourceBufferContentManager() { }
};
} // namespace mozilla
#endif /* MOZILLA_SOURCEBUFFERCONTENTMANAGER_H_ */