#ifndef __EV_UPLOAD_H__
#define __EV_UPLOAD_H__

#include <string>
#include <set>
#include <mutex>
#include <queue>
#include <jsoncons/json.hpp>
#include "evutils.hpp"
#include "internal_types.h"

typedef struct upload_item_t {
    int64_t tss;
    int64_t tse;
    uint8_t type;
    int retried; // -1 means fresh new
    int64_t last_access;
}upload_item_t;

typedef struct thread_upload_args_t {
    std::mutex *mut;
    std::condition_variable *cv;
    std::queue<upload_item_t> *que;
    jsoncons::json *config;
    char *dev_sn;
    evutils::OrderedList<int64_t> **recList;
}thread_upload_args_t;

//
void upload_svc_entry(thread_upload_args_t *pArg);
void record_video_entry(ev_module_config_t *pArgs);

//
std::string upload_video(std::string hostUrl, char* dev_sn, int64_t tss, int64_t tse, std::set<int64_t> slices, int8_t type);
void print_ts_files(evutils::OrderedList<int64_t> &_list);
void load_sd_files(evutils::OrderedList<int64_t> &_list);
void remove_ts_file(int64_t ts);

#endif