зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1049321 - Move SubBufferDecoder to a new file. r=cajbir
This commit is contained in:
Родитель
7319f8d88c
Коммит
d018ec3efe
|
@ -39,91 +39,6 @@ extern PRLogModuleInfo* GetMediaSourceAPILog();
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
class MediaResource;
|
||||
class ReentrantMonitor;
|
||||
|
||||
namespace layers {
|
||||
|
||||
class ImageContainer;
|
||||
|
||||
} // namespace layers
|
||||
|
||||
ReentrantMonitor&
|
||||
SubBufferDecoder::GetReentrantMonitor()
|
||||
{
|
||||
return mParentDecoder->GetReentrantMonitor();
|
||||
}
|
||||
|
||||
bool
|
||||
SubBufferDecoder::OnStateMachineThread() const
|
||||
{
|
||||
return mParentDecoder->OnStateMachineThread();
|
||||
}
|
||||
|
||||
bool
|
||||
SubBufferDecoder::OnDecodeThread() const
|
||||
{
|
||||
return mParentDecoder->OnDecodeThread();
|
||||
}
|
||||
|
||||
SourceBufferResource*
|
||||
SubBufferDecoder::GetResource() const
|
||||
{
|
||||
return static_cast<SourceBufferResource*>(mResource.get());
|
||||
}
|
||||
|
||||
void
|
||||
SubBufferDecoder::NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded)
|
||||
{
|
||||
return mParentDecoder->NotifyDecodedFrames(aParsed, aDecoded);
|
||||
}
|
||||
|
||||
void
|
||||
SubBufferDecoder::SetMediaDuration(int64_t aDuration)
|
||||
{
|
||||
mMediaDuration = aDuration;
|
||||
}
|
||||
|
||||
void
|
||||
SubBufferDecoder::UpdateEstimatedMediaDuration(int64_t aDuration)
|
||||
{
|
||||
MSE_DEBUG("SubBufferDecoder(%p)::UpdateEstimatedMediaDuration(aDuration=%lld)", this, aDuration);
|
||||
}
|
||||
|
||||
void
|
||||
SubBufferDecoder::SetMediaSeekable(bool aMediaSeekable)
|
||||
{
|
||||
MSE_DEBUG("SubBufferDecoder(%p)::SetMediaSeekable(aMediaSeekable=%d)", this, aMediaSeekable);
|
||||
}
|
||||
|
||||
layers::ImageContainer*
|
||||
SubBufferDecoder::GetImageContainer()
|
||||
{
|
||||
return mParentDecoder->GetImageContainer();
|
||||
}
|
||||
|
||||
MediaDecoderOwner*
|
||||
SubBufferDecoder::GetOwner()
|
||||
{
|
||||
return mParentDecoder->GetOwner();
|
||||
}
|
||||
|
||||
int64_t
|
||||
SubBufferDecoder::ConvertToByteOffset(double aTime)
|
||||
{
|
||||
// Uses a conversion based on (aTime/duration) * length. For the
|
||||
// purposes of eviction this should be adequate since we have the
|
||||
// byte threshold as well to ensure data actually gets evicted and
|
||||
// we ensure we don't evict before the current playable point.
|
||||
if (mMediaDuration == -1) {
|
||||
return -1;
|
||||
}
|
||||
int64_t length = GetResource()->GetLength();
|
||||
MOZ_ASSERT(length > 0);
|
||||
int64_t offset = (aTime / (double(mMediaDuration) / USECS_PER_S)) * length;
|
||||
return offset;
|
||||
}
|
||||
|
||||
class ContainerParser {
|
||||
public:
|
||||
virtual ~ContainerParser() {}
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
/* 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/. */
|
||||
|
||||
#include "SubBufferDecoder.h"
|
||||
#include "MediaSourceDecoder.h"
|
||||
#include "MediaDecoderReader.h"
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
extern PRLogModuleInfo* GetMediaSourceLog();
|
||||
extern PRLogModuleInfo* GetMediaSourceAPILog();
|
||||
|
||||
#define MSE_DEBUG(...) PR_LOG(GetMediaSourceLog(), PR_LOG_DEBUG, (__VA_ARGS__))
|
||||
#define MSE_API(...) PR_LOG(GetMediaSourceAPILog(), PR_LOG_DEBUG, (__VA_ARGS__))
|
||||
#else
|
||||
#define MSE_DEBUG(...)
|
||||
#define MSE_API(...)
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ReentrantMonitor;
|
||||
|
||||
namespace layers {
|
||||
|
||||
class ImageContainer;
|
||||
|
||||
} // namespace layers
|
||||
|
||||
|
||||
ReentrantMonitor&
|
||||
SubBufferDecoder::GetReentrantMonitor()
|
||||
{
|
||||
return mParentDecoder->GetReentrantMonitor();
|
||||
}
|
||||
|
||||
bool
|
||||
SubBufferDecoder::OnStateMachineThread() const
|
||||
{
|
||||
return mParentDecoder->OnStateMachineThread();
|
||||
}
|
||||
|
||||
bool
|
||||
SubBufferDecoder::OnDecodeThread() const
|
||||
{
|
||||
return mParentDecoder->OnDecodeThread();
|
||||
}
|
||||
|
||||
SourceBufferResource*
|
||||
SubBufferDecoder::GetResource() const
|
||||
{
|
||||
return static_cast<SourceBufferResource*>(mResource.get());
|
||||
}
|
||||
|
||||
void
|
||||
SubBufferDecoder::NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded)
|
||||
{
|
||||
return mParentDecoder->NotifyDecodedFrames(aParsed, aDecoded);
|
||||
}
|
||||
|
||||
void
|
||||
SubBufferDecoder::SetMediaDuration(int64_t aDuration)
|
||||
{
|
||||
mMediaDuration = aDuration;
|
||||
}
|
||||
|
||||
void
|
||||
SubBufferDecoder::UpdateEstimatedMediaDuration(int64_t aDuration)
|
||||
{
|
||||
MSE_DEBUG("SubBufferDecoder(%p)::UpdateEstimatedMediaDuration(aDuration=%lld)", this, aDuration);
|
||||
}
|
||||
|
||||
void
|
||||
SubBufferDecoder::SetMediaSeekable(bool aMediaSeekable)
|
||||
{
|
||||
MSE_DEBUG("SubBufferDecoder(%p)::SetMediaSeekable(aMediaSeekable=%d)", this, aMediaSeekable);
|
||||
}
|
||||
|
||||
layers::ImageContainer*
|
||||
SubBufferDecoder::GetImageContainer()
|
||||
{
|
||||
return mParentDecoder->GetImageContainer();
|
||||
}
|
||||
|
||||
MediaDecoderOwner*
|
||||
SubBufferDecoder::GetOwner()
|
||||
{
|
||||
return mParentDecoder->GetOwner();
|
||||
}
|
||||
|
||||
void
|
||||
SubBufferDecoder::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
|
||||
{
|
||||
mReader->NotifyDataArrived(aBuffer, aLength, aOffset);
|
||||
|
||||
// XXX: Params make no sense to parent decoder as it relates to a
|
||||
// specific SubBufferDecoder's data stream. Pass bogus values here to
|
||||
// force parent decoder's state machine to recompute end time for
|
||||
// infinite length media.
|
||||
mParentDecoder->NotifyDataArrived(nullptr, 0, 0);
|
||||
}
|
||||
|
||||
nsresult
|
||||
SubBufferDecoder::GetBuffered(dom::TimeRanges* aBuffered)
|
||||
{
|
||||
// XXX: Need mStartTime (from StateMachine) instead of passing 0.
|
||||
return mReader->GetBuffered(aBuffered, 0);
|
||||
}
|
||||
|
||||
int64_t
|
||||
SubBufferDecoder::ConvertToByteOffset(double aTime)
|
||||
{
|
||||
// Uses a conversion based on (aTime/duration) * length. For the
|
||||
// purposes of eviction this should be adequate since we have the
|
||||
// byte threshold as well to ensure data actually gets evicted and
|
||||
// we ensure we don't evict before the current playable point.
|
||||
if (mMediaDuration == -1) {
|
||||
return -1;
|
||||
}
|
||||
int64_t length = GetResource()->GetLength();
|
||||
MOZ_ASSERT(length > 0);
|
||||
int64_t offset = (aTime / (double(mMediaDuration) / USECS_PER_S)) * length;
|
||||
return offset;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
|
@ -12,7 +12,15 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
class MediaResource;
|
||||
class MediaSourceDecoder;
|
||||
class MediaDecoderReader;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class TimeRanges;
|
||||
|
||||
} // namespace dom
|
||||
|
||||
class SubBufferDecoder : public BufferDecoder
|
||||
{
|
||||
|
@ -47,22 +55,10 @@ public:
|
|||
virtual layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE;
|
||||
virtual MediaDecoderOwner* GetOwner() MOZ_OVERRIDE;
|
||||
|
||||
void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
|
||||
{
|
||||
mReader->NotifyDataArrived(aBuffer, aLength, aOffset);
|
||||
|
||||
// XXX: Params make no sense to parent decoder as it relates to a
|
||||
// specific SubBufferDecoder's data stream. Pass bogus values here to
|
||||
// force parent decoder's state machine to recompute end time for
|
||||
// infinite length media.
|
||||
mParentDecoder->NotifyDataArrived(nullptr, 0, 0);
|
||||
}
|
||||
|
||||
nsresult GetBuffered(dom::TimeRanges* aBuffered)
|
||||
{
|
||||
// XXX: Need mStartTime (from StateMachine) instead of passing 0.
|
||||
return mReader->GetBuffered(aBuffered, 0);
|
||||
}
|
||||
// Warning: these mirror calls from MediaDecoder, but this class's base is
|
||||
// AbstractMediaDecoder, which does not supply this interface.
|
||||
void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset);
|
||||
nsresult GetBuffered(dom::TimeRanges* aBuffered);
|
||||
|
||||
// Given a time convert it into an approximate byte offset from the
|
||||
// cached data. Returns -1 if no such value is computable.
|
||||
|
|
|
@ -22,6 +22,7 @@ UNIFIED_SOURCES += [
|
|||
'SourceBuffer.cpp',
|
||||
'SourceBufferList.cpp',
|
||||
'SourceBufferResource.cpp',
|
||||
'SubBufferDecoder.cpp',
|
||||
]
|
||||
|
||||
FAIL_ON_WARNINGS = True
|
||||
|
|
Загрузка…
Ссылка в новой задаче