TicketNo:#IB00OX Description:代码重构,修改gn、cast_engine通用接口及部分定义

Signed-off-by: LongestDistance <cdwango@isoftstone.com>
This commit is contained in:
LongestDistance 2024-10-27 21:15:12 +08:00
parent 2e147c3554
commit 6c7c03ad53
36 changed files with 517 additions and 263 deletions

View File

@ -26,6 +26,7 @@
"hilog",
"hisysevent",
"hitrace",
"media_foundation",
"access_token",
"audio_framework",
"av_codec",
@ -35,6 +36,8 @@
"safwk",
"samgr",
"c_utils",
"eventhandler",
"power_manager",
"dsoftbus",
"device_manager",
"common_event_service",
@ -50,7 +53,14 @@
"image_framework",
"wifi",
"device_auth",
"eventhandler"
"device_info_manager",
"thermal_manager",
"screenlock_mgr",
"state_registry",
"core_service",
"call_manager",
"os_account",
"sharing_framework"
],
"third_party":[
"glib",

View File

@ -21,7 +21,13 @@ config("cast_client_config") {
}
ohos_static_library("cast_client_inner") {
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
}
sources = [
"src/cast_engine_service_load_callback.cpp",
"src/cast_service_listener_impl_stub.cpp",
"src/cast_session.cpp",
"src/cast_session_impl_proxy.cpp",
@ -29,12 +35,11 @@ ohos_static_library("cast_client_inner") {
"src/cast_session_manager.cpp",
"src/cast_session_manager_adaptor.cpp",
"src/cast_session_manager_service_proxy.cpp",
"src/cast_engine_service_load_callback.cpp",
"src/stream_player_listener_impl_stub.cpp",
"src/mirror_player.cpp",
"src/mirror_player_impl_proxy.cpp",
"src/stream_player.cpp",
"src/stream_player_impl_proxy.cpp",
"src/stream_player_listener_impl_stub.cpp",
]
configs = [
@ -50,11 +55,12 @@ ohos_static_library("cast_client_inner") {
external_deps = [
"c_utils:utils",
"graphic_surface:surface",
"hilog:libhilog",
"image_framework:image_native",
"init:libbegetutil",
"ipc:ipc_core",
"samgr:samgr_proxy",
"graphic_surface:surface",
"image_framework:image_native",
]
subsystem_name = "castplus"

View File

@ -36,7 +36,7 @@ DEFINE_CAST_ENGINE_LABEL("Cast-Client-ServiceListener");
int CastServiceListenerImplStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{
RETRUEN_IF_WRONG_TASK(code, data, reply, option);
RETURN_IF_WRONG_TASK(code, data, reply, option);
return EXECUTE_SINGLE_STUB_TASK(code, data, reply);
}

View File

@ -29,7 +29,7 @@ DEFINE_CAST_ENGINE_LABEL("Cast-Client-SessionListener");
int CastSessionListenerImplStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{
RETRUEN_IF_WRONG_TASK(code, data, reply, option);
RETURN_IF_WRONG_TASK(code, data, reply, option);
return EXECUTE_SINGLE_STUB_TASK(code, data, reply);
}

View File

@ -28,7 +28,7 @@ DEFINE_CAST_ENGINE_LABEL("Cast-Client-StreamPlayerListener");
int StreamPlayerListenerImplStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{
RETRUEN_IF_WRONG_TASK(code, data, reply, option);
RETURN_IF_WRONG_TASK(code, data, reply, option);
if (userListener_ == nullptr) {
CLOGE("userListener_ is null, code:%{public}d", code);
return ERR_NULL_OBJECT;

View File

@ -18,6 +18,11 @@ config("cast_engine_common_private_config") {
}
ohos_static_library("cast_engine_common_sources") {
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
}
sources = [
"src/cast_engine_common_helper.cpp",
"src/cast_engine_dfx.cpp",
@ -38,11 +43,14 @@ ohos_static_library("cast_engine_common_sources") {
]
external_deps = [
"access_token:libtokensetproc_shared",
"c_utils:utils",
"hilog:libhilog",
"hisysevent:libhisysevent",
"ipc:ipc_core",
"image_framework:image_native",
"init:libbegetutil",
"eventhandler:libeventhandler",
]
subsystem_name = "castplus"

View File

@ -35,6 +35,7 @@ struct CastInnerRemoteDevice {
TriggerType triggerType{ TriggerType::UNSPEC_TAG };
std::string authData;
int sessionId{ INVALID_ID };
int localCastSessionId{ INVALID_ID };
ChannelType channelType{ ChannelType::SOFT_BUS };
uint8_t sessionKey[16] = { 0 };
uint32_t sessionKeyLength{ 0 };
@ -42,7 +43,11 @@ struct CastInnerRemoteDevice {
std::string localWifiIp;
std::string wifiIp;
uint16_t wifiPort = 0;
bool isWifiFresh = false;
bool isBleFresh = false;
std::string customData;
uint32_t capabilityInfo = 0;
uint32_t mediumTypes{ 0 };
int rtspPort{ INVALID_PORT };
ProtocolType protocolType;
std::string udid;
@ -50,11 +55,19 @@ struct CastInnerRemoteDevice {
std::string localIp;
std::string remoteIp;
std::string networkId;
std::string authVersion;
bool isLeagacy{ false };
CapabilityType capability{ CapabilityType::CAST_PLUS };
uint32_t dlnaDeviceId{ static_cast<uint32_t>(INVALID_ID) };
std::vector<std::string> drmCapabilities;
std::string dlnaDeviceModelNameStr;
std::string dlnaDeviceManufacturerStr;
bool operator==(const CastInnerRemoteDevice &rhs) const
{
return deviceId == rhs.deviceId && deviceName == rhs.deviceName && bleMac == rhs.bleMac
&& wifiIp == rhs.wifiIp && wifiPort == rhs.wifiPort && customData == rhs.customData;
&& wifiIp == rhs.wifiIp && wifiPort == rhs.wifiPort && customData == rhs.customData
&& isWifiFresh == rhs.isWifiFresh && isBleFresh == rhs.isBleFresh;
}
bool operator!=(const CastInnerRemoteDevice &rhs) const

View File

@ -38,7 +38,7 @@ private:
return ERR_FLATTEN_OBJECT; \
}
#define RETRUEN_IF_WRONG_TASK(code, data, reply, option) \
#define RETURN_IF_WRONG_TASK(code, data, reply, option) \
do { \
RETURN_IF_WRONG_INTERFACE_TOKEN(data); \
if (taskMap_.count(code) == 0) { \

View File

@ -58,7 +58,11 @@ public:
virtual int32_t Release() = 0;
virtual int32_t NotifyEvent(EventId eventId, std::string &jsonParam) = 0;
virtual int32_t SetCastMode(CastMode mode, std::string &jsonParam) = 0;
virtual void OnSessionEvent(const std::string &deviceId, const EventCode eventCode) {}
virtual void OnSessionEvent(const std::string &deviceId, const ReasonCode eventCode) {}
virtual int32_t GetRemoteDeviceInfo(std::string deviceId, CastRemoteDevice &remoteDevice)
{
return 0;
}
virtual bool AddDevice(const CastInnerRemoteDevice &remoteDevice)
{
return false;
@ -73,6 +77,10 @@ public:
return CAST_ENGINE_ERROR;
}
virtual void SetSessionProtocolType(ProtocolType protocolType) {}
virtual uint8_t GetSessionState()
{
return 0;
}
protected:
enum {

View File

@ -80,7 +80,7 @@ std::optional<VideoProperty> ReadVideoProperty(Parcel &parcel)
property.videoHeight = static_cast<uint32_t>(parcel.ReadInt32());
property.fps = static_cast<uint32_t>(parcel.ReadInt32());
auto codecType = parcel.ReadInt32();
property.gop = static_cast<uint32_t>(parcel.ReadInt32());
property.gop = parcel.ReadInt32();
property.bitrate = static_cast<uint32_t>(parcel.ReadInt32());
property.minBitrate = static_cast<uint32_t>(parcel.ReadInt32());
property.maxBitrate = static_cast<uint32_t>(parcel.ReadInt32());
@ -123,6 +123,10 @@ const AudioProperty ReadAudioProperty(Parcel &parcel)
int GetLocalFd(const std::string &url)
{
if (url.empty()) {
CLOGE("url is empty.");
return INVALID_VALUE;
}
char *nextPtr = nullptr;
int fd = static_cast<int>(std::strtol(url.c_str(), &nextPtr, DECIMALISM));
if (errno == ERANGE || *nextPtr != '\0') {
@ -242,6 +246,7 @@ std::unique_ptr<MediaInfo> ReadMediaInfo(MessageParcel &parcel)
mediaInfo->startPosition = parcel.ReadUint32();
mediaInfo->duration = parcel.ReadUint32();
mediaInfo->closingCreditsPosition = parcel.ReadUint32();
mediaInfo->drmType = parcel.ReadString();
return mediaInfo;
}
@ -501,6 +506,10 @@ const OHNativeXcomponentTouchPoint ReadTouchPoint(Parcel &parcel)
void ReadTouchPoints(Parcel &parcel, uint32_t numPoints, OHNativeXcomponentTouchPoint points[])
{
if (numPoints > OH_MAX_TOUCH_POINTS_NUMBER) {
CLOGE("numPoints is invalid, numPoints:%{public}d", numPoints);
return;
}
for (uint32_t i = 0; i < numPoints; i++) {
points[i] = ReadTouchPoint(parcel);
}
@ -552,8 +561,10 @@ const OHNativeXcomponentKeyEvent ReadKeyEvent(Parcel &parcel)
void ReadContentEvent(Parcel &parcel, OHNativeXcomponentContentEvent &contentEvent)
{
contentEvent.msgLen = parcel.ReadUint16();
if (strcpy_s(contentEvent.inputText, OH_MAX_CONTENT_LEN, parcel.ReadCString()) != EOK) {
CLOGE("Failed copy content to array");
int32_t err = memcpy_s(contentEvent.inputText,
OH_MAX_CONTENT_LEN, parcel.ReadBuffer(contentEvent.msgLen), contentEvent.msgLen);
if (err != 0) {
CLOGE("memcpy_s inputText failed, err = %{public}d.", err);
}
}
@ -618,7 +629,7 @@ bool WriteDeviceStateInfo(Parcel &parcel, const DeviceStateInfo &stateInfo)
{
return parcel.WriteInt32(static_cast<int32_t>(stateInfo.deviceState)) &&
parcel.WriteString(stateInfo.deviceId) &&
parcel.WriteInt32(static_cast<int32_t>(stateInfo.eventCode));
parcel.WriteInt32(static_cast<int32_t>(stateInfo.reasonCode));
}
std::unique_ptr<DeviceStateInfo> ReadDeviceStateInfo(Parcel &parcel)
@ -642,8 +653,8 @@ std::unique_ptr<DeviceStateInfo> ReadDeviceStateInfo(Parcel &parcel)
stateInfo->deviceId = deviceId;
// Parse event code
int32_t eventCode = parcel.ReadInt32();
stateInfo->eventCode = static_cast<EventCode>(eventCode);
int32_t reasonCode = parcel.ReadInt32();
stateInfo->reasonCode = static_cast<ReasonCode>(reasonCode);
return stateInfo;
}

View File

@ -11,12 +11,28 @@
"path" : ["/system/bin/sa_main", "/system/profile/cast_engine_service.json"],
"ondemand" : true,
"uid" : "cast_engine_service",
"gid" : ["cast_engine_service", "shell"],
"gid" : ["cast_engine_service", "shell", "access_token"],
"permission" : [
"ohos.permission.DISTRIBUTED_DATASYNC",
"ohos.permission.CAPTURE_SCREEN",
"ohos.permission.ACCESS_SERVICE_DM",
"ohos.permission.MICROPHONE",
"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
"ohos.permission.CAST_AUDIO_OUTPUT",
"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"ohos.permission.RUNNING_STATE_OBSERVER",
"ohos.permission.MONITOR_DEVICE_NETWORK_STATE",
"ohos.permission.INTERNET",
"ohos.permission.MANAGE_SOFTBUS_NETWORK",
"ohos.permission.INJECT_INPUT_EVENT",
"ohos.permission.GET_WIFI_INFO",
"ohos.permission.GET_WIFI_PEERS_MAC",
"ohos.permission.GET_WIFI_INFO_INTERNAL",
"ohos.permission.ACCESS_CAST_ENGINE_MIRROR",
"ohos.permission.MANAGE_LOCAL_ACCOUNTS"
],
"permission_acls" : [
"ohos.permission.CAPTURE_SCREEN",
"ohos.permission.MONITOR_DEVICE_NETWORK_STATE",
"ohos.permission.INJECT_INPUT_EVENT"
],
"secon" : "u:r:cast_engine_service:s0"
}

View File

@ -42,12 +42,15 @@ enum class EXPORT DeviceType {
DEVICE_PAD_IN_CAR = 10,
DEVICE_SUPER_LAUNCHER = 11,
DEVICE_CAR_MULTI_SCREEN_PLAY = 12,
DEVICE_MIRACAST = 13,
};
inline constexpr int EXPORT INVALID_ID = -1;
inline bool EXPORT IsDeviceType(int32_t type)
{
return (type >= static_cast<int32_t>(DeviceType::DEVICE_OTHERS)) &&
(type <= static_cast<int32_t>(DeviceType::DEVICE_CAR_MULTI_SCREEN_PLAY));
(type <= static_cast<int32_t>(DeviceType::DEVICE_MIRACAST));
}
enum class EXPORT SubDeviceType {
@ -84,7 +87,12 @@ enum class EXPORT DeviceState {
DISCONNECTING,
DISCONNECTED,
STREAM,
MIRROR_TO_UI,
UI_TO_MIRROR,
UICAST,
AUTHING,
MIRROR_TO_STREAM,
STREAM_TO_MIRROR,
DEVICE_STATE_MAX,
};
@ -95,10 +103,10 @@ enum class EXPORT DeviceGrabState {
NO_GRAB,
};
enum ConnectEvent : int {
AUTH_START,
enum ConnectStageResult : int32_t {
AUTHING,
AUTH_SUCCESS,
AUTH_FILED,
AUTH_FAILED,
CONNECT_START,
CONNECT_FAIL,
CONNECT_SUCCESS,
@ -106,30 +114,35 @@ enum ConnectEvent : int {
};
/*
* code =0 -> no specific events
* code >0 -> regular events
* code = 1xxxx -> regular events
* code <0 -> error events
* code = -1xxxx -> error called from DM
* code = -2xxxx -> error called from cast session
* reason code for right process or user action
*/
enum class EXPORT EventCode {
UNKNOWN_EVENT = -99999,
ERR_CONNECTION_FAILED = -20000,
ERR_PIN_CODE_RETRY_COUNT_EXCEEDED = -10000,
ERR_CANCEL_BY_SINK = -10001,
ERR_DISTRUST_BY_SINK = -10002,
ERR_SINK_TIMEOUT = -10003,
DEFAULT_EVENT = 0,
EVT_TRUST_BY_SINK = 10000,
EVT_CANCEL_BY_SOURCE = 10001,
EVT_AUTHENTICATION_COMPLETED = 10002,
EVT_SHOW_AUTHORIZE_UI = 10003
enum EXPORT ReasonCode {
REASON_DEFAULT = 0,
// Peer of sink click "TRUST", both permanently and temporarily.
REASON_TRUST_BY_SINK = 10000,
// Peer of source click "CANCEL pin code input".
REASON_CANCEL_BY_SOURCE = 10001,
// Peer of source input correct pin code and click "CONFIRM".
REASON_BIND_COMPLETED = 10002,
// Start to show THREE-STATE window.
REASON_SHOW_TRUST_SELECT_UI = 10003,
// Process of bind is interrupted by user.
REASON_STOP_BIND_BY_SOURCE = 10004,
// Peer of source input wrong pin code over 3 times.
REASON_PIN_CODE_OVER_RETRY = 10005,
// Peer of sink click "CANCEL" during peer of source input pin code.
REASON_CANCEL_BY_SINK = 10006,
// Peer of sink click "DISTRUST" in THREE-STATE window.
REASON_DISTRUST_BY_SINK = 10007,
// user no action, so timeout
REASON_USER_TIMEOUT = 10008,
// Peer device is busy
REASON_DEVICE_IS_BUSY = 10009
};
const EXPORT std::array<std::string, static_cast<size_t>(DeviceState::DEVICE_STATE_MAX)> DEVICE_STATE_STRING = {
"CONNECTING", "CONNECTED", "PAUSED", "PLAYING", "DISCONNECTING", "DISCONNECTED", "STREAM",
"AUTHING",
"MIRROR_TO_UI", "UI_TO_MIRROR", "UICAST", "AUTHING",
};
inline bool EXPORT IsDeviceState(int32_t state)
@ -190,18 +203,24 @@ inline bool EXPORT IsChannelType(int32_t type)
enum class EXPORT CapabilityType {
CAST_PLUS,
DLNA,
CAST_AND_DLNA,
};
inline bool EXPORT IsCapabilityType(int32_t type)
{
return (type == static_cast<int32_t>(CapabilityType::CAST_PLUS)) ||
(type == static_cast<int32_t>(CapabilityType::DLNA)) ||
(type == static_cast<int32_t>(CapabilityType::CAST_AND_DLNA));
}
enum class EXPORT ProtocolType {
CAST_PLUS_MIRROR = 1 << 0,
CAST_PLUS_STREAM = 1 << 1,
MIRACAST = 1 << 2,
DLNA = 1 << 3,
COOPERATION_LEGACY = 1 << 4,
DLNA = 1 << 2,
MIRACAST = 1 << 3,
COOPERATION = 1 << 5,
HICAR = 1 << 6,
SUPER_LAUNCHER = 1 << 7,
CAST_COOPERATION = 1 << 8,
};
inline bool EXPORT IsProtocolType(int32_t type)
@ -212,9 +231,7 @@ inline bool EXPORT IsProtocolType(int32_t type)
static_cast<uint32_t>(ProtocolType::DLNA) |
static_cast<uint32_t>(ProtocolType::COOPERATION) |
static_cast<uint32_t>(ProtocolType::HICAR) |
static_cast<uint32_t>(ProtocolType::SUPER_LAUNCHER) |
static_cast<uint32_t>(ProtocolType::COOPERATION_LEGACY) |
static_cast<uint32_t>(ProtocolType::CAST_COOPERATION))) != 0;
static_cast<uint32_t>(ProtocolType::SUPER_LAUNCHER))) != 0;
}
enum class EXPORT EndType {
@ -230,7 +247,7 @@ inline bool EXPORT IsEndType(int32_t type)
struct EXPORT DeviceStateInfo {
DeviceState deviceState{ DeviceState::DISCONNECTED };
std::string deviceId{};
EventCode eventCode{ EventCode::DEFAULT_EVENT };
ReasonCode reasonCode{ ReasonCode::REASON_DEFAULT };
};
struct EXPORT VideoSize {
@ -280,11 +297,11 @@ inline bool EXPORT IsVideoCodecType(int32_t type)
}
struct EXPORT AudioProperty {
uint32_t sampleRate;
uint8_t sampleBitWidth;
uint32_t channelConfig;
uint32_t bitrate;
uint32_t codec;
uint32_t sampleRate{ 0 };
uint8_t sampleBitWidth{ 0 };
uint32_t channelConfig{ 0 };
uint32_t bitrate{ 0 };
uint32_t codec{ 0 };
};
struct EXPORT VideoProperty {
@ -292,7 +309,7 @@ struct EXPORT VideoProperty {
uint32_t videoHeight{ 0 };
uint32_t fps{ 0 };
VideoCodecType codecType{ VideoCodecType::H264 };
uint32_t gop{ 0 };
int gop{ 0 };
uint32_t bitrate{ 0 };
uint32_t minBitrate{ 0 };
uint32_t maxBitrate{ 0 };
@ -304,6 +321,14 @@ struct EXPORT VideoProperty {
uint32_t level{ 0 };
};
typedef struct EXPORT {
int32_t uicastMainVersion;
int32_t uicastSubVersion;
int32_t appApiVersion;
uint32_t capability;
uint8_t featureEnable;
} UICastCapability;
struct EXPORT CastSessionProperty {
ProtocolType protocolType{ ProtocolType::CAST_PLUS_MIRROR };
EndType endType{ EndType::CAST_SINK };
@ -336,10 +361,17 @@ struct EXPORT CastRemoteDevice {
std::string ipAddress;
ChannelType channelType;
CapabilityType capability;
uint32_t protocolCapabilities{ 0 };
std::string networkId{ "" };
std::string localIpAddress{ "" };
uint32_t sessionKeyLength{ 0 };
const uint8_t *sessionKey{ nullptr };
bool isLeagacy{ false };
int sessionId{ INVALID_ID };
std::vector<std::string> drmCapabilities;
uint32_t mediumTypes{ 0 };
std::string dlnaDeviceModelNameStr;
std::string dlnaDeviceManufacturerStr;
};
enum class EXPORT CastMode {
@ -347,6 +379,11 @@ enum class EXPORT CastMode {
APP_CAST = 2,
};
enum class EXPORT NotifyMediumType {
BLE = 1 << 0,
COAP = 1 << 1,
};
// Parameters for cast mode
const std::string EXPORT KEY_BUNDLE_NAME = "bundleName";
const std::string EXPORT KEY_PID = "pid";
@ -358,9 +395,31 @@ const int32_t EXPORT MAX_FILE_NUM = 16 * 1024;
enum class EXPORT EventId {
EVENT_BEGIN = 1,
MIRROR_BEGIN = 1000,
MIRROR_SUPER_LAUNCHER_DISPLAY_CREATED,
MIRROR_HICAR_DISPLAY_CREATED,
MIRROR_HICAR_NOTIFY_SCREEN_PARAM,
CAST_CAPABILITY,
FIRST_FRAME_RENDER,
MIRROR_END = 1999,
STREAM_BEGIN = 2000,
STEAM_DEVICE_DISCONNECTED,
STREAM_END = 2999,
UICAST_BEGIN = 3000,
UICAST_NOTIFY_SWITCH_TO_UICAST,
UICAST_NOTIFY_SWITCH_TO_MIRROR,
UICAST_REQUEST_SOURCE_APP_RESOURCE,
UICAST_ACE_TRANS_FILES_FINISH,
UICAST_FIRST_RENDER_READY,
UICAST_SINK_PAGE_READY,
UICAST_DELIVER_SOURCE_PACKAGE_NAME,
UICAST_APP_TURN_TO_FOREGROUND,
UICAST_NOTIFY_UICAST_EXIT,
UICAST_EXCEPTION_OCCUR,
UICAST_NOTIFY_RESOURCE_PATH,
UICAST_RCV_RESOURCE_PATH,
UICAST_NOTIFY_DUMP_UITREE,
UICAST_END = 3999,
EVENT_END = 5000,
};
@ -370,21 +429,22 @@ inline bool EXPORT IsEventId(int32_t state)
}
struct EXPORT MediaInfo {
std::string mediaId;
std::string mediaName;
std::string mediaUrl;
std::string mediaType;
size_t mediaSize;
uint32_t startPosition;
uint32_t duration;
uint32_t closingCreditsPosition;
std::string albumCoverUrl;
std::string albumTitle;
std::string mediaArtist;
std::string lrcUrl;
std::string lrcContent;
std::string appIconUrl;
std::string appName;
std::string mediaId{ "" };
std::string mediaName{ "" };
std::string mediaUrl{ "" };
std::string mediaType{ "" };
size_t mediaSize{ 0 };
uint32_t startPosition{ 0 };
uint32_t duration{ 0 };
uint32_t closingCreditsPosition{ 0 };
std::string albumCoverUrl{ "" };
std::string albumTitle{ "" };
std::string mediaArtist{ "" };
std::string lrcUrl{ "" };
std::string lrcContent{ "" };
std::string appIconUrl{ "" };
std::string appName{ "" };
std::string drmType;
};
struct EXPORT MediaInfoHolder {
@ -433,21 +493,49 @@ enum class EXPORT LoopMode {
LOOP_MODE_SHUFFLE = 3
};
struct EXPORT StreamCapability {
bool isPlaySupported{ false };
bool isPauseSupported{ false };
bool isStopSupported{ false };
bool isNextSupported{ false };
bool isPreviousSupported{ false };
bool isSeekSupported{ false };
bool isFastForwardSupported{ false };
bool isFastRewindSupported{ false };
bool isLoopModeSupported{ false };
bool isToggleFavoriteSupported{ false };
bool isSetVolumeSupported{ false };
};
enum class EXPORT PlaybackSpeed {
SPEED_FORWARD_0_75_X = 0,
SPEED_FORWARD_1_00_X = 1,
SPEED_FORWARD_1_25_X = 2,
SPEED_FORWARD_1_75_X = 3,
SPEED_FORWARD_2_00_X = 4
SPEED_FORWARD_2_00_X = 4,
SPEED_FORWARD_0_50_X = 5,
SPEED_FORWARD_1_50_X = 6,
};
enum class EXPORT LogCodeId {
OK = 0,
FULL = 1,
WRITE_FAIL = 2,
SEEK_FAIL = 3,
STOP_INDICATE = 4,
STOP_REPEAT = 5,
START_REPEAT = 6,
NOT_INIT = 7,
UID_MISMATCH = 8,
};
inline constexpr int EXPORT INVALID_ID = -1;
inline constexpr int EXPORT INVALID_PORT = -1;
inline constexpr int EXPORT INVALID_VALUE = -1;
inline constexpr int EXPORT DECIMALISM = 10;
inline constexpr int EXPORT SUBSYS_CASTPLUS_SYS_ABILITY_ID_BEGIN = 0x00010000;
inline constexpr int EXPORT CAST_ENGINE_SA_ID = 5526; // 65546
inline constexpr int EXPORT CAST_ENGINE_SA_ID = SUBSYS_CASTPLUS_SYS_ABILITY_ID_BEGIN + 10; // 65546
inline constexpr int EXPORT SUBSYS_CASTPLUS_SYS_ABILITY_ID_END = 0x0001001f;
inline constexpr int EXPORT S_TO_MS = 1000;
} // namespace CastEngine
} // namespace OHOS

View File

@ -34,6 +34,79 @@ constexpr int32_t EXPORT ERR_NO_PERMISSION = -(CAST_ENGINE_ERROR_BASE + 3);
constexpr int32_t EXPORT ERR_SESSION_NOT_EXIST = -(CAST_ENGINE_ERROR_BASE + 4);
constexpr int32_t EXPORT ERR_SERVICE_STATE_NOT_MATCH = -(CAST_ENGINE_ERROR_BASE + 5);
constexpr int32_t EXPORT ERR_SESSION_STATE_NOT_MATCH = -(CAST_ENGINE_ERROR_BASE + 6);
constexpr int32_t EXPORT ERR_SERVICE_IS_UNLOADING = -(CAST_ENGINE_ERROR_BASE + 7);
constexpr int32_t EXPORT ERROR_CODE_OK = 0;
// Generic error
constexpr int32_t EXPORT ERROR_CODE_UNSPECIFIED = 1000;
constexpr int32_t EXPORT ERROR_CODE_REMOTE_ERROR = 1001;
constexpr int32_t EXPORT ERROR_CODE_BEHIND_LIVE_WINDOW = 1002;
constexpr int32_t EXPORT ERROR_CODE_TIMEOUT = 1003;
constexpr int32_t EXPORT ERROR_CODE_FAILED_RUNTIME_CHECK = 1004;
constexpr int32_t EXPORT ERROR_CODE_PLAYER_ERROR = 1100;
constexpr int32_t EXPORT ERROR_CODE_SEEK_MODE_UNSUPPORTED = 1101;
constexpr int32_t EXPORT ERROR_CODE_ILLEGAL_SEEK_TARGET = 1102;
constexpr int32_t EXPORT ERROR_CODE_PLAY_MODE_UNSUPPORTED = 1103;
constexpr int32_t EXPORT ERROR_CODE_PLAY_SPEED_UNSUPPORTED = 1104;
constexpr int32_t EXPORT ERROR_CODE_DEVICE_MISSED = 1105;
constexpr int32_t EXPORT ERROR_CODE_INVALID_PARAM = 1106;
constexpr int32_t EXPORT ERROR_CODE_NO_MEMORY = 1107;
constexpr int32_t EXPORT ERROR_OPERATION_NOT_ALLOWED = 1108;
// Input/Output errors
constexpr int32_t EXPORT ERROR_CODE_IO_UNSPECIFIED = 2000;
constexpr int32_t EXPORT ERROR_CODE_IO_NETWORK_CONNECTION_FAILED = 2001;
constexpr int32_t EXPORT ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT = 2002;
constexpr int32_t EXPORT ERROR_CODE_IO_INVALID_HTTP_CONTENT_TYPE = 2003;
constexpr int32_t EXPORT ERROR_CODE_IO_BAD_HTTP_STATUS = 2004;
constexpr int32_t EXPORT ERROR_CODE_IO_FILE_NOT_FOUND = 2005;
constexpr int32_t EXPORT ERROR_CODE_IO_NO_PERMISSION = 2006;
constexpr int32_t EXPORT ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED = 2007;
constexpr int32_t EXPORT ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE = 2008;
constexpr int32_t EXPORT ERROR_CODE_IO_NO_CONTENTS = 2100;
constexpr int32_t EXPORT ERROR_CODE_IO_READ_ERROR = 2101;
constexpr int32_t EXPORT ERROR_CODE_IO_CONTENT_BUSY = 2102;
constexpr int32_t EXPORT ERROR_CODE_IO_CONTENT_EXPIRED = 2103;
constexpr int32_t EXPORT ERROR_CODE_IO_CONTENT_NON_ALLOWED_USE = 2104;
constexpr int32_t EXPORT ERROR_CODE_IO_CONTENT_CANNOT_VERIFIED = 2105;
constexpr int32_t EXPORT ERROR_CODE_IO_CONTENT_EXHAUSTED_ALLOWED_USES = 2106;
constexpr int32_t EXPORT ERROR_CODE_IO_NETWORK_PACKET_SENDING_FAILURE = 2107;
// Content parsing errors
constexpr int32_t EXPORT ERROR_CODE_PARSING_UNSPECIFIED = 3000;
constexpr int32_t EXPORT ERROR_CODE_PARSING_CONTAINER_MALFORMED = 3001;
constexpr int32_t EXPORT ERROR_CODE_PARSING_MANIFEST_MALFORMED = 3002;
constexpr int32_t EXPORT ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED = 3003;
constexpr int32_t EXPORT ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED = 3004;
// Decoding errors
constexpr int32_t EXPORT ERROR_CODE_DECODE_UNSPECIFIED = 4000;
constexpr int32_t EXPORT ERROR_CODE_DECODER_INIT_FAILED = 4001;
constexpr int32_t EXPORT ERROR_CODE_DECODER_QUERY_FAILED = 4002;
constexpr int32_t EXPORT ERROR_CODE_DECODING_FAILED = 4003;
constexpr int32_t EXPORT ERROR_CODE_DECODING_FORMAT_EXCEEDS_CAPABILITIES = 4004;
constexpr int32_t EXPORT ERROR_CODE_DECODING_FORMAT_UNSUPPORTED = 4005;
// AudioTrack errors
constexpr int32_t EXPORT ERROR_CODE_AUDIO_TRACK_UNSPECIFIED = 5000;
constexpr int32_t EXPORT ERROR_CODE_AUDIO_TRACK_INIT_FAILED = 5001;
constexpr int32_t EXPORT ERROR_CODE_AUDIO_TRACK_WRITE_FAILED = 5002;
// DRM errors
constexpr int32_t EXPORT ERROR_CODE_DRM_UNSPECIFIED = 6000;
constexpr int32_t EXPORT ERROR_CODE_DRM_SCHEME_UNSUPPORTED = 6001;
constexpr int32_t EXPORT ERROR_CODE_DRM_PROVISIONING_FAILED = 6002;
constexpr int32_t EXPORT ERROR_CODE_DRM_CONTENT_ERROR = 6003;
constexpr int32_t EXPORT ERROR_CODE_DRM_LICENSE_ACQUISITION_FAILED = 6004;
constexpr int32_t EXPORT ERROR_CODE_DRM_DISALLOWED_OPERATION = 6005;
constexpr int32_t EXPORT ERROR_CODE_DRM_SYSTEM_ERROR = 6006;
constexpr int32_t EXPORT ERROR_CODE_DRM_DEVICE_REVOKED = 6007;
constexpr int32_t EXPORT ERROR_CODE_DRM_LICENSE_EXPIRED = 6008;
constexpr int32_t EXPORT ERROR_CODE_DRM_PROVIDE_KEY_RESPONSE_ERROR = 6100;
} // namespace CastEngine
} // namespace OHOS

View File

@ -51,6 +51,7 @@ ohos_shared_library("cast") {
"napi:ace_napi",
"image_framework:image",
"image_framework:image_native",
"init:libbegetutil",
]
relative_install_dir = "module"

View File

@ -178,18 +178,26 @@ static napi_value ExportEventCode(napi_env env)
napi_value result = nullptr;
NAPI_CALL(env, napi_create_object(env, &result));
(void)SetNamedProperty(env, result, "UNKNOWN_EVENT", static_cast<int32_t>(EventCode::UNKNOWN_EVENT));
(void)SetNamedProperty(env, result, "ERR_CONNECTION_FAILED", static_cast<int32_t>(
EventCode::ERR_CONNECTION_FAILED));
(void)SetNamedProperty(env, result, "ERR_PIN_CODE_RETRY_COUNT_EXCEEDED", static_cast<int32_t>(
EventCode::ERR_PIN_CODE_RETRY_COUNT_EXCEEDED));
(void)SetNamedProperty(env, result, "ERR_CANCEL_BY_SINK", static_cast<int32_t>(EventCode::ERR_CANCEL_BY_SINK));
(void)SetNamedProperty(env, result, "ERR_DISTRUST_BY_SINK", static_cast<int32_t>(EventCode::ERR_DISTRUST_BY_SINK));
(void)SetNamedProperty(env, result, "DEFAULT_EVENT", static_cast<int32_t>(EventCode::DEFAULT_EVENT));
(void)SetNamedProperty(env, result, "EVT_TRUST_BY_SINK", static_cast<int32_t>(EventCode::EVT_TRUST_BY_SINK));
(void)SetNamedProperty(env, result, "EVT_CANCEL_BY_SOURCE", static_cast<int32_t>(EventCode::EVT_CANCEL_BY_SOURCE));
(void)SetNamedProperty(env, result, "EVT_AUTHENTICATION_COMPLETED",
static_cast<int32_t>(EventCode::EVT_AUTHENTICATION_COMPLETED));
(void)SetNamedProperty(env, result, "REASON_DEFAULT", static_cast<int32_t>(ReasonCode::REASON_DEFAULT));
(void)SetNamedProperty(env, result, "REASON_TRUST_BY_SINK", static_cast<int32_t>(ReasonCode::REASON_TRUST_BY_SINK));
(void)SetNamedProperty(env, result, "REASON_CANCEL_BY_SOURCE",
static_cast<int32_t>(ReasonCode::REASON_CANCEL_BY_SOURCE));
(void)SetNamedProperty(env, result, "REASON_BIND_COMPLETED",
static_cast<int32_t>(ReasonCode::REASON_BIND_COMPLETED));
(void)SetNamedProperty(env, result, "REASON_SHOW_TRUST_SELECT_UI",
static_cast<int32_t>(ReasonCode::REASON_SHOW_TRUST_SELECT_UI));
(void)SetNamedProperty(env, result, "REASON_STOP_BIND_BY_SOURCE",
static_cast<int32_t>(ReasonCode::REASON_STOP_BIND_BY_SOURCE));
(void)SetNamedProperty(env, result, "REASON_PIN_CODE_OVER_RETRY",
static_cast<int32_t>(ReasonCode::REASON_PIN_CODE_OVER_RETRY));
(void)SetNamedProperty(env, result, "REASON_CANCEL_BY_SINK",
static_cast<int32_t>(ReasonCode::REASON_CANCEL_BY_SINK));
(void)SetNamedProperty(env, result, "REASON_DISTRUST_BY_SINK",
static_cast<int32_t>(ReasonCode::REASON_DISTRUST_BY_SINK));
(void)SetNamedProperty(env, result, "REASON_USER_TIMEOUT", static_cast<int32_t>(ReasonCode::REASON_USER_TIMEOUT));
(void)SetNamedProperty(env, result, "REASON_DEVICE_IS_BUSY",
static_cast<int32_t>(ReasonCode::REASON_DEVICE_IS_BUSY));
NAPI_CALL(env, napi_object_freeze(env, result));
return result;
}
@ -259,10 +267,8 @@ static napi_value ExportProtocolType(napi_env env)
(void)SetNamedProperty(env, result, "MIRACAST", static_cast<int32_t>(ProtocolType::MIRACAST));
(void)SetNamedProperty(env, result, "DLNA", static_cast<int32_t>(ProtocolType::DLNA));
(void)SetNamedProperty(env, result, "COOPERATION", static_cast<int32_t>(ProtocolType::COOPERATION));
(void)SetNamedProperty(env, result, "COOPERATION_LEGACY", static_cast<int32_t>(ProtocolType::COOPERATION_LEGACY));
(void)SetNamedProperty(env, result, "HICAR", static_cast<int32_t>(ProtocolType::HICAR));
(void)SetNamedProperty(env, result, "SUPER_LAUNCHER", static_cast<int32_t>(ProtocolType::SUPER_LAUNCHER));
(void)SetNamedProperty(env, result, "CAST_COOPERATION", static_cast<int32_t>(ProtocolType::CAST_COOPERATION));
NAPI_CALL(env, napi_object_freeze(env, result));
return result;
}
@ -339,7 +345,7 @@ napi_status InitEnums(napi_env env, napi_value exports)
DECLARE_NAPI_PROPERTY("SubDeviceType", ExportSubDeviceType(env)),
DECLARE_NAPI_PROPERTY("TriggerType", ExportTriggerType(env)),
DECLARE_NAPI_PROPERTY("DeviceState", ExportDeviceState(env)),
DECLARE_NAPI_PROPERTY("EventCode", ExportEventCode(env)),
DECLARE_NAPI_PROPERTY("ReasonCode", ExportEventCode(env)),
DECLARE_NAPI_PROPERTY("ServiceStatus", ExportServiceStatus(env)),
DECLARE_NAPI_PROPERTY("DeviceStatusState", ExportDeviceStatusState(env)),
DECLARE_NAPI_PROPERTY("PropertyType", ExportPropertyType(env)),

View File

@ -193,9 +193,9 @@ napi_value ConvertDeviceStateInfoToJS(napi_env env, const DeviceStateInfo &state
NAPI_CALL(env, napi_create_string_utf8(env, stateEvent.deviceId.c_str(), NAPI_AUTO_LENGTH, &deviceId));
NAPI_CALL(env, napi_set_named_property(env, stateEventCallback, "deviceId", deviceId));
napi_value eventCode = nullptr;
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(stateEvent.eventCode), &eventCode));
NAPI_CALL(env, napi_set_named_property(env, stateEventCallback, "eventCode", eventCode));
napi_value reasonCode = nullptr;
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(stateEvent.reasonCode), &reasonCode));
NAPI_CALL(env, napi_set_named_property(env, stateEventCallback, "reasonCode", reasonCode));
return stateEventCallback;
}

View File

@ -48,6 +48,7 @@ ohos_shared_library("cast_engine_service") {
"graphic_surface:surface",
"hilog:libhilog",
"hisysevent:libhisysevent",
"init:libbegetutil",
"input:libmmi-client",
"ipc:ipc_core",
"player_framework:media_client",
@ -55,6 +56,9 @@ ohos_shared_library("cast_engine_service") {
"samgr:samgr_proxy",
"ability_runtime:app_manager",
"image_framework:image_native",
"power_manager:powermgr_client",
"os_account:os_account_innerkits",
"bundle_framework:appexecfwk_core",
]
subsystem_name = "castplus"

View File

@ -58,7 +58,7 @@ int OnSessionOpened(int sessionId, int result)
CLOGE("device is empty");
return result;
}
ConnectionManager::GetInstance().NotifySessionEvent(device->deviceId, ConnectEvent::DISCONNECT_START);
ConnectionManager::GetInstance().NotifySessionEvent(device->deviceId, ConnectStageResult::DISCONNECT_START);
return result;
}
int role = GetSessionSide(sessionId);
@ -203,8 +203,9 @@ public:
std::vector<CastRemoteDevice> remoteDevices;
for (const auto &device : devices) {
remoteDevices.push_back(CastRemoteDevice{ device.deviceId, device.deviceName, device.deviceType,
device.subDeviceType, device.ipAddress, device.channelType,
CapabilityType::CAST_PLUS, device.networkId, "", 0, nullptr});
device.subDeviceType, device.ipAddress, device.channelType, device.capability,
device.capabilityInfo, device.networkId, "", 0, nullptr, device.isLeagacy, device.sessionId,
device.drmCapabilities, device.mediumTypes });
}
service->ReportDeviceFound(remoteDevices);
}
@ -254,7 +255,7 @@ public:
CLOGE("Session addDevice fail");
return false;
}
ConnectionManager::GetInstance().NotifySessionEvent(device.deviceId, ConnectEvent::CONNECT_START);
ConnectionManager::GetInstance().NotifySessionEvent(device.deviceId, ConnectStageResult::CONNECT_START);
return true;
}
@ -269,7 +270,7 @@ public:
CLOGD("OnDeviceOffline out");
}
void OnEvent(const std::string &deviceId, EventCode currentEventCode) override
void OnEvent(const std::string &deviceId, ReasonCode currentEventCode) override
{
auto service = service_.promote();
if (!service) {

View File

@ -31,7 +31,7 @@ DEFINE_CAST_ENGINE_LABEL("Cast-Service");
int CastSessionManagerServiceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{
RETRUEN_IF_WRONG_TASK(code, data, reply, option);
RETURN_IF_WRONG_TASK(code, data, reply, option);
return EXECUTE_SINGLE_STUB_TASK(code, data, reply);
}

View File

@ -51,6 +51,14 @@ ohos_static_library("cast_discovery") {
"hisysevent:libhisysevent",
"init:libbegetutil",
"eventhandler:libeventhandler",
"graphic_surface:surface",
"sharing_framework:sharingwfd_client",
"wifi:wifi_sdk",
"ability_base:want",
"ability_runtime:extension_manager",
"screenlock_mgr:screenlock_client",
"common_event_service:cesfwk_innerkits",
"power_manager:powermgr_client",
]
subsystem_name = "castplus"

View File

@ -53,7 +53,8 @@ private:
void HandleConnectDeviceAction(const PeerTargetId &targetId, const json &authInfo);
bool GetSessionKey(const json &authInfo, uint8_t *sessionkey);
void HandleQueryIpAction(const PeerTargetId &targetId, const json &authInfo);
static const std::map<int32_t, EventCode> EVENT_CODE_MAP;
static const std::map<int32_t, int32_t> RESULT_REASON_MAP;
static const std::map<int32_t, int32_t> STATUS_REASON_MAP;
};
class CastUnBindTargetCallback : public UnbindTargetCallback {
@ -69,7 +70,7 @@ public:
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, EventCode currentEventCode) = 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;
@ -104,13 +105,15 @@ public:
void NotifySessionIsReady(int transportId);
void NotifyDeviceIsOffline(const std::string &deviceId);
bool NotifySessionEvent(const std::string &deviceId, int result);
void ReportErrorByListener(const std::string &deviceId, EventCode currentEventCode);
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);
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_;
@ -121,8 +124,6 @@ private:
std::string GetAuthVersion(const CastInnerRemoteDevice &device);
void SendConsultData(const CastInnerRemoteDevice &device, int port);
bool QueryP2PIp(const CastInnerRemoteDevice &device);
bool IsHuaweiDevice(const CastInnerRemoteDevice &device);
bool IsThirdDevice(const CastInnerRemoteDevice &device);
std::string GetConsultationData(const CastInnerRemoteDevice &device, int port, json &body);
void EncryptPort(int port, const uint8_t *sessionKey, json &body);

