2015-01-16 00:37:54 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2013, Mozilla Foundation and contributors
|
|
|
|
*
|
|
|
|
* 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 __VideoDecoder_h__
|
|
|
|
#define __VideoDecoder_h__
|
2015-01-16 00:37:54 +03:00
|
|
|
|
2015-08-25 13:40:20 +03:00
|
|
|
#include <atomic>
|
2017-01-11 23:52:05 +03:00
|
|
|
#include <queue>
|
|
|
|
#include <thread>
|
2015-08-25 13:40:20 +03:00
|
|
|
|
2017-01-11 23:52:05 +03:00
|
|
|
// This include is required in order for content_decryption_module to work
|
|
|
|
// on Unix systems.
|
|
|
|
#include "stddef.h"
|
|
|
|
#include "content_decryption_module.h"
|
2015-01-16 00:37:54 +03:00
|
|
|
#include "WMFH264Decoder.h"
|
|
|
|
|
2017-01-11 23:52:05 +03:00
|
|
|
class VideoDecoder : public RefCounted
|
2015-01-16 00:37:54 +03:00
|
|
|
{
|
|
|
|
public:
|
2017-01-11 23:52:05 +03:00
|
|
|
explicit VideoDecoder(cdm::Host_8 *aHost);
|
2015-01-16 00:37:54 +03:00
|
|
|
|
2017-01-11 23:52:05 +03:00
|
|
|
cdm::Status InitDecode(const cdm::VideoDecoderConfig& aConfig);
|
2015-01-16 00:37:54 +03:00
|
|
|
|
2017-01-11 23:52:05 +03:00
|
|
|
cdm::Status Decode(const cdm::InputBuffer& aEncryptedBuffer,
|
|
|
|
cdm::VideoFrame* aVideoFrame);
|
2015-01-16 00:37:54 +03:00
|
|
|
|
2017-01-11 23:52:05 +03:00
|
|
|
void Reset();
|
2015-01-16 00:37:54 +03:00
|
|
|
|
2017-01-11 23:52:05 +03:00
|
|
|
void DecodingComplete();
|
2015-01-16 00:37:54 +03:00
|
|
|
|
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 ~VideoDecoder();
|
|
|
|
|
2017-01-11 23:52:05 +03:00
|
|
|
cdm::Status Drain(cdm::VideoFrame* aVideoFrame);
|
2015-01-16 00:37:54 +03:00
|
|
|
|
2015-12-01 08:13:58 +03:00
|
|
|
struct DecodeData {
|
|
|
|
std::vector<uint8_t> mBuffer;
|
2017-01-11 23:52:05 +03:00
|
|
|
uint64_t mTimestamp = 0;
|
2015-12-01 08:13:58 +03:00
|
|
|
CryptoMetaData mCrypto;
|
|
|
|
};
|
|
|
|
|
2017-01-11 23:52:05 +03:00
|
|
|
cdm::Status OutputFrame(cdm::VideoFrame* aVideoFrame);
|
2015-01-16 00:37:54 +03:00
|
|
|
|
|
|
|
HRESULT SampleToVideoFrame(IMFSample* aSample,
|
2015-02-28 00:23:33 +03:00
|
|
|
int32_t aWidth,
|
|
|
|
int32_t aHeight,
|
|
|
|
int32_t aStride,
|
2017-01-11 23:52:05 +03:00
|
|
|
cdm::VideoFrame* aVideoFrame);
|
2015-03-22 21:59:42 +03:00
|
|
|
|
2017-01-11 23:52:05 +03:00
|
|
|
cdm::Host_8* mHost;
|
2015-01-16 00:37:54 +03:00
|
|
|
wmf::AutoPtr<wmf::WMFH264Decoder> mDecoder;
|
2015-01-16 00:37:54 +03:00
|
|
|
|
2017-01-11 23:52:05 +03:00
|
|
|
std::queue<wmf::CComPtr<IMFSample>> mOutputQueue;
|
2015-08-20 01:06:36 +03:00
|
|
|
|
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 // __VideoDecoder_h__
|