回退 'Pull Request !6987 : 新增分层编码配置'

This commit is contained in:
openharmony_ci 2024-07-25 02:45:09 +00:00 committed by Gitee
parent 38c6315c83
commit fb3b8f0821
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
20 changed files with 17 additions and 282 deletions

View File

@ -261,33 +261,6 @@ typedef enum {
OPT_LEVEL_SOFTBUS, /**< @reserved Softbus level option. */
OPT_LEVEL_BUTT,
} OptLevel;
/**
* @brief Enumerate frame event status.
*
* @since 2.0
* @version 2.0
*/
typedef enum {
FRAME_UNSEND,
FRAME_SENDING,
FRAME_RETRING,
FRAME_RECEIVED,
FRAME_DROPPED,
FRAME_UNMANAGED,
} FrameEvtStatus;
typedef struct {
int32_t seq;
int32_t level;
int32_t subSeqNum;
FrameEvtStatus status;
uint32_t interval; /**< frame sending interval */
uint32_t queueUsage; /**< send queue percentage of use */
uint32_t cachedFrameCnt; /**< frame count in VTP */
} FrameEvtCbInfo;
typedef int (*OnFrameEvt)(int fd, const FrameEvtCbInfo *info);
#ifdef __cplusplus
}
#endif

View File

@ -90,8 +90,6 @@ int32_t ClientEmitFileEvent(int32_t channelId);
int32_t TransLimitChange(int32_t channelId, uint8_t tos);
int32_t TransSetUdpChanelSessionId(int32_t channelId, int32_t sessionId);
int32_t TransUdpChannelSetStreamMultiLayer(int32_t channelId, const void *optValue);
#ifdef __cplusplus
}
#endif

View File

