Bug 1089480 - Assume a start time of 0 for MSE videos. r=cajbir

--HG--
extra : rebase_source : fb44192e9f7f97a9ed1d753dd185dc82fdeaaa48
This commit is contained in:
Matt Woodrow 2014-10-29 09:30:36 +13:00
Родитель b6106b43d2
Коммит 1668f024f7
4 изменённых файлов: 25 добавлений и 18 удалений

Просмотреть файл

@ -20,15 +20,10 @@ namespace mozilla {
#ifdef PR_LOGGING #ifdef PR_LOGGING
extern PRLogModuleInfo* gMediaDecoderLog; extern PRLogModuleInfo* gMediaDecoderLog;
#define DECODER_LOG(type, msg) PR_LOG(gMediaDecoderLog, type, msg) #define DECODER_LOG(x, ...) \
#ifdef SEEK_LOGGING PR_LOG(gMediaDecoderLog, PR_LOG_DEBUG, ("Decoder=%p " x, mDecoder, ##__VA_ARGS__))
#define SEEK_LOG(type, msg) PR_LOG(gMediaDecoderLog, type, msg)
#else #else
#define SEEK_LOG(type, msg) #define DECODER_LOG(x, ...)
#endif
#else
#define DECODER_LOG(type, msg)
#define SEEK_LOG(type, msg)
#endif #endif
class VideoQueueMemoryFunctor : public nsDequeFunctor { class VideoQueueMemoryFunctor : public nsDequeFunctor {
@ -139,6 +134,20 @@ MediaDecoderReader::GetBuffered(mozilla::dom::TimeRanges* aBuffered,
return NS_OK; return NS_OK;
} }
int64_t
MediaDecoderReader::ComputeStartTime(const VideoData* aVideo, const AudioData* aAudio)
{
int64_t startTime = std::min<int64_t>(aAudio ? aAudio->mTime : INT64_MAX,
aVideo ? aVideo->mTime : INT64_MAX);
if (startTime == INT64_MAX) {
startTime = 0;
}
DECODER_LOG("ComputeStartTime first video frame start %lld", aVideo ? aVideo->mTime : -1);
DECODER_LOG("ComputeStartTime first audio frame start %lld", aAudio ? aAudio->mTime : -1);
MOZ_ASSERT(startTime >= 0);
return startTime;
}
class RequestVideoWithSkipTask : public nsRunnable { class RequestVideoWithSkipTask : public nsRunnable {
public: public:
RequestVideoWithSkipTask(MediaDecoderReader* aReader, RequestVideoWithSkipTask(MediaDecoderReader* aReader,

Просмотреть файл

@ -148,6 +148,8 @@ public:
virtual nsresult GetBuffered(dom::TimeRanges* aBuffered, virtual nsresult GetBuffered(dom::TimeRanges* aBuffered,
int64_t aStartTime); int64_t aStartTime);
virtual int64_t ComputeStartTime(const VideoData* aVideo, const AudioData* aAudio);
// Returns the number of bytes of memory allocated by structures/frames in // Returns the number of bytes of memory allocated by structures/frames in
// the video queue. // the video queue.
size_t SizeOfVideoQueueInBytes() const; size_t SizeOfVideoQueueInBytes() const;

Просмотреть файл

@ -2016,18 +2016,9 @@ MediaDecoderStateMachine::FinishDecodeMetadata()
} }
if (!mScheduler->IsRealTime() && !mDecodingFrozenAtStateMetadata) { if (!mScheduler->IsRealTime() && !mDecodingFrozenAtStateMetadata) {
const VideoData* v = VideoQueue().PeekFront(); const VideoData* v = VideoQueue().PeekFront();
const AudioData* a = AudioQueue().PeekFront(); const AudioData* a = AudioQueue().PeekFront();
SetStartTime(mReader->ComputeStartTime(v, a));
int64_t startTime = std::min<int64_t>(a ? a->mTime : INT64_MAX,
v ? v->mTime : INT64_MAX);
if (startTime == INT64_MAX) {
startTime = 0;
}
DECODER_LOG("DecodeMetadata first video frame start %lld", v ? v->mTime : -1);
DECODER_LOG("DecodeMetadata first audio frame start %lld", a ? a->mTime : -1);
SetStartTime(startTime);
if (VideoQueue().GetSize()) { if (VideoQueue().GetSize()) {
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor()); ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
RenderVideoFrame(VideoQueue().PeekFront(), TimeStamp::Now()); RenderVideoFrame(VideoQueue().PeekFront(), TimeStamp::Now());

Просмотреть файл

@ -70,6 +70,11 @@ public:
return mInfo.HasAudio(); return mInfo.HasAudio();
} }
// We can't compute a proper start time since we won't necessarily
// have the first frame of the resource available. This does the same
// as chrome/blink and assumes that we always start at t=0.
virtual int64_t ComputeStartTime(const VideoData* aVideo, const AudioData* aAudio) MOZ_OVERRIDE { return 0; }
bool IsMediaSeekable() { return true; } bool IsMediaSeekable() { return true; }
nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) MOZ_OVERRIDE; nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) MOZ_OVERRIDE;