mirror of
https://gitee.com/openharmony/castengine_cast_framework
synced 2024-11-23 06:29:46 +00:00
TicketNo:#IB2R8O Description:根据检视意见优化代码
Signed-off-by: LongestDistance <cdwango@isoftstone.com>
This commit is contained in:
parent
7d7b5c0011
commit
bab9ddff50
@ -157,6 +157,29 @@ int32_t CastSessionImplProxy::StartAuth(const AuthInfo &authInfo)
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t CastSessionImplProxy::Release()
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t ret = Remote()->SendRequest(RELEASE, data, reply, option);
|
||||
if (ret == ERR_UNKNOWN_TRANSACTION) {
|
||||
CLOGE("No permission when releasing the cast session");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when releasing the cast session");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t CastSessionImplProxy::GetSessionId(std::string &sessionId)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
@ -284,6 +307,31 @@ int32_t CastSessionImplProxy::SetSessionProperty(const CastSessionProperty &prop
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t CastSessionImplProxy::SetCastMode(CastMode mode, std::string &jsonParam)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!data.WriteInt32(static_cast<int32_t>(mode))) {
|
||||
CLOGE("Failed to write cast mode");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!data.WriteString(jsonParam)) {
|
||||
CLOGE("Failed to write json param");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (Remote()->SendRequest(SET_CAST_MODE, data, reply, option) != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when set cast mode");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t CastSessionImplProxy::CreateMirrorPlayer(sptr<IMirrorPlayerImpl> &mirrorPlayer)
|
||||
{
|
||||
MessageParcel data;
|
||||
@ -348,54 +396,6 @@ int32_t CastSessionImplProxy::CreateStreamPlayer(sptr<IStreamPlayerIpc> &streamP
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
int32_t CastSessionImplProxy::Release()
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t ret = Remote()->SendRequest(RELEASE, data, reply, option);
|
||||
if (ret == ERR_UNKNOWN_TRANSACTION) {
|
||||
CLOGE("No permission when releasing the cast session");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when releasing the cast session");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t CastSessionImplProxy::SetCastMode(CastMode mode, std::string &jsonParam)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!data.WriteInt32(static_cast<int32_t>(mode))) {
|
||||
CLOGE("Failed to write cast mode");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!data.WriteString(jsonParam)) {
|
||||
CLOGE("Failed to write json param");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (Remote()->SendRequest(SET_CAST_MODE, data, reply, option) != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when set cast mode");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t CastSessionImplProxy::NotifyEvent(EventId eventId, std::string &jsonParam)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
|
@ -49,31 +49,6 @@ int32_t MirrorPlayer::Pause(const std::string &deviceId)
|
||||
return proxy_ ? proxy_->Pause(deviceId) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t MirrorPlayer::SetSurface(const std::string &surfaceId)
|
||||
{
|
||||
errno = 0;
|
||||
uint64_t surfaceUniqueId = static_cast<uint64_t>(std::strtoll(surfaceId.c_str(), nullptr, 10));
|
||||
if (errno == ERANGE) {
|
||||
return ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
sptr<Surface> surface = SurfaceUtils::GetInstance()->GetSurface(surfaceUniqueId);
|
||||
if (!surface) {
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
sptr<IBufferProducer> producer = surface->GetProducer();
|
||||
if (!producer) {
|
||||
CLOGE("producer is null");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
return proxy_ ? proxy_->SetSurface(producer) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t MirrorPlayer::SetAppInfo(const AppInfo &appInfo)
|
||||
{
|
||||
return proxy_ ? proxy_->SetAppInfo(appInfo) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t MirrorPlayer::DeliverInputEvent(OHRemoteControlEvent event)
|
||||
{
|
||||
return proxy_ ? proxy_->DeliverInputEvent(event) : CAST_ENGINE_ERROR;
|
||||
@ -99,6 +74,34 @@ int32_t MirrorPlayer::GetDisplayId(std::string &displayId)
|
||||
return proxy_ ? proxy_->GetDisplayId(displayId) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t MirrorPlayer::SetAppInfo(const AppInfo &appInfo)
|
||||
{
|
||||
return proxy_ ? proxy_->SetAppInfo(appInfo) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t MirrorPlayer::SetSurface(const std::string &surfaceId)
|
||||
{
|
||||
errno = 0;
|
||||
char *end = nullptr;
|
||||
uint64_t surfaceUniqueId = static_cast<uint64_t>(std::strtoll(surfaceId.c_str(), &end, 10));
|
||||
if (errno == ERANGE || (surfaceUniqueId == 0 && *end != '\0')) {
|
||||
CLOGE("Failed to strtoll, errno: %{public}d", errno);
|
||||
return ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
sptr<Surface> surface = SurfaceUtils::GetInstance()->GetSurface(surfaceUniqueId);
|
||||
if (!surface) {
|
||||
CLOGE("surface is null, surface uniqueId %{public}" PRIu64, surfaceUniqueId);
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
sptr<IBufferProducer> producer = surface->GetProducer();
|
||||
if (!producer) {
|
||||
CLOGE("producer is null");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
return proxy_ ? proxy_->SetSurface(producer) : CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
} // namespace CastEngineClient
|
||||
} // namespace CastEngine
|
||||
} // namespace OHOS
|
@ -89,58 +89,6 @@ int32_t MirrorPlayerImplProxy::Pause(const std::string &deviceId)
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t MirrorPlayerImplProxy::SetSurface(sptr<IBufferProducer> producer)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!data.WriteRemoteObject(producer->AsObject())) {
|
||||
CLOGE("Failed to write surface producer");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t ret = Remote()->SendRequest(SET_SURFACE, data, reply, option);
|
||||
if (ret == ERR_UNKNOWN_TRANSACTION) {
|
||||
CLOGE("No permission when setting surface");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when setting surface");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t MirrorPlayerImplProxy::SetAppInfo(const AppInfo &appInfo)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!data.WriteInt32(appInfo.appUid) || !data.WriteUint32(appInfo.appTokenId) ||
|
||||
!data.WriteInt32(appInfo.appPid)) {
|
||||
CLOGE("Failed to write appInfo");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
CLOGI("start set app info impl proxy");
|
||||
int32_t ret = Remote()->SendRequest(SET_APP_INFO, data, reply, option);
|
||||
if (ret == ERR_UNKNOWN_TRANSACTION) {
|
||||
CLOGE("No permission when setting surface");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when setting surface");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t MirrorPlayerImplProxy::DeliverInputEvent(const OHRemoteControlEvent &event)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
@ -227,30 +175,6 @@ int32_t MirrorPlayerImplProxy::Release()
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t MirrorPlayerImplProxy::GetDisplayId(std::string &displayId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
displayId = std::string{};
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t ret = Remote()->SendRequest(GET_DISPLAYID, data, reply, option);
|
||||
if (ret == ERR_UNKNOWN_TRANSACTION) {
|
||||
CLOGE("No permission when getDisplayId");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when getDisplayId");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
int32_t errorCode = reply.ReadInt32();
|
||||
CHECK_AND_RETURN_RET_LOG(errorCode != CAST_ENGINE_SUCCESS, errorCode, "CastEngine Errors");
|
||||
displayId = reply.ReadString();
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
int32_t MirrorPlayerImplProxy::ResizeVirtualScreen(uint32_t width, uint32_t height)
|
||||
{
|
||||
@ -277,6 +201,84 @@ int32_t MirrorPlayerImplProxy::ResizeVirtualScreen(uint32_t width, uint32_t heig
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t MirrorPlayerImplProxy::GetDisplayId(std::string &displayId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
displayId = std::string{};
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t ret = Remote()->SendRequest(GET_DISPLAYID, data, reply, option);
|
||||
if (ret == ERR_NO_PERMISSION) {
|
||||
CLOGE("No permission when getDisplayId");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when getDisplayId");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
int32_t errorCode = reply.ReadInt32();
|
||||
CHECK_AND_RETURN_RET_LOG(errorCode != CAST_ENGINE_SUCCESS, errorCode, "CastEngine Errors");
|
||||
displayId = reply.ReadString();
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
int32_t MirrorPlayerImplProxy::SetAppInfo(const AppInfo &appInfo)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!data.WriteInt32(appInfo.appUid) || !data.WriteUint32(appInfo.appTokenId) ||
|
||||
!data.WriteInt32(appInfo.appPid)) {
|
||||
CLOGE("Failed to write appInfo");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
CLOGI("start set app info impl proxy");
|
||||
int32_t ret = Remote()->SendRequest(SET_APP_INFO, data, reply, option);
|
||||
if (ret == ERR_NO_PERMISSION) {
|
||||
CLOGE("No permission when setting surface");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when setting surface");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t MirrorPlayerImplProxy::SetSurface(sptr<IBufferProducer> producer)
|
||||
{
|
||||
MessageParcel data, reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
CLOGE("Failed to write the interface token");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
if (!data.WriteRemoteObject(producer->AsObject())) {
|
||||
CLOGE("Failed to write surface producer");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
int32_t ret = Remote()->SendRequest(SET_SURFACE, data, reply, option);
|
||||
if (ret == ERR_NO_PERMISSION) {
|
||||
CLOGE("No permission when setting surface");
|
||||
return ERR_NO_PERMISSION;
|
||||
} else if (ret != ERR_NONE) {
|
||||
CLOGE("Failed to send ipc request when setting surface");
|
||||
return CAST_ENGINE_ERROR;
|
||||
}
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
} // namespace CastEngineClient
|
||||
} // namespace CastEngine
|
||||
} // namespace OHOS
|
||||
|
@ -25,7 +25,9 @@
|
||||
#include <shared_mutex>
|
||||
|
||||
#include "cast_session_manager_service_stub.h"
|
||||
#include "connection_manager_listener.h"
|
||||
#include "session.h"
|
||||
#include "system_ability_load_callback_stub.h"
|
||||
#include "system_ability.h"
|
||||
|
||||
using SharedRLock = std::shared_lock<std::shared_mutex>;
|
||||
@ -64,6 +66,12 @@ public:
|
||||
void ReportDeviceOffline(const std::string &deviceId);
|
||||
sptr<ICastSessionImpl> GetCastSessionInner(std::string sessionId);
|
||||
|
||||
class CastServiceLoadCallback : public SystemAbilityLoadCallbackStub {
|
||||
public:
|
||||
void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr<IRemoteObject> &remoteObject) override;
|
||||
void OnLoadSystemAbilityFail(int32_t systemAbilityId) override;
|
||||
};
|
||||
|
||||
private:
|
||||
class CastEngineClientDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
|
@ -760,6 +760,32 @@ void CastSessionManagerService::CastEngineClientDeathRecipient::OnRemoteDied(con
|
||||
}
|
||||
service->ReleaseServiceResources(pid_, uid_);
|
||||
}
|
||||
|
||||
void CastSessionManagerService::CastServiceLoadCallback::OnLoadSystemAbilitySuccess(
|
||||
int32_t systemAbilityId, const sptr<IRemoteObject> &remoteObject)
|
||||
{
|
||||
CLOGI("In systemAbilityId: %d", systemAbilityId);
|
||||
|
||||
if (systemAbilityId != CAST_ENGINE_SA_ID) {
|
||||
CLOGE("Start aystemabilityId is not sinkSAId!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (remoteObject == nullptr) {
|
||||
CLOGE("RemoteObject is nullptr.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CastSessionManagerService::CastServiceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
|
||||
{
|
||||
CLOGI("In systemAbilityId: %d.", systemAbilityId);
|
||||
|
||||
if (systemAbilityId != CAST_ENGINE_SA_ID) {
|
||||
CLOGE("Start aystemabilityId is not sinkSAId!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace CastEngineService
|
||||
} // namespace CastEngine
|
||||
} // namespace OHOS
|
||||
|
@ -94,7 +94,9 @@ int32_t CastSessionManagerServiceStub::DoReleaseTask(MessageParcel &data, Messag
|
||||
{
|
||||
static_cast<void>(data);
|
||||
|
||||
if (!Permission::CheckMirrorPermission() && !Permission::CheckStreamPermission()) {
|
||||
if ((!Permission::CheckMirrorPermission() &&
|
||||
!Permission::CheckStreamPermission()) ||
|
||||
!Permission::CheckPidPermission()) {
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
|
||||
@ -108,7 +110,7 @@ int32_t CastSessionManagerServiceStub::DoReleaseTask(MessageParcel &data, Messag
|
||||
|
||||
int32_t CastSessionManagerServiceStub::DoSetLocalDeviceTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
if (!Permission::CheckMirrorPermission()) {
|
||||
if (!Permission::CheckMirrorPermission() || !Permission::CheckPidPermission()) {
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
|
||||
@ -127,7 +129,9 @@ int32_t CastSessionManagerServiceStub::DoSetLocalDeviceTask(MessageParcel &data,
|
||||
|
||||
int32_t CastSessionManagerServiceStub::DoCreateCastSessionTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
if (!Permission::CheckMirrorPermission() && !Permission::CheckStreamPermission()) {
|
||||
if ((!Permission::CheckMirrorPermission() &&
|
||||
!Permission::CheckStreamPermission()) ||
|
||||
!Permission::CheckPidPermission()) {
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
|
||||
@ -158,7 +162,7 @@ int32_t CastSessionManagerServiceStub::DoSetSinkSessionCapacityTask(MessageParce
|
||||
{
|
||||
static_cast<void>(reply);
|
||||
|
||||
if (!Permission::CheckMirrorPermission()) {
|
||||
if (!Permission::CheckMirrorPermission() || !Permission::CheckPidPermission()) {
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
|
||||
@ -174,7 +178,9 @@ int32_t CastSessionManagerServiceStub::DoSetSinkSessionCapacityTask(MessageParce
|
||||
|
||||
int32_t CastSessionManagerServiceStub::DoStartDiscoveryTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
if (!Permission::CheckMirrorPermission() && !Permission::CheckStreamPermission()) {
|
||||
if ((!Permission::CheckMirrorPermission() &&
|
||||
!Permission::CheckStreamPermission()) ||
|
||||
!Permission::CheckPidPermission()) {
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
|
||||
@ -197,7 +203,9 @@ int32_t CastSessionManagerServiceStub::DoStartDiscoveryTask(MessageParcel &data,
|
||||
|
||||
int32_t CastSessionManagerServiceStub::DoSetDiscoverableTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
if (!Permission::CheckMirrorPermission() && !Permission::CheckStreamPermission()) {
|
||||
if ((!Permission::CheckMirrorPermission() &&
|
||||
!Permission::CheckStreamPermission()) ||
|
||||
!Permission::CheckPidPermission()) {
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
|
||||
@ -211,7 +219,9 @@ int32_t CastSessionManagerServiceStub::DoSetDiscoverableTask(MessageParcel &data
|
||||
|
||||
int32_t CastSessionManagerServiceStub::DoStopDiscoveryTask(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
if (!Permission::CheckMirrorPermission() && !Permission::CheckStreamPermission()) {
|
||||
if ((!Permission::CheckMirrorPermission() &&
|
||||
!Permission::CheckStreamPermission()) ||
|
||||
!Permission::CheckPidPermission()) {
|
||||
return ERR_NO_PERMISSION;
|
||||
}
|
||||
|
||||
|
@ -62,20 +62,6 @@ public:
|
||||
void OnUnbindResult(const PeerTargetId &targetId, int32_t result, std::string content) override;
|
||||
};
|
||||
|
||||
class IConnectionManagerListener {
|
||||
public:
|
||||
IConnectionManagerListener() = default;
|
||||
virtual ~IConnectionManagerListener() = default;
|
||||
|
||||
virtual int NotifySessionIsReady() = 0;
|
||||
virtual void NotifyDeviceIsOffline(const std::string &deviceId) = 0;
|
||||
virtual bool NotifyRemoteDeviceIsReady(int castSessionId, const CastInnerRemoteDevice &device) = 0;
|
||||
virtual void OnEvent(const std::string &deviceId, ReasonCode currentEventCode) = 0;
|
||||
virtual void GrabDevice(int32_t sessionId) = 0;
|
||||
virtual int32_t GetSessionProtocolType(int sessionId, ProtocolType &protocolType) = 0;
|
||||
virtual int32_t SetSessionProtocolType(int sessionId, ProtocolType protocolType) = 0;
|
||||
};
|
||||
|
||||
class ConnectionManager {
|
||||
public:
|
||||
static ConnectionManager &GetInstance();
|
||||
@ -108,13 +94,15 @@ public:
|
||||
void ReportErrorByListener(const std::string &deviceId, ReasonCode currentEventCode);
|
||||
void UpdateGrabState(bool changeState, int32_t sessionId);
|
||||
void SetSessionListener(std::shared_ptr<IConnectManagerSessionListener> listener);
|
||||
|
||||
int32_t GetSessionProtocolType(int sessionId, ProtocolType &protocolType);
|
||||
int32_t SetSessionProtocolType(int sessionId, ProtocolType protocolType);
|
||||
|
||||
void SetRTSPPort(int port);
|
||||
void SendConsultInfo(const std::string &deviceId, int port);
|
||||
bool IsSingle(const CastInnerRemoteDevice &device);
|
||||
bool IsHuaweiDevice(const CastInnerRemoteDevice &device);
|
||||
bool IsThirdDevice(const CastInnerRemoteDevice &device);
|
||||
void SendConsultInfo(const std::string &deviceId, int port);
|
||||
|
||||
std::map<std::string, bool> isBindTargetMap_;
|
||||
|
||||
@ -122,23 +110,26 @@ private:
|
||||
bool BindTarget(const CastInnerRemoteDevice &dev);
|
||||
bool BuildBindParam(const CastInnerRemoteDevice &device, std::map<std::string, std::string> &bindParam);
|
||||
std::string GetAuthVersion(const CastInnerRemoteDevice &device);
|
||||
void SendConsultData(const CastInnerRemoteDevice &device, int port);
|
||||
|
||||
bool QueryP2PIp(const CastInnerRemoteDevice &device);
|
||||
|
||||
void SendConsultData(const CastInnerRemoteDevice &device, int port);
|
||||
std::string GetConsultationData(const CastInnerRemoteDevice &device, int port, json &body);
|
||||
|
||||
void EncryptPort(int port, const uint8_t *sessionKey, json &body);
|
||||
std::string convLatin1ToUTF8(std::string &latin1);
|
||||
void EncryptIp(const std::string &ip, const std::string &key, const uint8_t *sessionKey, json &body);
|
||||
std::unique_ptr<uint8_t[]> intToByteArray(int32_t num);
|
||||
std::string convLatin1ToUTF8(std::string &latin1);
|
||||
|
||||
void DestroyConsulationSession(const std::string &deviceId);
|
||||
int GetCastSessionId(int transportId);
|
||||
|
||||
std::unique_ptr<CastInnerRemoteDevice> GetRemoteFromJsonData(const std::string &Data);
|
||||
|
||||
int GetRTSPPort();
|
||||
void SetListener(std::shared_ptr<IConnectionManagerListener> listener);
|
||||
bool HasListener();
|
||||
void ResetListener();
|
||||
int GetRTSPPort();
|
||||
|
||||
std::mutex mutex_;
|
||||
int protocolType_ = 0;
|
||||
|
@ -1,37 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2023-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Description: connection manager session listener
|
||||
* Author: jiangfan
|
||||
* Create: 2023-11-08
|
||||
*/
|
||||
#ifndef LIBCASTENGINE_CONNECTMANAGER_LISTENER_H
|
||||
#define LIBCASTENGINE_CONNECTMANAGER_LISTENER_H
|
||||
|
||||
#include "cast_engine_common.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace CastEngine {
|
||||
namespace CastEngineService {
|
||||
|
||||
class IConnectManagerSessionListener {
|
||||
public:
|
||||
virtual ~IConnectManagerSessionListener() {}
|
||||
|
||||
virtual void NotifyConnectStage(const std::string &deviceId, int result, int32_t reasonCode) = 0;
|
||||
};
|
||||
} // namespace CastEngineService
|
||||
} // namespace CastEngine
|
||||
} // namespace OHOS
|
||||
|
||||
/*
|
||||
* Copyright (C) 2023-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Description: connection manager session listener
|
||||
* Author: jiangfan
|
||||
* Create: 2023-11-08
|
||||
*/
|
||||
|
||||
#ifndef LIBCASTENGINE_CONNECTMANAGER_LISTENER_H
|
||||
#define LIBCASTENGINE_CONNECTMANAGER_LISTENER_H
|
||||
|
||||
#include "cast_engine_common.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace CastEngine {
|
||||
namespace CastEngineService {
|
||||
|
||||
class IConnectionManagerListener {
|
||||
public:
|
||||
IConnectionManagerListener() = default;
|
||||
virtual ~IConnectionManagerListener() = default;
|
||||
|
||||
virtual int NotifySessionIsReady() = 0;
|
||||
virtual void NotifyDeviceIsOffline(const std::string &deviceId) = 0;
|
||||
virtual bool NotifyRemoteDeviceIsReady(int castSessionId, const CastInnerRemoteDevice &device) = 0;
|
||||
virtual void OnEvent(const std::string &deviceId, ReasonCode currentEventCode) = 0;
|
||||
virtual void GrabDevice(int32_t sessionId) = 0;
|
||||
virtual int32_t GetSessionProtocolType(int sessionId, ProtocolType &protocolType) = 0;
|
||||
virtual int32_t SetSessionProtocolType(int sessionId, ProtocolType protocolType) = 0;
|
||||
};
|
||||
|
||||
class IConnectManagerSessionListener {
|
||||
public:
|
||||
virtual ~IConnectManagerSessionListener() {}
|
||||
|
||||
virtual void NotifyConnectStage(const std::string &deviceId, int result, int32_t reasonCode) = 0;
|
||||
};
|
||||
} // namespace CastEngineService
|
||||
} // namespace CastEngine
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // LIBCASTENGINE_CONNECTMANAGER_LISTENER_H
|
Loading…
Reference in New Issue
Block a user