View File

@ -146,49 +146,34 @@ void DeviceAuthWriteWrap(const std::string& funcName, int sceneType, const std::
{"PEER_UDID", puid}});
}
void OnBindResultFailedWriteWrap(const std::string& funcName, int32_t result, const std::string& puid)
{
auto errorCode = GetErrorCode(CAST_ENGINE_SYSTEM_ID, CAST_ENGINE_CAST_PLUS_MODULE_ID,
static_cast<uint16_t>(result));
HiSysEventWriteWrap(funcName, {
{"BIZ_SCENE", static_cast<int32_t>(GetBIZSceneType(
ConnectionManager::GetInstance().GetProtocolType()))},
{"BIZ_STATE", static_cast<int32_t>(BIZStateType::BIZ_STATE_END)},
{"BIZ_STAGE", static_cast<int32_t>(BIZSceneStage::DEVICE_AUTHENTICATION)},
{"STAGE_RES", static_cast<int32_t>(StageResType::STAGE_RES_FAILED)},
{"ERROR_CODE", errorCode}}, {
{"TO_CALL_PKG", DEVICE_MANAGER_NAME},
{"LOCAL_SESS_NAME", ""},
{"PEER_SESS_NAME", ""},
{"PEER_UDID", puid}});
}
} // namespace
/*
* User's unusual action or other event scenarios could cause changing of STATE or RESULT which delivered
* by DM.
*/
const std::map<int, EventCode> CastBindTargetCallback::EVENT_CODE_MAP = {
// ----- ON RESULT != 0 -----
const std::map<int32_t, int32_t> CastBindTargetCallback::RESULT_REASON_MAP = {
// SINK peer click distrust button during 3-state authentication.
{ ERR_DM_AUTH_PEER_REJECT, EventCode::ERR_DISTRUST_BY_SINK },
{ ERR_DM_AUTH_PEER_REJECT, REASON_DISTRUST_BY_SINK },
// SINK peer click cancel button during pin code inputting.
{ ERR_DM_BIND_USER_CANCEL_PIN_CODE_DISPLAY, EventCode::ERR_CANCEL_BY_SINK },
{ ERR_DM_BIND_USER_CANCEL_PIN_CODE_DISPLAY, REASON_CANCEL_BY_SINK },
// SOURCE peer input wrong pin code up to 3 times
{ ERR_DM_BIND_PIN_CODE_ERROR, EventCode::ERR_PIN_CODE_RETRY_COUNT_EXCEEDED },
{ ERR_DM_BIND_PIN_CODE_ERROR, REASON_PIN_CODE_OVER_RETRY },
// SOURCE peer click cancel button during pin code inputting.
{ ERR_DM_BIND_USER_CANCEL_ERROR, EventCode::EVT_CANCEL_BY_SOURCE },
// SINK peer PIN code window closed.
{ ERR_DM_TIME_OUT, EventCode::ERR_SINK_TIMEOUT },
// ----- ON RESULT == 0 -----
{ ERR_DM_BIND_USER_CANCEL_ERROR, REASON_CANCEL_BY_SOURCE },
// User interupt binding.
{ STOP_BIND, REASON_STOP_BIND_BY_SOURCE }
};
const std::map<int32_t, int32_t> CastBindTargetCallback::STATUS_REASON_MAP = {
// DEFAULT event
{ DmAuthStatus::STATUS_DM_AUTH_DEFAULT, EventCode::DEFAULT_EVENT },
{ DmAuthStatus::STATUS_DM_AUTH_DEFAULT, REASON_DEFAULT },
// Sink peer click trust during 3-state authentication.
{ DmAuthStatus::STATUS_DM_SHOW_PIN_INPUT_UI, EventCode::EVT_TRUST_BY_SINK },
// Build connection successfully.
{ DmAuthStatus::STATUS_DM_AUTH_FINISH, EventCode::EVT_AUTHENTICATION_COMPLETED },
{ DmAuthStatus::STATUS_DM_SHOW_PIN_INPUT_UI, REASON_TRUST_BY_SINK },
// input right pin code, so close input dialog and show connecting dialog
{ DmAuthStatus::STATUS_DM_CLOSE_PIN_INPUT_UI, REASON_BIND_COMPLETED },
// Waiting for user to click confirm
{ DmAuthStatus::STATUS_DM_SHOW_AUTHORIZE_UI, EventCode::EVT_SHOW_AUTHORIZE_UI }
{ DmAuthStatus::STATUS_DM_SHOW_AUTHORIZE_UI, REASON_SHOW_TRUST_SELECT_UI }
};
ConnectionManager &ConnectionManager::GetInstance()
@ -199,7 +184,7 @@ ConnectionManager &ConnectionManager::GetInstance()
void ConnectionManager::Init(std::shared_ptr<IConnectionManagerListener> listener)
{
CLOGD("ConnectionManager init start");
CLOGI("ConnectionManager init start");
if (listener == nullptr) {
CLOGE("The input listener is null!");
return;
@ -222,12 +207,31 @@ void ConnectionManager::Init(std::shared_ptr<IConnectionManagerListener> listene
void ConnectionManager::Deinit()
{
CLOGD("Deinit start");
CLOGI("Deinit start");
ResetListener();
DisableDiscoverable();
DeviceManager::GetInstance().UnRegisterDevStateCallback(PKG_NAME);
}
bool ConnectionManager::IsDeviceTrusted(const std::string &deviceId, std::string &networkId)
{
std::vector<DmDeviceInfo> trustedDevices;
if (DeviceManager::GetInstance().GetTrustedDeviceList(PKG_NAME, "", trustedDevices) != DM_OK) {
CLOGE("Fail to get TrustedDeviceList from DM.");
return false;
}
for (const auto &device : trustedDevices) {
if (device.deviceId == deviceId) {
networkId = device.networkId;
CLOGI("Device: %{public}s has been trusted.", device.deviceId);
return true;
}
}
return false;
}
DmDeviceInfo ConnectionManager::GetDmDeviceInfo(const std::string &deviceId)
{
std::vector<DmDeviceInfo> trustedDevices;
@ -245,25 +249,6 @@ DmDeviceInfo ConnectionManager::GetDmDeviceInfo(const std::string &deviceId)
return {};
}
bool ConnectionManager::IsDeviceTrusted(const std::string &deviceId, std::string &networkId)
{
std::vector<DmDeviceInfo> trustedDevices;
if (DeviceManager::GetInstance().GetTrustedDeviceList(PKG_NAME, "", trustedDevices) != DM_OK) {
CLOGE("GetTrustedDeviceList fail");
return false;
}
for (const auto &device : trustedDevices) {
CLOGV("Trusted device id(%s)", device.deviceId);
if (device.deviceId == deviceId) {
networkId = device.networkId;
return true;
}
}
return false;
}
void ConnectionManager::SetProtocolType(int protocols)
{
protocolType_ = protocols;
@ -301,21 +286,9 @@ bool ConnectionManager::ConnectDevice(const CastInnerRemoteDevice &dev)
(void)UpdateDeviceState(deviceId, RemoteDeviceState::FOUND);
return false;
}
NotifySessionEvent(deviceId, ConnectEvent::AUTH_START);
(void)UpdateDeviceState(deviceId, RemoteDeviceState::CONNECTED);
return true;
}
NotifySessionEvent(deviceId, ConnectEvent::AUTH_START);
HiSysEventWriteWrap(__func__, {
{"BIZ_SCENE", GetBIZSceneType(GetProtocolType())},
{"BIZ_STATE", static_cast<int32_t>(BIZStateType::BIZ_STATE_BEGIN)},
{"BIZ_STAGE", static_cast<int32_t>(BIZSceneStage::DEVICE_AUTHENTICATION)},
{"STAGE_RES", static_cast<int32_t>(StageResType::STAGE_RES_IDLE)},
{"ERROR_CODE", CAST_RADAR_SUCCESS}}, {
{"TO_CALL_PKG", DEVICE_MANAGER_NAME},
{"LOCAL_SESS_NAME", ""}, {"PEER_SESS_NAME", ""},
{"PEER_UDID", GetAnonymousDeviceID(dev.deviceId)}});
if (!BindTarget(dev)) {
(void)UpdateDeviceState(deviceId, RemoteDeviceState::FOUND);
return false;
@ -662,7 +635,8 @@ void ConnectionManager::OnConsultSessionOpened(int transportId, bool isSource)
if (ConnectionManager::GetInstance().IsHuaweiDevice(*device)) {
ConnectionManager::GetInstance().QueryP2PIp(*device);
} else {
ConnectionManager::GetInstance().NotifySessionEvent((*device).deviceId, ConnectEvent::AUTH_SUCCESS);
ConnectionManager::GetInstance().NotifySessionEvent(
(*device).deviceId, ConnectStageResult::AUTH_SUCCESS);
}
return;
}
@ -915,7 +889,7 @@ bool ConnectionManager::UpdateDeviceState(const std::string &deviceId, RemoteDev
return CastDeviceDataManager::GetInstance().SetDeviceState(deviceId, state);
}
void ConnectionManager::ReportErrorByListener(const std::string &deviceId, EventCode currentEventCode)
void ConnectionManager::ReportErrorByListener(const std::string &deviceId, ReasonCode currentEventCode)
{
std::lock_guard<std::mutex> lock(mutex_);
if (!listener_) {
@ -975,49 +949,34 @@ void CastBindTargetCallback::OnBindResult(const PeerTargetId &targetId, int32_t
{
CLOGI("OnBindResult, device id:%s, content:%s, status: %{public}d, result: %{public}d", targetId.deviceId.c_str(),
content.c_str(), status, result);
json authInfo;
if (authInfo.accept(content)) {
authInfo = json::parse(content, nullptr, false);
int action = -1;
if (authInfo.contains(KEY_BIND_TARGET_ACTION) && authInfo[KEY_BIND_TARGET_ACTION].is_number()) {
action = authInfo[KEY_BIND_TARGET_ACTION];
}
if (result == DM_OK && status == DmAuthStatus::STATUS_DM_AUTH_FINISH && action != -1) {
HandleBindAction(targetId, action, authInfo);
if (action != ACTION_CONNECT_DEVICE) {
CLOGI("bindtarget action %d handle finish, return", action);
return;
}
}
auto remote = CastDeviceDataManager::GetInstance().GetDeviceByDeviceId(targetId.deviceId);
if (remote == std::nullopt) {
CLOGE("Get remote device is empty");
return;
}
EventCode currentEventCode;
// Non-zero RESULT as FIRST consideration, and STATE secondarily.
if (result != 0) {
CastEngineDfx::WriteErrorEvent(AUTHENTICATE_DEVICE_FAIL);
OnBindResultFailedWriteWrap(__func__, result, GetAnonymousDeviceID(targetId.deviceId));
currentEventCode = EVENT_CODE_MAP.count(result) ? EVENT_CODE_MAP.at(result) : EventCode::UNKNOWN_EVENT;
} else {
if (EVENT_CODE_MAP.count(status)) {
currentEventCode = EVENT_CODE_MAP.at(status);
} else {
CLOGI("unknown status %d, return ", status);
return;
}
HiSysEventWriteWrap(__func__, {
{"BIZ_SCENE", static_cast<int32_t>(GetBIZSceneType(
ConnectionManager::GetInstance().GetProtocolType()))},
{"BIZ_STATE", static_cast<int32_t>(BIZStateType::BIZ_STATE_END)},
{"BIZ_STAGE", static_cast<int32_t>(BIZSceneStage::DEVICE_AUTHENTICATION)},
{"STAGE_RES", static_cast<int32_t>(StageResType::STAGE_RES_SUCCESS)},
{"ERROR_CODE", CAST_RADAR_SUCCESS}}, {
{"TO_CALL_PKG", DEVICE_MANAGER_NAME},
{"LOCAL_SESS_NAME", ""},
{"PEER_SESS_NAME", ""},
{"PEER_UDID", GetAnonymousDeviceID(targetId.deviceId)}});
json jsonInfo{};
if (json::accept(content)) {
jsonInfo = json::parse(content, nullptr, false);
}
int action = -1;
switch (status) {
case DmAuthStatus::STATUS_DM_AUTH_FINISH:
if (jsonInfo.contains(KEY_BIND_TARGET_ACTION) && jsonInfo[KEY_BIND_TARGET_ACTION].is_number()) {
action = jsonInfo[KEY_BIND_TARGET_ACTION];
}
return HandleBindAction(targetId, action, jsonInfo);
case DmAuthStatus::STATUS_DM_SHOW_PIN_INPUT_UI:
case DmAuthStatus::STATUS_DM_CLOSE_PIN_INPUT_UI:
case DmAuthStatus::STATUS_DM_SHOW_AUTHORIZE_UI:
return;
case DmAuthStatus::STATUS_DM_AUTH_DEFAULT:
return;
default:
CLOGW("unknow status %{public}d", status);
return;
}
CLOGI("EventCode: %{public}d", static_cast<int32_t>(currentEventCode));
ConnectionManager::GetInstance().ReportErrorByListener(targetId.deviceId, currentEventCode);
}
void CastBindTargetCallback::HandleBindAction(const PeerTargetId &targetId, int action, const json &authInfo)
@ -1076,7 +1035,7 @@ void CastBindTargetCallback::HandleConnectDeviceAction(const PeerTargetId &targe
}
result = CastDeviceDataManager::GetInstance().SetDeviceSessionKey(deviceId, sessionKey);
CLOGD("auth version 1.0, set sessionkey result is %d", result);
ConnectionManager::GetInstance().NotifySessionEvent(deviceId, ConnectEvent::AUTH_SUCCESS);
ConnectionManager::GetInstance().NotifySessionEvent(deviceId, ConnectStageResult::AUTH_SUCCESS);
} else {
uint8_t sessionKey[SESSION_KEY_LENGTH] = {0};
RAND_bytes(sessionKey, SESSION_KEY_LENGTH);
@ -1119,7 +1078,7 @@ void CastBindTargetCallback::HandleQueryIpAction(const PeerTargetId &targetId, c
remoteIp = authInfo[KEY_REMOTE_P2P_IP];
}
CastDeviceDataManager::GetInstance().SetDeviceIp(targetId.deviceId, localIp, remoteIp);
ConnectionManager::GetInstance().NotifySessionEvent(targetId.deviceId, ConnectEvent::AUTH_SUCCESS);
ConnectionManager::GetInstance().NotifySessionEvent(targetId.deviceId, ConnectStageResult::AUTH_SUCCESS);
}
void CastUnBindTargetCallback::OnUnbindResult(const PeerTargetId &targetId, int32_t result, std::string content)

View File

@ -20,6 +20,11 @@ config("cast_session_config") {
}
ohos_static_library("cast_session") {
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
}
sources = [
"src/cast_session_impl.cpp",
"src/cast_session_impl_stub.cpp",
@ -56,16 +61,22 @@ ohos_static_library("cast_session") {
]
external_deps = [
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"hilog:libhilog",
"ipc:ipc_core",
"player_framework:media_client",
"audio_framework:audio_client",
"device_manager:devicemanagersdk",
"init:libbegetutil",
"input:libmmi-client",
"graphic_surface:surface",
"ability_runtime:app_manager",
"image_framework:image_native",
"wifi:wifi_sdk",
"power_manager:powermgr_client",
"state_registry:tel_state_registry_api",
"core_service:tel_core_service_api",
]
subsystem_name = "castplus"

View File

@ -129,8 +129,11 @@ private:
static constexpr int MODULE_ID_CAST_STREAM = 1009;
static constexpr int MODULE_ID_CAST_SESSION = 2000;
static constexpr int MODULE_ID_UI = 2001;
static constexpr double CAST_VERSION = 1.1;
static constexpr int TIMEOUT_CONNECT = 60 * 1000;
// COOPERATION/HICAR use it to colse media channel, don't modify it.
static constexpr double CAST_VERSION = 1.0;
static constexpr int TIMEOUT_CONNECT = 30 * 1000;
static constexpr int TIMEOUT_WAIT_CONFIRM = 35 * 1000;
static constexpr int TIMEOUT_WAIT_INPUT_PIN_CODE = 45 * 1000;
static constexpr int INVALID_PORT = -1;
static constexpr int UNUSED_VALUE = -1;
static constexpr int NO_DELAY = 0;
@ -152,11 +155,13 @@ private:
void UpdateRemoteDeviceSessionId(const std::string &deviceId, int sessionId);
void UpdateRemoteDeviceInfoFromCastDeviceDataManager(const std::string &deviceId);
void ChangeDeviceState(DeviceState state, const std::string &deviceId,
const EventCode eventCode = EventCode::DEFAULT_EVENT);
int32_t reasonCode = REASON_DEFAULT);
void ChangeDeviceStateLocked(
DeviceState state, const std::string &deviceId, const EventCode eventCode = EventCode::DEFAULT_EVENT);
void ReportDeviceStateInfo(DeviceState state, const std::string &deviceId, const EventCode eventCode);
void OnSessionEvent(const std::string& deviceId, const EventCode eventCode) override;
DeviceState state, const std::string &deviceId, int32_t reasonCode = REASON_DEFAULT);
void ReportDeviceStateInfo(DeviceState state, const std::string &deviceId, const ReasonCode eventCode);
void OnSessionEvent(const std::string& deviceId, const ReasonCode eventCode) override;
void ChangeDeviceStateInner(DeviceState state, const std::string &deviceId,
int32_t reasonCode = REASON_DEFAULT);
void OnEvent(EventId eventId, const std::string &data);
void OnRemoteCtrlEvent(int eventType, const uint8_t *data, uint32_t len);
bool TransferTo(std::shared_ptr<BaseState> state);

View File

@ -186,24 +186,9 @@ bool CastSessionImpl::AddDevice(const CastInnerRemoteDevice &remoteDevice)
}
WaitSinkSetProperty();
if (property_.protocolType == ProtocolType::HICAR || property_.protocolType == ProtocolType::SUPER_LAUNCHER) {
if (property_.protocolType == ProtocolType::HICAR || property_.protocolType == ProtocolType::SUPER_LAUNCHER ||
property_.protocolType == ProtocolType::COOPERATION) {
OtherAddDevice(remoteDevice);
} else if (property_.protocolType == ProtocolType::COOPERATION ||
property_.protocolType == ProtocolType::COOPERATION_LEGACY) {
CLOGI("cooperation scene protocolType:%x", static_cast<uint32_t>(property_.protocolType));
auto dmDevice = ConnectionManager::GetInstance().GetDmDeviceInfo(remoteDevice.deviceId);
if (remoteDevice.deviceId.compare(dmDevice.deviceId) != 0) {
CLOGE("Failed to get DmDeviceInfo");
return false;
}
std::string networkId;
if (!ConnectionManager::GetInstance().IsDeviceTrusted(remoteDevice.deviceId, networkId)) {
CLOGI("Is not a trusted device");
return false;
}
if (!CastDeviceDataManager::GetInstance().AddDevice(remoteDevice, dmDevice)) {
return false;
}
} else if (!CastDeviceDataManager::GetInstance().UpdateDevice(remoteDevice)) {
return false;
}
@ -213,10 +198,10 @@ bool CastSessionImpl::AddDevice(const CastInnerRemoteDevice &remoteDevice)
}
if (property_.protocolType == ProtocolType::COOPERATION ||
property_.protocolType == ProtocolType::COOPERATION_LEGACY ||
property_.protocolType == ProtocolType::HICAR || property_.protocolType == ProtocolType::SUPER_LAUNCHER) {
SendCastMessage(Message(MessageId::MSG_CONNECT, remoteDevice.deviceId));
}
CLOGI("AddDevice out.");
return true;
}
@ -592,7 +577,7 @@ void CastSessionImpl::InitRtspParamInfo(std::shared_ptr<CastRemoteDeviceInfo> re
VtpType::VTP_NOT_SUPPORT_VIDEO);
if (property_.protocolType == ProtocolType::CAST_PLUS_MIRROR ||
property_.protocolType == ProtocolType::CAST_PLUS_STREAM ||
property_.protocolType == ProtocolType::CAST_COOPERATION) {
property_.protocolType == ProtocolType::COOPERATION) {
rtspParamInfo_.SetAudioProperty(property_.audioProperty);
}
@ -714,14 +699,14 @@ std::pair<int, int> CastSessionImpl::GetMediaPort(ChannelType type, int port)
if (!IsChannelClient(type)) {
return (property_.protocolType == ProtocolType::CAST_PLUS_MIRROR ||
property_.protocolType == ProtocolType::CAST_PLUS_STREAM ||
property_.protocolType == ProtocolType::CAST_COOPERATION) ?
property_.protocolType == ProtocolType::COOPERATION) ?
std::pair<int, int> { INVALID_PORT, INVALID_PORT } :
std::pair<int, int> { INVALID_PORT, UNNEEDED_PORT };
}
if (property_.protocolType == ProtocolType::CAST_PLUS_MIRROR ||
property_.protocolType == ProtocolType::CAST_PLUS_STREAM ||
property_.protocolType == ProtocolType::CAST_COOPERATION) {
property_.protocolType == ProtocolType::COOPERATION) {
if (!IsVtpUsed(type)) {
// audio port is same as video base on tcp protocol, softbus don't care about the port.
return { port, port };
@ -850,7 +835,7 @@ bool CastSessionImpl::ProcessError(const Message &msg)
std::lock_guard<std::mutex> lock(mutex_);
auto &devices = remoteDeviceList_;
for (auto it = devices.begin(); it != devices.end();) {
ChangeDeviceStateLocked(DeviceState::DISCONNECTED, it->remoteDevice.deviceId);
ChangeDeviceStateLocked(DeviceState::DISCONNECTED, it->remoteDevice.deviceId, msg.arg1_);
ConnectionManager::GetInstance().DisconnectDevice(it->remoteDevice.deviceId);
devices.erase(it++);
}
@ -1023,13 +1008,13 @@ bool CastSessionImpl::IsAllowTransferState(SessionState desiredState) const
return true;
}
void CastSessionImpl::ChangeDeviceState(DeviceState state, const std::string &deviceId, const EventCode eventCode)
void CastSessionImpl::ChangeDeviceState(DeviceState state, const std::string &deviceId, int32_t eventCode)
{
std::lock_guard<std::mutex> lock(mutex_);
ChangeDeviceStateLocked(state, deviceId, eventCode);
}
void CastSessionImpl::ChangeDeviceStateLocked(DeviceState state, const std::string &deviceId, const EventCode eventCode)
void CastSessionImpl::ChangeDeviceStateLocked(DeviceState state, const std::string &deviceId, int32_t eventCode)
{
auto deviceInfo = FindRemoteDeviceLocked(deviceId);
if (!deviceInfo) {
@ -1041,7 +1026,7 @@ void CastSessionImpl::ChangeDeviceStateLocked(DeviceState state, const std::stri
DEVICE_STATE_STRING[static_cast<int>(state)].c_str(),
DEVICE_STATE_STRING[static_cast<int>(deviceInfo->deviceState)].c_str(),
deviceId.c_str(),
static_cast<int>(eventCode));
static_cast<ReasonCode>(eventCode));
if (state == deviceInfo->deviceState) {
return;
}
@ -1049,11 +1034,11 @@ void CastSessionImpl::ChangeDeviceStateLocked(DeviceState state, const std::stri
UpdateRemoteDeviceStateLocked(deviceId, state);
for (const auto &[pid, listener] : listeners_) {
listener->OnDeviceState(DeviceStateInfo { state, deviceId, eventCode });
listener->OnDeviceState(DeviceStateInfo { state, deviceId, static_cast<ReasonCode>(eventCode) });
}
}
void CastSessionImpl::ReportDeviceStateInfo(DeviceState state, const std::string &deviceId, const EventCode eventCode)
void CastSessionImpl::ReportDeviceStateInfo(DeviceState state, const std::string &deviceId, const ReasonCode eventCode)
{
CLOGI("ReportDeviceStateInfo in.");
auto deviceInfo = FindRemoteDeviceLocked(deviceId);
@ -1066,11 +1051,11 @@ void CastSessionImpl::ReportDeviceStateInfo(DeviceState state, const std::string
}
}
void CastSessionImpl::OnSessionEvent(const std::string &deviceId, const EventCode eventCode)
void CastSessionImpl::OnSessionEvent(const std::string &deviceId, const ReasonCode eventCode)
{
std::lock_guard<std::mutex> lock(mutex_);
CLOGD("Session event: %{public}d", static_cast<int32_t>(eventCode));
if (static_cast<int32_t>(eventCode) < 0 or eventCode == EventCode::EVT_CANCEL_BY_SOURCE) {
if (static_cast<int32_t>(eventCode) < 0 or eventCode == ReasonCode::REASON_CANCEL_BY_SOURCE) {
ConnectionManager::GetInstance().UpdateDeviceState(deviceId, RemoteDeviceState::FOUND);
SendCastMessage(Message(MessageId::MSG_DISCONNECT, deviceId, eventCode));
} else {

View File

@ -30,7 +30,7 @@ DEFINE_CAST_ENGINE_LABEL("Cast-SessionImpl");
int CastSessionImplStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{
RETRUEN_IF_WRONG_TASK(code, data, reply, option);
RETURN_IF_WRONG_TASK(code, data, reply, option);
return EXECUTE_SINGLE_STUB_TASK(code, data, reply);
}

View File

@ -163,16 +163,16 @@ void CastSessionImpl::ConnectManagerListenerImpl::NotifySessionEvent(const std::
return;
}
switch (result) {
case ConnectEvent::AUTH_START:
case ConnectStageResult::AUTHING:
session->SendCastMessage(Message(MessageId::MSG_AUTH, deviceId));
break;
case ConnectEvent::AUTH_SUCCESS:
case ConnectStageResult::AUTH_SUCCESS:
session->SendCastMessage(Message(MessageId::MSG_CONNECT, deviceId));
break;
case ConnectEvent::CONNECT_START:
case ConnectStageResult::CONNECT_START:
session->SendCastMessage(Message(MessageId::MSG_CONNECT, deviceId));
break;
case ConnectEvent::DISCONNECT_START:
case ConnectStageResult::DISCONNECT_START:
session->SendCastMessage(Message(MessageId::MSG_DISCONNECT, deviceId));
break;
default:
@ -394,7 +394,7 @@ bool CastSessionImpl::ChannelManagerListenerImpl::IsMediaChannelReady()
CLOGI("protocolType %d", session->property_.protocolType);
if (session->property_.protocolType == ProtocolType::CAST_PLUS_MIRROR ||
session->property_.protocolType == ProtocolType::CAST_PLUS_STREAM ||
session->property_.protocolType == ProtocolType::CAST_COOPERATION) {
session->property_.protocolType == ProtocolType::COOPERATION) {
CLOGI("mediaState %d, both %d", mediaChannelState_, VIDEO_CHANNEL_CONNECTED | AUDIO_CHANNEL_CONNECTED);
return mediaChannelState_ == (VIDEO_CHANNEL_CONNECTED | AUDIO_CHANNEL_CONNECTED);
}

View File

@ -181,7 +181,7 @@ bool CastSessionImpl::AuthingState::HandleMessage(const Message &msg)
case MessageId::MSG_DISCONNECT:
case MessageId::MSG_CONNECT_TIMEOUT:
session->ProcessDisconnect(msg);
session->ChangeDeviceState(DeviceState::DISCONNECTED, deviceId, msg.eventCode_);
session->ChangeDeviceState(DeviceState::DISCONNECTED, deviceId, msg.arg1_);
session->RemoveRemoteDevice(deviceId);
session->TransferTo(session->disconnectingState_);
break;
@ -190,10 +190,10 @@ bool CastSessionImpl::AuthingState::HandleMessage(const Message &msg)
session->TransferTo(session->disconnectingState_);
break;
case MessageId::MSG_AUTH:
session->ReportDeviceStateInfo(DeviceState::AUTHING, deviceId, msg.eventCode_);
session->ChangeDeviceState(DeviceState::AUTHING, deviceId, msg.arg1_);
break;
default:
CLOGW("unsupported msg: %s, in authing state", MESSAGE_ID_STRING[msgId].c_str());
CLOGW("unsupported msg: %{public}s, in authing state", MESSAGE_ID_STRING[msgId].c_str());
return false;
}
return true;
@ -285,10 +285,11 @@ void CastSessionImpl::ConnectingState::HandleDisconnectMessage(const Message &ms
}
std::string deviceId = msg.strArg_;
session->ProcessDisconnect(msg);
session->ChangeDeviceState(DeviceState::DISCONNECTED, deviceId, EventCode::ERR_CONNECTION_FAILED);
session->RemoveMessage(Message(static_cast<int>(MessageId::MSG_CONNECT_TIMEOUT)));
session->RemoveRemoteDevice(deviceId);
session->TransferTo(session->disconnectingState_);
session->ChangeDeviceState(DeviceState::DISCONNECTED, deviceId, msg.arg1_);
session->RemoveRemoteDevice(deviceId);
}
void CastSessionImpl::ConnectingState::HandleErrorMessage(const Message &msg, sptr<CastSessionImpl> session)

View File

@ -15,9 +15,20 @@ import("//foundation/CastEngine/castengine_cast_framework/cast_engine.gni")
config("cast_session_channel_config") {
include_dirs = [ "include", "src/softbus" ]
cflags = [
"-DPDT_MIRACAST",
"-DFILLP_SERVER_SUPPORT",
"-DFILLP_LINUX",
]
cflags_cc = cflags
}
ohos_static_library("cast_session_channel") {
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
}
sources = [
"src/channel_manager.cpp",
"src/softbus/softbus_connection.cpp",
@ -59,6 +70,7 @@ ohos_static_library("cast_session_channel") {
"hilog:libhilog",
"hisysevent:libhisysevent",
"device_manager:devicemanagersdk",
"init:libbegetutil",
]
subsystem_name = "castplus"

View File

@ -28,7 +28,7 @@ DEFINE_CAST_ENGINE_LABEL("Cast-MirrorPlayerImpl");
int MirrorPlayerImplStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{
RETRUEN_IF_WRONG_TASK(code, data, reply, option);
RETURN_IF_WRONG_TASK(code, data, reply, option);
return EXECUTE_SINGLE_STUB_TASK(code, data, reply);
}

View File

@ -18,6 +18,11 @@ config("cast_session_rtsp_config") {
}
ohos_static_library("cast_session_rtsp") {
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
}
sources = [
"src/rtsp_channel_manager.cpp",
"src/rtsp_controller.cpp",
@ -47,6 +52,7 @@ ohos_static_library("cast_session_rtsp") {
"hilog:libhilog",
"ipc:ipc_core",
"device_manager:devicemanagersdk",
"init:libbegetutil",
]
subsystem_name = "castplus"

View File

@ -27,6 +27,11 @@ config("cast_session_stream_config") {
}
ohos_static_library("cast_session_stream") {
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
}
sources = [
"src/cast_stream_manager_client.cpp",
"src/cast_stream_manager_server.cpp",
@ -55,6 +60,7 @@ ohos_static_library("cast_session_stream") {
"${cast_engine_service}/src/device_manager:cast_discovery",
"${cast_engine_service}/src/session/src/channel:cast_session_channel",
"${cast_engine_service}/src/session/src/utils:cast_session_utils",
"${cast_engine_service}/src/session/src/rtsp:cast_session_rtsp",
]
external_deps = [
@ -63,6 +69,7 @@ ohos_static_library("cast_session_stream") {
"graphic_surface:surface",
"hilog:libhilog",
"hisysevent:libhisysevent",
"init:libbegetutil",
"player_framework:media_client",
"image_framework:image_native",
]

View File

@ -39,7 +39,7 @@ int StreamPlayerImplStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Me
if (!Permission::CheckPidPermission()) {
return ERR_UNKNOWN_TRANSACTION;
}
RETRUEN_IF_WRONG_TASK(code, data, reply, option);
RETURN_IF_WRONG_TASK(code, data, reply, option);
return EXECUTE_SINGLE_STUB_TASK(code, data, reply);
}

View File

@ -22,6 +22,11 @@ config("cast_session_utils_config") {
}
ohos_static_library("cast_session_utils") {
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
}
sources = [
"src/encrypt_decrypt.cpp",
"src/handler.cpp",
@ -47,10 +52,18 @@ ohos_static_library("cast_session_utils") {
external_deps = [
"access_token:libaccesstoken_sdk",
"access_token:libtokensetproc_shared",
"c_utils:utils",
"hilog:libhilog",
"init:libbegetutil",
"ipc:ipc_core",
"wifi:wifi_sdk",
"os_account:os_account_innerkits",
"os_account:libaccountkits",
"power_manager:powermgr_client",
"state_registry:tel_state_registry_api",
"core_service:tel_core_service_api",
"call_manager:tel_call_manager_api",
]
subsystem_name = "castplus"

View File

@ -33,7 +33,7 @@ public:
int what_;
int arg1_{ 0 };
int arg2_{ 0 };
EventCode eventCode_{ EventCode::DEFAULT_EVENT };
ReasonCode eventCode_{ ReasonCode::REASON_DEFAULT };
using Function = std::function<void()>;
Function task_ = nullptr;
@ -51,10 +51,11 @@ public:
Message &operator=(const Message &msg);
explicit Message(int what);
Message(int what, std::string strArg);
Message(int what, std::string deviceId, EventCode eventCode) : what_(what),
Message(int what, std::string deviceId, ReasonCode eventCode) : what_(what),
eventCode_(eventCode), strArg_(deviceId) {}
Message(int what, int arg1);
Message(int what, int arg1, int arg2);
Message(int what, int arg1, int arg2, std::string strArg);
Message(int what, int arg1, int arg2, long uptimeMillis);
Message(int what, int arg1, int arg2, long uptimeMillis, std::string strArg);
Message(int what, int arg1, std::string strArg);

View File

@ -32,6 +32,8 @@ Message::Message(int what, int arg1) : Message(what, arg1, 0, 0) {}
Message::Message(int what, int arg1, int arg2) : Message(what, arg1, arg2, 0) {}
Message::Message(int what, int arg1, int arg2, std::string strArg) : Message(what, arg1, arg2, 0, strArg) {}
Message::Message(int what, int arg1, std::string strArg) : Message(what, arg1, 0, 0, strArg) {}
Message::Message(int what, int arg1, int arg2, long uptimeMillis) : Message(what, arg1, arg2, uptimeMillis, "") {}
@ -73,7 +75,6 @@ Message &Message::operator=(const Message &msg)
this->task_ = msg.task_;
this->ptrArg_ = msg.ptrArg_;
this->strArg_ = msg.strArg_;
this->eventCode_ = msg.eventCode_;
return *this;
}
@ -86,7 +87,6 @@ Message::Message(const Message &msg)
this->task_ = msg.task_;
this->ptrArg_ = msg.ptrArg_;
this->strArg_ = msg.strArg_;
this->eventCode_ = msg.eventCode_;
}
} // namespace CastEngineService
} // namespace CastEngine