当前位置: 首页>>代码示例>>C++>>正文


C++ TaskInfo::scheduleStart方法代码示例

本文整理汇总了C++中TaskInfo::scheduleStart方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskInfo::scheduleStart方法的具体用法?C++ TaskInfo::scheduleStart怎么用?C++ TaskInfo::scheduleStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TaskInfo的用法示例。


在下文中一共展示了TaskInfo::scheduleStart方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadTasks

void PvrManager::loadTasks()
{
    STUB();
    m_tasks.clear();
    const QString str = m_profile->datasource()->get("PVR", "tasks");
    const QJsonArray arr = QJsonDocument::fromJson(str.toUtf8()).array();
    for(size_t index = 0; index< arr.size(); index++)
    {
        TaskInfo* task = TaskInfo::fromJson(m_profile, arr.at(index).toObject(), this);
        if(task)
        {
            m_tasks.insert(QString::number(task->m_id), task);
            task->scheduleStart();
        }
    }
    DEBUG() << "Tasks loaded:" << m_tasks.size();
}
开发者ID:mvasilchuk,项目名称:yasem-mag-api,代码行数:17,代码来源:pvrmanager.cpp

示例2: CreateTask

/**
 * @brief PvrManager::CreateTask
 * Schedule channel recording task.
 *
 * @param url address of the stream that will be recorded (http://..., rtp://..., udp://...)
 * @param fileName full file name of recording (/media/USB-... or /ram/media/USB-...)
 * @param startTime recording start time
 * UTC time in "YYYYMMDDThhmmss" format or number of seconds since Epoch (1970/01/01 UTC)
 *
 * @param endTime recording end time
 * UTC time in "YYYYMMDDThhmmss" format or number of seconds since Epoch (1970/01/01 UTC)
 *
 * @return unique task identifier if operation was successful, otherwise return value is a string representing error code (<0) from error codes table
 *
 * @example
 * // number of seconds since Epoch can be obtained via Date object
 * var date = new Date();
 * var startTime = date.getTime()/1000;
 */
QString PvrManager::CreateTask(const QString &url, const QString &fileName, const QString &startTime, const QString &endTime)
{
    STUB() << url << fileName << startTime << endTime;

    if(m_tasks.size() >= m_max_record_count - 1)
    {
        DEBUG() << "Reached maximum of simultaneous records!" << m_tasks.size();
        return QString::number(TaskInfo::ERROR_MAX_SIMULTANEOUS_RECORDS);
    }

    QDateTime start_time = QDateTime::fromString(startTime, DATE_TIME_FORMAT);;
    if(!start_time.isValid())
        start_time = QDateTime::fromMSecsSinceEpoch(startTime.toLongLong() * 1000);

    QDateTime end_time = QDateTime::fromString(endTime, DATE_TIME_FORMAT);
    if(!end_time.isValid())
        end_time = QDateTime::fromMSecsSinceEpoch(endTime.toLongLong() * 1000);

    if(!start_time.isValid() || !end_time.isValid())
    {
        DEBUG() << "Start or end time is incorrect" << start_time << end_time;
        return QString::number(TaskInfo::ERROR_BAD_ARGUMENT);
    }

    if( (start_time > end_time)
        || ((end_time.currentMSecsSinceEpoch() - start_time.currentMSecsSinceEpoch()) > 24*60*60*1000) // 24 hours
        )
    {
        DEBUG() << "Incorrect time range!" << start_time << end_time;
        return QString::number(TaskInfo::ERROR_WRONG_RANGE);
    }

    if(!fileName.startsWith("/media/USB-")
            && !fileName.startsWith("/ram/media/USB-")
            && !fileName.startsWith("USB-")
            )
    {
        DEBUG() << "Wrong file name" << fileName;
        return QString::number(TaskInfo::ERROR_WRONG_FILE_NAME);
    }

    for(const TaskInfo* item: m_tasks)
    {
        if(item->m_file_name == fileName)
        {
            DEBUG() << "File" << fileName << "already exists";
            return QString::number(TaskInfo::ERROR_DUPLICATE_TASKS);
        }
    }

    TaskInfo* task = new TaskInfo(m_profile, ++m_last_task_index, url, fileName, start_time, end_time, this);

    connect(task, &TaskInfo::errorHappened, this, &PvrManager::onTaskError);

    m_tasks.insert(QString::number(task->m_id), task);

    DEBUG() << task->m_url << task->m_file_name << task->m_start_time << task->m_end_time;

    TaskInfo::ErrorCode result = task->scheduleStart();
    if(result != TaskInfo::ERROR_SUCCESSFUL)
        return QString::number(result);

    return QString::number(task->m_id);
}
开发者ID:mvasilchuk,项目名称:yasem-mag-api,代码行数:83,代码来源:pvrmanager.cpp


注:本文中的TaskInfo::scheduleStart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。