34 #include "trm/TunerState.h"
36 #include "trm/JsonEncoder.h"
42 #include "Executors.h"
45 std::string GetDeviceId();
61 static bool RequireTokenInRequest(
void) {
65 static bool allowLinearRecordSharing(
void) {
69 static bool enableConflictsForHotRecording(
void) {
82 static bool allowOverlapRecordings(
void) {
87 void FindConflictsForRequestedLive(
const ReserveTuner &request, ReserveTunerResponse::ConflictCT &conflicts)
99 TunerReservation::TokenList R_tokens_on_R_tuners;
100 TunerReservation::TokenList R_tokens_on_F_tuners;
101 TunerReservation::TokenList L_tokens_on_Self_tuner;
102 TunerReservation::TokenList R_tokens_on_Self_tuner;
104 Tuner::IdList tunerIds;
107 Filter<ByActivity>(Activity::kRecord,
108 Manager::getInstance().
109 getReservationTokens(R_tokens_on_R_tuners,
110 Filter<ByTunerState>(TunerState::kRecord, Manager::getInstance().getTunerIds(tunerIds))));
112 Filter<ByActivity>(Activity::kRecord,
113 Manager::getInstance().
114 getReservationTokens(R_tokens_on_F_tuners,
115 Filter<ByTunerState>(TunerState::kFree, Manager::getInstance().getTunerIds(tunerIds))));
121 Filter<ByDevice>(request.getDevice(),
122 Filter<ByActivity>(Activity::kLive,
123 Manager::getInstance().getReservationTokens(L_tokens_on_Self_tuner, Manager::getInstance().getTunerIds(tunerIds))));
125 Assert(L_tokens_on_Self_tuner.size() <= 1);
127 if (L_tokens_on_Self_tuner.size() == 1) {
129 Filter<ByActivity>(Activity::kRecord,
130 Manager::getInstance().getReservationTokens(R_tokens_on_Self_tuner,
131 Manager::getInstance().getParent(*L_tokens_on_Self_tuner.begin())));
136 const int kStateActive = TunerReservation::ACTIVE;
137 Filter<ByReservationState> (kStateActive, R_tokens_on_R_tuners);
138 Filter<ByReservationState> (kStateActive, R_tokens_on_F_tuners);
139 Filter<ByReservationState> (kStateActive, R_tokens_on_Self_tuner);
142 TunerReservation::TokenList::const_iterator it;
144 for (it = R_tokens_on_R_tuners.begin(); it != R_tokens_on_R_tuners.end(); it++) {
145 conflicts.push_back(Manager::getInstance().getReservation(*it));
148 for (it = R_tokens_on_F_tuners.begin(); it != R_tokens_on_F_tuners.end(); it++) {
149 conflicts.push_back(Manager::getInstance().getReservation(*it));
152 for (it = R_tokens_on_Self_tuner.begin(); it != R_tokens_on_Self_tuner.end(); it++) {
153 conflicts.push_back(Manager::getInstance().getReservation(*it));
157 void FindConflictsForRequestedRecord(
const ReserveTuner &request, ReserveTunerResponse::ConflictCT &conflicts)
165 TunerReservation::TokenList L_tokens_on_L_tuners;
166 Tuner::IdList tunerIds;
171 Filter<ByInConflict>(
false,
172 Filter<ByActivity>(Activity::kLive,
173 Manager::getInstance().
174 getReservationTokens(L_tokens_on_L_tuners,
175 Filter<ByTunerState>(TunerState::kLive, Manager::getInstance().getTunerIds(tunerIds))))));
176 if (L_tokens_on_L_tuners.size() != 0) {
182 TunerReservation::TokenList::iterator it = L_tokens_on_L_tuners.begin();
183 while (it != L_tokens_on_L_tuners.end()) {
184 TunerReservation::TokenList R_tokens_on_L_tuner;
185 R_tokens_on_L_tuner.clear();
186 Filter<ByActivity>(Activity::kRecord,
187 Manager::getInstance().
188 getReservationTokens(R_tokens_on_L_tuner,
189 Manager::getInstance().getParent(*it)));
190 if (R_tokens_on_L_tuner.size() != 0) {
192 it = L_tokens_on_L_tuners.erase(it);
206 Filter<ByInConflict>(
false,
207 Filter<ByActivity>(Activity::kLive,
208 Manager::getInstance().
209 getReservationTokens(L_tokens_on_L_tuners,
210 Filter<ByTunerState>(TunerState::kLive, Manager::getInstance().getTunerIds(tunerIds)))));
214 TunerReservation::TokenList::iterator it = L_tokens_on_L_tuners.begin();
215 while (it != L_tokens_on_L_tuners.end()) {
216 TunerReservation::TokenList R_tokens_on_L_tuner;
217 R_tokens_on_L_tuner.clear();
218 Filter<ByActivity>(Activity::kRecord,
219 Manager::getInstance().
220 getReservationTokens(R_tokens_on_L_tuner,
221 Manager::getInstance().getParent(*it)));
222 if (R_tokens_on_L_tuner.size() != 0) {
224 it = L_tokens_on_L_tuners.erase(it);
237 TunerReservation::TokenList::const_iterator it;
240 it = L_tokens_on_L_tuners.begin();
241 if (it != L_tokens_on_L_tuners.end()) {
242 conflicts.push_back(Manager::getInstance().getReservation(*it));
245 if (conflicts.size() == 0) {
249 TunerReservation::TokenList R_tokens_on_H_tuners_That_Ends_Before_New_StartTime;
252 Filter<ByActivity>(Activity::kRecord,
253 Manager::getInstance().
254 getReservationTokens(R_tokens_on_H_tuners_That_Ends_Before_New_StartTime,
255 Filter<ByTunerState>(TunerState::kHybrid, Manager::getInstance().getTunerIds(tunerIds)))));
259 it = R_tokens_on_H_tuners_That_Ends_Before_New_StartTime.begin();
261 Log() <<
"Found A future conflict to return \r\n" << std::endl;
262 TunerReservation::TokenList L_tokens_on_H_tuners;
265 L_tokens_on_H_tuners.clear();
267 if (it != R_tokens_on_H_tuners_That_Ends_Before_New_StartTime.end()) {
268 Filter<ByActivity>(Activity::kLive,
269 Manager::getInstance().getReservationTokens(L_tokens_on_H_tuners,
270 Filter<ByTunerId>(Manager::getInstance().getParent(*it), Manager::getInstance().getTunerIds(tunerIds))));
272 Assert(tunerIds.size() == 1);
274 Assert(L_tokens_on_H_tuners.size() == 1);
275 conflicts.push_back(Manager::getInstance().getReservation(*L_tokens_on_H_tuners.begin()));
310 response.getStatus() +=
"Start reservation process for <Live> \r\n";
313 const int alwaysAllowFuture = 1;
314 const int firstThreshold = (60 * 1000);
315 const int secondThreshold = (300 * 1000);
322 if (alwaysAllowFuture || diff <= firstThreshold) {
323 if (!alwaysAllowFuture) {
324 Log() <<
"Requesting <Live> reservation is less than 60 seoncds in the future...this is now allowed\r\n";
325 response.getStatus() +=
"Requesting <Live> reservation is less than 60 seconds in the future...this is now allowed \r\n";
328 Log() <<
"Requesting <Live> reservation starts from 'NOW'\r\n";
329 response.getStatus() +=
"Requesting <Live> reservation starts from 'NOW'\r\n";
335 Log() <<
"Requesting <Live> reservation is more than 60 seoncds in the future...this is not allowed\r\n";
336 response.getStatus() +=
"Requesting <Live> reservation is more than 60 seconds in the future...this is not allowed \r\n";
337 response.getStatus() = ResponseStatus::kMalFormedRequest;
347 std::string tokenToAddTo =
"";
348 std::string tokenToRelease =
"";
349 std::string tunerToAddTo =
"";
350 std::string tokenToResurrect =
"";
353 int isResurrect = (request.
getResurrect().compare(
"true") == 0);
356 Tuner::IdList tunerIds;
357 TunerReservation::TokenList tokens;
361 Filter<ByDevice>(request.getDevice(),
362 Filter<ByActivity>(Activity::kLive,
363 Manager::getInstance().getReservationTokens(tokens, Manager::getInstance().getTunerIds(tunerIds))));
365 if (tokens.size() != 0) {
366 Log() <<
"Found Existing <Live> reservation owned by requesting device\r\n";
367 response.getStatus() +=
"Found Existing <Live> reservation owned by requesting device \r\n";
369 Assert(tokens.size() == 1);
370 tokenToRelease = (*tokens.begin());
374 if((isResurrect) && (!tokenToAddTo.empty()))
376 tokenToResurrect = tokenToAddTo;
378 Log() <<
"Existing <Live> reservation does not exist\r\n";
379 Log() <<
"Use Resurrect Token = " << tokenToResurrect << std::endl;
384 if ((!tokenToRelease.empty()) && (Manager::getInstance().getReservation(tokenToRelease).state == TunerReservation::IDLE)) {
385 Log() <<
"Existing <Live> reservation is not yet started\r\n";
386 response.getStatus() +=
"Existing <Live> reservation is not yet started \r\n";
387 response.getStatus() = ResponseStatus::kInvalidState;
391 if ( ((tokenToRelease.empty()) && (!tokenToAddTo.empty())) ||
392 ((!tokenToRelease.empty()) && (Manager::getInstance().getReservation(tokenToRelease).state == TunerReservation::IDLE)) ||
393 ((!tokenToRelease.empty()) && (!tokenToAddTo.empty()) && (tokenToRelease.compare(tokenToAddTo) != 0)))
395 Log() <<
"Existing <Live> reservation does not exist\r\n";
396 response.getStatus() +=
"Existing <Live> reservation does not match that in request \r\n";
397 response.getStatus() = ResponseStatus::kInvalidToken;
401 tokenToAddTo = tokenToRelease;
403 Log() <<
"tokenToRelease = " << tokenToRelease << std::endl;
404 Log() <<
"tokenToAddTo = " << tokenToAddTo << std::endl;
406 if (!tokenToRelease.empty()) {
410 compare(Manager::getInstance().getReservation(tokenToRelease).getServiceLocator()) == 0) {
411 Log() <<
"Existing <Live> reservation has same locator, reuse it \r\n";
412 response.getStatus() +=
"Existing <Live> reservation has same locator, reuse it \r\n";
413 tunerToAddTo = Manager::getInstance().getTuner(Manager::getInstance().getParent(tokenToRelease)).getId();
419 if (tunerToAddTo.empty()) {
420 Tuner::IdList tunerIds;
421 TunerReservation::TokenList tokens;
425 Log() <<
"look for R tuner that has tokens of same locator \r\n";
426 response.getStatus() +=
"look for R tuner that has tokens of same locator \r\n";
428 Filter<ByTunerState>(TunerState::kRecord, Manager::getInstance().getTunerIds(tunerIds));
430 if (tunerIds.size() != 0) {
431 Tuner::IdList::const_iterator tidIT = tunerIds.begin();
432 while (tidIT != tunerIds.end()) {
435 Manager::getInstance().getTuner(*tidIT).getReservation(Activity::kLive, TunerReservation::ACTIVE);
442 if (Manager::getInstance().
444 getReservation(Activity::kRecord, TunerReservation::ACTIVE).
447 Log() <<
"found R tuner that has tokens of same locator \r\n";
448 response.getStatus() +=
"found R tuner that has tokens of same locator \r\n";
449 tunerToAddTo = *tidIT;
460 std::string fallbackTuner =
"";
462 if (tunerToAddTo.empty()) {
463 if (((!tokenToRelease.empty())) &&
464 Manager::getInstance().
465 getTuner(Manager::getInstance().getParent(tokenToRelease)).
466 getState() == TunerState::kLive) {
470 if (Manager::getInstance().
471 getTuner(Manager::getInstance().getParent(tokenToRelease)).
472 getReservation(Activity::kRecord, TunerReservation::IDLE).
475 Log() <<
"Current L tuner that has Future R token of same locator \r\n";
476 response.getStatus() +=
"Current L tuner that has Future R token of same locator \r\n";
477 tunerToAddTo = Manager::getInstance().getTuner(Manager::getInstance().getParent(tokenToRelease)).getId();
480 Log() <<
"Current L tuner that has Future R token of different locator \r\n";
481 response.getStatus() +=
"Current L tuner that has Future R token of different locator \r\n";
482 fallbackTuner = Manager::getInstance().getTuner(Manager::getInstance().getParent(tokenToRelease)).getId();
488 Log() <<
"Current L tuner that no Future R tokens\r\n";
489 response.getStatus() +=
"Current L tuner that no Future R tokens \r\n";
490 fallbackTuner = Manager::getInstance().getTuner(Manager::getInstance().getParent(tokenToRelease)).getId();
498 if (tunerToAddTo.empty()) {
500 Tuner::IdList tunerIds;
501 TunerReservation::TokenList tokens;
505 Log() <<
"look for F tuner that has future tokens of same locator \r\n";
506 response.getStatus() +=
"look for F tuner that has future tokens of same locator \r\n";
508 Filter<ByTunerState>(TunerState::kFree, Manager::getInstance().getTunerIds(tunerIds));
510 if (tunerIds.size() != 0) {
511 Tuner::IdList::const_iterator tidIT = tunerIds.begin();
512 while (tidIT != tunerIds.end()) {
515 Manager::getInstance().getTuner(*tidIT).getReservation(Activity::kLive, TunerReservation::ACTIVE);
522 Manager::getInstance().getTuner(*tidIT).getReservation(Activity::kRecord, TunerReservation::ACTIVE);
530 if (Manager::getInstance().
532 getReservation(Activity::kRecord, TunerReservation::IDLE).
535 Log() <<
"found F tuner that has future R tokens of same locator \r\n";
536 response.getStatus() +=
"found F tuner that has future R tokens of same locator \r\n";
537 tunerToAddTo = *tidIT;
553 if (tunerToAddTo.empty()) {
554 Tuner::IdList tunerIds;
557 Log() <<
"look for F tuner that has no future tokens \r\n";
558 response.getStatus() +=
"look for F tuner that has no future tokens \r\n";
560 Filter<ByTunerState>(TunerState::kFree, Manager::getInstance().getTunerIds(tunerIds));
562 if (tunerIds.size() != 0) {
563 Tuner::IdList::const_iterator tidIT = tunerIds.begin();
564 while (tidIT != tunerIds.end()) {
567 Manager::getInstance().getTuner(*tidIT).getReservation(Activity::kLive, TunerReservation::ACTIVE);
574 Manager::getInstance().getTuner(*tidIT).getReservation(Activity::kRecord, TunerReservation::ACTIVE);
580 TunerReservation::TokenList tokens;
582 Manager::getInstance().getTuner(*tidIT).getReservationTokens(tokens);
583 if (tokens.size() == 0) {
584 tunerToAddTo = *tidIT;
593 if (!tunerToAddTo.empty()) {
597 if (request.getDevice().compare(GetDeviceId()) != 0) {
598 Tuner::IdList tunerIds;
601 Filter<ByTunerState>(TunerState::kFree, Manager::getInstance().getTunerIds(tunerIds));
602 if ((tunerIds.size() == 1) && (tunerToAddTo.compare(Manager::getInstance().getLocalTuner()) == 0)) {
603 Log() <<
"There are (" << tunerIds.size() <<
" - 1) F tuners (" << tunerToAddTo <<
") to move reservedDeviceId to for remote device" << std::endl;
604 if (fallbackTuner.empty()) {
607 Filter<ByTunerState>(TunerState::kRecord, Manager::getInstance().getTunerIds(tunerIds));
608 Log() <<
"There are (" << tunerIds.size() <<
" R tuners to move reservedDeviceId to for remote device" << std::endl;
609 if (tunerIds.size() >= 1) {
611 Log() <<
"set reservedDeviceId to R tuner" << std::endl;
612 Manager::getInstance().setLocalTuner(*(tunerIds.begin()));
625 if (tunerToAddTo.empty()) {
626 tunerToAddTo = fallbackTuner;
629 if (tunerToAddTo.empty()) {
631 Tuner::IdList tunerIds;
634 Log() <<
"look for F tuner that has ANY future tokens (of diff serviceLocator) \r\n";
635 response.getStatus() +=
"look for F tuner that has ANY future tokens (of diff serviceLocator) \r\n";
637 Filter<ByTunerState>(TunerState::kFree, Manager::getInstance().getTunerIds(tunerIds));
639 if (tunerIds.size() != 0) {
640 Tuner::IdList::const_iterator tidIT = tunerIds.begin();
641 while (tidIT != tunerIds.end()) {
643 Manager::getInstance().getTuner(*tidIT).getReservation(Activity::kRecord, TunerReservation::IDLE);
644 Log() <<
"found F tuner that has future R tokens of diff locator \r\n";
645 response.getStatus() +=
"found F tuner that has future R tokens of diff locator \r\n";
646 tunerToAddTo = *tidIT;
658 if (!tunerToAddTo.empty()) {
666 if (tunerToAddTo.compare(fallbackTuner) == 0) {
668 Log() <<
"[reserveLocal] Reusing current tuner. No changes" << std::endl;
669 if ((request.getDevice().compare(GetDeviceId()) == 0) && Manager::getInstance().getLocalTuner().empty()) {
670 Log() <<
"[reserveLocal] set reservedDeviceId for local tuner" << std::endl;
671 Manager::getInstance().setLocalTuner(tunerToAddTo);
674 else if (!GetDeviceId().empty()) {
676 Log() <<
"[reserveLocal] switching to new tuner for Live. The new tuner (Free or Record) is curently in state "
677 << (
const char *)(Manager::getInstance().getTuner(tunerToAddTo).getState().getState())
680 if (request.getDevice().compare(GetDeviceId()) == 0) {
681 Log() <<
"[reserveLocal] requester is local host, moving reservedDeviceId "
682 << GetDeviceId() <<
" from "
683 << Manager::getInstance().getLocalTuner()
684 <<
" to " << tunerToAddTo << std::endl;
686 Manager::getInstance().setLocalTuner(tunerToAddTo);
689 Log() <<
"[reserveLocal] requester is remote host" << std::endl;
696 if (tunerToAddTo.compare(Manager::getInstance().getLocalTuner()) == 0) {
698 bool foundReserved =
false;
699 if (!foundReserved) {
700 Tuner::IdList tunerIds;
703 Filter<ByTunerState>(TunerState::kFree, Manager::getInstance().getTunerIds(tunerIds));
704 if (tunerIds.size() != 0) {
705 Log() <<
"There are (" << tunerIds.size() <<
" - 1) F tuners to move reservedDeviceId to " << std::endl;
706 tunerIds.remove(tunerToAddTo);
707 if (tunerIds.size() != 0) {
708 Manager::getInstance().setLocalTuner(*tunerIds.begin());
709 foundReserved =
true;
718 if (!foundReserved) {
719 Log() <<
"There is no more F tuner to move reservedDeviceId to " << std::endl;
720 Tuner::IdList tunerIds;
723 Filter<ByTunerState>(TunerState::kRecord, Manager::getInstance().getTunerIds(tunerIds));
724 if (tunerIds.size() != 0) {
725 Log() <<
"There are (" << tunerIds.size() <<
" - 1) R tuners to move reservedDeviceId to " << std::endl;
726 tunerIds.remove(tunerToAddTo);
727 if (tunerIds.size() != 0) {
728 Manager::getInstance().setLocalTuner(*tunerIds.begin());
729 foundReserved =
true;
737 if (!foundReserved) {
738 Log() <<
"cannot find a new home for reserved tuner, reject current request " << std::endl;
745 Log() <<
"Warning: DeviceId Not available, ignore reserveDeviceId assignment " << std::endl;
746 Manager::getInstance().setLocalTuner(std::string(
""));
750 if (!tunerToAddTo.empty()) {
751 Log() <<
"Granting New Reservation to Live on tuner " << tunerToAddTo << std::endl;
754 if (!tokenToRelease.empty()) {
756 Manager::getInstance().releaseReservation(tokenToRelease,
false);
758 else if((isResurrect) && (!tokenToResurrect.empty())) {
760 Log() <<
"Granting Reservation on Live with Resurrect Token = " << tokenToResurrect << std::endl;
766 const bool considerFutureToken =
false;
767 if(!Manager::getInstance().getTuner(tunerToAddTo).getServiceLocator(considerFutureToken).empty()) {
769 compare(Manager::getInstance().getTuner(tunerToAddTo).getServiceLocator(considerFutureToken)) != 0) {
770 Log() <<
"Modify response locator from " << newReservation.
getServiceLocator() <<
" to " << Manager::getInstance().getTuner(tunerToAddTo).getServiceLocator(considerFutureToken) <<
"\r\n";
771 response.getStatus() +=
"Modify response locator\r\n";
772 newReservation.
setServiceLocator(Manager::getInstance().getTuner(tunerToAddTo).getServiceLocator(considerFutureToken));
776 Manager::getInstance().addReservation(newReservation, tunerToAddTo);
777 printf(
"===============+Reservation %s from Connection %x ADDED\r\n", newReservation.
getReservationToken().c_str(), clientId);
778 Manager::getInstance().setReservationAttributes(newReservation.
getReservationToken(), ReservationAttributes(clientId));
780 response.setTunerReservation(newReservation);
781 response.getStatus() = ResponseStatus::kOk;
784 response.getStatus() +=
"Error: Reservation Failed with conflicts\r\n";
785 response.getStatus() = ResponseStatus::kGeneralError;
786 FindConflictsForRequestedLive(request, response.getConflicts());
789 if (response.getConflicts().size() == 0){
790 response.getStatus() = ResponseStatus::kInsufficientResource;
793 response.getStatus() = ResponseStatus::kOk;
804 Tuner::IdList tunerIds;
805 TunerReservation::TokenList tokens;
806 std::string tokenToRenew =
"";
809 Log() <<
"Look for Existing <Record> reservation for the same locator\r\n";
810 response.getStatus() +=
"Look for Existing <Record> reservation for the same locator\r\n";
814 Filter<ByActivity>(Activity::kRecord,
817 Manager::getInstance().getReservationTokens(tokens, Manager::getInstance().getTunerIds(tunerIds)))));
819 if (tokens.size() != 0) {
820 Log() <<
"Found Existing <Record> reservation for SrcID "
824 SafeAssert(tokens.size() == 1);
826 response.getStatus() +=
"Found Existing <Record> reservation : ";
827 response.getStatus() += (*tokens.begin()).c_str();
828 response.getStatus() +=
" owned by requesting device \r\n";
830 Log() <<
"Found Existing <Record> reservation : " << (*tokens.begin()) <<
" owned by requesting device \r\n";
833 tokenToRenew = (*tokens.begin());
841 Log() <<
"Token to renew is " << tokenToRenew << std::endl;
844 tunerIds.insert(tunerIds.begin(), Manager::getInstance().getParent(tokenToRenew));
846 if (!tokenToRenew.empty()) {
847 Manager::getInstance().releaseReservation(tokenToRenew,
false);
848 Manager::getInstance().addReservation(request.
getTunerReservation(), (*(tunerIds.begin())));
857 Log() <<
"No Existing <Record> reservation owned by requesting device\r\n";
858 response.getStatus() +=
"No Existing <Record> reservation owned by requesting device \r\n";
860 response.getStatus() = ResponseStatus::kInvalidToken;
867 response.getStatus() +=
"Start reservation process for <Recording> \r\n";
869 std::string tunerToAddTo =
"";
886 Log() <<
"Renew existing token \r\n";
887 response.getStatus() +=
"Renew existing token \r\n";
888 renewRecord(request, response, clientId);
894 Tuner::IdList tunerIds;
897 Manager::getInstance().getTunerIds(tunerIds);
898 Tuner::IdList::const_iterator tidIT = tunerIds.begin();
899 while (tidIT != tunerIds.end()) {
901 Manager::getInstance().getTuner(*tidIT).getReservation(
903 TunerReservation::ACTIVE,
913 if(!Policy::allowOverlapRecordings()) {
929 Tuner::IdList tunerIds;
932 Manager::getInstance().getTunerIds(tunerIds);
933 Tuner::IdList::const_iterator tidIT = tunerIds.begin();
934 while (tidIT != tunerIds.end()) {
936 Manager::getInstance().getTuner(*tidIT).getReservation(
938 TunerReservation::IDLE,
940 Log() <<
"There is already an pending recording on locator "
942 <<
" on tuner " << tunerToAddTo
949 tunerToAddTo = *tidIT;
959 if (!Policy::allowOverlapRecordings()) Assert(count <= 1);
962 if (tunerToAddTo.empty())
964 Tuner::IdList tunerIds;
965 TunerReservation::TokenList tokens;
967 Log() <<
"First look for H tuner whose R end time is before the new start time and whose srcId is same \r\n";
968 response.getStatus() +=
"First look for H tuner whose R end time is before the new start time and whose srcId is same \r\n";
971 Filter<ByTunerEndBefore>(endTime,
972 Filter<ByTunerState>(TunerState::kHybrid, Manager::getInstance().getTunerIds(tunerIds))));
974 if (tunerIds.size() != 0) {
975 Log() <<
"Found <Hybrid> tuner of same locator for the recording \r\n";
976 response.getStatus() +=
"Found <Hybrid> tuner of same locator for the recording\r\n";
977 Assert(tunerIds.size() == 1);
978 tunerToAddTo = (*tunerIds.begin());
982 if (tunerToAddTo.empty())
984 Tuner::IdList tunerIds;
987 Log() <<
"Then look for L tuner with no <future> R who has the longest active time and whose srcId is same \r\n";
988 response.getStatus() +=
"Then look for L tuner with no <future> R who has the longest active time and whose srcId is same \r\n";
991 Filter<ByTunerState>(TunerState::kLive, Manager::getInstance().getTunerIds(tunerIds)));
993 Tuner::IdList::const_iterator tidIT = tunerIds.begin();
994 while (tidIT != tunerIds.end()) {
996 TunerReservation::TokenList tokens;
999 Manager::getInstance().getTuner(*tidIT).getReservationTokens(tokens);
1000 if (tokens.size() == 1) {
1001 if (Manager::getInstance().
1003 getServiceLocator(
false).
1005 Log() <<
"found L tuner with no <future> R who has the longest active time and whose srcId is same \r\n";
1006 response.getStatus() +=
"found L tuner with no <future> R who has the longest active time and whose srcId is same \r\n";
1007 tunerToAddTo = (*tidIT);
1015 if (tunerToAddTo.empty())
1017 Tuner::IdList tunerIds;
1020 Log() <<
"Then look for R tuner of same sourceId whose end time is before the new start time \r\n";
1021 response.getStatus() +=
"Then look for R tuner of same sourceId whose end time is before the new start time \r\n";
1025 Filter<ByTunerEndBefore>(endTime,
1026 Filter<ByTunerState>(TunerState::kRecord, Manager::getInstance().getTunerIds(tunerIds))));
1029 if (!Policy::allowOverlapRecordings()) Assert(((
int)tunerIds.size()) <= 1);
1030 if (tunerIds.size() != 0) {
1031 tunerToAddTo = (*tunerIds.begin());
1035 if (tunerToAddTo.empty())
1037 Tuner::IdList tunerIds;
1040 Log() <<
"Then look for R tuner of different sourceId whose end time is before the new start time \r\n";
1041 response.getStatus() +=
"Then look for R tuner of different sourceId whose end time is before the new start time \r\n";
1044 Filter<ByTunerEndBefore>(endTime,
1045 Filter<ByTunerState>(TunerState::kRecord, Manager::getInstance().getTunerIds(tunerIds)));
1047 if (tunerIds.size() != 0) {
1048 tunerToAddTo = (*tunerIds.begin());
1052 if (tunerToAddTo.empty())
1054 Log() <<
"Then look for F tuner with no future R \r\n";
1055 response.getStatus() +=
"Then look for F tuner with no future R \r\n";
1057 Tuner::IdList tunerIds;
1060 Filter<ByTunerState>(TunerState::kFree, Manager::getInstance().getTunerIds(tunerIds));
1062 if (tunerIds.size() != 0) {
1063 Tuner::IdList::const_iterator tidIT = tunerIds.begin();
1064 while (tidIT != tunerIds.end()) {
1067 Manager::getInstance().getTuner(*tidIT).getReservation(Activity::kLive, TunerReservation::ACTIVE);
1074 Manager::getInstance().getTuner(*tidIT).getReservation(Activity::kRecord, TunerReservation::ACTIVE);
1082 Manager::getInstance().getTuner(*tidIT).getReservation(Activity::kLive, TunerReservation::IDLE);
1083 Log() <<
"Tuner " << *tidIT <<
" has IDLE tokens " << std::endl;
1089 TunerReservation::TokenList tokens;
1091 Manager::getInstance().getTuner(*tidIT).getReservationTokens(tokens);
1092 if (tokens.size() == 0) {
1093 tunerToAddTo = *tidIT;
1096 else if (tokens.size() == 1) {
1098 if (Manager::getInstance().getReservation(*tokens.begin()).getActivity() == Activity::kLive) {
1100 TunerReservation reservation = Manager::getInstance().getTuner(*tidIT).getReservation(Activity::kLive, TunerReservation::IDLE);
1103 Log() <<
"Tuner " << *tidIT <<
" is accepted " << std::endl;
1104 tunerToAddTo = *tidIT;
1124 if (!tunerToAddTo.empty()) {
1125 if ((Manager::getInstance().getTuner(tunerToAddTo).getState().getState() == TunerState::kFree) &&
1126 (tunerToAddTo.compare(Manager::getInstance().getLocalTuner()) == 0)) {
1128 Tuner::IdList tunerIds;
1130 Filter<ByTunerState>(TunerState::kFree, Manager::getInstance().getTunerIds(tunerIds));
1131 if (tunerIds.size() != 0) {
1132 tunerIds.remove(tunerToAddTo);
1134 if (tunerIds.size() != 0) {
1135 Log() <<
"[reserveLocal] requester is recorder, moving reservedDeviceId "
1136 << GetDeviceId() <<
" from "
1137 << Manager::getInstance().getLocalTuner()
1138 <<
" to " << *tunerIds.begin() << std::endl;
1139 Manager::getInstance().setLocalTuner(*tunerIds.begin());
1148 if (!tunerToAddTo.empty())
1150 Log() <<
"Granting New Reservation to Record on tuner " << tunerToAddTo << std::endl;
1153 recordReservation.setReservationToken(GenerateUUID());
1155 Manager::getInstance().addReservation(recordReservation, ((tunerToAddTo)));
1156 Manager::getInstance().setReservationAttributes(recordReservation.getReservationToken(), ReservationAttributes(clientId));
1157 response.setTunerReservation(recordReservation);
1162 response.getStatus() +=
"Error: Reservation Failed with conflicts\r\n";
1163 response.getStatus() = ResponseStatus::kInsufficientResource;
1167 response.getStatus() +=
"Error: This is a recording, see if we can find resolution\r\n";
1168 FindConflictsForRequestedRecord(request, response.getConflicts());
1171 response.getStatus() +=
"Error: This is a hot recording, let request fail\r\n";
1174 ReserveTunerResponse::ConflictCT & conflicts = response.getConflicts();
1175 if (conflicts.size() == 0 ) {
1177 response.getStatus() +=
"Error: All tuners are recording\r\n";
1179 else if (conflicts.size() == 1) {
1180 Log() <<
"Found one L tuner to start Conflict-resolution process\r\n";
1181 response.getStatus() +=
"Found one L tuner to start Conflict-resolution process\r\n";
1183 else if (conflicts.size() > 1) {
1192 extern Server *serverInstance;
1202 Log() <<
"[EXEC]Reserving"
1204 <<
" From Device " << request.getDevice() << std::endl;
1212 reserveLive(request, response, exec.getClientId());
1213 exec.messageOut = response;
1216 exec.messageOut.getStatus() += (response.getStatus().getDetails() +
" -->Error: Token Is In a bad state").c_str();
1217 exec.messageOut.getStatus() = ResponseStatus::kInvalidState;
1220 exec.messageOut.getStatus() += (response.getStatus().getDetails() +
" -->Error: Token Is Not Found").c_str();
1221 exec.messageOut.getStatus() = ResponseStatus::kInvalidToken;
1224 exec.messageOut.getStatus() += (response.getStatus().getDetails() +
" -->Error: Request Is malformed").c_str();
1225 exec.messageOut.getStatus() = ResponseStatus::kMalFormedRequest;
1229 Log() <<
"Sending the message:RL: " << std::endl;
1230 std::vector<uint8_t> out;
1231 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1232 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1237 reserveRecord(request, response, exec.getClientId());
1238 exec.messageOut = response;
1240 if (exec.messageOut.getConflicts().size() == 1) {
1243 std::string temporaryToken = GenerateUUID();
1244 const int CONFLICT_RESOLUTION_TIMEOUT_MS = (53500);
1249 ReservationAttributes &attrs = Manager::getInstance().getReservationAttributes(conflict.
getReservationToken());
1258 notification.getConflicts().begin()->setReservationToken(temporaryToken);
1259 std::string parentId = Manager::getInstance().getParent(notification.getTunerReservation().getReservationToken());
1260 Manager::getInstance().addPendingRequest(
new PendingReserveTunerConflictProcessor(temporaryToken, exec.getClientId(), notification, request, parentId), CONFLICT_RESOLUTION_TIMEOUT_MS);
1263 std::vector<uint8_t> out;
1264 SerializeMessage(notification, attrs.clientId, out);
1265 ::serverInstance->getConnection(attrs.clientId).sendAsync(out);
1269 Log() <<
"to Send Record Response, with no conflict resolution\r\n";
1270 std::vector<uint8_t> out;
1271 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1272 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1277 Log() <<
"to Send failed Record Response, with no conflict resolution included\r\n";
1278 exec.messageOut.getStatus() = ResponseStatus::kGeneralError;
1279 std::vector<uint8_t> out;
1280 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1281 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1287 Log() <<
"Connection for message has reset/lost, discarding message\r\n";
1300 Log() <<
"[EXEC]Releasing"
1301 <<
" Token " << request.getReservationToken()
1302 <<
" From device" << request.getDevice() << std::endl;
1305 Manager::getInstance().releaseReservation(request.getReservationToken());
1306 response.setReleased(
true);
1307 response.getStatus() = ResponseStatus::kOk;
1308 exec.messageOut = response;
1312 exec.messageOut.setReleased(
false);
1313 exec.messageOut.getStatus() +=
"Error: Token Is Not Found";
1314 exec.messageOut.getStatus() = ResponseStatus::kInvalidToken;
1317 std::vector<uint8_t> out;
1318 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1319 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1327 Log() <<
"[EXEC]Validating"
1328 <<
" Token " << request.getReservationToken()
1329 <<
" From device" << request.getDevice() << std::endl;
1331 TunerReservation &reservation = Manager::getInstance().getReservation(request.getReservationToken());
1332 ReservationAttributes & attr = Manager::getInstance().getReservationAttributes(reservation.
getReservationToken());
1334 if (attr.clientId == exec.getClientId()) {
1335 exec.messageOut.setValid(
true);
1336 response.getStatus() = ResponseStatus::kOk;
1337 exec.messageOut = response;
1340 Log() <<
"Throw ItemNotFoundException from Execute()" << std::endl;
1345 exec.messageOut.setValid(
false);
1346 exec.messageOut.getStatus() +=
"Error: Token Is Not Found";
1347 exec.messageOut.getStatus() = ResponseStatus::kOk;
1350 std::vector<uint8_t> out;
1351 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1352 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1365 if (Manager::getInstance().isPendingConflict(request.getReservationToken())) {
1367 PendingReserveTunerConflictProcessor &pendingRequest = *
static_cast<PendingReserveTunerConflictProcessor *
>(&Manager::getInstance().getPendingRequest(request.getReservationToken()));
1369 Assert(pendingRequest.getUUID() == request.getReservationToken());
1370 Log() <<
"[EXEC]CancelRecording "
1371 <<
"Temporary Recording Token " << pendingRequest.getUUID()
1372 <<
" clientId " << exec.getClientId()
1373 <<
" clientId2 " << pendingRequest.clientId
1379 response.getStatus() +=
"User canceled recording as Conflict Resolution";
1380 response.getStatus() = ResponseStatus::kUserCancellation;
1382 SafeAssert(pendingRequest.clientId != exec.getClientId());
1384 std::vector<uint8_t> out;
1386 SerializeMessage(response, pendingRequest.clientId, out);
1387 ::serverInstance->getConnection(pendingRequest.clientId).sendAsync(out);
1390 Manager::getInstance().removePendingRequest(pendingRequest.getUUID());
1391 delete &pendingRequest;
1395 response.getStatus() +=
"Cancellation Success \r\n";
1396 response.getStatus() = ResponseStatus::kOk;
1397 response.setCanceled(
true);
1399 exec.messageOut = response;
1400 std::vector<uint8_t> out;
1401 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1402 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1407 if (!(Manager::getInstance().getReservation(request.getReservationToken()).getActivity() == Activity::kRecord)) {
1411 Log() <<
"[EXEC]CancelRecording "
1412 <<
"From client " << exec.getClientId() <<
" "
1413 <<
"Actual Recording Token " << Manager::getInstance().getReservation(request.getReservationToken()).getReservationToken()
1416 const int CANCEL_RECORDING_TIMEOUT_MS = (15000);
1419 Manager::getInstance().addPendingRequest(
new PendingCancelRecordingProcessor(exec.getClientId(), request), CANCEL_RECORDING_TIMEOUT_MS);
1421 std::vector<uint8_t> out;
1422 SerializeMessage(exec.messageIn, exec.getClientId(), out);
1423 ::serverInstance->getConnection(Connection::kRecorderClientId).sendAsync(out);
1429 exec.messageOut.getStatus() +=
"Recorder is not connected \r\n";
1430 exec.messageOut.getStatus() = ResponseStatus::kGeneralError;
1431 exec.messageOut.setCanceled(
false);
1433 std::vector<uint8_t> out;
1434 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1435 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1438 exec.messageOut.getStatus() +=
"Reservation Token is not valid \r\n";
1439 exec.messageOut.getStatus() = ResponseStatus::kGeneralError;
1440 exec.messageOut.setCanceled(
false);
1442 std::vector<uint8_t> out;
1443 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1444 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1450 exec.messageOut.getStatus() +=
"Error: Token Is Not Found";
1451 exec.messageOut.getStatus() = ResponseStatus::kInvalidToken;
1452 exec.messageOut.setCanceled(
false);
1454 std::vector<uint8_t> out;
1455 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1456 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1466 Log() <<
"[EXEC]CancelRecordingResponse"
1467 <<
" Token " << response.getReservationToken()
1468 <<
" For Client " << exec.getClientId()
1471 if (!(Manager::getInstance().getReservation(response.getReservationToken()).getActivity() == Activity::kRecord)) {
1475 if (exec.getClientId() == Connection::kTrmClientId) {
1481 const PendingCancelRecordingProcessor &pendingRequest = *
static_cast<PendingCancelRecordingProcessor *
>(&Manager::getInstance().getPendingRequest(response.getUUID()));
1484 Log() <<
"[EXEC]CancelRecordingResponse "
1485 <<
"Recording Token " << pendingRequest.request.getReservationToken()
1486 <<
"for client " << pendingRequest.clientId
1489 Assert(pendingRequest.request.getReservationToken() == response.getReservationToken());
1492 Log() <<
"Release the reservation and Send the response to the orginator" << std::endl;
1493 Manager::getInstance().removePendingRequest(response.getUUID());
1494 Assert(!Manager::getInstance().isPendingRequest(response.getUUID()));
1496 std::vector<uint8_t> out;
1497 SerializeMessage(exec.messageIn, pendingRequest.clientId, out);
1498 ::serverInstance->getConnection(pendingRequest.clientId).sendAsync(out);
1500 delete &pendingRequest;
1505 Manager::getInstance().releaseReservation(response.getReservationToken());
1509 Log() <<
"[EXEC]CancelRecordingResponse contains invalid arguments..discarding " << std::endl;
1513 Log() <<
"[EXEC]Assert Error caught " << std::endl;
1516 Log() <<
"[EXEC]Matching CancelRecording Request is not found" << std::endl;
1520 Log() <<
"[EXEC]Unknonw Exception caught " << std::endl;
1530 Tuner::IdList tunerIds;
1531 response.addTunerId(Manager::getInstance().getTunerIds(tunerIds));
1532 response.getStatus() = ResponseStatus::kOk;
1533 response.getStatus() +=
"GetAllTunerIds ok";
1534 exec.messageOut = response;
1537 exec.messageOut.getStatus() +=
"Error: Cannot get IDs";
1538 exec.messageOut.getStatus() = ResponseStatus::kGeneralError;
1541 std::vector<uint8_t> out;
1542 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1543 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1551 Tuner::IdList tunerIds;
1552 Manager::getInstance().getTunerIds(tunerIds);
1553 Tuner::IdList::const_iterator it;
1554 for (it=tunerIds.begin(); it != tunerIds.end(); it++) {
1555 response.addTunerState(*it, (
const char *)(Manager::getInstance().getTuner(*it).getState().getState()));
1559 for (it=tunerIds.begin(); it != tunerIds.end(); it++) {
1560 Log() <<
"Adding Detailed Tuner State "
1561 << (
const char *)(Manager::getInstance().getTuner(*it).getState().getState())
1562 <<
" with locator " << (Manager::getInstance().getTuner(*it).getServiceLocator())
1563 <<
" for Tuner " << *it
1566 std::string reservedDeviceId =
"";
1567 if (Manager::getInstance().getLocalTuner().compare(*it) == 0) {
1568 reservedDeviceId = GetDeviceId();
1570 response.addTunerState(*it,
1571 (
const char *)(Manager::getInstance().getTuner(*it).getState().getState()),
1572 (Manager::getInstance().getTuner(*it).getServiceLocator()), reservedDeviceId);
1574 TunerReservation::TokenList tokens;
1575 TunerReservation::TokenList::const_iterator itt;
1576 Manager::getInstance().getReservationTokens(tokens, *it);
1577 for (itt=tokens.begin(); itt != tokens.end(); itt++) {
1579 if (Manager::getInstance().getReservation(*itt).state == TunerReservation::ACTIVE) {
1580 Log() <<
"Adding Detailed Tuner Activity "
1581 << (
const char *)Manager::getInstance().getReservation(*itt).getActivity().getActivity()
1582 <<
" with Owner " << Manager::getInstance().getReservation(*itt).getDevice()
1584 response.addTunerOwner(*it,
1585 (
const char *)Manager::getInstance().getReservation(*itt).getActivity().getActivity(),
1586 Manager::getInstance().getReservation(*itt).getDevice());
1589 Log() <<
"Ignoring Inactive token " << *itt << std::endl;
1594 response.getStatus() = ResponseStatus::kOk;
1595 exec.messageOut = response;
1598 exec.messageOut.getStatus() +=
"Error: Cannot get States";
1599 exec.messageOut.getStatus() = ResponseStatus::kGeneralError;
1602 std::vector<uint8_t> out;
1603 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1604 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1613 Tuner::IdList tunerIds;
1614 Manager::getInstance().getTunerIds(tunerIds);
1615 Tuner::IdList::const_iterator it;
1616 for (it=tunerIds.begin(); it != tunerIds.end(); it++) {
1617 TunerReservation::TokenList tokens;
1618 Manager::getInstance().getReservationTokens(tokens, *it);
1620 if (!request.getFilter(
"device").empty()) {
1621 Filter<ByDevice>(request.getFilter(
"device"), tokens);
1624 if (!request.getFilter(
"activity").empty()) {
1625 Filter<ByActivity>(
Activity(request.getFilter(
"activity").c_str()).
getActivity(), tokens);
1628 if (!request.getFilter(
"state").empty()) {
1629 Filter<ByTunerState>(
TunerState(request.getFilter(
"state").c_str()).getState(), tokens);
1632 TunerReservation::TokenList::const_iterator itt;
1633 for (itt = tokens.begin(); itt != tokens.end(); itt++) {
1634 response.addTunerReservation(*it, Manager::getInstance().getReservation(*itt));
1637 response.getStatus() = ResponseStatus::kOk;
1638 exec.messageOut = response;
1641 exec.messageOut.getStatus() +=
"Error: Cannot get Reservations";
1642 exec.messageOut.getStatus() = ResponseStatus::kGeneralError;
1645 std::vector<uint8_t> out;
1646 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1647 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1655 Log() <<
"[EXEC]Reserving and Always Granting"
1657 <<
" From Device " << request.getDevice() << std::endl;
1668 recordReservation.setReservationToken(GenerateUUID());
1674 response.getStatus() +=
"Granting token unconditionally\r\n";
1675 response.getStatus() = ResponseStatus::kOk;
1678 response.setTunerReservation(recordReservation);
1680 uint64_t origStartTime = recordReservation.getStartTime();
1681 uint64_t origDuration = recordReservation.getDuration();
1687 const TunerState &tunerState = Manager::getInstance().getTuner(parentTunerId).getState();
1688 if (tunerState.getState() == TunerState::kFree || tunerState.getState() == TunerState::kLive) {
1689 recordReservation.setStartTime(GetCurrentEpoch()-1);
1693 if (origStartTime < GetCurrentEpoch()) {
1695 recordReservation.setStartTime(GetCurrentEpoch());
1698 if (recordReservation.getStartTime() > origStartTime) {
1700 if (recordReservation.getStartTime() > (origStartTime + origDuration)) {
1701 recordReservation.setDuration(0);
1704 recordReservation.setDuration(origStartTime + origDuration - recordReservation.getStartTime());
1709 recordReservation.setDuration(origDuration + origStartTime - recordReservation.getStartTime());
1712 SafeAssert((origStartTime + origDuration) == (recordReservation.getStartTime() + recordReservation.getDuration()));
1714 Log() <<
"Orig Record (start,dur) vs Adjusted : ("
1715 << origStartTime <<
", " << origDuration <<
"), ("
1716 << recordReservation.getStartTime() <<
", " << recordReservation.getDuration() <<
")"
1719 Manager::getInstance().addReservation(recordReservation, parentTunerId);
1720 Manager::getInstance().setReservationAttributes(recordReservation.getReservationToken(), ReservationAttributes(exec.getClientId()));
1721 exec.messageOut = response;
1723 Log() <<
"Sending the message:RL: " << std::endl;
1724 std::vector<uint8_t> out;
1725 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1726 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1729 Log() <<
"Sending the mssage failed" << std::endl;
1745 response.setVersion(GetSpecVersion().toString().c_str());
1746 response.getStatus() = ResponseStatus::kOk;
1747 response.getStatus() +=
"GetVersion ok";
1748 exec.messageOut = response;
1751 exec.messageOut.getStatus() +=
"Error: Cannot get version";
1752 exec.messageOut.getStatus() = ResponseStatus::kGeneralError;
1755 std::vector<uint8_t> out;
1756 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1757 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1765 std::vector<uint8_t> out;
1766 SerializeMessage(request, Connection::kTunerAgentId, out);
1767 ::serverInstance->getConnection(Connection::kTunerAgentId).sendAsync(out);
1769 exec.messageOut = response;
1771 Log() <<
"Sending UpdateTunerActivityStatusResponse: " << std::endl;
1772 std::vector<uint8_t> out;
1773 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1774 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1788 Log() <<
"Executing CancelLive from " << std::hex << exec.getClientId() << std::endl;
1791 std::vector<uint8_t> out;
1792 SerializeMessage(exec.messageIn, exec.getClientId(), out);
1793 ::serverInstance->getConnection(Connection::kRecorderClientId).sendAsync(out);
1798 exec.messageOut.getStatus() +=
"Test: Fake Cancel";
1799 exec.messageOut.getStatus() = ResponseStatus::kOk;
1800 exec.messageOut.setCanceled(
true);
1802 std::vector<uint8_t> out;
1803 SerializeMessage(exec.messageOut, exec.getClientId(), out);
1804 ::serverInstance->getConnection(exec.getClientId()).sendAsync(out);
1813 if(Manager::getInstance().isPendingRequest(response.getUUID())) {
1814 Log() <<
"emit CancelLiveResponse from " << std::hex << exec.getClientId() << std::endl;
1815 PendingCancelLiveProcessor &pendingRequest = *
static_cast<PendingCancelLiveProcessor *
>(&Manager::getInstance().getPendingRequest(response.getUUID()));
1816 emit Manager::getInstance().cancelLiveResponse(response, pendingRequest.reserveRequest, pendingRequest.parentId);
1817 Manager::getInstance().removePendingRequest(response.getUUID());
1818 delete &pendingRequest;