@ -501,21 +501,6 @@ int32_t TransUdpChannelSendStream(int32_t channelId, const StreamData *data, con
return TransSendStream(channelId, data, ext, param);
}
int32_t TransUdpChannelSetStreamMultiLayer(int32_t channelId, const void *optValue)
{
UdpChannel channel;
(void)memset_s(&channel, sizeof(UdpChannel), 0, sizeof(UdpChannel));
if (TransGetUdpChannel(channelId, &channel) != SOFTBUS_OK) {
TRANS_LOGE(TRANS_STREAM, "get channel by channelId=%{public}d failed.", channelId);
return SOFTBUS_TRANS_UDP_GET_CHANNEL_FAILED;
}
if (!channel.isEnable) {
TRANS_LOGE(TRANS_STREAM, "udp channel is not enable.");
return SOFTBUS_TRANS_UDP_CHANNEL_DISABLE;
}
return TransSetStreamMultiLayer(channelId, optValue);
}
static void OnUdpChannelClosed(int32_t channelId, ShutdownReason reason)
{
if ((g_sessionCb == NULL) || (g_sessionCb->OnSessionClosed == NULL)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 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
@ -68,7 +68,6 @@ int32_t StartVtpStreamChannelClient(int32_t channelId, const VtpStreamOpenParam
const IStreamListener *callback);
int32_t SendVtpStream(int32_t channelId, const StreamData *data, const StreamData *ext, const StreamFrameInfo *param);
int32_t CloseVtpStreamChannel(int32_t channelId, const char *pkgName);
int32_t SetVtpStreamMultiLayerOpt(int32_t channelId, const void *optValue);
#ifdef __cplusplus
#if __cplusplus

View File

@ -143,25 +143,6 @@ int32_t SendVtpStream(int32_t channelId, const StreamData *inData, const StreamD
return adaptor->GetStreamManager()->Send(std::move(stream)) ? SOFTBUS_OK : SOFTBUS_TRANS_MAKE_STREAM_FAILED;
}
int32_t SetVtpStreamMultiLayerOpt(int32_t channelId, const void *optValue)
{
if (optValue == nullptr) {
TRANS_LOGE(TRANS_STREAM, "invalid argument optValue");
return SOFTBUS_INVALID_PARAM;
}
std::shared_ptr<StreamAdaptor> adaptor = nullptr;
{
std::lock_guard<std::mutex> lock(g_mutex);
auto it = g_adaptorMap.find(channelId);
if (it == g_adaptorMap.end()) {
TRANS_LOGE(TRANS_STREAM, "channelId %{public}u adaptor not existed!", channelId);
return SOFTBUS_TRANS_ADAPTOR_NOT_EXISTED;
}
adaptor = it->second;
}
return adaptor->GetStreamManager()->SetMultiLayer(optValue);
}
int32_t StartVtpStreamChannelServer(int32_t channelId, const VtpStreamOpenParam *param, const IStreamListener *callback)
{
if (channelId < 0 || param == nullptr || param->pkgName == nullptr || callback == nullptr) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
* Copyright (c) 2021 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
@ -34,8 +34,6 @@ int32_t TransOnstreamChannelOpened(const ChannelInfo *channel, int32_t *streamPo
int32_t TransCloseStreamChannel(int32_t channelId);
int32_t TransSendStream(int32_t channelId, const StreamData *data, const StreamData *ext, const StreamFrameInfo *param);
int32_t TransSetStreamMultiLayer(int32_t channelId, const void *optValue);
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
* Copyright (c) 2021-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
@ -75,7 +75,6 @@ public:
virtual bool Send(std::unique_ptr<IStream> stream) = 0;
virtual bool SetOption(int type, const StreamAttr &value) = 0;
virtual int32_t SetMultiLayer(const void *para) = 0;
virtual StreamAttr GetOption(int type) const = 0;
virtual bool SetStreamListener(std::shared_ptr<IStreamSocketListener> receiver) = 0;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 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
@ -64,7 +64,6 @@ public:
virtual bool Send(std::unique_ptr<IStream>) = 0;
virtual bool SetOption(int type, const StreamAttr &value) = 0;
virtual int32_t SetMultiLayer(const void *para) = 0;
virtual StreamAttr GetOption(int type) const = 0;
virtual void SetStreamRecvListener(std::shared_ptr<IStreamManagerListener> recvListener) = 0;

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021-2024 Huawei Device Co., Ltd.
# Copyright (c) 2021 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
@ -13,7 +13,6 @@
import("../../../../../../dsoftbus.gni")
libsoftbus_stream_sdk_path = "$dsoftbus_root_path/sdk/transmission/trans_channel/udp/stream/libsoftbus_stream"
vtp_stream_opt_ext_path = "$dsoftbus_root_path/dsoftbus_enhance/sdk/transmission/trans_channel/udp/stream/src"
dstream_native_source_path = rebase_path("$dsoftbus_root_path")
dstream_dep_file = "components/nstackx_enhanced/fillp/BUILD.gn"
@ -24,10 +23,7 @@ enhanced = exec_script("$dsoftbus_root_path/check_sub_module.py",
],
"value")
libsoftbus_stream_inc = [
"$libsoftbus_stream_sdk_path/include",
"$libsoftbus_stream_sdk_path",
]
libsoftbus_stream_inc = [ "$libsoftbus_stream_sdk_path/include" ]
if (enhanced) {
libsoftbus_stream_inc += [
@ -50,12 +46,6 @@ libsoftbus_stream_src = [
"$libsoftbus_stream_sdk_path/vtp_stream_socket.cpp",
]
if (enhanced) {
libsoftbus_stream_src += [ "$vtp_stream_opt_ext_path/vtp_stream_opt_ext.c" ]
} else {
libsoftbus_stream_src += [ "$libsoftbus_stream_sdk_path/vtp_stream_opt.c" ]
}
libsoftbus_stream_ext_deps = []
if (defined(ohos_lite)) {
libsoftbus_stream_inc += [

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
* Copyright (c) 2021 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
@ -138,17 +138,6 @@ bool StreamManager::SetOption(int type, const StreamAttr &value)
return false;
}
int32_t StreamManager::SetMultiLayer(const void *para)
{
auto it = socketMap_.find(curProtocol_);
if (it != socketMap_.end()) {
auto streamSocket = it->second;
return streamSocket->SetMultiLayer(para);
}
TRANS_LOGE(TRANS_STREAM, "do not found curProtocol=%{public}d", curProtocol_);
return SOFTBUS_TRANS_SESSION_SET_CHANNEL_FAILED;
}
StreamAttr StreamManager::GetOption(int type) const
{
auto it = socketMap_.find(curProtocol_);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 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
@ -89,7 +89,6 @@ public:
bool Send(std::unique_ptr<IStream> data) override;
bool SetOption(int type, const StreamAttr &value) override;
int32_t SetMultiLayer(const void *para) override;
StreamAttr GetOption(int type) const override;
void SetStreamRecvListener(std::shared_ptr<IStreamManagerListener> recvListener) override;

View File

@ -1,40 +0,0 @@
/*
* Copyright (c) 2024-2024 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.
*/
#include "vtp_stream_opt.h"
#include "softbus_errcode.h"
int32_t VtpSetSocketMultiLayer(int fd, OnFrameEvt *cb, const void *para)
{
(void)fd;
(void)cb;
(void)para;
return SOFTBUS_FUNC_NOT_SUPPORT;
}
bool IsVtpFrameSentEvt(const FtEventCbkInfo *info)
{
(void)info;
return false;
}
int HandleVtpFrameEvt(int fd, OnFrameEvt cb, const FtEventCbkInfo *info)
{
(void)fd;
(void)cb;
(void)info;
return SOFTBUS_FUNC_NOT_SUPPORT;
}

View File

@ -1,34 +0,0 @@
/*
* Copyright (c) 2024 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.
*/
#ifndef VTP_STREAM_OPT_H
#define VTP_STREAM_OPT_H
#include <stdbool.h>
#include "fillpinc.h"
#include "trans_type.h"
#ifdef __cplusplus
extern "C" {
#endif
int32_t VtpSetSocketMultiLayer(int fd, OnFrameEvt *cb, const void *para);
bool IsVtpFrameSentEvt(const FtEventCbkInfo *info);
int HandleVtpFrameEvt(int fd, OnFrameEvt cb, const FtEventCbkInfo *info);
#ifdef __cplusplus
}
#endif
#endif // VTP_STREAM_OPT_H

View File

@ -35,7 +35,6 @@
#include "stream_common_data.h"
#include "stream_depacketizer.h"
#include "stream_packetizer.h"
#include "vtp_stream_opt.h"
namespace Communication {
namespace SoftBus {
@ -250,33 +249,6 @@ int VtpStreamSocket::HandleRipplePolicy(int fd, const FtEventCbkInfo *info)
return SOFTBUS_OK;
}
int VtpStreamSocket::HandleFillpFrameEvt(int fd, const FtEventCbkInfo *info)
{
if (info == nullptr) {
TRANS_LOGE(TRANS_STREAM, "fd is %{public}d, info is nullptr", fd);
return SOFTBUS_INVALID_PARAM;
}
std::lock_guard<std::mutex> guard(g_streamSocketMapLock_);
auto itListener = g_streamSocketMap.find(fd);
if (itListener != g_streamSocketMap.end()) {
return itListener->second->HandleFillpFrameEvtInner(fd, info);
} else {
TRANS_LOGE(TRANS_STREAM, "OnFillpFrameEvt for the fd is empty in the map. fd=%{public}d", fd);
}
return SOFTBUS_OK;
}
int VtpStreamSocket::HandleFillpFrameEvtInner(int fd, const FtEventCbkInfo *info)
{
if (onStreamEvtCb_ != nullptr) {
TRANS_LOGD(TRANS_STREAM, "onStreamEvtCb_ enter");
return HandleVtpFrameEvt(fd, onStreamEvtCb_, info);
} else {
TRANS_LOGD(TRANS_STREAM, "onStreamEvtCb_ is nullptr");
}
return SOFTBUS_OK;
}
#ifdef FILLP_SUPPORT_BW_DET
void VtpStreamSocket::FillSupportDet(int fd, const FtEventCbkInfo *info, QosTv *metricList)
{
@ -312,9 +284,9 @@ void VtpStreamSocket::FillSupportDet(int fd, const FtEventCbkInfo *info, QosTv *
/* This function is used to prompt the metrics returned by FtApiRegEventCallbackFunc() function */
int VtpStreamSocket::FillpStatistics(int fd, const FtEventCbkInfo *info)
{
if (info == nullptr || fd < 0) {
if (info == nullptr || fd <= 0) {
TRANS_LOGE(TRANS_STREAM, "param invalid");
return SOFTBUS_INVALID_PARAM;
return -1;
}
if (info->evt == FT_EVT_FRAME_STATS) {
TRANS_LOGI(TRANS_STREAM, "recv fillp frame stats");
@ -322,9 +294,6 @@ int VtpStreamSocket::FillpStatistics(int fd, const FtEventCbkInfo *info)
} else if (info->evt == FT_EVT_TRAFFIC_DATA) {
TRANS_LOGI(TRANS_STREAM, "recv fillp traffic data");
return HandleRipplePolicy(fd, info);
} else if (IsVtpFrameSentEvt(info)) {
TRANS_LOGI(TRANS_STREAM, "fd %{public}d recv fillp frame send evt", fd);
return HandleFillpFrameEvt(fd, info);
}
#ifdef FILLP_SUPPORT_BW_DET
if (info->evt == FT_EVT_BW_DET || info->evt == FT_EVT_JITTER_DET) {
@ -1590,12 +1559,6 @@ ssize_t VtpStreamSocket::Decrypt(const void *in, ssize_t inLen, void *out, ssize
return outLen;
}
int32_t VtpStreamSocket::SetMultiLayer(const void *para)
{
int fd = GetStreamSocketFd(FD).GetIntValue();
return VtpSetSocketMultiLayer(fd, &onStreamEvtCb_, para);
}
void VtpStreamSocket::CreateServerProcessThread()
{
auto self = this->GetSelf();

View File

@ -30,7 +30,6 @@
#include "i_stream_socket.h"
#include "stream_common.h"
#include "vtp_instance.h"
#include "vtp_stream_opt.h"
namespace Communication {
namespace SoftBus {
@ -66,7 +65,6 @@ public:
bool Send(std::unique_ptr<IStream> stream) override;
bool SetOption(int type, const StreamAttr &value) override;
int32_t SetMultiLayer(const void *para) override;
StreamAttr GetOption(int type) const override;
bool SetStreamListener(std::shared_ptr<IStreamSocketListener> receiver) override;
@ -186,10 +184,6 @@ private:
static int HandleRipplePolicy(int fd, const FtEventCbkInfo *info);
static int HandleFillpFrameEvt(int fd, const FtEventCbkInfo *info);
int HandleFillpFrameEvtInner(int fd, const FtEventCbkInfo *info);
static int FillpStatistics(int fd, const FtEventCbkInfo *info);
void FillpAppStatistics();
@ -212,7 +206,6 @@ private:
int scene_ = UNKNOWN_SCENE;
int streamHdrSize_ = 0;
bool isDestroyed_ = false;
OnFrameEvt onStreamEvtCb_;
};
} // namespace SoftBus
} // namespace Communication

View File

@ -214,15 +214,6 @@ int32_t TransSendStream(int32_t channelId, const StreamData *data, const StreamD
return SendVtpStream(channelId, data, ext, param);
}
int32_t TransSetStreamMultiLayer(int32_t channelId, const void *optValue)
{
if (channelId < 0) {
TRANS_LOGE(TRANS_STREAM, "param invalid");
return SOFTBUS_INVALID_PARAM;
}
return SetVtpStreamMultiLayerOpt(channelId, optValue);
}
int32_t TransCloseStreamChannel(int32_t channelId)
{
TRANS_LOGI(TRANS_STREAM, "close stream channel. channelId=%{public}d", channelId);

View File

@ -220,8 +220,9 @@ HWTEST_F(ClientTransStreamTest, TransOnstreamChannelOpened001, TestSize.Level0)
{
int ret = TransClientInit();
EXPECT_EQ(ret, SOFTBUS_OK);
ChannelInfo *channel = (ChannelInfo*)SoftBusCalloc(sizeof(ChannelInfo));
ChannelInfo *channel = (ChannelInfo*)SoftBusMalloc(sizeof(ChannelInfo));
ASSERT_TRUE(channel != nullptr);
(void)memset_s(channel, sizeof(ChannelInfo), 0, sizeof(ChannelInfo));
int32_t streamPort = 2;
ret = TransOnstreamChannelOpened(NULL, &streamPort);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
* Copyright (c) 2022 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
@ -184,20 +184,4 @@ HWTEST_F(StreamManagerTest, SetOption001, TestSize.Level1)
streamSocketListener->SetStreamRecvListener(recvListener);
streamSocketListener->SetStreamRecvListener(nullptr);
}
/**
* @tc.name: SetMultiLayer001
* @tc.desc: SetMultiLayer, use the wrong parameter.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(StreamManagerTest, SetMultiLayer001, TestSize.Level1)
{
std::shared_ptr<Communication::SoftBus::IStreamManagerListener> streamListener;
auto streamSocketListener = std::make_shared<Communication::SoftBus::StreamManager>(streamListener);
int para = 0;
int32_t ret = streamSocketListener->SetMultiLayer((void *)&para);
EXPECT_NE(SOFTBUS_OK, ret);
}
} // OHOS

View File

@ -1,4 +1,4 @@
# Copyright (c) 2022-2024 Huawei Device Co., Ltd.
# Copyright (c) 2022 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
@ -38,7 +38,7 @@ ohos_unittest("VtpStreamSocketTest") {
deps = [
"$dsoftbus_root_path/core/common:softbus_utils",
"$dsoftbus_root_path/core/frame:softbus_server",
"$dsoftbus_root_path/tests/sdk/frame/fuzztest/softbusclientstub_fuzzer:softbus_client_static",
"$dsoftbus_root_path/sdk:softbus_client",
]
native_source_path = rebase_path("$dsoftbus_root_path")

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
* Copyright (c) 2022 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
@ -596,7 +596,7 @@ HWTEST_F(VtpStreamSocketTest, FillpStatistics001, TestSize.Level1)
int fd = 2;
int ret = vtpStreamSocket->FillpStatistics(fd, nullptr);
EXPECT_NE(SOFTBUS_OK, ret);
EXPECT_EQ(-1, ret);
info->evt = FT_EVT_FRAME_STATS;
ret = vtpStreamSocket->FillpStatistics(fd, info);
@ -1019,39 +1019,6 @@ HWTEST_F(VtpStreamSocketTest, HandleRipplePolicy001, TestSize.Level1)
}
}
/**
* @tc.name: HandleFillpFrameEvt001
* @tc.desc: HandleFillpFrameEvt, use the wrong parameter.
* @tc.desc: RecvStreamLen, use the wrong parameter.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(VtpStreamSocketTest, HandleFillpFrameEvt001, TestSize.Level1)
{
std::shared_ptr<Communication::SoftBus::VtpStreamSocket> vtpStreamSocket =
std::make_shared<Communication::SoftBus::VtpStreamSocket>();
int fd = 1;
FtEventCbkInfo *info = (FtEventCbkInfo*)SoftBusCalloc(sizeof(FtEventCbkInfo));
ASSERT_TRUE(info != nullptr);
ASSERT_TRUE(!vtpStreamSocket->g_streamSocketMap.empty());
int ret = vtpStreamSocket->HandleFillpFrameEvt(fd, nullptr);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
ret = vtpStreamSocket->HandleFillpFrameEvt(fd, info);
EXPECT_EQ(0, ret);
ret = vtpStreamSocket->HandleFillpFrameEvtInner(fd, info);
EXPECT_EQ(0, ret);
fd = 10;
ret = vtpStreamSocket->HandleFillpFrameEvt(fd, info);
EXPECT_NE(fd, ret);
if (info != nullptr) {
SoftBusFree(info);
}
}
/**
* @tc.name: InsertBufferLength001
* @tc.desc: SetSocketEpollMode, use the wrong parameter.