2016-04-14 07:01:55 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* 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 "SeekTask.h"
|
|
|
|
#include "MediaDecoderReaderWrapper.h"
|
|
|
|
#include "mozilla/AbstractThread.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
SeekTask::SeekTask(const void* aDecoderID,
|
|
|
|
AbstractThread* aThread,
|
2016-04-19 11:14:46 +03:00
|
|
|
MediaDecoderReaderWrapper* aReader,
|
2016-07-05 09:12:42 +03:00
|
|
|
const SeekTarget& aTarget)
|
2016-04-14 07:01:55 +03:00
|
|
|
: mDecoderID(aDecoderID)
|
|
|
|
, mOwnerThread(aThread)
|
2016-04-19 11:14:46 +03:00
|
|
|
, mReader(aReader)
|
2016-07-05 09:12:42 +03:00
|
|
|
, mTarget(aTarget)
|
2016-04-14 07:01:55 +03:00
|
|
|
, mIsDiscarded(false)
|
|
|
|
, mIsAudioQueueFinished(false)
|
|
|
|
, mIsVideoQueueFinished(false)
|
|
|
|
{
|
2016-05-24 06:02:57 +03:00
|
|
|
AssertOwnerThread();
|
2016-04-14 07:01:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
SeekTask::~SeekTask()
|
|
|
|
{
|
2016-05-24 06:02:57 +03:00
|
|
|
AssertOwnerThread();
|
2016-04-14 07:01:55 +03:00
|
|
|
MOZ_ASSERT(mIsDiscarded);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SeekTask::Resolve(const char* aCallSite)
|
|
|
|
{
|
2016-05-24 06:02:57 +03:00
|
|
|
AssertOwnerThread();
|
|
|
|
|
2016-04-14 07:01:55 +03:00
|
|
|
SeekTaskResolveValue val;
|
|
|
|
val.mSeekedAudioData = mSeekedAudioData;
|
|
|
|
val.mSeekedVideoData = mSeekedVideoData;
|
|
|
|
val.mIsAudioQueueFinished = mIsAudioQueueFinished;
|
|
|
|
val.mIsVideoQueueFinished = mIsVideoQueueFinished;
|
|
|
|
|
|
|
|
mSeekTaskPromise.Resolve(val, aCallSite);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-09-10 17:45:34 +03:00
|
|
|
SeekTask::RejectIfExist(const MediaResult& aError, const char* aCallSite)
|
2016-04-14 07:01:55 +03:00
|
|
|
{
|
2016-05-24 06:02:57 +03:00
|
|
|
AssertOwnerThread();
|
|
|
|
|
2016-04-14 07:01:55 +03:00
|
|
|
SeekTaskRejectValue val;
|
|
|
|
val.mIsAudioQueueFinished = mIsAudioQueueFinished;
|
|
|
|
val.mIsVideoQueueFinished = mIsVideoQueueFinished;
|
2016-09-10 17:45:34 +03:00
|
|
|
val.mError = aError;
|
2016-04-14 07:01:55 +03:00
|
|
|
|
|
|
|
mSeekTaskPromise.RejectIfExists(val, aCallSite);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SeekTask::AssertOwnerThread() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
|
|
|
|
}
|
|
|
|
|
|
|
|
AbstractThread*
|
|
|
|
SeekTask::OwnerThread() const
|
|
|
|
{
|
2016-05-24 06:02:57 +03:00
|
|
|
AssertOwnerThread();
|
2016-04-14 07:01:55 +03:00
|
|
|
return mOwnerThread;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mozilla
|