2016-03-31 11:32:03 +03:00
|
|
|
/* -*- 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 MediaDecoderReaderWrapper_h_
|
|
|
|
#define MediaDecoderReaderWrapper_h_
|
|
|
|
|
|
|
|
#include "mozilla/AbstractThread.h"
|
|
|
|
#include "mozilla/RefPtr.h"
|
2016-07-07 09:44:53 +03:00
|
|
|
#include "mozilla/Variant.h"
|
2016-03-31 11:32:03 +03:00
|
|
|
#include "nsISupportsImpl.h"
|
|
|
|
|
|
|
|
#include "MediaDecoderReader.h"
|
2016-06-14 06:22:45 +03:00
|
|
|
#include "MediaEventSource.h"
|
2016-03-31 11:32:03 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A wrapper around MediaDecoderReader to offset the timestamps of Audio/Video
|
|
|
|
* samples by the start time to ensure MDSM can always assume zero start time.
|
|
|
|
* It also adjusts the seek target passed to Seek() to ensure correct seek time
|
|
|
|
* is passed to the underlying reader.
|
|
|
|
*/
|
|
|
|
class MediaDecoderReaderWrapper {
|
|
|
|
typedef MediaDecoderReader::MetadataPromise MetadataPromise;
|
2017-03-22 06:28:33 +03:00
|
|
|
typedef MediaDecoderReader::AudioDataPromise AudioDataPromise;
|
|
|
|
typedef MediaDecoderReader::VideoDataPromise VideoDataPromise;
|
2016-03-31 11:32:03 +03:00
|
|
|
typedef MediaDecoderReader::SeekPromise SeekPromise;
|
2016-04-19 11:14:30 +03:00
|
|
|
typedef MediaDecoderReader::WaitForDataPromise WaitForDataPromise;
|
2016-05-31 07:32:37 +03:00
|
|
|
typedef MediaDecoderReader::TrackSet TrackSet;
|
2016-03-31 11:32:03 +03:00
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderReaderWrapper);
|
|
|
|
|
|
|
|
public:
|
2016-08-15 09:54:10 +03:00
|
|
|
MediaDecoderReaderWrapper(AbstractThread* aOwnerThread,
|
2016-03-31 11:32:03 +03:00
|
|
|
MediaDecoderReader* aReader);
|
|
|
|
|
|
|
|
media::TimeUnit StartTime() const;
|
|
|
|
RefPtr<MetadataPromise> ReadMetadata();
|
2016-04-27 09:50:23 +03:00
|
|
|
|
2017-03-22 06:28:33 +03:00
|
|
|
RefPtr<AudioDataPromise> RequestAudioData();
|
2016-12-20 08:17:05 +03:00
|
|
|
|
2017-03-22 06:28:33 +03:00
|
|
|
RefPtr<VideoDataPromise>
|
2016-12-20 08:17:05 +03:00
|
|
|
RequestVideoData(bool aSkipToNextKeyframe, media::TimeUnit aTimeThreshold);
|
2016-04-27 09:50:23 +03:00
|
|
|
|
2016-12-20 09:31:29 +03:00
|
|
|
RefPtr<WaitForDataPromise> WaitForData(MediaData::Type aType);
|
2016-04-27 09:50:23 +03:00
|
|
|
|
2016-11-29 17:42:50 +03:00
|
|
|
RefPtr<SeekPromise> Seek(const SeekTarget& aTarget);
|
2016-04-19 11:14:30 +03:00
|
|
|
RefPtr<ShutdownPromise> Shutdown();
|
|
|
|
|
2016-08-17 10:03:30 +03:00
|
|
|
void ReleaseResources();
|
2016-05-31 07:32:37 +03:00
|
|
|
void ResetDecode(TrackSet aTracks);
|
2016-04-19 11:14:30 +03:00
|
|
|
|
|
|
|
nsresult Init() { return mReader->Init(); }
|
|
|
|
bool IsAsync() const { return mReader->IsAsync(); }
|
2016-04-19 11:14:33 +03:00
|
|
|
bool UseBufferingHeuristics() const { return mReader->UseBufferingHeuristics(); }
|
2016-04-19 11:14:30 +03:00
|
|
|
|
|
|
|
bool VideoIsHardwareAccelerated() const {
|
|
|
|
return mReader->VideoIsHardwareAccelerated();
|
|
|
|
}
|
|
|
|
TimedMetadataEventSource& TimedMetadataEvent() {
|
|
|
|
return mReader->TimedMetadataEvent();
|
|
|
|
}
|
2016-04-20 09:45:40 +03:00
|
|
|
MediaEventSource<void>& OnMediaNotSeekable() {
|
|
|
|
return mReader->OnMediaNotSeekable();
|
|
|
|
}
|
|
|
|
size_t SizeOfVideoQueueInBytes() const {
|
|
|
|
return mReader->SizeOfVideoQueueInBytes();
|
|
|
|
}
|
|
|
|
size_t SizeOfAudioQueueInBytes() const {
|
|
|
|
return mReader->SizeOfAudioQueueInBytes();
|
|
|
|
}
|
2016-04-19 11:14:30 +03:00
|
|
|
size_t SizeOfAudioQueueInFrames() const {
|
|
|
|
return mReader->SizeOfAudioQueueInFrames();
|
|
|
|
}
|
|
|
|
size_t SizeOfVideoQueueInFrames() const {
|
|
|
|
return mReader->SizeOfVideoQueueInFrames();
|
|
|
|
}
|
|
|
|
void ReadUpdatedMetadata(MediaInfo* aInfo) {
|
|
|
|
mReader->ReadUpdatedMetadata(aInfo);
|
|
|
|
}
|
|
|
|
AbstractCanonical<media::TimeIntervals>* CanonicalBuffered() {
|
|
|
|
return mReader->CanonicalBuffered();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetCDMProxy(CDMProxy* aProxy) { mReader->SetCDMProxy(aProxy); }
|
2016-03-31 11:32:03 +03:00
|
|
|
|
2016-07-29 09:51:18 +03:00
|
|
|
void SetVideoBlankDecode(bool aIsBlankDecode);
|
|
|
|
|
2016-03-31 11:32:03 +03:00
|
|
|
private:
|
|
|
|
~MediaDecoderReaderWrapper();
|
|
|
|
void OnMetadataRead(MetadataHolder* aMetadata);
|
|
|
|
void OnMetadataNotRead() {}
|
2016-05-19 14:02:20 +03:00
|
|
|
|
2016-03-31 11:32:03 +03:00
|
|
|
const RefPtr<AbstractThread> mOwnerThread;
|
|
|
|
const RefPtr<MediaDecoderReader> mReader;
|
|
|
|
|
|
|
|
bool mShutdown = false;
|
2016-10-14 14:10:24 +03:00
|
|
|
Maybe<media::TimeUnit> mStartTime;
|
2016-03-31 11:32:03 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // MediaDecoderReaderWrapper_h_
|