hunting/application/MissionManager/src/MediaTask.h
2024-07-20 15:12:27 +08:00

61 lines
2.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 MEDIA_TASK_H
#define MEDIA_TASK_H
#include "DataProcessing.h"
#include "IMediaManager.h"
#include <string>
#include <vector>
constexpr unsigned int MEDIA_TASK_TIMEOUT_MS = 1000 * 60;
constexpr int DEFAULT_VIDEO_DURATION_MS = 1000 * 10;
typedef struct media_task_info
{
const std::vector<MediaTaskResponse> mResponse;
const unsigned long mSerialNumber;
const long long mCreateTime_s;
} MediaTaskInfo;
class VMediaTaskIniator
{
public:
VMediaTaskIniator() = default;
virtual ~VMediaTaskIniator() = default;
virtual void TaskResponse(const MediaTaskInfo &taskinfo) = 0;
};
class MediaTask : public VMediaTask
{
public:
MediaTask(const MediaTaskType &type, const InternalStateEvent &bindEvent,
const std::weak_ptr<VMediaTaskIniator> &iniator, const unsigned long &serialNumber,
const std::string &savePath);
virtual ~MediaTask() = default;
virtual unsigned int GetTaskTimeOutMs(void);
std::string GetTargetNameForSaving(void) override;
std::string GetThumbnailNameForSaving(const std::string &targetName) override;
int GetVideoDuration_ms(void) override;
void Response(const std::vector<MediaTaskResponse> &response) override;
private:
const MediaTaskType mType;
const InternalStateEvent mBindEvent;
const std::weak_ptr<VMediaTaskIniator> mIniator;
const unsigned long mSerialNumber;
const std::string mSavePath;
bool mFinished = false;
std::shared_ptr<MediaTaskResponse> mResponseData;
std::string mTargetName;
long long mCreateTime_s;
std::vector<std::string> mTargetNameList;
};
#endif