Bug 1173631 - [EME] Implement async shutdown in clearkey GMP. r=cpearce

This commit is contained in:
Gerald Squelart 2015-06-11 22:05:00 +02:00
parent e4e281e7ce
commit 52007e9665
5 changed files with 89 additions and 1 deletions

View File

@ -587,6 +587,7 @@ GMPChild::ShutdownComplete()
{
LOGD("%s", __FUNCTION__);
MOZ_ASSERT(mGMPMessageLoop == MessageLoop::current());
mAsyncShutdown = nullptr;
SendAsyncShutdownComplete();
}

View File

@ -0,0 +1,45 @@
/*
* Copyright 2015, 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.
*/
#include "ClearKeyAsyncShutdown.h"
#include "gmp-task-utils.h"
ClearKeyAsyncShutdown::ClearKeyAsyncShutdown(GMPAsyncShutdownHost *aHostAPI)
: mHost(aHostAPI)
{
CK_LOGD("ClearKeyAsyncShutdown::ClearKeyAsyncShutdown");
AddRef();
}
ClearKeyAsyncShutdown::~ClearKeyAsyncShutdown()
{
CK_LOGD("ClearKeyAsyncShutdown::~ClearKeyAsyncShutdown");
}
void ShutdownTask(ClearKeyAsyncShutdown* aSelf, GMPAsyncShutdownHost* aHost)
{
// Dumb implementation that just immediately reports completion.
// Real GMPs should ensure they are properly shutdown.
CK_LOGD("ClearKeyAsyncShutdown::BeginShutdown calling ShutdownComplete");
aHost->ShutdownComplete();
aSelf->Release();
}
void ClearKeyAsyncShutdown::BeginShutdown()
{
CK_LOGD("ClearKeyAsyncShutdown::BeginShutdown dispatching asynchronous shutdown task");
GetPlatform()->runonmainthread(WrapTaskNM(ShutdownTask, this, mHost));
}

View File

@ -0,0 +1,37 @@
/*
* Copyright 2015, 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.
*/
#ifndef __ClearKeyAsyncShutdown_h__
#define __ClearKeyAsyncShutdown_h__
#include "gmp-async-shutdown.h"
#include "RefCounted.h"
class ClearKeyAsyncShutdown : public GMPAsyncShutdown
, public RefCounted
{
public:
explicit ClearKeyAsyncShutdown(GMPAsyncShutdownHost *aHostAPI);
void BeginShutdown() override;
private:
virtual ~ClearKeyAsyncShutdown();
GMPAsyncShutdownHost* mHost;
};
#endif // __ClearKeyAsyncShutdown_h__

View File

@ -18,7 +18,9 @@
#include <stdio.h>
#include <string.h>
#include "ClearKeyAsyncShutdown.h"
#include "ClearKeySessionManager.h"
#include "gmp-api/gmp-async-shutdown.h"
#include "gmp-api/gmp-decryption.h"
#include "gmp-api/gmp-platform.h"
@ -68,7 +70,9 @@ GMPGetAPI(const char* aApiName, void* aHostAPI, void** aPluginAPI)
*aPluginAPI = new VideoDecoder(static_cast<GMPVideoHost*>(aHostAPI));
}
#endif
else {
else if (!strcmp(aApiName, GMP_API_ASYNC_SHUTDOWN)) {
*aPluginAPI = new ClearKeyAsyncShutdown(static_cast<GMPAsyncShutdownHost*> (aHostAPI));
} else {
CK_LOGE("GMPGetAPI couldn't resolve API name |%s|\n", aApiName);
}

View File

@ -9,6 +9,7 @@ SharedLibrary('clearkey')
FINAL_TARGET = 'dist/bin/gmp-clearkey/0.1'
UNIFIED_SOURCES += [
'ClearKeyAsyncShutdown.cpp',
'ClearKeyBase64.cpp',
'ClearKeyDecryptionManager.cpp',
'ClearKeyPersistence.cpp',