[mythtv] Programmatically schedule recordings at backend

Kunal Kandekar kunalkandekar at gmail.com
Tue Feb 23 16:01:27 UTC 2010


I am trying to create new scheduled recordings at mythbackend as part
of a UPnP Scheduled Recording Services component. However, I'm having
no luck... the following code ends up making an entry in the
"oldrecorded" table rather than the "record" table, and so the program
never gets recorded (the code has been simplified by removing
extraneous details and basic error checking):

    // srsObject is constructed from a UPnP request
    ProgramInfo *progInfo  = new ProgramInfo;
    progInfo->title              = srsObject->m_sTitle;
    progInfo->description   = progInfo->title;
    progInfo->recpriority    = 1;
    progInfo->chanid         = srsObject->chanid;
    int chanid                   = progInfo->chanid.toUInt();
    progInfo->sourceid      = ChannelUtil::GetSourceIDForChannel(chanid);
    progInfo->chanstr        = ChannelUtil::GetChanNum(chanid);
    progInfo->chansign      = ChannelUtil::GetCallsign(chanid);
    progInfo->channame    = ChannelUtil::GetServiceName(chanid);

    progInfo->startts          =
SRSObject::StringToDateTime(srsObject->scheduledStartDateTime, &days);
    int secs                      =
    progInfo->endts           = progInfo->startts.addSecs(secs);
    progInfo->hostname     = gContext->GetHostName();

    ScheduledRecording *record = new ScheduledRecording();
    record->Save(); //should write into record table, but doesn't

    QStringList prog;
    MythEvent me("SCHEDULER_ADD_RECORDING", prog);

    VERBOSE(VB_UPNP, QString(" |-- New prog [%1]").arg(prog.join(",")));

    //2010-02-23 10:17:20.397  |-- New prog

Creating recordings via mythfrontend works just fine.

I am hesitant to make an entry directly into the "record" database
table via SQL, because that's not how it is done currently, and so I
think that would not be the correct way to do it. For instance, I
haven't fully understood all the DB interactions involved, so I'm not
sure if other tables would need to be updated as well.

A caveat: I don't have EPG information in my database for the channels
I am testing this code with. However, since manual recording of those
channels via mythfrontend works, I don't think that is the issue.

Could anyone please tell me what I am doing wrong? Alternatively,
could you point me to the relevant source files to look at? I am
working with 0.22 source, and have been looking at the following files
so far:


More information about the mythtv-dev mailing list