2015-01-16 00:37:54 +03:00
|
|
|
/*
|
2015-04-02 23:08:27 +03:00
|
|
|
* Copyright 2015, Mozilla Foundation and contributors
|
2015-01-16 00:37:54 +03:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2015-01-16 00:37:54 +03:00
|
|
|
#ifndef __AudioDecoder_h__
|
|
|
|
#define __AudioDecoder_h__
|
2015-01-16 00:37:54 +03:00
|
|
|
|
2015-01-16 00:37:54 +03:00
|
|
|
#include "gmp-audio-decode.h"
|
|
|
|
#include "gmp-audio-host.h"
|
2015-03-22 21:59:42 +03:00
|
|
|
#include "gmp-task-utils.h"
|
2015-01-16 00:37:54 +03:00
|
|
|
#include "WMFAACDecoder.h"
|
2015-05-06 02:40:40 +03:00
|
|
|
#include "RefCounted.h"
|
2015-01-16 00:37:54 +03:00
|
|
|
|
|
|
|
#include "mfobjects.h"
|
2015-01-16 00:37:54 +03:00
|
|
|
|
|
|
|
class AudioDecoder : public GMPAudioDecoder
|
2015-05-06 02:40:40 +03:00
|
|
|
, public RefCounted
|
2015-01-16 00:37:54 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
AudioDecoder(GMPAudioHost *aHostAPI);
|
|
|
|
|
|
|
|
virtual void InitDecode(const GMPAudioCodec& aCodecSettings,
|
|
|
|
GMPAudioDecoderCallback* aCallback) override;
|
|
|
|
|
|
|
|
virtual void Decode(GMPAudioSamples* aEncodedSamples);
|
|
|
|
|
|
|
|
virtual void Reset() override;
|
|
|
|
|
|
|
|
virtual void Drain() override;
|
|
|
|
|
|
|
|
virtual void DecodingComplete() override;
|
|
|
|
|
2015-03-22 21:59:42 +03:00
|
|
|
bool HasShutdown() { return mHasShutdown; }
|
|
|
|
|
2015-01-16 00:37:54 +03:00
|
|
|
private:
|
2015-05-06 02:40:40 +03:00
|
|
|
virtual ~AudioDecoder();
|
2015-01-16 00:37:54 +03:00
|
|
|
|
2015-01-16 00:37:54 +03:00
|
|
|
void EnsureWorker();
|
|
|
|
|
2015-01-16 00:37:54 +03:00
|
|
|
void DecodeTask(GMPAudioSamples* aEncodedSamples);
|
|
|
|
void DrainTask();
|
|
|
|
|
|
|
|
void ReturnOutput(IMFSample* aSample);
|
|
|
|
|
|
|
|
HRESULT MFToGMPSample(IMFSample* aSample,
|
|
|
|
GMPAudioSamples* aAudioFrame);
|
|
|
|
|
2015-05-06 02:40:40 +03:00
|
|
|
void MaybeRunOnMainThread(GMPTask* aTask);
|
2015-03-22 21:59:42 +03:00
|
|
|
|
2015-01-16 00:37:54 +03:00
|
|
|
GMPAudioHost *mHostAPI; // host-owned, invalid at DecodingComplete
|
|
|
|
GMPAudioDecoderCallback* mCallback; // host-owned, invalid at DecodingComplete
|
|
|
|
GMPThread* mWorkerThread;
|
|
|
|
GMPMutex* mMutex;
|
2015-01-16 00:37:54 +03:00
|
|
|
wmf::AutoPtr<wmf::WMFAACDecoder> mDecoder;
|
2015-01-16 00:37:54 +03:00
|
|
|
|
|
|
|
int32_t mNumInputTasks;
|
2015-03-22 21:59:42 +03:00
|
|
|
|
|
|
|
bool mHasShutdown;
|
2015-01-16 00:37:54 +03:00
|
|
|
};
|
|
|
|
|
2015-01-16 00:37:54 +03:00
|
|
|
#endif // __AudioDecoder_h__
|