Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #include "EMEVideoDecoder.h"
8 : #include "GMPVideoEncodedFrameImpl.h"
9 : #include "MP4Decoder.h"
10 : #include "MediaData.h"
11 : #include "PlatformDecoderModule.h"
12 : #include "VPXDecoder.h"
13 : #include "mozilla/CDMProxy.h"
14 :
15 : namespace mozilla {
16 :
17 0 : EMEVideoDecoder::EMEVideoDecoder(CDMProxy* aProxy,
18 0 : const GMPVideoDecoderParams& aParams)
19 0 : : GMPVideoDecoder(GMPVideoDecoderParams(aParams))
20 : , mProxy(aProxy)
21 0 : , mDecryptorId(aProxy->GetDecryptorId())
22 : {
23 0 : }
24 :
25 : void
26 0 : EMEVideoDecoder::InitTags(nsTArray<nsCString>& aTags)
27 : {
28 0 : VideoInfo config = GetConfig();
29 0 : if (MP4Decoder::IsH264(config.mMimeType)) {
30 0 : aTags.AppendElement(NS_LITERAL_CSTRING("h264"));
31 0 : } else if (VPXDecoder::IsVP8(config.mMimeType)) {
32 0 : aTags.AppendElement(NS_LITERAL_CSTRING("vp8"));
33 0 : } else if (VPXDecoder::IsVP9(config.mMimeType)) {
34 0 : aTags.AppendElement(NS_LITERAL_CSTRING("vp9"));
35 : }
36 0 : aTags.AppendElement(NS_ConvertUTF16toUTF8(mProxy->KeySystem()));
37 0 : }
38 :
39 : nsCString
40 0 : EMEVideoDecoder::GetNodeId()
41 : {
42 0 : return mProxy->GetNodeId();
43 : }
44 :
45 : GMPUniquePtr<GMPVideoEncodedFrame>
46 0 : EMEVideoDecoder::CreateFrame(MediaRawData* aSample)
47 : {
48 : GMPUniquePtr<GMPVideoEncodedFrame> frame =
49 0 : GMPVideoDecoder::CreateFrame(aSample);
50 0 : if (frame && aSample->mCrypto.mValid) {
51 0 : static_cast<gmp::GMPVideoEncodedFrameImpl*>(frame.get())
52 0 : ->InitCrypto(aSample->mCrypto);
53 : }
54 0 : return frame;
55 : }
56 :
57 : } // namespace mozilla
|