342 lines
8.2 KiB
C++
342 lines
8.2 KiB
C++
/*
|
|
* Copyright (c) 2023 Fancy Code.
|
|
* 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 I_APP_EMANAGER_H
|
|
#define I_APP_EMANAGER_H
|
|
#include "StatusCode.h"
|
|
#include <iostream>
|
|
#include <memory>
|
|
#include <vector>
|
|
bool CreateAppManagerModule(void);
|
|
bool DestroyAppManagerModule(void);
|
|
enum class ResposeResult
|
|
{
|
|
SUCCESSFUL = 0,
|
|
FAILED,
|
|
END
|
|
};
|
|
enum class UploadCommand
|
|
{
|
|
UPGRADE_CPU = 0,
|
|
END
|
|
};
|
|
enum class ChargeStatus
|
|
{
|
|
UNCHARGED = 0,
|
|
CHARGING,
|
|
END
|
|
};
|
|
enum class SdCardStatus
|
|
{
|
|
NORMAL = 0,
|
|
UNFORMATTED = 1,
|
|
NOT_INSERTED = 2,
|
|
CARD_DAMAGED = 3,
|
|
CARD_LOCKED = 10,
|
|
SLOW_CARD = 11,
|
|
FORMAT_REQUIRED = 12,
|
|
FORMATTING = 13,
|
|
END = 99
|
|
};
|
|
enum class LockVideoStatus
|
|
{
|
|
UNLOCK = 0,
|
|
LOCK,
|
|
END
|
|
};
|
|
enum class StorageType
|
|
{
|
|
EMMC = 0,
|
|
SD_CARD_1,
|
|
SD_CARD_2,
|
|
END
|
|
};
|
|
enum class PlayBackEvent
|
|
{
|
|
START = 0,
|
|
STOP,
|
|
END
|
|
};
|
|
enum class StorageFileType
|
|
{
|
|
PICTURE = 1,
|
|
VIDEO,
|
|
END
|
|
};
|
|
enum class StorageFileEvent
|
|
{
|
|
LOOP = 0,
|
|
PIR,
|
|
CRASH,
|
|
EMR,
|
|
EVENT,
|
|
PARK,
|
|
END
|
|
};
|
|
enum class SwitchStatus
|
|
{
|
|
OFF = 0,
|
|
ON,
|
|
END
|
|
};
|
|
enum class GpsCapability
|
|
{
|
|
NOT_SUPPORT = 0,
|
|
END
|
|
};
|
|
enum class DeviceType
|
|
{
|
|
DASH_CAMERA = 0,
|
|
END
|
|
};
|
|
enum class DashAlbum
|
|
{
|
|
SUPPORT_PARKING_MONITOR_ALBUM = 0,
|
|
NOT_SUPPORT_PARKING_MONITOR_ALBUM,
|
|
END
|
|
};
|
|
enum class AppLock
|
|
{
|
|
NOT_SUPPORT_APP_LOCK = 0,
|
|
SUPPORT_APP_LOCK,
|
|
END
|
|
};
|
|
enum class DeleteLock
|
|
{
|
|
SUPPORT_DELETE_LOCK = 0,
|
|
NOT_SUPPORT_DELETE_LOCK,
|
|
END
|
|
};
|
|
enum class DeviceMode
|
|
{
|
|
NEED_TO_SWITCH = 0,
|
|
NOT_NEED_TO_SWITCH,
|
|
END
|
|
};
|
|
enum class PlaybackType
|
|
{
|
|
DOWNLOAD_PLAYBACK = 0,
|
|
RTSP_TCP,
|
|
RTSP_UDP,
|
|
END
|
|
};
|
|
enum class PhotographCapability
|
|
{
|
|
SUPPORT_TAKE_PICTURE = 0,
|
|
NOT_SUPPORT_TAKE_PICTURE,
|
|
END
|
|
};
|
|
enum class WifiCapability
|
|
{
|
|
SUPPORT_MODIFY_SSID_AND_PASSWORD = 0,
|
|
ONLY_SUPPORT_MODIFY_PASSWORD,
|
|
NOLY_SUPPORT_MODIFY_SSID,
|
|
NOT_SUPPORT_MODIFY_ANYTHING,
|
|
END
|
|
};
|
|
enum class FileCopy
|
|
{
|
|
NOT_SUPPORT_COPY = 0,
|
|
SUPPORT_COPY,
|
|
END
|
|
};
|
|
enum class RecordingStatus
|
|
{
|
|
RECORDING_STOP = 0,
|
|
RECORDING_START,
|
|
END
|
|
};
|
|
enum class MicrophoneStatus
|
|
{
|
|
OFF = 0,
|
|
ON,
|
|
END
|
|
};
|
|
enum class BatteryStatus
|
|
{
|
|
CHARGING = 0,
|
|
NOT_CHARGING,
|
|
END
|
|
};
|
|
typedef struct app_get_product_info
|
|
{
|
|
app_get_product_info();
|
|
std::string mModel;
|
|
std::string mCompany;
|
|
std::string mSoc;
|
|
std::string mSp;
|
|
} AppGetProductInfo;
|
|
typedef struct app_get_device_attr
|
|
{
|
|
app_get_device_attr();
|
|
std::string mUUID;
|
|
std::string mSoftVersion;
|
|
std::string mOtaVersion;
|
|
std::string mHardwareVersion;
|
|
std::string mSSID;
|
|
std::string mBSSID;
|
|
std::string mCameraNumber;
|
|
std::string mCurrentCameraID;
|
|
std::string mWifiReboot;
|
|
} AppGetDeviceAttr;
|
|
typedef struct app_get_media_info
|
|
{
|
|
app_get_media_info();
|
|
std::string mRtspUrl;
|
|
std::string mTransport;
|
|
int mPort; ///< The port number of TCP, which the APP will use to initiate TCP connections to the device (server).
|
|
} AppGetMediaInfo;
|
|
typedef struct app_get_sd_card_info
|
|
{
|
|
app_get_sd_card_info();
|
|
SdCardStatus mStatus;
|
|
unsigned long long mFree;
|
|
unsigned long long mTotal;
|
|
} AppGetSdCardInfo;
|
|
typedef struct app_get_battery_info
|
|
{
|
|
app_get_battery_info();
|
|
int mCapacity;
|
|
ChargeStatus mChargeStatus;
|
|
} AppGetBatteryInfo;
|
|
typedef struct app_get_param_value
|
|
{
|
|
app_get_param_value();
|
|
SwitchStatus mMicStatus;
|
|
SwitchStatus mRec;
|
|
} AppParamValue;
|
|
typedef struct app_get_capability
|
|
{
|
|
app_get_capability();
|
|
GpsCapability mGpsCapability;
|
|
DeviceType mDeviceType;
|
|
DashAlbum mAlbum;
|
|
AppLock mAppLock;
|
|
DeleteLock mDeleteLock;
|
|
DeviceMode mDeviceMode;
|
|
PlaybackType mPlaybackType;
|
|
PhotographCapability mPhotographCapability;
|
|
WifiCapability mWifiCapability;
|
|
FileCopy mFileCopy;
|
|
} AppGetCapability;
|
|
typedef struct app_get_storage_info
|
|
{
|
|
app_get_storage_info();
|
|
int mIndex;
|
|
StorageType mType;
|
|
std::string mName;
|
|
unsigned long long mFree;
|
|
unsigned long long mTotal;
|
|
} AppGetStorageInfo;
|
|
typedef struct app_get_file_info
|
|
{
|
|
app_get_file_info();
|
|
int mStartIndex;
|
|
int mStopIndex;
|
|
StorageFileEvent mEvent;
|
|
} AppGetFileInfo;
|
|
typedef struct app_get_file_list
|
|
{
|
|
app_get_file_list();
|
|
std::string mName;
|
|
int mDuration;
|
|
int mSize;
|
|
time_t mCreateTime_s;
|
|
StorageFileType mType;
|
|
} AppGetFileList;
|
|
typedef struct app_set_param_value
|
|
{
|
|
app_set_param_value();
|
|
std::string mName;
|
|
int mValue;
|
|
} AppSetParamValue;
|
|
typedef struct app_set_date_time
|
|
{
|
|
app_set_date_time(const unsigned int year, const unsigned int month, const unsigned int day,
|
|
const unsigned int hour, const unsigned int minute, const unsigned int second);
|
|
const unsigned int mYear;
|
|
const unsigned int mMonth;
|
|
const unsigned int mDay;
|
|
const unsigned int mHour;
|
|
const unsigned int mMinute;
|
|
const unsigned int mSecond;
|
|
} AppSetDateTime;
|
|
typedef struct app_upload_file
|
|
{
|
|
app_upload_file(const std::string filePath, const UploadCommand command);
|
|
const std::string mFilePath;
|
|
const UploadCommand mCommand;
|
|
ResposeResult mResult;
|
|
} AppUploadFile;
|
|
typedef struct app_get_thumbnail
|
|
{
|
|
app_get_thumbnail(const std::string file);
|
|
const std::string mFile;
|
|
std::string mThumbnail;
|
|
} AppGetThumbnail;
|
|
typedef struct app_param
|
|
{
|
|
app_param(const char *ip, const int &httpPort, const int &tcpPort);
|
|
const char *mIP;
|
|
const int mHttpPort;
|
|
const int mTcpPort;
|
|
} AppParam;
|
|
class VAppClient
|
|
{
|
|
public:
|
|
VAppClient() = default;
|
|
virtual ~VAppClient() = default;
|
|
virtual void SetRecordingStatus(const RecordingStatus &status);
|
|
virtual void SetMicrophoneStatus(const MicrophoneStatus &status);
|
|
virtual void SetBatteryStatus(const BatteryStatus &status, const int &batteryCapacity);
|
|
virtual void SetSdCardStatus(const SdCardStatus &status);
|
|
virtual void DeletedFileMessage(const std::string &file, const StorageFileType &type);
|
|
virtual void CreatedFileMessage(const std::string &file, const StorageFileType &type);
|
|
};
|
|
class VAppMonitor
|
|
{
|
|
public:
|
|
VAppMonitor() = default;
|
|
virtual ~VAppMonitor() = default;
|
|
virtual StatusCode GetProductInfo(AppGetProductInfo ¶m);
|
|
virtual StatusCode GetDeviceAttr(AppGetDeviceAttr ¶m);
|
|
virtual StatusCode GetMediaInfo(AppGetMediaInfo ¶m);
|
|
virtual StatusCode GetSdCardInfo(AppGetSdCardInfo ¶m);
|
|
virtual StatusCode GetBatteryInfo(AppGetBatteryInfo ¶m);
|
|
virtual StatusCode GetParamValue(AppParamValue ¶m);
|
|
virtual StatusCode GetCapability(AppGetCapability ¶m);
|
|
virtual StatusCode GetLockVideoStatus(LockVideoStatus ¶m);
|
|
virtual StatusCode GetStorageInfo(std::vector<AppGetStorageInfo> ¶m);
|
|
virtual StatusCode GetStorageFileList(const AppGetFileInfo &fileInfo, std::vector<AppGetFileList> ¶m);
|
|
virtual StatusCode SetDateTime(const AppSetDateTime ¶m);
|
|
virtual StatusCode SetTimeZone(const unsigned int &zone);
|
|
virtual StatusCode SetParamValue(const AppSetParamValue ¶m);
|
|
virtual StatusCode EnterRecorder(void);
|
|
virtual StatusCode AppPlayback(const PlayBackEvent &event);
|
|
virtual StatusCode UploadFile(AppUploadFile ¶m);
|
|
virtual StatusCode GetThumbnail(AppGetThumbnail ¶m);
|
|
virtual StatusCode AppClientConnected(std::shared_ptr<VAppClient> &client);
|
|
};
|
|
class IAppManager
|
|
{
|
|
public:
|
|
IAppManager() = default;
|
|
virtual ~IAppManager() = default;
|
|
static std::shared_ptr<IAppManager> &GetInstance(std::shared_ptr<IAppManager> *impl = nullptr);
|
|
virtual const StatusCode Init(const AppParam ¶m);
|
|
virtual const StatusCode UnInit(void);
|
|
virtual const StatusCode SetAppMonitor(std::shared_ptr<VAppMonitor> &monitor);
|
|
virtual StatusCode SetSdCardStatus(const SdCardStatus &status);
|
|
};
|
|
#endif |