Esempio n. 1
0
static int RebuildSeekTable(ProgramInfo *pginfo, int jobid)
{
    QString filename = get_filename(pginfo);

    if (!DoesFileExist(pginfo))
    {
        // file not found on local filesystem
        // assume file is in Video storage group on local backend
        // and try again

        filename = QString("myth://Videos@%1/%2")
                            .arg(gCoreContext->GetHostName()).arg(filename);
        pginfo->SetPathname(filename);
        if (!DoesFileExist(pginfo))
        {
            LOG(VB_GENERAL, LOG_ERR,
                "Unable to find file in defined storage paths.");
            return GENERIC_EXIT_PERMISSIONS_ERROR;
        }
    }

    // Update the file size since mythcommflag --rebuild is often used in user
    // scripts after transcoding or other size-changing operations
    UpdateFileSize(pginfo);

    RingBuffer *tmprbuf = RingBuffer::Create(filename, false);
    if (!tmprbuf)
    {
        LOG(VB_GENERAL, LOG_ERR,
            QString("Unable to create RingBuffer for %1").arg(filename));
        return GENERIC_EXIT_PERMISSIONS_ERROR;
    }

    MythCommFlagPlayer *cfp = new MythCommFlagPlayer(
                                    (PlayerFlags)(kAudioMuted | kVideoIsNull |
                                                  kDecodeNoDecode | kNoITV));
    PlayerContext *ctx = new PlayerContext(kFlaggerInUseID);
    ctx->SetPlayingInfo(pginfo);
    ctx->SetRingBuffer(tmprbuf);
    ctx->SetPlayer(cfp);
    cfp->SetPlayerInfo(NULL, NULL, ctx);

    if (progress)
    {
        QString time = QDateTime::currentDateTime().toString(Qt::TextDate);
        cerr << "Rebuild started at " << qPrintable(time) << endl;
    }

    cfp->RebuildSeekTable(progress);

    if (progress)
    {
        QString time = QDateTime::currentDateTime().toString(Qt::TextDate);
        cerr << "Rebuild completed at " << qPrintable(time) << endl;
    }

    delete ctx;

    return GENERIC_EXIT_OK;
}
Esempio n. 2
0
static int RebuildSeekTable(ProgramInfo *pginfo, int jobid)
{
    if (!DoesFileExist(pginfo))
        return GENERIC_EXIT_PERMISSIONS_ERROR;

    QString filename = get_filename(pginfo);

    RingBuffer *tmprbuf = RingBuffer::Create(filename, false);
    if (!tmprbuf)
    {
        LOG(VB_GENERAL, LOG_ERR,
            QString("Unable to create RingBuffer for %1").arg(filename));
        return GENERIC_EXIT_PERMISSIONS_ERROR;
    }

    MythCommFlagPlayer *cfp = new MythCommFlagPlayer();
    PlayerContext *ctx = new PlayerContext(kFlaggerInUseID);
    AVSpecialDecode sp = (AVSpecialDecode) (kAVSpecialDecode_LowRes         |
                                            kAVSpecialDecode_SingleThreaded |
                                            kAVSpecialDecode_NoLoopFilter);

    ctx->SetSpecialDecode(sp);
    ctx->SetPlayingInfo(pginfo);
    ctx->SetRingBuffer(tmprbuf);
    ctx->SetPlayer(cfp);
    cfp->SetPlayerInfo(NULL, NULL, true, ctx);

    time_t time_now;
    if (progress)
    {
        time_now = time(NULL);
        cerr << "Rebuild started at " << ctime(&time_now) << endl;
    }

    cfp->RebuildSeekTable(progress);

    if (progress)
    {
        time_now = time(NULL);
        cerr << "Rebuild completed at " << ctime(&time_now) << endl;
    }

    delete ctx;

    return GENERIC_EXIT_OK;
}
Esempio n. 3
0
static int BuildVideoMarkup(ProgramInfo *program_info, bool useDB)
{
    QString filename;

    if (program_info->IsMythStream())
        filename = program_info->GetPathname();
    else
        filename = get_filename(program_info);

    RingBuffer *tmprbuf = RingBuffer::Create(filename, false);
    if (!tmprbuf)
    {
        LOG(VB_GENERAL, LOG_ERR,
            QString("Unable to create RingBuffer for %1").arg(filename));
        return GENERIC_EXIT_PERMISSIONS_ERROR;
    }

    if (useDB && !MSqlQuery::testDBConnection())
    {
        LOG(VB_GENERAL, LOG_ERR,
            "Unable to open DB connection for commercial flagging.");
        delete tmprbuf;
        return GENERIC_EXIT_DB_ERROR;
    }

    MythCommFlagPlayer *cfp = new MythCommFlagPlayer();
    PlayerContext *ctx = new PlayerContext("seektable rebuilder");
    ctx->SetSpecialDecode(kAVSpecialDecode_NoDecode);
    ctx->SetPlayingInfo(program_info);
    ctx->SetRingBuffer(tmprbuf);
    ctx->SetPlayer(cfp);
    cfp->SetPlayerInfo(NULL, NULL, true, ctx);
    cfp->RebuildSeekTable(progress);

    if (progress)
        cerr << "Rebuilt" << endl;

    delete ctx;

    return GENERIC_EXIT_OK;
}