Ticket #3126: patch
File patch, 7.5 KB (added by , 17 years ago) |
---|
-
programs/mythbackend/mainserver.cpp
627 627 { 628 628 VERBOSE(VB_IMPORTANT, "Got 'OK' out of sequence."); 629 629 } 630 else if (command == "START_TRANSCODE_DISK" || command == "STOP_TRANSCODE_DISK") 631 { 632 preHandleTranscodeDisk(command, tokens, pbs->getSocket()); 633 } 630 634 else if (command == "UNKNOWN_COMMAND") 631 635 { 632 636 VERBOSE(VB_IMPORTANT, "Got 'UNKNOWN_COMMAND' out of sequence."); … … 3653 3657 gContext->RefreshBackendConfig(); 3654 3658 3655 3659 QStringList retlist = "OK"; 3656 SendResponse(socket, retlist); 3660 SendResponse(socket, retlist); 3657 3661 } 3658 3662 3663 int MainServer::HandleTranscodeDisk(int kind, QString chanid,\ 3664 QDateTime starttime, QString profile) 3665 { 3666 if (!JobQueue::IsJobQueuedOrRunning(JOB_TRANSCODE, chanid, starttime)) 3667 { 3668 if (kind == 0) 3669 { 3670 QString jobHost = ""; 3671 if (gContext->GetNumSetting("JobsRunOnRecordHost", 0)) 3672 jobHost = gContext->GetHostName(); //set as local hostname 3673 3674 if ( SetTranscodeProfile(profile, chanid, starttime) == 0 ) 3675 JobQueue::QueueJob(JOB_TRANSCODE, chanid, starttime, 3676 "", "", "", JOB_USE_CUTLIST); 3677 else return -1; 3678 } 3679 } 3680 else 3681 if (kind == 1) 3682 //Cancell job (kind == 1) 3683 JobQueue::ChangeJobCmds(JOB_TRANSCODE, chanid, 3684 starttime, JOB_STOP); 3685 3686 return 0; 3687 } 3688 3689 void MainServer::preHandleTranscodeDisk(QString command, QStringList tokens, MythSocket *socket) 3690 { 3691 QStringList retlist; 3692 // 3 = command, from, to 3693 // 2 = command, from (then it'll overwrite the original one) 3694 if ( ( (tokens.size() < 3) && (command == "START_TRANSCODE_DISK") ) || 3695 ( (tokens.size() != 2) && (command == "STOP_TRANSCODE_DISK") ) ) 3696 VERBOSE(VB_IMPORTANT, "Bad Transcode query"); 3697 else 3698 { 3699 QStringList from = QStringList::split("_", tokens[1]); 3700 QStringList date = QStringList::split(".", from[1]); 3701 QString chanid = from[0]; 3702 3703 //create the right date format 3704 char* temp = (char*)malloc(sizeof(char) * date[0].length()); 3705 strncpy(temp, date[0].ascii(), date[0].length()); 3706 3707 char* temp1 = (char*)malloc(sizeof(char) * 20); 3708 snprintf(temp1, 20, "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s\n", temp, temp+4,\ 3709 temp+6, temp+8, temp+10, temp+12); 3710 temp1[19] = '\0'; 3711 3712 QString date_iso = QString(temp1); 3713 QDateTime starttime = QDateTime::fromString(date_iso, Qt::ISODate); 3714 free(temp); 3715 free(temp1); 3716 3717 int result; 3718 QStringList strlist; 3719 3720 if (command == "START_TRANSCODE_DISK") 3721 { 3722 //tokens[2] = PROFILE FOR TRANSCODING 3723 VERBOSE(VB_IMPORTANT,"Starting transcode of file on disk."); 3724 QString profile = QString(""); 3725 uint i; 3726 for (i=2; i <= tokens.size(); i++) 3727 { 3728 profile.append(tokens[i]); 3729 if (i < (tokens.size()-1) ) 3730 profile.append(" "); 3731 } 3732 3733 result = HandleTranscodeDisk(0, chanid, starttime, profile); 3734 } 3735 else if (command == "STOP_TRANSCODE_DISK") 3736 { 3737 VERBOSE(VB_IMPORTANT,"Stop transcode of file on disk."); 3738 result = HandleTranscodeDisk(1, chanid, starttime, NULL); 3739 } 3740 3741 if (result == 0) 3742 strlist << "OK"; 3743 else 3744 strlist << "ERROR"; 3745 3746 SendResponse(socket, strlist); 3747 return; 3748 } 3749 } 3750 3751 3659 3752 void MainServer::HandleBlockShutdown(bool blockShutdown, PlaybackSock *pbs) 3660 3753 { 3661 3754 pbs->setBlockShutdown(blockShutdown); -
programs/mythbackend/mainserver.h
67 67 } DeleteStruct; 68 68 69 69 void ProcessRequestWork(MythSocket *sock); 70 void preHandleTranscodeDisk(QString command, QStringList tokens,\ 71 MythSocket *socket); 72 int HandleTranscodeDisk(int kind, QString chanid,\ 73 QDateTime starttime, QString profile); 70 74 void HandleAnnounce(QStringList &slist, QStringList commands, 71 75 MythSocket *socket); 72 76 void HandleDone(MythSocket *socket); -
programs/mythbackend/backendutil.cpp
287 287 } 288 288 } 289 289 290 int SetTranscodeProfile(QString profile, QString chanid, QDateTime recstartts) 291 { 292 if(profile == "Default") // use whatever is already in the transcoder 293 return 0; 294 295 MSqlQuery query(MSqlQuery::InitCon()); 296 297 if(profile == "Autodetect") 298 { 299 query.prepare("UPDATE recorded " 300 "SET transcoder = 0 " 301 "WHERE chanid = :CHANID " 302 "AND starttime = :START"); 303 query.bindValue(":CHANID", chanid); 304 query.bindValue(":START", recstartts); 305 306 if (!query.exec()) 307 { 308 MythContext::DBError("MythBackendUtil: unable to update transcoder " 309 "in recorded table", query); 310 return -1; 311 } 312 } 313 else 314 { 315 MSqlQuery pidquery(MSqlQuery::InitCon()); 316 pidquery.prepare("SELECT r.id " 317 "FROM recordingprofiles r, profilegroups p " 318 "WHERE r.profilegroup = p.id " 319 "AND p.name = 'Transcoders' " 320 "AND r.name = :PROFILE "); 321 pidquery.bindValue(":PROFILE", profile); 322 323 if (pidquery.exec() && pidquery.isActive() && pidquery.next()) 324 { 325 query.prepare("UPDATE recorded " 326 "SET transcoder = :TRANSCODER " 327 "WHERE chanid = :CHANID " 328 "AND starttime = :START"); 329 query.bindValue(":TRANSCODER", pidquery.value(0).toInt()); 330 query.bindValue(":CHANID", chanid); 331 query.bindValue(":START", recstartts); 332 333 if (!query.exec()) 334 { 335 MythContext::DBError("MythBackendUtil: unable to update transcoder " 336 "in recorded table", query); 337 return -1; 338 } 339 } 340 else 341 { 342 MythContext::DBError("MythBackend: unable to query transcoder " 343 "profile ID", query); 344 return -1; 345 } 346 } 347 348 return 0; 349 } 350 290 351 /* vim: set expandtab tabstop=4 shiftwidth=4: */ -
programs/mythbackend/backendutil.h
13 13 void GetFilesystemInfos(QMap<int, EncoderLink*> *tvList, 14 14 vector <FileSystemInfo> &fsInfos); 15 15 16 int SetTranscodeProfile(QString profile, QString chanid, QDateTime recstartts); 17 16 18 #endif 17 19 18 20 /* vim: set expandtab tabstop=4 shiftwidth=4: */