blob: d28cbdc5701ff2524189341260ab527ddd5d6f13 [file] [log] [blame]
/*
* Copyright (C) 2017 The Android Open Source Project
*
* 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 MOCK_CAS_SESSION_LIBRARY_H_
#define MOCK_CAS_SESSION_LIBRARY_H_
#include <media/cas/CasAPI.h>
#include <media/stagefright/foundation/ABase.h>
#include <utils/KeyedVector.h>
#include <utils/Mutex.h>
#include <utils/RefBase.h>
namespace android {
struct SessionInfo {
CasPlugin *plugin;
uint16_t program_number;
uint16_t elementary_PID;
};
class MockCasSession : public RefBase {
public:
explicit MockCasSession() {}
virtual ~MockCasSession() {}
private:
friend class MockSessionLibrary;
SessionInfo mSessionInfo;
void setSessionInfo(const SessionInfo &info);
const SessionInfo& getSessionInfo() const;
DISALLOW_EVIL_CONSTRUCTORS(MockCasSession);
};
class MockSessionLibrary {
public:
static MockSessionLibrary* get();
status_t addSession(
CasPlugin *plugin,
uint16_t program_number,
uint16_t elementary_PID,
CasSessionId *sessionId);
sp<MockCasSession> findSession(const CasSessionId& sessionId);
void destroySession(const CasSessionId& sessionId);
void destroyPlugin(CasPlugin *plugin);
private:
static Mutex sSingletonLock;
static MockSessionLibrary* sSingleton;
Mutex mSessionsLock;
uint32_t mNextSessionId;
KeyedVector<CasSessionId, sp<MockCasSession> > mIDToSessionMap;
KeyedVector<SessionInfo, CasSessionId> mSessionInfoToIDMap;
MockSessionLibrary();
DISALLOW_EVIL_CONSTRUCTORS(MockSessionLibrary);
};
} // namespace android
#endif // MOCK_CAS_SESSION_LIBRARY_H_