[mythtv] Programmatically schedule recordings at backend

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


Hi,

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                      =
SRSObject::DurationToSecs(srsObject->scheduledDuration);
    progInfo->endts           = progInfo->startts.addSecs(secs);
    progInfo->hostname     = gContext->GetHostName();

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

    QStringList prog;
    progInfo->ToStringList(prog);
    MythEvent me("SCHEDULER_ADD_RECORDING", prog);
    gContext->dispatch(me);

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

    //2010-02-23 10:17:20.397  |-- New prog
[Spanish,,Spanish,,5002,2,5002,,,0,0,1266938280,1266938580,0,0,0,kunaldevmini,5,0,0,1,0,0,0,15,6,1266938240,1266938240,0,0,Default,0,,,,1266938240,0.000000,,0,Default,0,0,Default,0,0,0,]

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:
programs/mythbackend/scheduler.cpp
programs/mythfrontend/manualschedule.cpp

Thanks!
Kunal


More information about the mythtv-dev mailing list