mirror of
https://github.com/openharmony/multimedia_camera_lite.git
synced 2026-07-20 01:03:35 -04:00
fix issues like null point check.
Signed-off-by: boxwall <hezhiqiang19@huawei.com>
This commit is contained in:
Executable → Regular
@@ -56,6 +56,6 @@ private:
|
||||
SvcIdentity sid_;
|
||||
int32_t ret_ = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace Media
|
||||
} // namespace OHOS
|
||||
#endif // CAMERA_DEVICE_CLIENT_H
|
||||
@@ -328,5 +328,5 @@ int32_t CameraDeviceClient::DeviceClientCallback(const IpcContext* context, void
|
||||
client->cameraClient_->ClearIpcMsg(ipcMsg);
|
||||
return MEDIA_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Media
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -48,6 +48,10 @@ CameraServiceClient::~CameraServiceClient()
|
||||
|
||||
void CameraServiceClient::InitCameraServiceClient(CameraServiceCallback *callback)
|
||||
{
|
||||
if (callback == nullptr) {
|
||||
MEDIA_INFO_LOG("Camera client initialize fail,empty callback.");
|
||||
return;
|
||||
}
|
||||
cameraServiceCb_ = callback;
|
||||
if (cameraClient_->InitCameraClient()) {
|
||||
MEDIA_INFO_LOG("Camera client initialize success.");
|
||||
@@ -311,5 +315,5 @@ void CameraServiceClient::CreateCamera(string cameraId)
|
||||
MEDIA_ERR_LOG("Create camera ipc transmission failed. (ret=%d)", ans);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Media
|
||||
} // namespace OHOS
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
+2
-3
@@ -37,7 +37,6 @@ private:
|
||||
std::set<uint32_t> supportProperties_;
|
||||
};
|
||||
} // namespace Media
|
||||
} // namespace
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
#endif // OHOS_CAMERA_ABILITY_IMPL_H
|
||||
#endif // OHOS_CAMERA_ABILITY_IMPL_H
|
||||
|
||||
Executable → Regular
+2
-2
@@ -72,5 +72,5 @@ void CameraClient::ClearIpcMsg(void *ipcMsg)
|
||||
FreeBuffer(nullptr, ipcMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Media
|
||||
} // namespace OHOS
|
||||
|
||||
Executable → Regular
+2
-2
@@ -31,6 +31,6 @@ private:
|
||||
~CameraClient() {}
|
||||
IClientProxy *proxy_ = nullptr;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace Media
|
||||
} // namespace OHOS
|
||||
#endif // CAMERA_CLIENT_H
|
||||
|
||||
Executable → Regular
Executable → Regular
+3
@@ -58,6 +58,9 @@ void CameraImpl::Configure(CameraConfig &config)
|
||||
return;
|
||||
}
|
||||
|
||||
if (deviceClient_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = deviceClient_->SetCameraConfig(config);
|
||||
if (ret != MEDIA_OK) {
|
||||
MEDIA_ERR_LOG("Set camera config failed in cameraImpl.");
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
+3
@@ -42,6 +42,9 @@ bool EventHandler::IsRunning()
|
||||
|
||||
void EventHandler::EventDispatch(EventHandler *hdl)
|
||||
{
|
||||
if (hdl == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(hdl->mtx_);
|
||||
hdl->running_ = true;
|
||||
while (hdl->running_) {
|
||||
|
||||
Executable → Regular
@@ -45,6 +45,6 @@ private:
|
||||
CameraConfig *cc_ = nullptr;
|
||||
CameraService *cameraService_ = nullptr;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // CAMERA_DEVICE_CLIENT_H
|
||||
} // namespace Media
|
||||
} // namespace OHOS
|
||||
#endif // CAMERA_DEVICE_CLIENT_H
|
||||
|
||||
@@ -74,5 +74,5 @@ void CameraServiceClient::CreateCamera(string cameraId)
|
||||
static_cast<CameraServiceCallback::CameraStauts>(cameraService_->CreateCamera(cameraId));
|
||||
cameraServiceCb_->OnCameraStatusChange(cameraId, cameraStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Media
|
||||
} // namespace OHOS
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
+3
-3
@@ -95,6 +95,6 @@ public:
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // OHOS_CAMERA_INFO_H
|
||||
} // namespace Media
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_CAMERA_INFO_H
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
+3
-3
@@ -43,8 +43,8 @@ public:
|
||||
private:
|
||||
struct EventObj {
|
||||
EventObj() = default;
|
||||
virtual ~EventObj() {};
|
||||
virtual void Exec() {};
|
||||
virtual ~EventObj() {}
|
||||
virtual void Exec() {}
|
||||
};
|
||||
|
||||
std::queue<EventObj *> msgQ_;
|
||||
@@ -55,7 +55,7 @@ private:
|
||||
|
||||
template<typename F>
|
||||
struct PostTask : public EventObj {
|
||||
PostTask(const F &f) : f_(f) {}
|
||||
explicit PostTask(const F &f) : f_(f) {}
|
||||
const F f_;
|
||||
void Exec() override
|
||||
{
|
||||
|
||||
Executable → Regular
+1
-1
@@ -70,7 +70,7 @@ public:
|
||||
* @param type Indicates the frame configuration mode, which can be <b>FRAME_CONFIG_PREVIEW</b>,
|
||||
* @<b>FRAME_CONFIG_RECORD</b>, or <b>FRAME_CONFIG_CAPTURE</b>.
|
||||
*/
|
||||
FrameConfig(int32_t type);
|
||||
explicit FrameConfig(int32_t type);
|
||||
|
||||
/**
|
||||
* @brief A destructor used to delete the <b>FrameConfig</b> instance.
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
@@ -75,7 +75,7 @@ class PreviewAssistant : public DeviceAssistant {
|
||||
public:
|
||||
int32_t SetFrameConfig(FrameConfig &fc, uint32_t *streamId) override;
|
||||
int32_t Start(uint32_t streamId) override;
|
||||
virtual int32_t Stop() override;
|
||||
int32_t Stop() override;
|
||||
Surface *capSurface_ = nullptr;
|
||||
private:
|
||||
pthread_t threadId;
|
||||
@@ -85,7 +85,7 @@ private:
|
||||
class CaptureAssistant : public DeviceAssistant {
|
||||
int32_t SetFrameConfig(FrameConfig &fc, uint32_t *streamId) override;
|
||||
int32_t Start(uint32_t streamId) override;
|
||||
virtual int32_t Stop() override;
|
||||
int32_t Stop() override;
|
||||
CODEC_HANDLETYPE vencHdl_ = nullptr;
|
||||
Surface *capSurface_ = nullptr;
|
||||
};
|
||||
@@ -94,7 +94,7 @@ class CallbackAssistant : public DeviceAssistant {
|
||||
public:
|
||||
int32_t SetFrameConfig(FrameConfig &fc, uint32_t *streamId) override;
|
||||
int32_t Start(uint32_t streamId) override;
|
||||
virtual int32_t Stop() override;
|
||||
int32_t Stop() override;
|
||||
Surface *capSurface_ = nullptr;
|
||||
private:
|
||||
pthread_t threadId;
|
||||
@@ -104,7 +104,7 @@ private:
|
||||
class CameraDevice {
|
||||
public:
|
||||
CameraDevice();
|
||||
CameraDevice(uint32_t cameraId);
|
||||
explicit CameraDevice(uint32_t cameraId);
|
||||
virtual ~CameraDevice();
|
||||
|
||||
int32_t Initialize();
|
||||
|
||||
@@ -259,6 +259,9 @@ static int32_t CameraCreateJpegEnc(FrameConfig &fc, StreamAttr stream, uint32_t
|
||||
|
||||
static int32_t CopyCodecOutput(void *dst, uint32_t *size, OutputInfo *buffer)
|
||||
{
|
||||
if (dst == nullptr || size == nullptr || buffer == nullptr) {
|
||||
return MEDIA_ERR;
|
||||
}
|
||||
char *dstBuf = reinterpret_cast<char *>(dst);
|
||||
for (uint32_t i = 0; i < buffer->bufferCnt; i++) {
|
||||
uint32_t packSize = buffer->buffers[i].length - buffer->buffers[i].offset;
|
||||
@@ -584,6 +587,10 @@ int32_t CaptureAssistant::Start(uint32_t streamId)
|
||||
int32_t retCode = MEDIA_ERR;
|
||||
state_ = LOOP_LOOPING;
|
||||
HalCameraStreamOn(cameraId_, streamId);
|
||||
if (capSurface_ == nullptr) {
|
||||
MEDIA_ERR_LOG("Create capture venc failed.");
|
||||
return retCode;
|
||||
}
|
||||
int pictures = capSurface_->GetQueueSize();
|
||||
int32_t ret = CodecStart(vencHdl_);
|
||||
if (ret != 0) {
|
||||
|
||||
@@ -51,6 +51,6 @@ struct CallBackPara {
|
||||
};
|
||||
const char SERVICE_NAME[] = "CameraServer";
|
||||
static const int32_t DEFAULT_IPC_SIZE = 300;
|
||||
}
|
||||
}
|
||||
} // namespace Media
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
|
||||
@@ -47,6 +47,9 @@ static const char* GetName(Service* service)
|
||||
|
||||
static BOOL Initialize(Service* service, Identity identity)
|
||||
{
|
||||
if (service == nullptr) {
|
||||
return FALSE;
|
||||
}
|
||||
CameraService* example = (CameraService*)service;
|
||||
example->identity = identity;
|
||||
MEDIA_INFO_LOG("Initialize(%s)! Identity<%d, %d, %p>", Media::SERVICE_NAME,
|
||||
@@ -56,6 +59,9 @@ static BOOL Initialize(Service* service, Identity identity)
|
||||
|
||||
static BOOL MessageHandle(Service* service, Request* msg)
|
||||
{
|
||||
if (service == nullptr || msg == nullptr) {
|
||||
return FALSE;
|
||||
}
|
||||
MEDIA_INFO_LOG("MessageHandle(%s)! Request<%d, %d, %p>",
|
||||
service->GetName(service), msg->msgId, msg->msgValue, msg->data);
|
||||
return FALSE;
|
||||
|
||||
Executable → Regular
Executable → Regular
Reference in New Issue
Block a user