mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1056537 - Move MediaDecoderReader::FindStartTime down to only remaining user, OggReader. r=cpearce
This commit is contained in:
parent
e5d3630e74
commit
6524479634
@ -105,79 +105,6 @@ nsresult MediaDecoderReader::ResetDecode()
|
||||
return res;
|
||||
}
|
||||
|
||||
VideoData* MediaDecoderReader::DecodeToFirstVideoData()
|
||||
{
|
||||
bool eof = false;
|
||||
while (!eof && VideoQueue().GetSize() == 0) {
|
||||
{
|
||||
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
|
||||
if (mDecoder->IsShutdown()) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
bool keyframeSkip = false;
|
||||
eof = !DecodeVideoFrame(keyframeSkip, 0);
|
||||
}
|
||||
if (eof) {
|
||||
VideoQueue().Finish();
|
||||
}
|
||||
VideoData* d = nullptr;
|
||||
return (d = VideoQueue().PeekFront()) ? d : nullptr;
|
||||
}
|
||||
|
||||
AudioData* MediaDecoderReader::DecodeToFirstAudioData()
|
||||
{
|
||||
bool eof = false;
|
||||
while (!eof && AudioQueue().GetSize() == 0) {
|
||||
{
|
||||
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
|
||||
if (mDecoder->IsShutdown()) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
eof = !DecodeAudioData();
|
||||
}
|
||||
if (eof) {
|
||||
AudioQueue().Finish();
|
||||
}
|
||||
AudioData* d = nullptr;
|
||||
return (d = AudioQueue().PeekFront()) ? d : nullptr;
|
||||
}
|
||||
|
||||
VideoData* MediaDecoderReader::FindStartTime(int64_t& aOutStartTime)
|
||||
{
|
||||
NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
|
||||
"Should be on state machine or decode thread.");
|
||||
|
||||
// Extract the start times of the bitstreams in order to calculate
|
||||
// the duration.
|
||||
int64_t videoStartTime = INT64_MAX;
|
||||
int64_t audioStartTime = INT64_MAX;
|
||||
VideoData* videoData = nullptr;
|
||||
|
||||
if (HasVideo()) {
|
||||
videoData = DecodeToFirstVideoData();
|
||||
if (videoData) {
|
||||
videoStartTime = videoData->mTime;
|
||||
DECODER_LOG(PR_LOG_DEBUG, ("MediaDecoderReader::FindStartTime() video=%lld", videoStartTime));
|
||||
}
|
||||
}
|
||||
if (HasAudio()) {
|
||||
AudioData* audioData = DecodeToFirstAudioData();
|
||||
if (audioData) {
|
||||
audioStartTime = audioData->mTime;
|
||||
DECODER_LOG(PR_LOG_DEBUG, ("MediaDecoderReader::FindStartTime() audio=%lld", audioStartTime));
|
||||
}
|
||||
}
|
||||
|
||||
int64_t startTime = std::min(videoStartTime, audioStartTime);
|
||||
if (startTime != INT64_MAX) {
|
||||
aOutStartTime = startTime;
|
||||
}
|
||||
|
||||
return videoData;
|
||||
}
|
||||
|
||||
nsresult
|
||||
MediaDecoderReader::GetBuffered(mozilla::dom::TimeRanges* aBuffered,
|
||||
int64_t aStartTime)
|
||||
|
@ -95,12 +95,6 @@ public:
|
||||
virtual nsresult ReadMetadata(MediaInfo* aInfo,
|
||||
MetadataTags** aTags) = 0;
|
||||
|
||||
// TODO: DEPRECATED. This uses synchronous decoding.
|
||||
// Stores the presentation time of the first frame we'd be able to play if
|
||||
// we started playback at the current position. Returns the first video
|
||||
// frame, if we have video.
|
||||
virtual VideoData* FindStartTime(int64_t& aOutStartTime);
|
||||
|
||||
// Moves the decode head to aTime microseconds. aStartTime and aEndTime
|
||||
// denote the start and end times of the media in usecs, and aCurrentTime
|
||||
// is the current playback position in microseconds.
|
||||
@ -169,9 +163,6 @@ public:
|
||||
return mDecoder;
|
||||
}
|
||||
|
||||
AudioData* DecodeToFirstAudioData();
|
||||
VideoData* DecodeToFirstVideoData();
|
||||
|
||||
MediaInfo GetMediaInfo() { return mInfo; }
|
||||
|
||||
// Indicates if the media is seekable.
|
||||
|
@ -916,7 +916,7 @@ int64_t OggReader::RangeStartTime(int64_t aOffset)
|
||||
nsresult res = resource->Seek(nsISeekableStream::NS_SEEK_SET, aOffset);
|
||||
NS_ENSURE_SUCCESS(res, 0);
|
||||
int64_t startTime = 0;
|
||||
MediaDecoderReader::FindStartTime(startTime);
|
||||
FindStartTime(startTime);
|
||||
return startTime;
|
||||
}
|
||||
|
||||
@ -1860,6 +1860,79 @@ nsresult OggReader::GetBuffered(dom::TimeRanges* aBuffered, int64_t aStartTime)
|
||||
#endif
|
||||
}
|
||||
|
||||
VideoData* OggReader::FindStartTime(int64_t& aOutStartTime)
|
||||
{
|
||||
NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
|
||||
"Should be on state machine or decode thread.");
|
||||
|
||||
// Extract the start times of the bitstreams in order to calculate
|
||||
// the duration.
|
||||
int64_t videoStartTime = INT64_MAX;
|
||||
int64_t audioStartTime = INT64_MAX;
|
||||
VideoData* videoData = nullptr;
|
||||
|
||||
if (HasVideo()) {
|
||||
videoData = DecodeToFirstVideoData();
|
||||
if (videoData) {
|
||||
videoStartTime = videoData->mTime;
|
||||
LOG(PR_LOG_DEBUG, ("OggReader::FindStartTime() video=%lld", videoStartTime));
|
||||
}
|
||||
}
|
||||
if (HasAudio()) {
|
||||
AudioData* audioData = DecodeToFirstAudioData();
|
||||
if (audioData) {
|
||||
audioStartTime = audioData->mTime;
|
||||
LOG(PR_LOG_DEBUG, ("OggReader::FindStartTime() audio=%lld", audioStartTime));
|
||||
}
|
||||
}
|
||||
|
||||
int64_t startTime = std::min(videoStartTime, audioStartTime);
|
||||
if (startTime != INT64_MAX) {
|
||||
aOutStartTime = startTime;
|
||||
}
|
||||
|
||||
return videoData;
|
||||
}
|
||||
|
||||
VideoData* OggReader::DecodeToFirstVideoData()
|
||||
{
|
||||
bool eof = false;
|
||||
while (!eof && VideoQueue().GetSize() == 0) {
|
||||
{
|
||||
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
|
||||
if (mDecoder->IsShutdown()) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
bool keyframeSkip = false;
|
||||
eof = !DecodeVideoFrame(keyframeSkip, 0);
|
||||
}
|
||||
if (eof) {
|
||||
VideoQueue().Finish();
|
||||
}
|
||||
VideoData* d = nullptr;
|
||||
return (d = VideoQueue().PeekFront()) ? d : nullptr;
|
||||
}
|
||||
|
||||
AudioData* OggReader::DecodeToFirstAudioData()
|
||||
{
|
||||
bool eof = false;
|
||||
while (!eof && AudioQueue().GetSize() == 0) {
|
||||
{
|
||||
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
|
||||
if (mDecoder->IsShutdown()) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
eof = !DecodeAudioData();
|
||||
}
|
||||
if (eof) {
|
||||
AudioQueue().Finish();
|
||||
}
|
||||
AudioData* d = nullptr;
|
||||
return (d = AudioQueue().PeekFront()) ? d : nullptr;
|
||||
}
|
||||
|
||||
OggCodecStore::OggCodecStore()
|
||||
: mMonitor("CodecStore")
|
||||
{
|
||||
|
@ -84,6 +84,14 @@ public:
|
||||
virtual bool IsMediaSeekable() MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
// TODO: DEPRECATED. This uses synchronous decoding.
|
||||
// Stores the presentation time of the first frame we'd be able to play if
|
||||
// we started playback at the current position. Returns the first video
|
||||
// frame, if we have video.
|
||||
VideoData* FindStartTime(int64_t& aOutStartTime);
|
||||
AudioData* DecodeToFirstAudioData();
|
||||
VideoData* DecodeToFirstVideoData();
|
||||
|
||||
// This monitor should be taken when reading or writing to mIsChained.
|
||||
ReentrantMonitor mMonitor;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user