!85 修改分布式屏幕codex异常

Merge pull request !85 from qinlong/master
This commit is contained in:
openharmony_ci
2022-06-09 02:37:32 +00:00
committed by Gitee
6 changed files with 31 additions and 13 deletions
+1
View File
@@ -23,6 +23,7 @@ namespace DistributedHardware {
int32_t GetLocalDeviceNetworkId(std::string &networkId);
std::string GetRandomID();
std::string GetAnonyString(const std::string &value);
std::string GetInterruptString(const std::string &value);
} // namespace DistributedHardware
} // namespace OHOS
#endif
+15
View File
@@ -94,5 +94,20 @@ std::string GetAnonyString(const std::string &value)
return res;
}
std::string GetInterruptString(const std::string &value)
{
constexpr size_t INT32_MIN_ID_LENGTH = 3;
constexpr size_t STRING_HALF_LENGTH = 2;
std::string res;
size_t strlen = value.length();
if (strlen <= INT32_MIN_ID_LENGTH) {
res = value;
} else {
res = value.substr(0, strlen / STRING_HALF_LENGTH);
}
return res;
}
} // namespace DistributedHardware
} // namespace OHOS
+6 -8
View File
@@ -62,12 +62,9 @@ using namespace OHOS;
using namespace OHOS::Media;
using namespace std;
namespace {
constexpr uint32_t DEFAULT_WIDTH = 480;
constexpr uint32_t DEFAULT_HEIGHT = 360;
constexpr uint32_t DEFAULT_FRAME_RATE = 30;
constexpr uint32_t MAX_INPUT_BUFFER_SIZE = 30000;
constexpr uint32_t FRAME_DURATION_US = 33000;
constexpr uint32_t DEFAULT_FRAME_COUNT = 1;
constexpr uint32_t VIDEO_DATA_FORMAT_NV12 = 2;
constexpr uint32_t VIDEO_DATA_FORMAT_RGBA = 5;
constexpr uint32_t SLEEP_THREE_SECOND = 3;
@@ -81,8 +78,8 @@ void VDecDemo::RunCase()
CheckCodecType();
CreateVdec();
Format format;
format.PutIntValue("width", DEFAULT_WIDTH);
format.PutIntValue("height", DEFAULT_HEIGHT);
format.PutIntValue("width", width_);
format.PutIntValue("height", height_);
if (isW) {
format.PutIntValue("pixel_format", VIDEO_DATA_FORMAT_NV12);
} else {
@@ -217,11 +214,12 @@ const int32_t* VDecDemo::GetFrameLen()
const int32_t* frameLen = nullptr;
if (isW) {
frameLen = ES_W;
return frameLen;
defaultFrameCount_ = sizeof(ES_W)/sizeof(ES_W[0]);
} else {
frameLen = ES_R;
return frameLen;
defaultFrameCount_ = sizeof(ES_R)/sizeof(ES_R[0]);
}
return frameLen;
}
void VDecDemo::InputFunc()
@@ -274,7 +272,7 @@ void VDecDemo::InputFunc()
signal_->inQueue_.pop();
frameCount_++;
if (frameCount_ == DEFAULT_FRAME_COUNT) {
if (frameCount_ == defaultFrameCount_) {
cout << "Finish decode, exit" << endl;
break;
}
+1
View File
@@ -88,6 +88,7 @@ private:
bool isW = true;
int64_t timeStamp_ = 0;
uint32_t frameCount_ = 0;
uint32_t defaultFrameCount_ = 0;
};
} // namespace Media
} // namespace OHOS
+5 -4
View File
@@ -19,6 +19,7 @@
#include "display_manager.h"
#include "dscreen_source_handler.h"
#include "dscreen_sink_handler.h"
#include "dscreen_util.h"
#include "idistributed_hardware_sink.h"
#include "idistributed_hardware_source.h"
#include "screen.h"
@@ -65,7 +66,7 @@ vector<sptr<Screen>> QueryRemoteScreenInfo()
}
cout << endl;
cout << "--------screen id " << screen->GetId() << "---------" << endl;
cout << "screen name: " << screen->GetName() << endl;
cout << "screen name: " << GetAnonyString(screen->GetName()).c_str() << endl;
cout << "width: " << screen->GetWidth() << endl;
cout << "height: " << screen->GetHeight() << endl;
cout << "-------------------------------------------" << endl;
@@ -220,20 +221,20 @@ static void PrintNodeProperty(NodeBasicInfo *nodeInfo)
}
printf("DeviceName = %s\n", nodeInfo->deviceName);
printf("NetworkId = %s\n", nodeInfo->networkId);
printf("NetworkId = %s\n", GetAnonyString(nodeInfo->networkId).c_str());
NodeDeviceInfoKey key = NODE_KEY_UDID;
unsigned char udid[UDID_BUF_LEN] = {0};
if (GetNodeKeyInfo(g_pkgName, nodeInfo->networkId, key, udid, UDID_BUF_LEN) != 0) {
printf("GetNodeKeyInfo Fail!\n");
} else {
printf("Udid = %s\n", udid);
printf("Udid = %s\n", GetAnonyString((char *)udid).c_str());
}
key = NODE_KEY_UUID;
unsigned char uuid[UUID_BUF_LEN] = {0};
if (GetNodeKeyInfo(g_pkgName, nodeInfo->networkId, key, uuid, UUID_BUF_LEN) != 0) {
printf("GetNodeKeyInfo Fail!\n");
} else {
printf("Uuid = %s\n", uuid);
printf("Uuid = %s\n", GetAnonyString((char *)uuid).c_str());
}
}
@@ -25,6 +25,7 @@
#include "dscreen_errcode.h"
#include "dscreen_hisysevent.h"
#include "dscreen_log.h"
#include "dscreen_util.h"
namespace OHOS {
namespace DistributedHardware {
@@ -40,7 +41,8 @@ uint64_t ScreenMgrAdapter::CreateVirtualScreen(const std::string &devId, const s
{
DHLOGI("CreateVirtualScreen, width: %u, height: %u", videoParam->GetScreenWidth(),
videoParam->GetScreenHeight());
std::string screenName = DSCREEN_PREFIX + SEPERATOR + devId + SEPERATOR + dhId;
std::string screenName = DSCREEN_PREFIX + SEPERATOR + GetInterruptString(devId) +
SEPERATOR + GetInterruptString(dhId);
auto iter = screenIdMap_.find(screenName);
if (iter != screenIdMap_.end()) {
DHLOGI("remove an exist virtual screen.");