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 "EMEAudioDecoder.h"
8 #include "mozilla/CDMProxy.h"
9 
10 namespace mozilla {
11 
12 void
Error(GMPErr aErr)13 EMEAudioCallbackAdapter::Error(GMPErr aErr)
14 {
15   if (aErr == GMPNoKeyErr) {
16     // The GMP failed to decrypt a frame due to not having a key. This can
17     // happen if a key expires or a session is closed during playback.
18     NS_WARNING("GMP failed to decrypt due to lack of key");
19     return;
20   }
21   AudioCallbackAdapter::Error(aErr);
22 }
23 
EMEAudioDecoder(CDMProxy * aProxy,const GMPAudioDecoderParams & aParams)24 EMEAudioDecoder::EMEAudioDecoder(CDMProxy* aProxy,
25                                  const GMPAudioDecoderParams& aParams)
26   : GMPAudioDecoder(GMPAudioDecoderParams(aParams).WithAdapter(
27                     new EMEAudioCallbackAdapter(aParams.mCallback)))
28   , mProxy(aProxy)
29 {}
30 
31 void
InitTags(nsTArray<nsCString> & aTags)32 EMEAudioDecoder::InitTags(nsTArray<nsCString>& aTags)
33 {
34   aTags.AppendElement(NS_LITERAL_CSTRING("aac"));
35   aTags.AppendElement(NS_ConvertUTF16toUTF8(mProxy->KeySystem()));
36 }
37 
38 nsCString
GetNodeId()39 EMEAudioDecoder::GetNodeId()
40 {
41   return mProxy->GetNodeId();
42 }
43 
44 } // namespace mozilla
45