mirror of
https://gitee.com/openharmony/castengine_cast_framework
synced 2024-11-23 06:29:46 +00:00
TicketNo:#IB12YJ Description:完善inner_api接口及相关实现
Signed-off-by: LongestDistance <cdwango@isoftstone.com>
This commit is contained in:
parent
c87351fe0e
commit
0787c05342
@ -39,14 +39,18 @@ private:
|
||||
|
||||
bool GetCastRemoteDevices(MessageParcel &data, std::vector<CastRemoteDevice> &deviceList);
|
||||
bool GetCastSession(MessageParcel &data, std::shared_ptr<ICastSession> &castSession);
|
||||
|
||||
int32_t DoDeviceFoundTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoDeviceOfflineTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoSessionCreateTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoServiceDieTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoOnLogEventTask(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
void OnDeviceFound(const std::vector<CastRemoteDevice> &deviceList) override;
|
||||
void OnDeviceOffline(const std::string &deviceId) override;
|
||||
void OnSessionCreated(const sptr<ICastSessionImpl> &castSession) override;
|
||||
void OnServiceDied() override;
|
||||
void OnLogEvent(int32_t eventId, int64_t param) override;
|
||||
|
||||
std::shared_ptr<ICastSessionManagerListener> userListener_;
|
||||
};
|
||||
|
@ -34,18 +34,23 @@ public:
|
||||
|
||||
int32_t RegisterListener(std::shared_ptr<ICastSessionListener> listener) override;
|
||||
int32_t UnregisterListener() override;
|
||||
|
||||
int32_t AddDevice(const CastRemoteDevice &remoteDevice) override;
|
||||
int32_t RemoveDevice(const std::string &deviceId) override;
|
||||
|
||||
int32_t StartAuth(const AuthInfo &authInfo) override;
|
||||
int32_t GetSessionId(std::string &sessionId) override;
|
||||
int32_t SetSessionProperty(const CastSessionProperty &property) override;
|
||||
int32_t SetSessionId(std::string sessionId);
|
||||
int32_t CreateMirrorPlayer(std::shared_ptr<IMirrorPlayer> &mirrorPlayer) override;
|
||||
int32_t CreateStreamPlayer(std::shared_ptr<IStreamPlayer> &streamPlayer) override;
|
||||
int32_t Release() override;
|
||||
int32_t NotifyEvent(EventId eventId, std::string &jsonParam) override;
|
||||
|
||||
int32_t GetSessionId(std::string &sessionId) override;
|
||||
int32_t GetRemoteDeviceInfo(std::string deviceId, CastRemoteDevice &remoteDevice) override;
|
||||
|
||||
int32_t SetSessionProperty(const CastSessionProperty &property) override;
|
||||
int32_t SetSessionId(std::string sessionId);
|
||||
int32_t SetCastMode(CastMode mode, std::string &jsonParam) override;
|
||||
|
||||
int32_t CreateMirrorPlayer(std::shared_ptr<IMirrorPlayer> &mirrorPlayer) override;
|
||||
int32_t CreateStreamPlayer(std::shared_ptr<IStreamPlayer> &streamPlayer) override;
|
||||
private:
|
||||
sptr<ICastSessionImpl> proxy_;
|
||||
std::string sessionId_{};
|
||||
|
@ -41,12 +41,17 @@ public:
|
||||
sptr<IRemoteObject::DeathRecipient> deathRecipient) override;
|
||||
int32_t UnregisterListener() override;
|
||||
int32_t Release() override;
|
||||
int32_t SetLocalDevice(const CastLocalDevice &localDevice) override;
|
||||
int32_t CreateCastSession(const CastSessionProperty &property, std::shared_ptr<ICastSession> &castSession) override;
|
||||
int32_t SetSinkSessionCapacity(int sessionCapacity) override;
|
||||
int32_t StartDiscovery(int protocols) override;
|
||||
int32_t SetDiscoverable(bool enable) override;
|
||||
|
||||
int32_t StartDeviceLogging(int32_t fd, uint32_t maxSize) override;
|
||||
int32_t StartDiscovery(int protocols, std::vector<std::string> drmSchemes) override;
|
||||
int32_t StopDiscovery() override;
|
||||
|
||||
int32_t CreateCastSession(const CastSessionProperty &property, std::shared_ptr<ICastSession> &castSession) override;
|
||||
|
||||
int32_t SetLocalDevice(const CastLocalDevice &localDevice) override;
|
||||
int32_t SetSinkSessionCapacity(int sessionCapacity) override;
|
||||
int32_t SetDiscoverable(bool enable) override;
|
||||
|
||||
int32_t GetCastSession(std::string sessionId, std::shared_ptr<ICastSession> &castSession) override;
|
||||
|
||||
private:
|
||||
|
@ -35,12 +35,16 @@ public:
|
||||
int32_t RegisterListener(sptr<ICastServiceListenerImpl> listener) override;
|
||||
int32_t UnregisterListener() override;
|
||||
int32_t Release() override;
|
||||
int32_t SetLocalDevice(const CastLocalDevice &localDevice) override;
|
||||
|
||||
int32_t CreateCastSession(const CastSessionProperty &property, sptr<ICastSessionImpl> &castSession) override;
|
||||
int32_t SetLocalDevice(const CastLocalDevice &localDevice) override;
|
||||
int32_t SetSinkSessionCapacity(int sessionCapacity) override;
|
||||
int32_t StartDiscovery(int protocols) override;
|
||||
int32_t SetDiscoverable(bool enable) override;
|
||||
|
||||
int32_t StartDiscovery(int protocols, std::vector<std::string> drmSchemes) override;
|
||||
int32_t StopDiscovery() override;
|
||||
int32_t StartDeviceLogging(int32_t fd, uint32_t maxSize) override;
|
||||
|
||||
sptr<IRemoteObject> GetSessionManagerService();
|
||||
int32_t GetCastSession(std::string sessionId, sptr<ICastSessionImpl> &castSession) override;
|
||||
|
||||
|
@ -48,13 +48,16 @@ public:
|
||||
int32_t SetVolume(int volume) override;
|
||||
int32_t SetMute(bool mute) override;
|
||||
int32_t SetLoopMode(const LoopMode mode) override;
|
||||
int32_t SetAvailableCapability(const StreamCapability &streamCapability) override;
|
||||
int32_t SetSpeed(const PlaybackSpeed speed) override;
|
||||
|
||||
int32_t GetPlayerStatus(PlayerStates &playerStates) override;
|
||||
int32_t GetPosition(int &position) override;
|
||||
int32_t GetDuration(int &duration) override;
|
||||
int32_t GetVolume(int &volume, int &maxVolume) override;
|
||||
int32_t GetMute(bool &mute) override;
|
||||
int32_t GetLoopMode(LoopMode &loopMode) override;
|
||||
int32_t GetAvailableCapability(StreamCapability &streamCapability) override;
|
||||
int32_t GetPlaySpeed(PlaybackSpeed &playbackSpeed) override;
|
||||
int32_t GetMediaInfoHolder(MediaInfoHolder &mediaInfoHolder) override;
|
||||
int32_t Release() override;
|
||||
|
@ -48,13 +48,16 @@ public:
|
||||
int32_t SetVolume(int volume) override;
|
||||
int32_t SetMute(bool mute) override;
|
||||
int32_t SetLoopMode(const LoopMode mode) override;
|
||||
int32_t SetAvailableCapability(const StreamCapability &streamCapability) override;
|
||||
int32_t SetSpeed(const PlaybackSpeed speed) override;
|
||||
|
||||
int32_t GetPlayerStatus(PlayerStates &playerStates) override;
|
||||
int32_t GetPosition(int &position) override;
|
||||
int32_t GetDuration(int &duration) override;
|
||||
int32_t GetVolume(int &volume, int &maxVolume) override;
|
||||
int32_t GetMute(bool &mute) override;
|
||||
int32_t GetLoopMode(LoopMode &loopMode) override;
|
||||
int32_t GetAvailableCapability(StreamCapability &streamCapability) override;
|
||||
int32_t GetPlaySpeed(PlaybackSpeed &playbackSpeed) override;
|
||||
int32_t GetMediaInfoHolder(MediaInfoHolder &mediaInfoHolder) override;
|
||||
int32_t Release() override;
|
||||
|
@ -53,6 +53,8 @@ private:
|
||||
int32_t DoOnPlayRequestTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoOnImageChangedTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoOnAlbumCoverChangedTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoOnAvailableCapabilityChangedTask(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
void OnStateChanged(const PlayerStates playbackState, bool isPlayWhenReady) override;
|
||||
void OnPositionChanged(int position, int bufferPosition, int duration) override;
|
||||
void OnMediaItemChanged(const MediaInfo &mediaInfo) override;
|
||||
@ -68,6 +70,7 @@ private:
|
||||
void OnPlayRequest(const MediaInfo &mediaInfo) override;
|
||||
void OnImageChanged(std::shared_ptr<Media::PixelMap> pixelMap) override;
|
||||
void OnAlbumCoverChanged(std::shared_ptr<Media::PixelMap> pixelMap) override;
|
||||
void OnAvailableCapabilityChanged(const StreamCapability &streamCapability) override;
|
||||
|
||||
std::shared_ptr<IStreamPlayerListener> userListener_;
|
||||
};
|
||||
|
@ -19,14 +19,14 @@
|
||||
#include "cast_engine_log.h"
|
||||
#include "cast_engine_common.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "cast_engine_service_load_callback.h"
|
||||
#include "cast_session_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace CastEngine {
|
||||
namespace CastEngineClient {
|
||||
DEFINE_CAST_ENGINE_LABEL("Cast-Client-LoadServiceCallback");
|
||||
|
||||
void CastEngineServiceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId,
|
||||
void CastSessionManager::CastEngineServiceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId,
|
||||
const sptr<IRemoteObject> &remoteObject)
|
||||
{
|
||||
CLOGI("In systemAbilityId: %d", systemAbilityId);
|
||||
@ -40,11 +40,11 @@ void CastEngineServiceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbi
|
||||
}
|
||||
}
|
||||
|
||||
void CastEngineServiceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
|
||||
void CastSessionManager::CastEngineServiceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
|
||||
{
|
||||
CLOGI("In systemAbilityId: %d.", systemAbilityId);
|
||||
if (systemAbilityId != CAST_ENGINE_SA_ID) {
|
||||
CLOGE("Start aystemabilityId is not sinkSAId!");
|
||||
CLOGE("Start systemAbilityId is not sinkSAId!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -33,13 +33,6 @@ namespace CastEngine {
|
||||
namespace CastEngineClient {
|
||||
DEFINE_CAST_ENGINE_LABEL("Cast-Client-ServiceListener");
|
||||
|
||||
int CastServiceListenerImplStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
{
|
||||
RETURN_IF_WRONG_TASK(code, data, reply, option);
|
||||
return EXECUTE_SINGLE_STUB_TASK(code, data, reply);
|
||||
}
|
||||
|
||||
CastServiceListenerImplStub::CastServiceListenerImplStub(std::shared_ptr<ICastSessionManagerListener> userListener)
|
||||
: userListener_(userListener)
|
||||
{
|
||||
@ -47,12 +40,14 @@ CastServiceListenerImplStub::CastServiceListenerImplStub(std::shared_ptr<ICastSe
|
||||
FILL_SINGLE_STUB_TASK(ON_DEVICE_OFFLINE, &CastServiceListenerImplStub::DoDeviceOfflineTask);
|
||||
FILL_SINGLE_STUB_TASK(ON_SESSION_CREATE, &CastServiceListenerImplStub::DoSessionCreateTask);
|
||||
FILL_SINGLE_STUB_TASK(ON_SERVICE_DIE, &CastServiceListenerImplStub::DoServiceDieTask);
|
||||
FILL_SINGLE_STUB_TASK(ON_LOG_EVENT, &CastServiceListenerImplStub::DoOnLogEventTask);
|
||||
}
|
||||
|
||||
int32_t CastServiceListenerImplStub::DoServiceDieTask(MessageParcel &data, MessageParcel &reply)
|
||||
int CastServiceListenerImplStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
{
|
||||
userListener_->OnServiceDied();
|
||||
return ERR_NONE;
|
||||
RETURN_IF_WRONG_TASK(code, data, reply, option);
|
||||
return EXECUTE_SINGLE_STUB_TASK(code, data, reply);
|
||||
}
|
||||
|
||||
bool CastServiceListenerImplStub::GetCastRemoteDevices(MessageParcel &data, std::vector<CastRemoteDevice> &deviceList)
|
||||
@ -91,7 +86,7 @@ bool CastServiceListenerImplStub::GetCastSession(MessageParcel &data, std::share
|
||||
|
||||
int32_t CastServiceListenerImplStub::DoDeviceFoundTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
CLOGI("DoOnDeviceStatusTask in");
|
||||
CLOGI("%{public}s in", __func__);
|
||||
std::vector<CastRemoteDevice> remoteDevices;
|
||||
if (!GetCastRemoteDevices(data, remoteDevices)) {
|
||||
CLOGE("DoDeviceFoundTask, failed get remote devices info");
|
||||
@ -102,12 +97,24 @@ int32_t CastServiceListenerImplStub::DoDeviceFoundTask(MessageParcel &data, Mess
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t CastServiceListenerImplStub::DoDeviceOfflineTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
CLOGI("%{public}s in", __func__);
|
||||
std::string deviceId = data.ReadString();
|
||||
if (deviceId.empty()) {
|
||||
CLOGE("%{public}s, failed get deviceId", __func__);
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
userListener_->OnDeviceOffline(deviceId);
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t CastServiceListenerImplStub::DoSessionCreateTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
CLOGI("DoSessionCreateTask in");
|
||||
CLOGI("%{public}s in", __func__);
|
||||
std::shared_ptr<ICastSession> castSession;
|
||||
if (!GetCastSession(data, castSession)) {
|
||||
CLOGE("DoSessionCreateTask, failed get cast session info");
|
||||
CLOGE("%{public}s, failed get cast session info", __func__);
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
userListener_->OnSessionCreated(castSession);
|
||||
@ -115,15 +122,18 @@ int32_t CastServiceListenerImplStub::DoSessionCreateTask(MessageParcel &data, Me
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t CastServiceListenerImplStub::DoDeviceOfflineTask(MessageParcel &data, MessageParcel &reply)
|
||||
int32_t CastServiceListenerImplStub::DoServiceDieTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
CLOGI("DoDeviceOfflineTask in");
|
||||
std::string deviceId = data.ReadString();
|
||||
if (deviceId.empty()) {
|
||||
CLOGE("DoDeviceOfflineTask, failed get deviceId");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
userListener_->OnDeviceOffline(deviceId);
|
||||
userListener_->OnServiceDied();
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t CastServiceListenerImplStub::DoOnLogEventTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
CLOGI("%{public}s in", __func__);
|
||||
int32_t eventId = data.ReadInt32();
|
||||
int64_t param = data.ReadInt64();
|
||||
userListener_->OnLogEvent(eventId, param);
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
@ -132,6 +142,11 @@ void CastServiceListenerImplStub::OnDeviceFound(const std::vector<CastRemoteDevi
|
||||
static_cast<void>(deviceList);
|
||||
}
|
||||
|
||||
void CastServiceListenerImplStub::OnDeviceOffline(const std::string &deviceId)
|
||||
{
|
||||
static_cast<void>(deviceId);
|
||||
}
|
||||
|
||||
void CastServiceListenerImplStub::OnSessionCreated(const sptr<ICastSessionImpl> &castSession)
|
||||
{
|
||||
static_cast<void>(castSession);
|
||||
@ -139,9 +154,10 @@ void CastServiceListenerImplStub::OnSessionCreated(const sptr<ICastSessionImpl>
|
||||
|
||||
void CastServiceListenerImplStub::OnServiceDied() {}
|
||||
|
||||
void CastServiceListenerImplStub::OnDeviceOffline(const std::string &deviceId)
|
||||
void CastServiceListenerImplStub::OnLogEvent(int32_t eventId, int64_t param)
|
||||
{
|
||||
static_cast<void>(deviceId);
|
||||
static_cast<void>(eventId);
|
||||
static_cast<void>(param);
|
||||
}
|
||||
} // namespace CastEngineClient
|
||||
} // namespace CastEngine
|
||||
|
@ -20,11 +20,8 @@
|
||||
|
||||
#include "cast_session_manager.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include "cast_engine_errors.h"
|
||||
#include "cast_engine_log.h"
|
||||
#include "cast_engine_service_load_callback.h"
|
||||
#include "cast_session_manager_adaptor.h"
|
||||
#include "cast_session_manager_service_proxy.h"
|
||||
#include "i_cast_session.h"
|
||||
@ -36,6 +33,9 @@ namespace OHOS {
|
||||
namespace CastEngine {
|
||||
namespace CastEngineClient {
|
||||
DEFINE_CAST_ENGINE_LABEL("Cast-Client-SessionManager");
|
||||
namespace {
|
||||
constexpr int WAIT_SERVICE_LOAD_TIME_OUT_SECOND = 2;
|
||||
}
|
||||
|
||||
CastSessionManager::CastSessionManager()
|
||||
{
|
||||
@ -51,7 +51,7 @@ CastSessionManager &CastSessionManager::GetInstance()
|
||||
std::shared_ptr<ICastSessionManagerAdaptor> CastSessionManager::GetAdaptor()
|
||||
{
|
||||
CLOGI("in");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
if (adaptor_) {
|
||||
return adaptor_;
|
||||
}
|
||||
@ -66,29 +66,27 @@ std::shared_ptr<ICastSessionManagerAdaptor> CastSessionManager::GetAdaptor()
|
||||
CLOGE("Failed to new object");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto result = samgr->LoadSystemAbility(CAST_ENGINE_SA_ID, loadCallback);
|
||||
if (result != ERR_OK) {
|
||||
CLOGE("systemAbilityId: %d load failed, result code: %d", CAST_ENGINE_SA_ID, result);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
constexpr int32_t sleepTimeMs = 30;
|
||||
constexpr int32_t retryTimes = 150; // The service startup timeout interval is 4s.
|
||||
int32_t retryTime = 0;
|
||||
|
||||
sptr<IRemoteObject> object;
|
||||
while ((object = samgr->CheckSystemAbility(CAST_ENGINE_SA_ID)) == nullptr && (retryTime < retryTimes)) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(sleepTimeMs));
|
||||
constexpr int32_t retryTimes = 5;
|
||||
int retryTime = 0;
|
||||
bool ret = false;
|
||||
isNeedLoadService_ = true;
|
||||
while (!ret && retryTime < retryTimes) {
|
||||
retryTime++;
|
||||
if (isNeedLoadService_) {
|
||||
auto result = samgr->LoadSystemAbility(CAST_ENGINE_SA_ID, loadCallback);
|
||||
if (result != ERR_OK) {
|
||||
CLOGE("systemAbilityId: %d load failed, result code: %d", CAST_ENGINE_SA_ID, result);
|
||||
return nullptr;
|
||||
}
|
||||
isNeedLoadService_ = false;
|
||||
}
|
||||
ret = loadServiceCond_.wait_for(lock, std::chrono::seconds(WAIT_SERVICE_LOAD_TIME_OUT_SECOND),
|
||||
[this] { return (adaptor_ != nullptr); });
|
||||
}
|
||||
if (object == nullptr) {
|
||||
CLOGE("Failed to get cast engine manager");
|
||||
if (!ret) {
|
||||
CLOGE("wait service loaded timeout");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto proxy = iface_cast<CastSessionManagerServiceProxy>(object);
|
||||
adaptor_ = std::make_shared<CastSessionManagerAdaptor>(proxy);
|
||||
return adaptor_;
|
||||
}
|
||||
|
||||
@ -99,21 +97,37 @@ int32_t CastSessionManager::RegisterListener(std::shared_ptr<ICastSessionManager
|
||||
CLOGE("Failed to init due to the null listener");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
auto adaptor = GetAdaptor();
|
||||
if (!adaptor) {
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
sptr<CastEngineServiceDeathRecipient> deathRecipient(
|
||||
new (std::nothrow) CastEngineServiceDeathRecipient(listener));
|
||||
if (!deathRecipient) {
|
||||
CLOGE("Death recipient malloc failed");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (adaptor->RegisterListener(listener, deathRecipient) == CAST_ENGINE_SUCCESS) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
deathRecipient_ = deathRecipient;
|
||||
return CAST_ENGINE_SUCCESS;
|
||||
}
|
||||
constexpr int32_t sleepTimeMs = 200;
|
||||
constexpr int32_t retryTimes = 1;
|
||||
int retryTime = 0;
|
||||
bool retry = false;
|
||||
do {
|
||||
retry = false;
|
||||
auto adaptor = GetAdaptor();
|
||||
if (!adaptor) {
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
sptr<CastEngineServiceDeathRecipient> deathRecipient(
|
||||
new (std::nothrow) CastEngineServiceDeathRecipient(listener));
|
||||
if (!deathRecipient) {
|
||||
CLOGE("Death recipient malloc failed");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
int32_t ret = adaptor->RegisterListener(listener, deathRecipient);
|
||||
if (ret == CAST_ENGINE_SUCCESS) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
deathRecipient_ = deathRecipient;
|
||||
return CAST_ENGINE_SUCCESS;
|
||||
}
|
||||
if (ret == ERR_SERVICE_IS_UNLOADING && retryTime < retryTimes) {
|
||||
CLOGI("cast service is unloading, wait and retry angain");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(sleepTimeMs));
|
||||
retry = true;
|
||||
retryTime++;
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
adaptor_ = nullptr;
|
||||
}
|
||||
} while (retry);
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
@ -165,11 +179,11 @@ int32_t CastSessionManager::SetSinkSessionCapacity(int sessionCapacity)
|
||||
return adaptor ? adaptor->SetSinkSessionCapacity(sessionCapacity) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t CastSessionManager::StartDiscovery(int protocols)
|
||||
int32_t CastSessionManager::StartDiscovery(int protocols, std::vector<std::string> drmSchemes)
|
||||
{
|
||||
CLOGD("in");
|
||||
auto adaptor = GetAdaptor();
|
||||
return adaptor ? adaptor->StartDiscovery(protocols) : CAST_ENGINE_ERROR;
|
||||
return adaptor ? adaptor->StartDiscovery(protocols, drmSchemes) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t CastSessionManager::SetDiscoverable(bool enable)
|
||||
@ -186,6 +200,13 @@ int32_t CastSessionManager::StopDiscovery()
|
||||
return adaptor ? adaptor->StopDiscovery() : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t CastSessionManager::StartDeviceLogging(int32_t fd, uint32_t maxSize)
|
||||
{
|
||||
CLOGI("in");
|
||||
auto adaptor = GetAdaptor();
|
||||
return adaptor ? adaptor->StartDeviceLogging(fd, maxSize) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t CastSessionManager::GetCastSession(std::string sessionId, std::shared_ptr<ICastSession> &castSession)
|
||||
{
|
||||
CLOGI("in");
|
||||
@ -196,9 +217,9 @@ int32_t CastSessionManager::GetCastSession(std::string sessionId, std::shared_pt
|
||||
void CastSessionManager::ReleaseClientResources()
|
||||
{
|
||||
CLOGD("Release client resources");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::shared_ptr<ICastSessionManagerListener> listener;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (!!deathRecipient_) {
|
||||
listener = deathRecipient_->GetListener();
|
||||
}
|
||||
|
@ -73,9 +73,19 @@ int32_t CastSessionManagerAdaptor::Release()
|
||||
return proxy_ ? proxy_->Release() : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerAdaptor::SetLocalDevice(const CastLocalDevice &localDevice)
|
||||
int32_t CastSessionManagerAdaptor::StartDeviceLogging(int32_t fd, uint32_t maxSize)
|
||||
{
|
||||
return proxy_ ? proxy_->SetLocalDevice(localDevice) : CAST_ENGINE_ERROR;
|
||||
return proxy_ ? proxy_->StartDeviceLogging(fd, maxSize) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerAdaptor::StartDiscovery(int protocols, std::vector<std::string> drmSchemes)
|
||||
{
|
||||
return proxy_ ? proxy_->StartDiscovery(protocols, drmSchemes) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerAdaptor::StopDiscovery()
|
||||
{
|
||||
return proxy_ ? proxy_->StopDiscovery() : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerAdaptor::CreateCastSession(const CastSessionProperty &property,
|
||||
@ -106,26 +116,21 @@ int32_t CastSessionManagerAdaptor::CreateCastSession(const CastSessionProperty &
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerAdaptor::SetLocalDevice(const CastLocalDevice &localDevice)
|
||||
{
|
||||
return proxy_ ? proxy_->SetLocalDevice(localDevice) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerAdaptor::SetSinkSessionCapacity(int sessionCapacity)
|
||||
{
|
||||
return proxy_ ? proxy_->SetSinkSessionCapacity(sessionCapacity) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerAdaptor::StartDiscovery(int protocols)
|
||||
{
|
||||
return proxy_ ? proxy_->StartDiscovery(protocols) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerAdaptor::SetDiscoverable(bool enable)
|
||||
{
|
||||
return proxy_ ? proxy_->SetDiscoverable(enable) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerAdaptor::StopDiscovery()
|
||||
{
|
||||
return proxy_ ? proxy_->StopDiscovery() : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerAdaptor::GetCastSession(std::string sessionId, std::shared_ptr<ICastSession> &castSession)
|
||||
{
|
||||
sptr<ICastSessionImpl> impl;
|
||||
|
@ -59,7 +59,7 @@ int32_t CastSessionManagerServiceProxy::UnregisterListener()
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
int32_t ret = Remote()->SendRequest(UNREGISTER_LISTENER, data, reply, option);
|
||||
if (ret == ERR_UNKNOWN_TRANSACTION) {
|
||||
if (ret == ERR_NO_PERMISSION) {
|
||||
CLOGE("No permission when unregistering listener");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret != ERR_NONE) {
|
||||
@ -81,7 +81,7 @@ int32_t CastSessionManagerServiceProxy::Release()
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
int32_t ret = Remote()->SendRequest(RELEASE, data, reply, option);
|
||||
if (ret == ERR_UNKNOWN_TRANSACTION) {
|
||||
if (ret == ERR_NO_PERMISSION) {
|
||||
CLOGE("No permission when Releasing the cast service");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret != ERR_NONE) {
|
||||
@ -92,36 +92,6 @@ int32_t CastSessionManagerServiceProxy::Release()
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerServiceProxy::SetLocalDevice(const CastLocalDevice &localDevice)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!WriteCastLocalDevice(data, localDevice)) {
|
||||
CLOGE("Failed to write cast local device");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t ret = Remote()->SendRequest(SET_LOCAL_DEVICE, data, reply, option);
|
||||
if (ret == ERR_UNKNOWN_TRANSACTION) {
|
||||
CLOGE("No permission when setting local device");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret == ERR_INVALID_DATA) {
|
||||
CLOGE("Invalid parameter when setting local device");
|
||||
return ERR_INVALID_PARAM;
|
||||
} else if (ret != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when setting local device");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerServiceProxy::CreateCastSession(const CastSessionProperty &property,
|
||||
sptr<ICastSessionImpl> &castSession)
|
||||
{
|
||||
@ -139,7 +109,7 @@ int32_t CastSessionManagerServiceProxy::CreateCastSession(const CastSessionPrope
|
||||
}
|
||||
|
||||
int32_t ret = Remote()->SendRequest(CREATE_CAST_SESSION, data, reply, option);
|
||||
if (ret == ERR_UNKNOWN_TRANSACTION) {
|
||||
if (ret == ERR_NO_PERMISSION) {
|
||||
CLOGE("No permission when creating cast session");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret == ERR_INVALID_DATA) {
|
||||
@ -162,6 +132,36 @@ int32_t CastSessionManagerServiceProxy::CreateCastSession(const CastSessionPrope
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerServiceProxy::SetLocalDevice(const CastLocalDevice &localDevice)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!WriteCastLocalDevice(data, localDevice)) {
|
||||
CLOGE("Failed to write cast local device");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t ret = Remote()->SendRequest(SET_LOCAL_DEVICE, data, reply, option);
|
||||
if (ret == ERR_NO_PERMISSION) {
|
||||
CLOGE("No permission when setting local device");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret == ERR_INVALID_DATA) {
|
||||
CLOGE("Invalid parameter when setting local device");
|
||||
return ERR_INVALID_PARAM;
|
||||
} else if (ret != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when setting local device");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerServiceProxy::SetSinkSessionCapacity(int sessionCapacity)
|
||||
{
|
||||
MessageParcel data;
|
||||
@ -178,7 +178,7 @@ int32_t CastSessionManagerServiceProxy::SetSinkSessionCapacity(int sessionCapaci
|
||||
}
|
||||
|
||||
int32_t ret = Remote()->SendRequest(SET_SINK_SESSION_CAPACITY, data, reply, option);
|
||||
if (ret == ERR_UNKNOWN_TRANSACTION) {
|
||||
if (ret == ERR_NO_PERMISSION) {
|
||||
CLOGE("No permission when setting sink session capacity");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret != ERR_NONE) {
|
||||
@ -189,36 +189,6 @@ int32_t CastSessionManagerServiceProxy::SetSinkSessionCapacity(int sessionCapaci
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerServiceProxy::StartDiscovery(int protocols)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!data.WriteInt32(protocols)) {
|
||||
CLOGE("Failed to write the protocol type");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t ret = Remote()->SendRequest(START_DISCOVERY, data, reply, option);
|
||||
if (ret == ERR_UNKNOWN_TRANSACTION) {
|
||||
CLOGE("No permission when starting discovery");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret == ERR_INVALID_DATA) {
|
||||
CLOGE("Invalid parameter when starting discovery");
|
||||
return ERR_INVALID_PARAM;
|
||||
} else if (ret != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when starting discovery");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerServiceProxy::SetDiscoverable(bool enable)
|
||||
{
|
||||
MessageParcel data;
|
||||
@ -235,7 +205,7 @@ int32_t CastSessionManagerServiceProxy::SetDiscoverable(bool enable)
|
||||
}
|
||||
|
||||
int32_t ret = Remote()->SendRequest(SET_DISCOVERABLE, data, reply, option);
|
||||
if (ret == ERR_UNKNOWN_TRANSACTION) {
|
||||
if (ret == ERR_NO_PERMISSION) {
|
||||
CLOGE("No permission when setting discoverable");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret != ERR_NONE) {
|
||||
@ -246,6 +216,46 @@ int32_t CastSessionManagerServiceProxy::SetDiscoverable(bool enable)
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerServiceProxy::StartDiscovery(int protocols, std::vector<std::string> drmSchemes)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!data.WriteInt32(protocols)) {
|
||||
CLOGE("Failed to write the protocol type");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!data.WriteUint32(drmSchemes.size())) {
|
||||
CLOGE("Failed to write the size of drm scheme");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
for (auto iter = drmSchemes.begin(); iter != drmSchemes.end(); iter++) {
|
||||
if (!data.WriteString(*iter)) {
|
||||
CLOGE("Failed to write the drm scheme");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t ret = Remote()->SendRequest(START_DISCOVERY, data, reply, option);
|
||||
if (ret == ERR_NO_PERMISSION) {
|
||||
CLOGE("No permission when starting discovery");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret == ERR_INVALID_DATA) {
|
||||
CLOGE("Invalid parameter when starting discovery");
|
||||
return ERR_INVALID_PARAM;
|
||||
} else if (ret != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when starting discovery");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerServiceProxy::StopDiscovery()
|
||||
{
|
||||
MessageParcel data;
|
||||
@ -258,8 +268,8 @@ int32_t CastSessionManagerServiceProxy::StopDiscovery()
|
||||
}
|
||||
|
||||
int32_t ret = Remote()->SendRequest(STOP_DISCOVERY, data, reply, option);
|
||||
if (ret == ERR_UNKNOWN_TRANSACTION) {
|
||||
CLOGE("No permission when setting discoverable");
|
||||
if (ret == ERR_NO_PERMISSION) {
|
||||
CLOGE("No permission when stop discoverable");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when setting discoverable");
|
||||
@ -269,6 +279,39 @@ int32_t CastSessionManagerServiceProxy::StopDiscovery()
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerServiceProxy::StartDeviceLogging(int32_t fd, uint32_t maxSize)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
(void)data.WriteFileDescriptor(fd);
|
||||
if (!data.WriteUint32(maxSize)) {
|
||||
CLOGE("Failed to write maxSize");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t ret = Remote()->SendRequest(START_DEVICE_LOGGING, data, reply, option);
|
||||
if (ret == ERR_NO_PERMISSION) {
|
||||
CLOGE("No permission when starting device logging");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when starting device logging");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> CastSessionManagerServiceProxy::GetSessionManagerService()
|
||||
{
|
||||
return this->AsObject();
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerServiceProxy::GetCastSession(std::string sessionId, sptr<ICastSessionImpl> &castSession)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
@ -298,11 +341,6 @@ int32_t CastSessionManagerServiceProxy::GetCastSession(std::string sessionId, sp
|
||||
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> CastSessionManagerServiceProxy::GetSessionManagerService()
|
||||
{
|
||||
return this->AsObject();
|
||||
}
|
||||
} // namespace CastEngineClient
|
||||
} // namespace CastEngine
|
||||
} // namespace OHOS
|
||||
|
@ -61,6 +61,7 @@ int32_t StreamPlayer::SetSurface(const std::string &surfaceId)
|
||||
|
||||
sptr<Surface> surface = SurfaceUtils::GetInstance()->GetSurface(surfaceUniqueId);
|
||||
if (!surface) {
|
||||
CLOGE("surface is null, surface uniqueId %" PRIu64, surfaceUniqueId);
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
sptr<IBufferProducer> producer = surface->GetProducer();
|
||||
@ -141,6 +142,11 @@ int32_t StreamPlayer::SetLoopMode(const LoopMode mode)
|
||||
return proxy_ ? proxy_->SetLoopMode(mode) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t StreamPlayer::SetAvailableCapability(const StreamCapability &streamCapability)
|
||||
{
|
||||
return proxy_ ? proxy_->SetAvailableCapability(streamCapability) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t StreamPlayer::SetSpeed(const PlaybackSpeed speed)
|
||||
{
|
||||
return proxy_ ? proxy_->SetSpeed(speed) : CAST_ENGINE_ERROR;
|
||||
@ -176,6 +182,11 @@ int32_t StreamPlayer::GetLoopMode(LoopMode &loopMode)
|
||||
return proxy_ ? proxy_->GetLoopMode(loopMode) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t StreamPlayer::GetAvailableCapability(StreamCapability &streamCapability)
|
||||
{
|
||||
return proxy_ ? proxy_->GetAvailableCapability(streamCapability) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t StreamPlayer::GetPlaySpeed(PlaybackSpeed &playbackSpeed)
|
||||
{
|
||||
return proxy_ ? proxy_->GetPlaySpeed(playbackSpeed) : CAST_ENGINE_ERROR;
|
||||
|
@ -341,7 +341,7 @@ int32_t StreamPlayerImplProxy::SetVolume(int volume)
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!data.WriteInt32(volume)) {
|
||||
CLOGE("Failed to write the position");
|
||||
CLOGE("Failed to write the volume");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (Remote()->SendRequest(SET_VOLUME, data, reply, option) != ERR_NONE) {
|
||||
@ -385,7 +385,7 @@ int32_t StreamPlayerImplProxy::SetLoopMode(const LoopMode mode)
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!data.WriteInt32(static_cast<int32_t>(mode))) {
|
||||
CLOGE("Failed to write the position");
|
||||
CLOGE("Failed to write the mode");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (Remote()->SendRequest(SET_LOOP_MODE, data, reply, option) != ERR_NONE) {
|
||||
@ -396,6 +396,28 @@ int32_t StreamPlayerImplProxy::SetLoopMode(const LoopMode mode)
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t StreamPlayerImplProxy::SetAvailableCapability(const StreamCapability &streamCapability)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!WriteStreamCapability(data, streamCapability)) {
|
||||
CLOGE("Failed to write the modeScope");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (Remote()->SendRequest(SET_AVAILABLE_CAPABILITY, data, reply, option) != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when set available capability");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t StreamPlayerImplProxy::SetSpeed(const PlaybackSpeed speed)
|
||||
{
|
||||
MessageParcel data;
|
||||
@ -553,6 +575,28 @@ int32_t StreamPlayerImplProxy::GetLoopMode(LoopMode &loopMode)
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
int32_t StreamPlayerImplProxy::GetAvailableCapability(StreamCapability &streamCapability)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (Remote()->SendRequest(GET_AVAILABLE_CAPABILITY, data, reply, option) != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when get available capability");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t errorCode = reply.ReadInt32();
|
||||
CHECK_AND_RETURN_RET_LOG(errorCode != CAST_ENGINE_SUCCESS, errorCode, "CastEngine Errors");
|
||||
streamCapability = ReadStreamCapability(reply);
|
||||
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
int32_t StreamPlayerImplProxy::GetPlaySpeed(PlaybackSpeed &playbackSpeed)
|
||||
{
|
||||
MessageParcel data;
|
||||
@ -611,11 +655,11 @@ int32_t StreamPlayerImplProxy::Release()
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return false;
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (Remote()->SendRequest(RELEASE, data, reply, option) != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when Releasing stream player");
|
||||
return false;
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
return reply.ReadInt32();
|
||||
|
@ -54,6 +54,8 @@ StreamPlayerListenerImplStub::StreamPlayerListenerImplStub(std::shared_ptr<IStre
|
||||
FILL_SINGLE_STUB_TASK(ON_PLAY_REQUEST, &StreamPlayerListenerImplStub::DoOnPlayRequestTask);
|
||||
FILL_SINGLE_STUB_TASK(ON_IMAGE_CHANGED, &StreamPlayerListenerImplStub::DoOnImageChangedTask);
|
||||
FILL_SINGLE_STUB_TASK(ON_ALBUM_COVER_CHANGED, &StreamPlayerListenerImplStub::DoOnAlbumCoverChangedTask);
|
||||
FILL_SINGLE_STUB_TASK(ON_AVAILABLE_CAPABILITY_CHANGED,
|
||||
&StreamPlayerListenerImplStub::DoOnAvailableCapabilityChangedTask);
|
||||
}
|
||||
|
||||
StreamPlayerListenerImplStub::~StreamPlayerListenerImplStub()
|
||||
@ -223,6 +225,14 @@ int32_t StreamPlayerListenerImplStub::DoOnAlbumCoverChangedTask(MessageParcel &d
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t StreamPlayerListenerImplStub::DoOnAvailableCapabilityChangedTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
static_cast<void>(reply);
|
||||
auto streamCapability = ReadStreamCapability(data);
|
||||
userListener_->OnAvailableCapabilityChanged(streamCapability);
|
||||
|
||||
return ERR_NONE;
|
||||
}
|
||||
void StreamPlayerListenerImplStub::OnStateChanged(const PlayerStates playbackState, bool isPlayWhenReady)
|
||||
{
|
||||
static_cast<void>(playbackState);
|
||||
@ -301,6 +311,11 @@ void StreamPlayerListenerImplStub::OnAlbumCoverChanged(std::shared_ptr<Media::Pi
|
||||
{
|
||||
static_cast<void>(pixelMap);
|
||||
}
|
||||
|
||||
void StreamPlayerListenerImplStub::OnAvailableCapabilityChanged(const StreamCapability &streamCapability)
|
||||
{
|
||||
static_cast<void>(streamCapability);
|
||||
}
|
||||
} // namespace CastEngineClient
|
||||
} // namespace CastEngine
|
||||
} // namespace OHOS
|
||||
|
@ -28,6 +28,9 @@ bool WriteCastRemoteDevice(Parcel &parcel, const CastRemoteDevice &device);
|
||||
std::unique_ptr<CastRemoteDevice> ReadCastRemoteDevice(Parcel &parcel);
|
||||
bool ReadCastRemoteDevice(Parcel &parcel, CastRemoteDevice &device);
|
||||
|
||||
bool WriteStreamCapability(MessageParcel &parcel, const StreamCapability &streamCapability);
|
||||
StreamCapability ReadStreamCapability(MessageParcel &parcel);
|
||||
|
||||
bool WriteMediaInfo(MessageParcel &parcel, const MediaInfo &mediaInfo);
|
||||
std::unique_ptr<MediaInfo> ReadMediaInfo(MessageParcel &parcel);
|
||||
|
||||
|
@ -40,13 +40,15 @@ public:
|
||||
virtual void OnDeviceOffline(const std::string &deviceId) = 0;
|
||||
virtual void OnSessionCreated(const sptr<ICastSessionImpl> &castSession) = 0;
|
||||
virtual void OnServiceDied() = 0;
|
||||
virtual void OnLogEvent(int32_t eventId, int64_t param) = 0;
|
||||
|
||||
protected:
|
||||
enum {
|
||||
ON_DEVICE_FOUND = 1,
|
||||
ON_DEVICE_OFFLINE,
|
||||
ON_SESSION_CREATE,
|
||||
ON_SERVICE_DIE
|
||||
ON_SERVICE_DIE,
|
||||
ON_LOG_EVENT
|
||||
};
|
||||
};
|
||||
} // namespace CastEngine
|
||||
|
@ -44,9 +44,10 @@ public:
|
||||
virtual int32_t SetLocalDevice(const CastLocalDevice &localDevice) = 0;
|
||||
virtual int32_t CreateCastSession(const CastSessionProperty &property, sptr<ICastSessionImpl> &castSession) = 0;
|
||||
virtual int32_t SetSinkSessionCapacity(int sessionCapacity) = 0;
|
||||
virtual int32_t StartDiscovery(int protocols) = 0;
|
||||
virtual int32_t StartDiscovery(int protocols, std::vector<std::string> drmSchemes) = 0;
|
||||
virtual int32_t SetDiscoverable(bool enable) = 0;
|
||||
virtual int32_t StopDiscovery() = 0;
|
||||
virtual int32_t StartDeviceLogging(int32_t fd, uint32_t maxSize) = 0;
|
||||
virtual int32_t GetCastSession(std::string sessionId, sptr<ICastSessionImpl> &castSession) = 0;
|
||||
|
||||
protected:
|
||||
@ -60,6 +61,7 @@ protected:
|
||||
START_DISCOVERY,
|
||||
SET_DISCOVERABLE,
|
||||
STOP_DISCOVERY,
|
||||
START_DEVICE_LOGGING,
|
||||
GET_CAST_SESSION
|
||||
};
|
||||
};
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
virtual int32_t SetVolume(int volume) = 0;
|
||||
virtual int32_t SetMute(bool mute) = 0;
|
||||
virtual int32_t SetLoopMode(const LoopMode mode) = 0;
|
||||
virtual int32_t SetAvailableCapability(const StreamCapability &streamCapability) = 0;
|
||||
virtual int32_t SetSpeed(const PlaybackSpeed speed) = 0;
|
||||
virtual int32_t GetPlayerStatus(PlayerStates &playerStates) = 0;
|
||||
virtual int32_t GetPosition(int &position) = 0;
|
||||
@ -63,6 +64,7 @@ public:
|
||||
virtual int32_t GetVolume(int &volume, int &maxVolume) = 0;
|
||||
virtual int32_t GetMute(bool &mute) = 0;
|
||||
virtual int32_t GetLoopMode(LoopMode &loopMode) = 0;
|
||||
virtual int32_t GetAvailableCapability(StreamCapability &streamCapability) = 0;
|
||||
virtual int32_t GetPlaySpeed(PlaybackSpeed &playbackSpeed) = 0;
|
||||
virtual int32_t GetMediaInfoHolder(MediaInfoHolder &mediaInfoHolder) = 0;
|
||||
virtual int32_t Release() = 0;
|
||||
@ -86,6 +88,7 @@ protected:
|
||||
SET_VOLUME,
|
||||
SET_MUTE,
|
||||
SET_LOOP_MODE,
|
||||
SET_AVAILABLE_CAPABILITY,
|
||||
SET_SPEED,
|
||||
GET_PLAYER_STATUS,
|
||||
GET_POSITION,
|
||||
@ -93,6 +96,7 @@ protected:
|
||||
GET_VOLUME,
|
||||
GET_MUTE,
|
||||
GET_LOOP_MODE,
|
||||
GET_AVAILABLE_CAPABILITY,
|
||||
GET_PLAY_SPEED,
|
||||
GET_MEDIA_INFO_HOLDER,
|
||||
RELEASE
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
virtual void OnPlayRequest(const MediaInfo &mediaInfo) = 0;
|
||||
virtual void OnImageChanged(std::shared_ptr<Media::PixelMap> pixelMap) = 0;
|
||||
virtual void OnAlbumCoverChanged(std::shared_ptr<Media::PixelMap> pixelMap) = 0;
|
||||
virtual void OnAvailableCapabilityChanged(const StreamCapability &streamCapability) = 0;
|
||||
|
||||
protected:
|
||||
enum {
|
||||
@ -67,7 +68,8 @@ protected:
|
||||
ON_END_OF_STREAM,
|
||||
ON_PLAY_REQUEST,
|
||||
ON_IMAGE_CHANGED,
|
||||
ON_ALBUM_COVER_CHANGED
|
||||
ON_ALBUM_COVER_CHANGED,
|
||||
ON_AVAILABLE_CAPABILITY_CHANGED,
|
||||
};
|
||||
};
|
||||
} // namespace CastEngine
|
||||
|
@ -25,6 +25,7 @@
|
||||
namespace OHOS {
|
||||
namespace CastEngine {
|
||||
DEFINE_CAST_ENGINE_LABEL("Cast-Engine-helper");
|
||||
constexpr uint32_t MAX_CYCLES_NUM = 10;
|
||||
|
||||
namespace {
|
||||
constexpr int SESSION_KEY_LENGTH = 16;
|
||||
@ -139,16 +140,25 @@ int GetLocalFd(const std::string &url)
|
||||
bool WriteCastRemoteDevice(Parcel &parcel, const CastRemoteDevice &device)
|
||||
{
|
||||
bool res = parcel.WriteInt32(static_cast<int32_t>(device.deviceType)) &&
|
||||
parcel.WriteInt32(static_cast<int32_t>(device.capability)) &&
|
||||
parcel.WriteInt32(static_cast<int32_t>(device.subDeviceType)) &&
|
||||
parcel.WriteInt32(static_cast<int32_t>(device.channelType)) && parcel.WriteString(device.deviceId) &&
|
||||
parcel.WriteString(device.deviceName) && parcel.WriteString(device.ipAddress) &&
|
||||
parcel.WriteString(device.networkId) && parcel.WriteString(device.localIpAddress);
|
||||
parcel.WriteString(device.networkId) && parcel.WriteString(device.localIpAddress) &&
|
||||
parcel.WriteBool(device.isLeagacy) && parcel.WriteInt32(device.sessionId) &&
|
||||
parcel.WriteUint32(device.mediumTypes) && parcel.WriteUint32(device.protocolCapabilities) &&
|
||||
parcel.WriteString(device.dlnaDeviceModelNameStr) && parcel.WriteString(device.dlnaDeviceManufacturerStr);
|
||||
if (device.sessionKeyLength == SESSION_KEY_LENGTH && device.sessionKey) {
|
||||
res = res && parcel.WriteUint32(device.sessionKeyLength);
|
||||
res = res && parcel.WriteBuffer(device.sessionKey, device.sessionKeyLength);
|
||||
} else {
|
||||
parcel.WriteUint32(0);
|
||||
}
|
||||
uint32_t drmCapabilitySize = device.drmCapabilities.size();
|
||||
res = res && parcel.WriteUint32(drmCapabilitySize);
|
||||
for (auto iter = device.drmCapabilities.begin(); iter != device.drmCapabilities.end(); iter++) {
|
||||
res = res && parcel.WriteString(*iter);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -168,9 +178,16 @@ std::unique_ptr<CastRemoteDevice> ReadCastRemoteDevice(Parcel &parcel)
|
||||
{
|
||||
auto device = std::make_unique<CastRemoteDevice>();
|
||||
auto deviceType = parcel.ReadInt32();
|
||||
auto capability = parcel.ReadInt32();
|
||||
auto subDeviceType = parcel.ReadInt32();
|
||||
auto channelType = parcel.ReadInt32();
|
||||
if (!IsDeviceType(deviceType) || !IsSubDeviceType(subDeviceType) ||
|
||||
!IsChannelType(channelType) || !IsCapabilityType(capability)) {
|
||||
CLOGE("ReadCastRemoteDevice error");
|
||||
return nullptr;
|
||||
}
|
||||
device->deviceType = static_cast<DeviceType>(deviceType);
|
||||
device->capability = static_cast<CapabilityType>(capability);
|
||||
device->subDeviceType = static_cast<SubDeviceType>(subDeviceType);
|
||||
device->channelType = static_cast<ChannelType>(channelType);
|
||||
device->deviceId = parcel.ReadString();
|
||||
@ -178,6 +195,12 @@ std::unique_ptr<CastRemoteDevice> ReadCastRemoteDevice(Parcel &parcel)
|
||||
device->ipAddress = parcel.ReadString();
|
||||
device->networkId = parcel.ReadString();
|
||||
device->localIpAddress = parcel.ReadString();
|
||||
device->isLeagacy = parcel.ReadBool();
|
||||
device->sessionId = parcel.ReadInt32();
|
||||
device->mediumTypes = parcel.ReadUint32();
|
||||
device->protocolCapabilities = parcel.ReadUint32();
|
||||
device->dlnaDeviceModelNameStr = parcel.ReadString();
|
||||
device->dlnaDeviceManufacturerStr = parcel.ReadString();
|
||||
device->sessionKeyLength = parcel.ReadUint32();
|
||||
if (device->sessionKeyLength == SESSION_KEY_LENGTH) {
|
||||
device->sessionKey = parcel.ReadBuffer(static_cast<size_t>(device->sessionKeyLength));
|
||||
@ -185,13 +208,46 @@ std::unique_ptr<CastRemoteDevice> ReadCastRemoteDevice(Parcel &parcel)
|
||||
device->sessionKeyLength = 0;
|
||||
device->sessionKey = nullptr;
|
||||
}
|
||||
if (!IsDeviceType(deviceType) || !IsSubDeviceType(subDeviceType) || !IsChannelType(channelType)) {
|
||||
CLOGE("ReadCastRemoteDevice error");
|
||||
return nullptr;
|
||||
uint32_t drmCapabilitySize = parcel.ReadUint32();
|
||||
for (uint32_t i = 0; (i < drmCapabilitySize) && (i < MAX_CYCLES_NUM); i++) {
|
||||
device->drmCapabilities.push_back(parcel.ReadString());
|
||||
}
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
bool WriteStreamCapability(MessageParcel &parcel, const StreamCapability &streamCapability)
|
||||
{
|
||||
return parcel.WriteBool(streamCapability.isPlaySupported) &&
|
||||
parcel.WriteBool(streamCapability.isPauseSupported) &&
|
||||
parcel.WriteBool(streamCapability.isStopSupported) &&
|
||||
parcel.WriteBool(streamCapability.isNextSupported) &&
|
||||
parcel.WriteBool(streamCapability.isPreviousSupported) &&
|
||||
parcel.WriteBool(streamCapability.isSeekSupported) &&
|
||||
parcel.WriteBool(streamCapability.isFastForwardSupported) &&
|
||||
parcel.WriteBool(streamCapability.isFastRewindSupported) &&
|
||||
parcel.WriteBool(streamCapability.isLoopModeSupported) &&
|
||||
parcel.WriteBool(streamCapability.isToggleFavoriteSupported) &&
|
||||
parcel.WriteBool(streamCapability.isSetVolumeSupported);
|
||||
}
|
||||
|
||||
StreamCapability ReadStreamCapability(MessageParcel &parcel)
|
||||
{
|
||||
StreamCapability streamCapability;
|
||||
streamCapability.isPlaySupported = parcel.ReadBool();
|
||||
streamCapability.isPauseSupported = parcel.ReadBool();
|
||||
streamCapability.isStopSupported = parcel.ReadBool();
|
||||
streamCapability.isNextSupported = parcel.ReadBool();
|
||||
streamCapability.isPreviousSupported = parcel.ReadBool();
|
||||
streamCapability.isSeekSupported = parcel.ReadBool();
|
||||
streamCapability.isFastForwardSupported = parcel.ReadBool();
|
||||
streamCapability.isFastRewindSupported = parcel.ReadBool();
|
||||
streamCapability.isLoopModeSupported = parcel.ReadBool();
|
||||
streamCapability.isToggleFavoriteSupported = parcel.ReadBool();
|
||||
streamCapability.isSetVolumeSupported = parcel.ReadBool();
|
||||
return streamCapability;
|
||||
}
|
||||
|
||||
bool WriteMediaInfo(MessageParcel &parcel, const MediaInfo &mediaInfo)
|
||||
{
|
||||
if (mediaInfo.mediaUrl.empty()) {
|
||||
@ -214,7 +270,8 @@ bool WriteMediaInfo(MessageParcel &parcel, const MediaInfo &mediaInfo)
|
||||
parcel.WriteString(mediaInfo.mediaArtist) && parcel.WriteString(mediaInfo.lrcUrl) &&
|
||||
parcel.WriteString(mediaInfo.lrcContent) && parcel.WriteString(mediaInfo.appIconUrl) &&
|
||||
parcel.WriteString(mediaInfo.appName) && parcel.WriteUint32(mediaInfo.startPosition) &&
|
||||
parcel.WriteUint32(mediaInfo.duration) && parcel.WriteUint32(mediaInfo.closingCreditsPosition);
|
||||
parcel.WriteUint32(mediaInfo.duration) && parcel.WriteUint32(mediaInfo.closingCreditsPosition) &&
|
||||
parcel.WriteString(mediaInfo.drmType);
|
||||
}
|
||||
|
||||
std::unique_ptr<MediaInfo> ReadMediaInfo(MessageParcel &parcel)
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include "system_ability_load_callback_stub.h"
|
||||
#include "cast_engine_common.h"
|
||||
#include "i_cast_session.h"
|
||||
#include "i_cast_session_manager_adaptor.h"
|
||||
@ -46,11 +47,10 @@ public:
|
||||
int32_t SetLocalDevice(const CastLocalDevice &localDevice);
|
||||
int32_t CreateCastSession(const CastSessionProperty &property, std::shared_ptr<ICastSession> &castSession);
|
||||
int32_t SetSinkSessionCapacity(int sessionCapacity);
|
||||
int32_t StartDiscovery(int protocols);
|
||||
int32_t StartDiscovery(int protocols, std::vector<std::string> drmSchemes);
|
||||
int32_t SetDiscoverable(bool enable);
|
||||
int32_t StopDiscovery();
|
||||
void ReleaseClientResources();
|
||||
|
||||
int32_t StartDeviceLogging(int32_t fd, uint32_t maxSize);
|
||||
int32_t GetCastSession(std::string sessionId, std::shared_ptr<ICastSession> &castSession);
|
||||
private:
|
||||
class CastEngineServiceDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
@ -66,14 +66,23 @@ private:
|
||||
private:
|
||||
std::shared_ptr<ICastSessionManagerListener> listener_;
|
||||
};
|
||||
class CastEngineServiceLoadCallback : public SystemAbilityLoadCallbackStub {
|
||||
public:
|
||||
void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr<IRemoteObject> &remoteObject) override;
|
||||
void OnLoadSystemAbilityFail(int32_t systemAbilityId) override;
|
||||
};
|
||||
|
||||
CastSessionManager();
|
||||
void ReleaseServiceDeathRecipient();
|
||||
void ReleaseClientResources();
|
||||
std::shared_ptr<ICastSessionManagerAdaptor> GetAdaptor();
|
||||
void NotifyServiceLoadResult(const sptr<IRemoteObject> &remoteObject);
|
||||
|
||||
std::mutex mutex_;
|
||||
std::condition_variable loadServiceCond_;
|
||||
std::shared_ptr<ICastSessionManagerAdaptor> adaptor_;
|
||||
sptr<CastEngineServiceDeathRecipient> deathRecipient_{ nullptr };
|
||||
bool isNeedLoadService_{ true };
|
||||
};
|
||||
} // namespace CastEngineClient
|
||||
} // namespace CastEngine
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
virtual int32_t NotifyEvent(EventId eventId, std::string &jsonParam) = 0;
|
||||
virtual int32_t SetCastMode(CastMode mode, std::string &jsonParam) = 0;
|
||||
virtual int32_t Release() = 0;
|
||||
virtual int32_t GetRemoteDeviceInfo(std::string deviceId, CastRemoteDevice &remoteDevice) = 0;
|
||||
};
|
||||
} // namespace CastEngine
|
||||
} // namespace OHOS
|
||||
|
@ -45,9 +45,10 @@ public:
|
||||
virtual int32_t CreateCastSession(const CastSessionProperty &property,
|
||||
std::shared_ptr<ICastSession> &castSession) = 0;
|
||||
virtual int32_t SetSinkSessionCapacity(int sessionCapacity) = 0;
|
||||
virtual int32_t StartDiscovery(int protocols) = 0;
|
||||
virtual int32_t StartDiscovery(int protocols, std::vector<std::string> drmSchemes) = 0;
|
||||
virtual int32_t SetDiscoverable(bool enable) = 0;
|
||||
virtual int32_t StopDiscovery() = 0;
|
||||
virtual int32_t StartDeviceLogging(int32_t fd, uint32_t maxSize) = 0;
|
||||
virtual int32_t GetCastSession(std::string sessionId, std::shared_ptr<ICastSession> &castSession) = 0;
|
||||
};
|
||||
} // namespace CastEngine
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
virtual void OnDeviceOffline(const std::string &deviceId) = 0;
|
||||
virtual void OnSessionCreated(const std::shared_ptr<ICastSession> &castSession) = 0;
|
||||
virtual void OnServiceDied() = 0;
|
||||
virtual void OnLogEvent(int32_t eventId, int64_t param) {};
|
||||
};
|
||||
} // namespace CastEngine
|
||||
} // namespace OHOS
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "cast_engine_common.h"
|
||||
#include "oh_remote_control_event.h"
|
||||
#include "pixel_map.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace CastEngine {
|
||||
@ -42,6 +43,11 @@ public:
|
||||
virtual int32_t Release() = 0;
|
||||
virtual int32_t GetDisplayId(std::string &displayId) = 0;
|
||||
virtual int32_t ResizeVirtualScreen(uint32_t width, uint32_t height) = 0;
|
||||
virtual int32_t SetDpi(uint32_t dpi) { return 0; }
|
||||
virtual int32_t SetFps(uint32_t fps) { return 0; }
|
||||
virtual int32_t SetBitrate(uint32_t minBitrate, uint32_t defaultBitrate, uint32_t maxBitrate) { return 0; }
|
||||
virtual int32_t SetCastRoute(const bool &remote) { return 0; }
|
||||
virtual int32_t GetScreenshot(std::shared_ptr<Media::PixelMap> &screenShot) { return 0; }
|
||||
};
|
||||
} // namespace CastEngine
|
||||
} // namespace OHOS
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
virtual void OnPlayRequest(const MediaInfo &mediaInfo) = 0;
|
||||
virtual void OnImageChanged(std::shared_ptr<Media::PixelMap> pixelMap) = 0;
|
||||
virtual void OnAlbumCoverChanged(std::shared_ptr<Media::PixelMap> pixelMap) = 0;
|
||||
virtual void OnAvailableCapabilityChanged(const StreamCapability &streamCapability) = 0;
|
||||
};
|
||||
|
||||
class EXPORT IStreamPlayer {
|
||||
@ -76,6 +77,7 @@ public:
|
||||
virtual int32_t SetVolume(int volume) = 0;
|
||||
virtual int32_t SetMute(bool mute) = 0;
|
||||
virtual int32_t SetLoopMode(const LoopMode mode) = 0;
|
||||
virtual int32_t SetAvailableCapability(const StreamCapability &streamCapability) = 0;
|
||||
virtual int32_t SetSpeed(const PlaybackSpeed speed) = 0;
|
||||
virtual int32_t GetPlayerStatus(PlayerStates &playerStates) = 0;
|
||||
virtual int32_t GetPosition(int &position) = 0;
|
||||
@ -83,6 +85,7 @@ public:
|
||||
virtual int32_t GetVolume(int &volume, int &maxVolume) = 0;
|
||||
virtual int32_t GetMute(bool &mute) = 0;
|
||||
virtual int32_t GetLoopMode(LoopMode &loopMode) = 0;
|
||||
virtual int32_t GetAvailableCapability(StreamCapability &streamCapability) = 0;
|
||||
virtual int32_t GetPlaySpeed(PlaybackSpeed &playbackSpeed) = 0;
|
||||
virtual int32_t GetMediaInfoHolder(MediaInfoHolder &mediaInfoHolder) = 0;
|
||||
virtual int32_t Release() = 0;
|
||||
|
@ -47,6 +47,7 @@ enum EXPORT OHNativeXcomponentTouchEventType {
|
||||
OH_NATIVEXCOMPONENT_TOUCH_UP,
|
||||
OH_NATIVEXCOMPONENT_TOUCH_MOVE,
|
||||
OH_NATIVEXCOMPONENT_TOUCH_CANCEL,
|
||||
OH_NATIVEXCOMPONENT_TOUCH_PULL_IN_WINDOW,
|
||||
};
|
||||
|
||||
enum EXPORT OHNativeXcomponentMouseEventAction {
|
||||
@ -54,6 +55,7 @@ enum EXPORT OHNativeXcomponentMouseEventAction {
|
||||
OH_NATIVEXCOMPONENT_MOUSE_RELEASE,
|
||||
OH_NATIVEXCOMPONENT_MOUSE_MOVE,
|
||||
OH_NATIVEXCOMPONENT_MOUSE_NONE,
|
||||
OH_NATIVEXCOMPONENT_MOUSE_PULL_IN_WINDOW,
|
||||
};
|
||||
|
||||
enum EXPORT OHNativeXcomponentKeyEventType {
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
EVENT_PLAY_REQUEST,
|
||||
EVENT_IMAGE_CHANGED,
|
||||
EVENT_ALBUM_COVER_CHANGED,
|
||||
EVENT_AVAILABLE_CAPABILITY_CHANGED,
|
||||
EVENT_TYPE_MAX
|
||||
};
|
||||
|
||||
@ -72,6 +73,7 @@ public:
|
||||
void OnPlayRequest(const MediaInfo &mediaInfo) override;
|
||||
void OnImageChanged(std::shared_ptr<Media::PixelMap> pixelMap) override;
|
||||
void OnAlbumCoverChanged(std::shared_ptr<Media::PixelMap> pixelMap) override;
|
||||
void OnAvailableCapabilityChanged(const StreamCapability &streamCapability) override;
|
||||
|
||||
napi_status AddCallback(napi_env env, int32_t event, napi_value callback);
|
||||
napi_status RemoveCallback(napi_env env, int32_t event, napi_value callback);
|
||||
|
@ -96,7 +96,7 @@ napi_value NapiCastSessionManager::StartDiscovery(napi_env env, napi_callback_in
|
||||
};
|
||||
napiAsyntask->GetJSInfo(env, info, inputParser);
|
||||
auto executor = [napiAsyntask]() {
|
||||
int32_t ret = CastSessionManager::GetInstance().StartDiscovery(napiAsyntask->protocolType_);
|
||||
int32_t ret = CastSessionManager::GetInstance().StartDiscovery(napiAsyntask->protocolType_, {});
|
||||
if (ret != CAST_ENGINE_SUCCESS) {
|
||||
if (ret == ERR_NO_PERMISSION) {
|
||||
napiAsyntask->errMessage = "StartDiscovery failed : no permission";
|
||||
|
@ -133,6 +133,11 @@ void NapiStreamPlayerListener::OnLoopModeChanged(const LoopMode loopMode)
|
||||
CLOGD("OnLoopModeChanged finish");
|
||||
}
|
||||
|
||||
void NapiStreamPlayerListener::OnAvailableCapabilityChanged(const StreamCapability &streamCapability)
|
||||
{
|
||||
CLOGD("OnAvailableCapabilityChanged finish");
|
||||
}
|
||||
|
||||
void NapiStreamPlayerListener::OnPlaySpeedChanged(const PlaybackSpeed speed)
|
||||
{
|
||||
CLOGD("OnPlaySpeedChanged start");
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
void OnDeviceOffline(const std::string &deviceId) override;
|
||||
void OnSessionCreated(const sptr<ICastSessionImpl> &castSession) override;
|
||||
void OnServiceDied() override;
|
||||
|
||||
void OnLogEvent(int32_t eventId, int64_t param) override;
|
||||
private:
|
||||
static inline BrokerDelegator<CastServiceListenerImplProxy> delegator_;
|
||||
};
|
||||
|
@ -50,9 +50,10 @@ public:
|
||||
int32_t SetLocalDevice(const CastLocalDevice &localDevice) override;
|
||||
int32_t CreateCastSession(const CastSessionProperty &property, sptr<ICastSessionImpl> &castSession) override;
|
||||
int32_t SetSinkSessionCapacity(int sessionCapacity) override;
|
||||
int32_t StartDiscovery(int protocols) override;
|
||||
int32_t StartDiscovery(int protocols, std::vector<std::string> drmSchemes) override;
|
||||
int32_t SetDiscoverable(bool enable) override;
|
||||
int32_t StopDiscovery() override;
|
||||
int32_t StartDeviceLogging(int32_t fd, uint32_t maxSize) override;
|
||||
void ReleaseServiceResources(pid_t pid);
|
||||
int32_t GetCastSession(std::string sessionId, sptr<ICastSessionImpl> &castSession) override;
|
||||
|
||||
|
@ -44,6 +44,7 @@ private:
|
||||
int32_t DoStartDiscoveryTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoSetDiscoverableTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoStopDiscoveryTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoStartDeviceLoggingTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoGetCastSessionTask(MessageParcel &data, MessageParcel &reply);
|
||||
};
|
||||
} // namespace CastEngineService
|
||||
|
@ -123,6 +123,27 @@ void CastServiceListenerImplProxy::OnDeviceOffline(const std::string &deviceId)
|
||||
CLOGD("send request");
|
||||
Remote()->SendRequest(ON_DEVICE_OFFLINE, data, reply, option);
|
||||
}
|
||||
void CastServiceListenerImplProxy::OnLogEvent(int32_t eventId, int64_t param)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
CLOGD("OnLogEvent in");
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(eventId)) {
|
||||
CLOGE("Failed to write the eventId:%d", eventId);
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt64(param)) {
|
||||
CLOGE("Failed to write the param:%lld", param);
|
||||
return;
|
||||
}
|
||||
CLOGD("send request");
|
||||
Remote()->SendRequest(ON_LOG_EVENT, data, reply, option);
|
||||
}
|
||||
} // namespace CastEngineService
|
||||
} // namespace CastEngine
|
||||
} // namespace OHOS
|
@ -187,6 +187,7 @@ void CastSessionManagerService::OnStop()
|
||||
|
||||
namespace {
|
||||
using namespace OHOS::DistributedHardware;
|
||||
constexpr int AV_SESSION_UID = 6700;
|
||||
|
||||
class DiscoveryManagerListener : public IDiscoveryManagerListener {
|
||||
public:
|
||||
@ -528,10 +529,10 @@ int32_t CastSessionManagerService::SetSinkSessionCapacity(int sessionCapacity)
|
||||
return CAST_ENGINE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerService::StartDiscovery(int protocols)
|
||||
int32_t CastSessionManagerService::StartDiscovery(int protocols, std::vector<std::string> drmSchemes)
|
||||
{
|
||||
static_cast<void>(protocols);
|
||||
CLOGD("StartDiscovery in, protocolType = %d", protocols);
|
||||
CLOGI("StartDiscovery in, protocolType = %{public}d, drm shcheme size = %{public}zu", protocols, drmSchemes.size());
|
||||
SharedRLock lock(mutex_);
|
||||
if (!Permission::CheckPidPermission()) {
|
||||
return ERR_NO_PERMISSION;
|
||||
@ -542,7 +543,7 @@ int32_t CastSessionManagerService::StartDiscovery(int protocols)
|
||||
|
||||
int32_t CastSessionManagerService::StopDiscovery()
|
||||
{
|
||||
CLOGD("StopDiscovery in");
|
||||
CLOGI("StopDiscovery in");
|
||||
SharedRLock lock(mutex_);
|
||||
if (!Permission::CheckPidPermission()) {
|
||||
return ERR_NO_PERMISSION;
|
||||
@ -551,9 +552,23 @@ int32_t CastSessionManagerService::StopDiscovery()
|
||||
return CAST_ENGINE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerService::StartDeviceLogging(int32_t fd, uint32_t maxSize)
|
||||
{
|
||||
CLOGI("StartDeviceLogging in");
|
||||
if (IPCSkeleton::GetCallingUid() != AV_SESSION_UID) {
|
||||
if (fd >= 0) {
|
||||
close(fd);
|
||||
}
|
||||
return static_cast<int32_t>(LogCodeId::UID_MISMATCH);
|
||||
}
|
||||
|
||||
// 待实现 DfxCastEngineStartDeviceLogging
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerService::SetDiscoverable(bool enable)
|
||||
{
|
||||
CLOGD("SetDiscoverable in, enable = %{public}d", enable);
|
||||
CLOGI("SetDiscoverable in, enable = %{public}d", enable);
|
||||
SharedRLock lock(mutex_);
|
||||
if (!Permission::CheckPidPermission()) {
|
||||
return ERR_NO_PERMISSION;
|
||||
|
@ -27,6 +27,7 @@ namespace OHOS {
|
||||
namespace CastEngine {
|
||||
namespace CastEngineService {
|
||||
DEFINE_CAST_ENGINE_LABEL("Cast-Service");
|
||||
constexpr uint32_t MAX_CYCLES_NUM = 10;
|
||||
|
||||
int CastSessionManagerServiceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
@ -46,6 +47,7 @@ CastSessionManagerServiceStub::CastSessionManagerServiceStub()
|
||||
FILL_SINGLE_STUB_TASK(START_DISCOVERY, &CastSessionManagerServiceStub::DoStartDiscoveryTask);
|
||||
FILL_SINGLE_STUB_TASK(SET_DISCOVERABLE, &CastSessionManagerServiceStub::DoSetDiscoverableTask);
|
||||
FILL_SINGLE_STUB_TASK(STOP_DISCOVERY, &CastSessionManagerServiceStub::DoStopDiscoveryTask);
|
||||
FILL_SINGLE_STUB_TASK(START_DEVICE_LOGGING, &CastSessionManagerServiceStub::DoStartDeviceLoggingTask);
|
||||
FILL_SINGLE_STUB_TASK(GET_CAST_SESSION, &CastSessionManagerServiceStub::DoGetCastSessionTask);
|
||||
}
|
||||
|
||||
@ -58,7 +60,7 @@ int32_t CastSessionManagerServiceStub::DoRegisterListenerTask(MessageParcel &dat
|
||||
{
|
||||
if (!Permission::CheckMirrorPermission() && !Permission::CheckStreamPermission() &&
|
||||
!Permission::CheckPidPermission()) {
|
||||
return ERR_UNKNOWN_TRANSACTION;
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
sptr<IRemoteObject> obj = data.ReadRemoteObject();
|
||||
if (obj == nullptr) {
|
||||
@ -93,7 +95,7 @@ int32_t CastSessionManagerServiceStub::DoReleaseTask(MessageParcel &data, Messag
|
||||
static_cast<void>(data);
|
||||
|
||||
if (!Permission::CheckMirrorPermission() && !Permission::CheckStreamPermission()) {
|
||||
return ERR_UNKNOWN_TRANSACTION;
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
|
||||
if (!reply.WriteInt32(Release())) {
|
||||
@ -107,7 +109,7 @@ int32_t CastSessionManagerServiceStub::DoReleaseTask(MessageParcel &data, Messag
|
||||
int32_t CastSessionManagerServiceStub::DoSetLocalDeviceTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
if (!Permission::CheckMirrorPermission()) {
|
||||
return ERR_UNKNOWN_TRANSACTION;
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
|
||||
auto device = ReadCastLocalDevice(data);
|
||||
@ -126,7 +128,7 @@ int32_t CastSessionManagerServiceStub::DoSetLocalDeviceTask(MessageParcel &data,
|
||||
int32_t CastSessionManagerServiceStub::DoCreateCastSessionTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
if (!Permission::CheckMirrorPermission() && !Permission::CheckStreamPermission()) {
|
||||
return ERR_UNKNOWN_TRANSACTION;
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
|
||||
auto property = ReadCastSessionProperty(data);
|
||||
@ -157,7 +159,7 @@ int32_t CastSessionManagerServiceStub::DoSetSinkSessionCapacityTask(MessageParce
|
||||
static_cast<void>(reply);
|
||||
|
||||
if (!Permission::CheckMirrorPermission()) {
|
||||
return ERR_UNKNOWN_TRANSACTION;
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
|
||||
int32_t capacity = data.ReadInt32();
|
||||
@ -173,7 +175,7 @@ int32_t CastSessionManagerServiceStub::DoSetSinkSessionCapacityTask(MessageParce
|
||||
int32_t CastSessionManagerServiceStub::DoStartDiscoveryTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
if (!Permission::CheckMirrorPermission() && !Permission::CheckStreamPermission()) {
|
||||
return ERR_UNKNOWN_TRANSACTION;
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
|
||||
int32_t type = data.ReadInt32();
|
||||
@ -181,7 +183,12 @@ int32_t CastSessionManagerServiceStub::DoStartDiscoveryTask(MessageParcel &data,
|
||||
CLOGE("Invalid protocol type comes, %{public}d", type);
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
if (!reply.WriteInt32(StartDiscovery(type))) {
|
||||
std::vector<std::string> drmSchemes;
|
||||
uint32_t drmSchemeSize = data.ReadUint32();
|
||||
for (uint32_t i = 0; (i < drmSchemeSize) && (i < MAX_CYCLES_NUM); i++) {
|
||||
drmSchemes.push_back(data.ReadString());
|
||||
}
|
||||
if (!reply.WriteInt32(StartDiscovery(type, drmSchemes))) {
|
||||
CLOGE("Failed to write int value");
|
||||
return IPC_STUB_WRITE_PARCEL_ERR;
|
||||
}
|
||||
@ -191,7 +198,7 @@ int32_t CastSessionManagerServiceStub::DoStartDiscoveryTask(MessageParcel &data,
|
||||
int32_t CastSessionManagerServiceStub::DoSetDiscoverableTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
if (!Permission::CheckMirrorPermission() && !Permission::CheckStreamPermission()) {
|
||||
return ERR_UNKNOWN_TRANSACTION;
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
|
||||
bool enable = data.ReadBool();
|
||||
@ -205,7 +212,7 @@ int32_t CastSessionManagerServiceStub::DoSetDiscoverableTask(MessageParcel &data
|
||||
int32_t CastSessionManagerServiceStub::DoStopDiscoveryTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
if (!Permission::CheckMirrorPermission() && !Permission::CheckStreamPermission()) {
|
||||
return ERR_UNKNOWN_TRANSACTION;
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
|
||||
if (!reply.WriteInt32(StopDiscovery())) {
|
||||
@ -215,9 +222,27 @@ int32_t CastSessionManagerServiceStub::DoStopDiscoveryTask(MessageParcel &data,
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerServiceStub::DoStartDeviceLoggingTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
if ((!Permission::CheckMirrorPermission() && !Permission::CheckStreamPermission()) ||
|
||||
!Permission::CheckPidPermission()) {
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
int32_t fd = data.ReadFileDescriptor();
|
||||
uint32_t maxSize = data.ReadUint32();
|
||||
if (!reply.WriteInt32(StartDeviceLogging(fd, maxSize))) {
|
||||
CLOGE("Failed to write int value");
|
||||
return IPC_STUB_WRITE_PARCEL_ERR;
|
||||
}
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t CastSessionManagerServiceStub::DoGetCastSessionTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
sptr<ICastSessionImpl> sessionStub;
|
||||
if (!Permission::CheckPidPermission()) {
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
int32_t ret = GetCastSession(data.ReadString(), sessionStub);
|
||||
if (sessionStub == nullptr) {
|
||||
return IPC_STUB_ERR;
|
||||
|
@ -17,6 +17,12 @@ config("cast_session_config") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"//third_party/jsoncpp/include",
|
||||
"//foundation/communication/wifi/wifi/interfaces/kits/c",
|
||||
"//foundation/CastEngine/castengine_wifi_display/interfaces/innerkits/native/wfd/include",
|
||||
"//foundation/CastEngine/castengine_wifi_display/services/impl/scene/wfd",
|
||||
"//foundation/CastEngine/castengine_wifi_display/services",
|
||||
"//foundation/CastEngine/castengine_wifi_display/services/interaction/ipc_codec",
|
||||
"//foundation/CastEngine/castengine_wifi_display/frameworks/innerkitsimpl/native/wfd",
|
||||
]
|
||||
}
|
||||
|
||||
|
3
service/src/session/src/stream/include/cast_stream_manager_client.h
Executable file → Normal file
3
service/src/session/src/stream/include/cast_stream_manager_client.h
Executable file → Normal file
@ -58,6 +58,7 @@ public:
|
||||
bool NotifyPeerSetVolume(int volume) override;
|
||||
bool NotifyPeerSetMute(bool mute) override;
|
||||
bool NotifyPeerSetRepeatMode(int mode) override;
|
||||
bool NotifyPeerSetAvailableCapability(const StreamCapability &streamCapability) override;
|
||||
bool NotifyPeerSetSpeed(int speed) override;
|
||||
PlayerStates GetPlayerStatus() override;
|
||||
int GetPosition() override;
|
||||
@ -66,6 +67,7 @@ public:
|
||||
int GetMaxVolume() override;
|
||||
bool GetMute() override;
|
||||
LoopMode GetLoopMode() override;
|
||||
StreamCapability GetAvailableCapability() override;
|
||||
PlaybackSpeed GetPlaySpeed() override;
|
||||
bool IsDoubleFrame() override;
|
||||
|
||||
@ -109,6 +111,7 @@ private:
|
||||
std::atomic<bool> isSeeking_{ false };
|
||||
std::atomic<bool> isNewResourceLoaded_{ false };
|
||||
std::atomic<bool> isDoubleFrame_{ false };
|
||||
StreamCapability availableCapability_{};
|
||||
};
|
||||
} // namespace CastEngineService
|
||||
} // namespace CastEngine
|
||||
|
1
service/src/session/src/stream/include/cast_stream_manager_server.h
Executable file → Normal file
1
service/src/session/src/stream/include/cast_stream_manager_server.h
Executable file → Normal file
@ -69,6 +69,7 @@ private:
|
||||
bool ProcessActionSetVolume(const json &data);
|
||||
bool ProcessActionSetMute(const json &data);
|
||||
bool ProcessActionSetRepeatMode(const json &data);
|
||||
bool ProcessActionSetAvailableCapability(const json &data);
|
||||
bool ProcessActionSetSpeed(const json &data);
|
||||
|
||||
std::shared_ptr<CastStreamPlayerManager> PlayerGetter();
|
||||
|
@ -77,11 +77,23 @@ protected:
|
||||
const std::string KEY_LRC_CONTENT = "LRC_CONTENT";
|
||||
const std::string KEY_APP_ICON_URL = "APP_ICON_URL";
|
||||
const std::string KEY_APP_NAME = "APP_NAME";
|
||||
const std::string KEY_DRM_TYPE = "DRM_TYPE";
|
||||
const std::string KEY_VOLUME = "VOLUME";
|
||||
const std::string KEY_MUTE = "MUTE";
|
||||
const std::string KEY_MAX_VOLUME = "MAX_VOLUME";
|
||||
const std::string KEY_MODE = "MODE";
|
||||
const std::string KEY_REPEAT_MODE = "REPEAT_MODE";
|
||||
const std::string KEY_SUPPORT_PLAY = "SUPPORT_PLAY";
|
||||
const std::string KEY_SUPPORT_PAUSE = "SUPPORT_PAUSE";
|
||||
const std::string KEY_SUPPORT_STOP = "SUPPORT_STOP";
|
||||
const std::string KEY_SUPPORT_NEXT = "SUPPORT_NEXT";
|
||||
const std::string KEY_SUPPORT_PREVIOUS = "SUPPORT_PREVIOUS";
|
||||
const std::string KEY_SUPPORT_SEEK = "SUPPORT_SEEK";
|
||||
const std::string KEY_SUPPORT_FASTFORWARD = "SUPPORT_FASTFORWARD";
|
||||
const std::string KEY_SUPPORT_FASTREWIND = "SUPPORT_FASTREWIND";
|
||||
const std::string KEY_SUPPORT_LOOPMODE = "SUPPORT_LOOPMODE";
|
||||
const std::string KEY_SUPPORT_TOGGLE_FAVORITE = "SUPPORT_TOGGLE_FAVORITE";
|
||||
const std::string KEY_SUPPORT_SET_VOLUME = "SUPPORT_SET_VOLUME";
|
||||
const std::string KEY_DELTA = "DELTA";
|
||||
const std::string KEY_SPEED = "SPEED";
|
||||
const std::string KEY_POSITION = "POSITION";
|
||||
@ -111,6 +123,7 @@ protected:
|
||||
const std::string ACTION_SET_VOLUME = "setVolume";
|
||||
const std::string ACTION_SET_MUTE = "setMute";
|
||||
const std::string ACTION_SET_REPEAT_MODE = "setRepeatMode";
|
||||
const std::string ACTION_SET_AVAILABLE_CAPABILITY = "setAvailableCapability";
|
||||
const std::string ACTION_SET_SPEED = "setSpeed";
|
||||
const std::string ACTION_PLAYER_STATUS_CHANGED = "onPlayerStatusChanged";
|
||||
const std::string ACTION_POSITION_CHANGED = "onPositionChanged";
|
||||
@ -130,6 +143,8 @@ protected:
|
||||
bool SendCallbackAction(const std::string &action, const json &dataBody = "{}");
|
||||
bool ParseMediaInfo(const json &data, MediaInfo &MediaInfo, bool isDoubleFrame);
|
||||
void EncapMediaInfo(const MediaInfo &mediaInfo, json &data, bool isDoubleFrame);
|
||||
bool ParseStreamCapability(const json &data, StreamCapability &streamCapability);
|
||||
void EncapStreamCapability(const StreamCapability &streamCapability, json &data);
|
||||
|
||||
using StreamActionProcessor = std::function<bool(const json &data)>;
|
||||
std::map<std::string, StreamActionProcessor> streamActionProcessor_ {};
|
||||
|
2
service/src/session/src/stream/include/i_cast_stream_manager_client.h
Executable file → Normal file
2
service/src/session/src/stream/include/i_cast_stream_manager_client.h
Executable file → Normal file
@ -43,6 +43,7 @@ public:
|
||||
virtual bool NotifyPeerSetVolume(int volume) = 0;
|
||||
virtual bool NotifyPeerSetMute(bool mute) = 0;
|
||||
virtual bool NotifyPeerSetRepeatMode(int mode) = 0;
|
||||
virtual bool NotifyPeerSetAvailableCapability(const StreamCapability &streamCapability) = 0;
|
||||
virtual bool NotifyPeerSetSpeed(int speed) = 0;
|
||||
virtual void OnEvent(EventId eventId, const std::string &data) = 0;
|
||||
virtual PlayerStates GetPlayerStatus() = 0;
|
||||
@ -52,6 +53,7 @@ public:
|
||||
virtual bool GetMute() = 0;
|
||||
virtual int GetMaxVolume() = 0;
|
||||
virtual LoopMode GetLoopMode() = 0;
|
||||
virtual StreamCapability GetAvailableCapability() = 0;
|
||||
virtual PlaybackSpeed GetPlaySpeed() = 0;
|
||||
virtual bool IsDoubleFrame() = 0;
|
||||
};
|
||||
|
19
service/src/session/src/stream/src/cast_stream_manager_client.cpp
Executable file → Normal file
19
service/src/session/src/stream/src/cast_stream_manager_client.cpp
Executable file → Normal file
@ -252,6 +252,18 @@ bool CastStreamManagerClient::NotifyPeerSetRepeatMode(int mode)
|
||||
return SendControlAction(ACTION_SET_REPEAT_MODE, body);
|
||||
}
|
||||
|
||||
bool CastStreamManagerClient::NotifyPeerSetAvailableCapability(const StreamCapability &streamCapability)
|
||||
{
|
||||
CLOGD("NotifyPeerSetAvailableCapability in");
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(eventMutex_);
|
||||
availableCapability_ = streamCapability;
|
||||
}
|
||||
json body;
|
||||
EncapStreamCapability(streamCapability, body);
|
||||
return SendControlAction(ACTION_SET_AVAILABLE_CAPABILITY, body);
|
||||
}
|
||||
|
||||
bool CastStreamManagerClient::NotifyPeerSetSpeed(int speed)
|
||||
{
|
||||
CLOGD("NotifyPeerSetSpeed in");
|
||||
@ -310,6 +322,13 @@ LoopMode CastStreamManagerClient::GetLoopMode()
|
||||
return currentMode_;
|
||||
}
|
||||
|
||||
StreamCapability CastStreamManagerClient::GetAvailableCapability()
|
||||
{
|
||||
CLOGD("GetAvailableCapability in");
|
||||
std::lock_guard<std::mutex> lock(eventMutex_);
|
||||
return availableCapability_;
|
||||
}
|
||||
|
||||
PlaybackSpeed CastStreamManagerClient::GetPlaySpeed()
|
||||
{
|
||||
CLOGD("GetPlaySpeed in");
|
||||
|
17
service/src/session/src/stream/src/cast_stream_manager_server.cpp
Executable file → Normal file
17
service/src/session/src/stream/src/cast_stream_manager_server.cpp
Executable file → Normal file
@ -45,6 +45,8 @@ CastStreamManagerServer::CastStreamManagerServer(std::shared_ptr<ICastStreamList
|
||||
{ ACTION_FAST_REWIND, [this](const json &data) { return ProcessActionFastRewind(data); } },
|
||||
{ ACTION_SET_VOLUME, [this](const json &data) { return ProcessActionSetVolume(data); } },
|
||||
{ ACTION_SET_REPEAT_MODE, [this](const json &data) { return ProcessActionSetRepeatMode(data); } },
|
||||
{ ACTION_SET_AVAILABLE_CAPABILITY,
|
||||
[this](const json &data) { return ProcessActionSetAvailableCapability(data); } },
|
||||
{ ACTION_SET_SPEED, [this](const json &data) { return ProcessActionSetSpeed(data); } }
|
||||
};
|
||||
streamListener_ = listener;
|
||||
@ -413,6 +415,21 @@ bool CastStreamManagerServer::ProcessActionSetRepeatMode(const json &data)
|
||||
return player->SetLoopMode(static_cast<LoopMode>(mode));
|
||||
}
|
||||
|
||||
bool CastStreamManagerServer::ProcessActionSetAvailableCapability(const json &data)
|
||||
{
|
||||
auto player = PlayerGetter();
|
||||
if (!player) {
|
||||
CLOGE("player is nullptr");
|
||||
return false;
|
||||
}
|
||||
StreamCapability streamCapability{};
|
||||
if (!ParseStreamCapability(data, streamCapability)) {
|
||||
CLOGE("ParseStreamCapability failed");
|
||||
return false;
|
||||
}
|
||||
return player->InnerSetAvailableCapability(streamCapability);
|
||||
}
|
||||
|
||||
bool CastStreamManagerServer::ProcessActionSetSpeed(const json &data)
|
||||
{
|
||||
auto player = PlayerGetter();
|
||||
|
32
service/src/session/src/stream/src/i_cast_stream_manager.cpp
Executable file → Normal file
32
service/src/session/src/stream/src/i_cast_stream_manager.cpp
Executable file → Normal file
@ -188,6 +188,38 @@ bool ICastStreamManager::ParseMediaInfo(const json &data, MediaInfo &mediaInfo,
|
||||
return true;
|
||||
}
|
||||
|
||||
void ICastStreamManager::EncapStreamCapability(const StreamCapability &streamCapability, json &data)
|
||||
{
|
||||
data[KEY_SUPPORT_PLAY] = streamCapability.isPlaySupported;
|
||||
data[KEY_SUPPORT_PAUSE] = streamCapability.isPauseSupported;
|
||||
data[KEY_SUPPORT_STOP] = streamCapability.isStopSupported;
|
||||
data[KEY_SUPPORT_NEXT] = streamCapability.isNextSupported;
|
||||
data[KEY_SUPPORT_PREVIOUS] = streamCapability.isPreviousSupported;
|
||||
data[KEY_SUPPORT_SEEK] = streamCapability.isSeekSupported;
|
||||
data[KEY_SUPPORT_FASTFORWARD] = streamCapability.isFastForwardSupported;
|
||||
data[KEY_SUPPORT_FASTREWIND] = streamCapability.isFastRewindSupported;
|
||||
data[KEY_SUPPORT_LOOPMODE] = streamCapability.isLoopModeSupported;
|
||||
data[KEY_SUPPORT_TOGGLE_FAVORITE] = streamCapability.isToggleFavoriteSupported;
|
||||
data[KEY_SUPPORT_SET_VOLUME] = streamCapability.isSetVolumeSupported;
|
||||
}
|
||||
|
||||
bool ICastStreamManager::ParseStreamCapability(const json &data, StreamCapability &streamCapability)
|
||||
{
|
||||
RETURN_FALSE_IF_PARSE_BOOL_WRONG(streamCapability.isPlaySupported, data, KEY_SUPPORT_PLAY);
|
||||
RETURN_FALSE_IF_PARSE_BOOL_WRONG(streamCapability.isPauseSupported, data, KEY_SUPPORT_PAUSE);
|
||||
RETURN_FALSE_IF_PARSE_BOOL_WRONG(streamCapability.isStopSupported, data, KEY_SUPPORT_STOP);
|
||||
RETURN_FALSE_IF_PARSE_BOOL_WRONG(streamCapability.isNextSupported, data, KEY_SUPPORT_NEXT);
|
||||
RETURN_FALSE_IF_PARSE_BOOL_WRONG(streamCapability.isPreviousSupported, data, KEY_SUPPORT_PREVIOUS);
|
||||
RETURN_FALSE_IF_PARSE_BOOL_WRONG(streamCapability.isSeekSupported, data, KEY_SUPPORT_SEEK);
|
||||
RETURN_FALSE_IF_PARSE_BOOL_WRONG(streamCapability.isFastForwardSupported, data,
|
||||
KEY_SUPPORT_FASTFORWARD);
|
||||
RETURN_FALSE_IF_PARSE_BOOL_WRONG(streamCapability.isFastRewindSupported, data, KEY_SUPPORT_FASTREWIND);
|
||||
RETURN_FALSE_IF_PARSE_BOOL_WRONG(streamCapability.isLoopModeSupported, data, KEY_SUPPORT_LOOPMODE);
|
||||
RETURN_FALSE_IF_PARSE_BOOL_WRONG(streamCapability.isToggleFavoriteSupported, data, KEY_SUPPORT_TOGGLE_FAVORITE);
|
||||
RETURN_FALSE_IF_PARSE_BOOL_WRONG(streamCapability.isSetVolumeSupported, data, KEY_SUPPORT_SET_VOLUME);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ICastStreamManager::SendControlAction(const std::string &action, const json &dataBody)
|
||||
{
|
||||
if (!streamListener_) {
|
||||
|
@ -69,6 +69,7 @@ public:
|
||||
void OnPreviousRequest();
|
||||
void OnSeekDone(int position);
|
||||
void OnLoopModeChanged(const LoopMode loopMode);
|
||||
void OnAvailableCapabilityChanged(const StreamCapability &streamCapability);
|
||||
void OnPlayRequest(const MediaInfo &mediaInfo);
|
||||
void OnImageChanged(std::shared_ptr<Media::PixelMap> pixelMap);
|
||||
void OnAlbumCoverChanged(std::shared_ptr<Media::PixelMap> pixelMap);
|
||||
|
@ -54,6 +54,8 @@ public:
|
||||
int32_t SetVolume(int volume) override;
|
||||
int32_t SetMute(bool mute) override;
|
||||
int32_t SetLoopMode(const LoopMode mode) override;
|
||||
int32_t SetAvailableCapability(const StreamCapability &streamCapability) override;
|
||||
int32_t InnerSetAvailableCapability(const StreamCapability &streamCapability);
|
||||
int32_t SetSpeed(const PlaybackSpeed speed) override;
|
||||
int32_t GetPlayerStatus(PlayerStates &playerStates) override;
|
||||
int32_t GetPosition(int &position) override;
|
||||
@ -61,6 +63,7 @@ public:
|
||||
int32_t GetVolume(int &volume, int &maxVolume) override;
|
||||
int32_t GetMute(bool &mute) override;
|
||||
int32_t GetLoopMode(LoopMode &loopMode) override;
|
||||
int32_t GetAvailableCapability(StreamCapability &streamCapability) override;
|
||||
int32_t GetPlaySpeed(PlaybackSpeed &playbackSpeed) override;
|
||||
int32_t GetMediaInfoHolder(MediaInfoHolder &mediaInfoHolder) override;
|
||||
int32_t Release() override;
|
||||
@ -80,7 +83,27 @@ private:
|
||||
std::atomic<bool> isReceivePlayCommand_{ false };
|
||||
std::atomic<bool> isReady_{ false };
|
||||
sptr<Surface> surface_;
|
||||
StreamCapability availableCapability_{};
|
||||
enum StreamActionId {
|
||||
INIT,
|
||||
LOAD,
|
||||
PLAY,
|
||||
PAUSE,
|
||||
NEXT,
|
||||
PREVIOUS,
|
||||
SEEK,
|
||||
FASTFORWARD,
|
||||
FASTREWIND,
|
||||
SET_VOLUME,
|
||||
SET_MUTE,
|
||||
SET_LOOP_MODE,
|
||||
};
|
||||
};
|
||||
|
||||
#define MOCK_TEST_PLAYER_ERROR(action) \
|
||||
if (MockPlayerError(action)) { \
|
||||
return CAST_ENGINE_ERROR; \
|
||||
}
|
||||
} // namespace CastEngineService
|
||||
} // namespace CastEngine
|
||||
} // namespace OHOS
|
||||
|
2
service/src/session/src/stream/src/player/include/i_stream_player_impl.h
Executable file → Normal file
2
service/src/session/src/stream/src/player/include/i_stream_player_impl.h
Executable file → Normal file
@ -48,6 +48,7 @@ public:
|
||||
virtual int32_t SetVolume(int volume) = 0;
|
||||
virtual int32_t SetMute(bool mute) = 0;
|
||||
virtual int32_t SetLoopMode(const LoopMode mode) = 0;
|
||||
virtual int32_t SetAvailableCapability(const StreamCapability &streamCapability) = 0;
|
||||
virtual int32_t SetSpeed(const PlaybackSpeed speed) = 0;
|
||||
virtual int32_t GetPlayerStatus(PlayerStates &playerStates) = 0;
|
||||
virtual int32_t GetPosition(int &position) = 0;
|
||||
@ -55,6 +56,7 @@ public:
|
||||
virtual int32_t GetVolume(int &volume, int &maxVolume) = 0;
|
||||
virtual int32_t GetMute(bool &mute) = 0;
|
||||
virtual int32_t GetLoopMode(LoopMode &loopMode) = 0;
|
||||
virtual int32_t GetAvailableCapability(StreamCapability &streamCapability) = 0;
|
||||
virtual int32_t GetPlaySpeed(PlaybackSpeed &playbackSpeed) = 0;
|
||||
virtual int32_t GetMediaInfoHolder(MediaInfoHolder &mediaInfoHolder) = 0;
|
||||
virtual int32_t Release() = 0;
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
int32_t SetVolume(int volume) override;
|
||||
int32_t SetMute(bool mute) override;
|
||||
int32_t SetLoopMode(const LoopMode mode) override;
|
||||
int32_t SetAvailableCapability(const StreamCapability &streamCapability) override;
|
||||
int32_t SetSpeed(const PlaybackSpeed speed) override;
|
||||
int32_t GetPlayerStatus(PlayerStates &playerStates) override;
|
||||
int32_t GetPosition(int &position) override;
|
||||
@ -61,6 +62,7 @@ public:
|
||||
int32_t GetVolume(int &volume, int &maxVolume) override;
|
||||
int32_t GetMute(bool &mute) override;
|
||||
int32_t GetLoopMode(LoopMode &loopMode) override;
|
||||
int32_t GetAvailableCapability(StreamCapability &streamCapability) override;
|
||||
int32_t GetPlaySpeed(PlaybackSpeed &playbackSpeed) override;
|
||||
int32_t GetMediaInfoHolder(MediaInfoHolder &mediaInfoHolder) override;
|
||||
int32_t Release() override;
|
||||
|
@ -52,6 +52,7 @@ private:
|
||||
int32_t DoFastRewindTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoSetVolumeTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoSetLoopModeTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoSetAvailableCapabilityTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoSetSpeedTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoGetPlayerStatusTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoGetPositionTask(MessageParcel &data, MessageParcel &reply);
|
||||
@ -61,6 +62,7 @@ private:
|
||||
int32_t DoGetPlaySpeedTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoSetMuteTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoGetLoopModeTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoGetAvailableCapabilityTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoGetMediaInfoHolderTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t DoReleaseTask(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t RegisterListener(sptr<IStreamPlayerListenerImpl> listener) override;
|
||||
@ -81,6 +83,7 @@ private:
|
||||
int32_t SetVolume(int volume) override;
|
||||
int32_t SetMute(bool mute) override;
|
||||
int32_t SetLoopMode(const LoopMode mode) override;
|
||||
int32_t SetAvailableCapability(const StreamCapability &streamCapability) override;
|
||||
int32_t SetSpeed(const PlaybackSpeed speed) override;
|
||||
int32_t GetPlayerStatus(PlayerStates &playerStates) override;
|
||||
int32_t GetPosition(int &position) override;
|
||||
@ -88,6 +91,7 @@ private:
|
||||
int32_t GetVolume(int &volume, int &maxVolume) override;
|
||||
int32_t GetMute(bool &mute) override;
|
||||
int32_t GetLoopMode(LoopMode &loopMode) override;
|
||||
int32_t GetAvailableCapability(StreamCapability &streamCapability) override;
|
||||
int32_t GetPlaySpeed(PlaybackSpeed &playbackSpeed) override;
|
||||
int32_t GetMediaInfoHolder(MediaInfoHolder &mediaInfoHolder) override;
|
||||
int32_t Release() override;
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
void OnPlayRequest(const MediaInfo &mediaInfo) override;
|
||||
void OnImageChanged(std::shared_ptr<Media::PixelMap> pixelMap) override;
|
||||
void OnAlbumCoverChanged(std::shared_ptr<Media::PixelMap> pixelMap) override;
|
||||
void OnAvailableCapabilityChanged(const StreamCapability &streamCapability) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<StreamPlayerListenerImplProxy> delegator_;
|
||||
|
@ -505,6 +505,18 @@ void CastStreamPlayerCallback::OnLoopModeChanged(const LoopMode loopMode)
|
||||
CLOGD("OnLoopModeChanged out");
|
||||
}
|
||||
|
||||
void CastStreamPlayerCallback::OnAvailableCapabilityChanged(const StreamCapability &streamCapability)
|
||||
{
|
||||
CLOGI("OnAvailableCapabilityChanged in");
|
||||
auto listener = ListenerGetter();
|
||||
if (!listener) {
|
||||
CLOGE("StreamPlayerListener is null");
|
||||
return;
|
||||
}
|
||||
listener->OnAvailableCapabilityChanged(streamCapability);
|
||||
CLOGI("OnAvailableCapabilityChanged out");
|
||||
}
|
||||
|
||||
void CastStreamPlayerCallback::OnPlayRequest(const MediaInfo &mediaInfo)
|
||||
{
|
||||
CLOGD("OnPlayRequest in");
|
||||
|
@ -590,6 +590,26 @@ int32_t CastStreamPlayerManager::SetLoopMode(const LoopMode mode)
|
||||
return CAST_ENGINE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t CastStreamPlayerManager::InnerSetAvailableCapability(const StreamCapability &streamCapability)
|
||||
{
|
||||
CLOGD("InnerSetAvailableCapability in");
|
||||
if (!callback_) {
|
||||
CLOGE("callback_ is null");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
callback_->OnAvailableCapabilityChanged(streamCapability);
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
availableCapability_ = streamCapability;
|
||||
CLOGD("InnerSetAvailableCapability out");
|
||||
return CAST_ENGINE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t CastStreamPlayerManager::SetAvailableCapability(const StreamCapability &streamCapability)
|
||||
{
|
||||
CLOGW("Don't support SetAvailableCapability");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t CastStreamPlayerManager::SetSpeed(const PlaybackSpeed speed)
|
||||
{
|
||||
HiSysEventWriteWrap(__func__, {
|
||||
@ -701,6 +721,18 @@ int32_t CastStreamPlayerManager::GetLoopMode(LoopMode &loopMode)
|
||||
return CAST_ENGINE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t CastStreamPlayerManager::GetAvailableCapability(StreamCapability &streamCapability)
|
||||
{
|
||||
CLOGD("GetAvailableCapability in");
|
||||
if (!player_) {
|
||||
CLOGE("player_ is null");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
streamCapability = availableCapability_;
|
||||
return CAST_ENGINE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t CastStreamPlayerManager::GetPlaySpeed(PlaybackSpeed &playbackSpeed)
|
||||
{
|
||||
CLOGD("GetPlaySpeed in");
|
||||
|
@ -463,6 +463,21 @@ int32_t RemotePlayerController::SetLoopMode(const LoopMode mode)
|
||||
return CAST_ENGINE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t RemotePlayerController::SetAvailableCapability(const StreamCapability &streamCapability)
|
||||
{
|
||||
CLOGI("SetAvailableCapability in");
|
||||
std::shared_ptr<ICastStreamManagerClient> targetCallback = callback_.lock();
|
||||
if (!targetCallback) {
|
||||
CLOGE("ICastStreamManagerClient is null");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!targetCallback->NotifyPeerSetAvailableCapability(streamCapability)) {
|
||||
CLOGE("NotifyPeerSetAvailableCapability failed");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
return CAST_ENGINE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t RemotePlayerController::SetSpeed(const PlaybackSpeed speed)
|
||||
{
|
||||
HiSysEventWriteWrap(__func__, {
|
||||
@ -564,6 +579,18 @@ int32_t RemotePlayerController::GetLoopMode(LoopMode &loopMode)
|
||||
return CAST_ENGINE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t RemotePlayerController::GetAvailableCapability(StreamCapability &streamCapability)
|
||||
{
|
||||
CLOGI("GetAvailableCapability in");
|
||||
std::shared_ptr<ICastStreamManagerClient> targetCallback = callback_.lock();
|
||||
if (!targetCallback) {
|
||||
CLOGE("ICastStreamManagerClient is null");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
streamCapability = targetCallback->GetAvailableCapability();
|
||||
return CAST_ENGINE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t RemotePlayerController::GetPlaySpeed(PlaybackSpeed &playbackSpeed)
|
||||
{
|
||||
CLOGI("GetPlaySpeed in");
|
||||
|
@ -33,11 +33,11 @@ int StreamPlayerImplStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Me
|
||||
MessageOption &option)
|
||||
{
|
||||
if (!Permission::CheckStreamPermission()) {
|
||||
return ERR_UNKNOWN_TRANSACTION;
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
|
||||
if (!Permission::CheckPidPermission()) {
|
||||
return ERR_UNKNOWN_TRANSACTION;
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
RETURN_IF_WRONG_TASK(code, data, reply, option);
|
||||
return EXECUTE_SINGLE_STUB_TASK(code, data, reply);
|
||||
@ -63,12 +63,14 @@ StreamPlayerImplStub::StreamPlayerImplStub(std::shared_ptr<IStreamPlayerImpl> st
|
||||
FILL_SINGLE_STUB_TASK(SET_VOLUME, &StreamPlayerImplStub::DoSetVolumeTask);
|
||||
FILL_SINGLE_STUB_TASK(SET_MUTE, &StreamPlayerImplStub::DoSetMuteTask);
|
||||
FILL_SINGLE_STUB_TASK(SET_LOOP_MODE, &StreamPlayerImplStub::DoSetLoopModeTask);
|
||||
FILL_SINGLE_STUB_TASK(SET_AVAILABLE_CAPABILITY, &StreamPlayerImplStub::DoSetAvailableCapabilityTask);
|
||||
FILL_SINGLE_STUB_TASK(SET_SPEED, &StreamPlayerImplStub::DoSetSpeedTask);
|
||||
FILL_SINGLE_STUB_TASK(GET_PLAYER_STATUS, &StreamPlayerImplStub::DoGetPlayerStatusTask);
|
||||
FILL_SINGLE_STUB_TASK(GET_POSITION, &StreamPlayerImplStub::DoGetPositionTask);
|
||||
FILL_SINGLE_STUB_TASK(GET_DURATION, &StreamPlayerImplStub::DoGetDurationTask);
|
||||
FILL_SINGLE_STUB_TASK(GET_VOLUME, &StreamPlayerImplStub::DoGetVolumeTask);
|
||||
FILL_SINGLE_STUB_TASK(GET_LOOP_MODE, &StreamPlayerImplStub::DoGetLoopModeTask);
|
||||
FILL_SINGLE_STUB_TASK(GET_AVAILABLE_CAPABILITY, &StreamPlayerImplStub::DoGetAvailableCapabilityTask);
|
||||
FILL_SINGLE_STUB_TASK(GET_PLAY_SPEED, &StreamPlayerImplStub::DoGetPlaySpeedTask);
|
||||
FILL_SINGLE_STUB_TASK(GET_MEDIA_INFO_HOLDER, &StreamPlayerImplStub::DoGetMediaInfoHolderTask);
|
||||
FILL_SINGLE_STUB_TASK(RELEASE, &StreamPlayerImplStub::DoReleaseTask);
|
||||
@ -278,6 +280,17 @@ int32_t StreamPlayerImplStub::DoSetLoopModeTask(MessageParcel &data, MessageParc
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t StreamPlayerImplStub::DoSetAvailableCapabilityTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
StreamCapability streamCapability = ReadStreamCapability(data);
|
||||
if (!reply.WriteInt32(SetAvailableCapability(streamCapability))) {
|
||||
CLOGE("Failed to write streamCapability value");
|
||||
return IPC_STUB_WRITE_PARCEL_ERR;
|
||||
}
|
||||
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t StreamPlayerImplStub::DoSetSpeedTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int speed = data.ReadInt32();
|
||||
@ -417,6 +430,23 @@ int32_t StreamPlayerImplStub::DoGetLoopModeTask(MessageParcel &data, MessageParc
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t StreamPlayerImplStub::DoGetAvailableCapabilityTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
static_cast<void>(data);
|
||||
StreamCapability streamCapability{};
|
||||
int32_t ret = GetAvailableCapability(streamCapability);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
CLOGE("Failed to write ret:%{public}d", ret);
|
||||
return IPC_STUB_WRITE_PARCEL_ERR;
|
||||
}
|
||||
if (!WriteStreamCapability(reply, streamCapability)) {
|
||||
CLOGE("Failed to write streamCapability");
|
||||
return IPC_STUB_WRITE_PARCEL_ERR;
|
||||
}
|
||||
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int32_t StreamPlayerImplStub::DoGetMediaInfoHolderTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
static_cast<void>(data);
|
||||
@ -621,6 +651,16 @@ int32_t StreamPlayerImplStub::SetLoopMode(const LoopMode mode)
|
||||
return streamPlayerImpl->SetLoopMode(mode);
|
||||
}
|
||||
|
||||
int32_t StreamPlayerImplStub::SetAvailableCapability(const StreamCapability &streamCapability)
|
||||
{
|
||||
auto streamPlayerImpl = PlayerImplGetter();
|
||||
if (!streamPlayerImpl) {
|
||||
CLOGE("playerImpl is nullptr");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
return streamPlayerImpl->SetAvailableCapability(streamCapability);
|
||||
}
|
||||
|
||||
int32_t StreamPlayerImplStub::SetSpeed(const PlaybackSpeed speed)
|
||||
{
|
||||
auto streamPlayerImpl = PlayerImplGetter();
|
||||
@ -691,6 +731,16 @@ int32_t StreamPlayerImplStub::GetLoopMode(LoopMode &loopMode)
|
||||
return streamPlayerImpl->GetLoopMode(loopMode);
|
||||
}
|
||||
|
||||
int32_t StreamPlayerImplStub::GetAvailableCapability(StreamCapability &streamCapability)
|
||||
{
|
||||
auto streamPlayerImpl = PlayerImplGetter();
|
||||
if (!streamPlayerImpl) {
|
||||
CLOGE("playerImpl is nullptr");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
return streamPlayerImpl->GetAvailableCapability(streamCapability);
|
||||
}
|
||||
|
||||
int32_t StreamPlayerImplStub::GetPlaySpeed(PlaybackSpeed &playbackSpeed)
|
||||
{
|
||||
auto streamPlayerImpl = PlayerImplGetter();
|
||||
|
@ -333,6 +333,26 @@ void StreamPlayerListenerImplProxy::OnAlbumCoverChanged(std::shared_ptr<Media::P
|
||||
CLOGE("Failed to send ipc request when reporting album cover changed");
|
||||
}
|
||||
}
|
||||
|
||||
void StreamPlayerListenerImplProxy::OnAvailableCapabilityChanged(const StreamCapability &streamCapability)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return;
|
||||
}
|
||||
if (!WriteStreamCapability(data, streamCapability)) {
|
||||
CLOGE("Failed to write the streamCapability");
|
||||
return;
|
||||
}
|
||||
if (Remote()->SendRequest(ON_AVAILABLE_CAPABILITY_CHANGED, data, reply, option) != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when reporting streamCapability");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace CastEngineService
|
||||
} // namespace CastEngine
|
||||
} // namespace OHOS
|
||||
|
Loading…
Reference in New Issue
Block a user