bool cSoppalusikkaLogoCache::LoadXpm(const char *fileNameP) { struct stat stbuf; cBitmap *bmp = new cBitmap(1, 1, 1); // create absolute filename cString filename = cString::sprintf("%s/%s.xpm", SoppalusikkaConfig.GetLogoDir(), fileNameP); debug1("%s (%s)", __PRETTY_FUNCTION__, *filename); // check validity if ((stat(*filename, &stbuf) == 0) && bmp->LoadXpm(*filename)) { // assign bitmap debug2("%s Logo found", __PRETTY_FUNCTION__); if (!DoubleEqual(1.0, xFactorM) || !DoubleEqual(1.0, yFactorM) || (bmp->Width() != DEFAULT_LOGO_WIDTH) || (bmp->Height() != DEFAULT_LOGO_HEIGHT)) { cBitmap *tmp = bmp; // scale bitmap keeping default proportions bmp = bmp->Scaled(yFactorM * DEFAULT_LOGO_WIDTH / bmp->Width(), yFactorM * DEFAULT_LOGO_HEIGHT / bmp->Height(), bmp->Bpp() > 4); debug2("%s Logo scaled", __PRETTY_FUNCTION__); DELETENULL(tmp); } bitmapM = bmp; return true; } // no valid xpm logo found - delete bitmap debug2("%s Logo not found or invalid resolution", __PRETTY_FUNCTION__); DELETENULL(bmp); bitmapM = NULL; return false; }
void cDvbSubtitleBitmaps::Draw(cOsd *Osd) { bool Scale = !(DoubleEqual(osdFactorX, 1.0) && DoubleEqual(osdFactorY, 1.0)); bool AntiAlias = true; if (Scale && osdFactorX > 1.0 || osdFactorY > 1.0) { // Upscaling requires 8bpp: int Bpp[MAXOSDAREAS]; for (int i = 0; i < numAreas; i++) { Bpp[i] = areas[i].bpp; areas[i].bpp = 8; } if (Osd->CanHandleAreas(areas, numAreas) != oeOk) { for (int i = 0; i < numAreas; i++) Bpp[i] = areas[i].bpp = Bpp[i]; AntiAlias = false; } } if (Osd->SetAreas(areas, numAreas) == oeOk) { for (int i = 0; i < bitmaps.Size(); i++) { cBitmap *b = bitmaps[i]; if (Scale) b = b->Scaled(osdFactorX, osdFactorY, AntiAlias); Osd->DrawBitmap(int(round(b->X0() * osdFactorX)), int(round(b->Y0() * osdFactorY)), *b); if (b != bitmaps[i]) delete b; } Osd->Flush(); } }
void cFemonSymbolCache::Refresh() { int width, height; double aspect, xfactor, yfactor; cDevice::PrimaryDevice()->GetOsdSize(width, height, aspect); debug1("%s width=%d height=%d", __PRETTY_FUNCTION__, width, height); xfactor = (double)width / DEFAULT_WIDTH; yfactor = (double)height / DEFAULT_HEIGHT; if (!DoubleEqual(xfactor, xFactorM) || !DoubleEqual(yfactor, yFactorM)) { xFactorM = xfactor; yFactorM = yfactor; Populate(); } }
bool COARpeak::Equal( const IOARpeak &x1, const IOARpeak &x2, bool bCheckAllele, bool bCheckArtifact) { bool bRtn = true; if(bCheckArtifact) { bool bArtifact = x1.IsArtifact(); if(bArtifact != x2.IsArtifact()) { bRtn = false; } else if(bArtifact) { int n1 = x1.GetCriticalLevel(); int n2 = x2.GetCriticalLevel(); bRtn = (n1 == n2) && (x1.IsEditable() == x2.IsEditable()); } } if(!bRtn) {;} else if(x1.GetID() != x2.GetID()) { bRtn = false; } else if(x1.GetAlleleCount() != x2.GetAlleleCount()) { bRtn = false; } else if(!DoubleEqual(x1.GetBPS(),x2.GetBPS())) { bRtn = false; } else if(!DoubleEqual(x1.GetMeanBPS(),x2.GetMeanBPS())) { bRtn = false; } else if(!DoubleEqual(x1.GetRFU(),x2.GetRFU())) { bRtn = false; } else if(!DoubleEqual(x1.GetPullupHeightCorrection(),x2.GetPullupHeightCorrection())) { bRtn = false; } else if(!DoubleEqual(x1.GetTime(),x2.GetTime())) { bRtn = false; } else if(!DoubleEqual(x1.GetPeakArea(),x2.GetPeakArea())) { bRtn = false; } else if(!DoubleEqual(x1.GetWidth(),x2.GetWidth())) { bRtn = false; } else if(!DoubleEqual(x1.GetFit(),x2.GetFit(),FIT_DIGIT_MATCH)) { bRtn = false; } // else if( bCheckArtifact && (x1.IsArtifact() != x2.IsArtifact()) ) // { bRtn = false; } else if( bCheckAllele && (x1.IsAllele() != x2.IsAllele()) ) { bRtn = false; } else if(x1.IsDisabled() != x2.IsDisabled()) { bRtn = false; } else if(x1.GetOffLadderString() != x2.GetOffLadderString()) { bRtn = false; } else if(x1.GetAlleleName() != x2.GetAlleleName()) { bRtn = false; } else if(x1.GetLocusName() != x2.GetLocusName()) { bRtn = false; } else if(bCheckArtifact && (x1.GetArtifactLabel() != x2.GetArtifactLabel())) { bRtn = false; } else if(bCheckArtifact && (x1.GetArtifactUserDisplay() != x2.GetArtifactUserDisplay())) { bRtn = false; } return bRtn; }
void cRecorder::Action(void) { cTimeMs t(MAXBROKENTIMEOUT); bool InfoWritten = false; bool FirstIframeSeen = false; while (Running()) { int r; uchar *b = ringBuffer->Get(r); if (b) { int Count = frameDetector->Analyze(b, r); if (Count) { if (!Running() && frameDetector->IndependentFrame()) // finish the recording before the next independent frame break; if (frameDetector->Synced()) { if (!InfoWritten) { cRecordingInfo RecordingInfo(recordingName); if (RecordingInfo.Read()) { if (frameDetector->FramesPerSecond() > 0 && DoubleEqual(RecordingInfo.FramesPerSecond(), DEFAULTFRAMESPERSECOND) && !DoubleEqual(RecordingInfo.FramesPerSecond(), frameDetector->FramesPerSecond())) { RecordingInfo.SetFramesPerSecond(frameDetector->FramesPerSecond()); RecordingInfo.Write(); Recordings.UpdateByName(recordingName); } } InfoWritten = true; cRecordingUserCommand::InvokeCommand(RUC_STARTRECORDING, recordingName); } if (FirstIframeSeen || frameDetector->IndependentFrame()) { FirstIframeSeen = true; // start recording with the first I-frame if (!NextFile()) break; if (index && frameDetector->NewFrame()) index->Write(frameDetector->IndependentFrame(), fileName->Number(), fileSize); if (frameDetector->IndependentFrame()) { recordFile->Write(patPmtGenerator.GetPat(), TS_SIZE); fileSize += TS_SIZE; int Index = 0; while (uchar *pmt = patPmtGenerator.GetPmt(Index)) { recordFile->Write(pmt, TS_SIZE); fileSize += TS_SIZE; } } if (recordFile->Write(b, Count) < 0) { LOG_ERROR_STR(fileName->Name()); break; } fileSize += Count; t.Set(MAXBROKENTIMEOUT); } } ringBuffer->Del(Count); } } if (t.TimedOut()) { esyslog("ERROR: video data stream broken"); ShutdownHandler.RequestEmergencyExit(); t.Set(MAXBROKENTIMEOUT); } } }
TEST(LINE, GetLength) { for (int i = -20; i != 20; ++i) { for (int j = -20; j != 20; ++j) { Shape2D* line = new Line2D(Point2D(i, j)); for (int k = 0; k <= line->GetLength(); ++k) { Point2D temp(0.0, 0.0); line->GetPoint(k, temp); if (i == 0 && j == 0) continue; ASSERT_TRUE(DoubleEqual(temp.x, i * k / line->GetLength())); ASSERT_TRUE(DoubleEqual(temp.y, j * k / line->GetLength())); } ASSERT_TRUE(DoubleEqual(line->GetLength(), sqrt(i * i + j * j))); delete line; } } }
void PrintDoubleChange(const char* desc, double oldVal, double newVal) { if(!(DoubleEqual(oldVal, newVal))) { logger.Info(boost::str(boost::format("%s has been changed : %.2f => %.2f") % desc % oldVal %newVal)); } }
trade::PosiDirectionType CScalperStrategy2::GetTradeDirection() { double askDiff = fabs(m_Ask - m_prevAsk); double bidDiff = fabs(m_Bid - m_prevBid); double absDiffDiff = fabs(askDiff - bidDiff); if(m_Ask > m_prevAsk && m_Bid > m_prevBid) { return trade::LONG; } else if(m_Ask < m_prevAsk && m_Bid < m_prevBid) { return trade::SHORT; } else if(DoubleEqual(m_Bid, m_prevBid) && DoubleEqual(m_Ask, m_prevAsk)) { return CalcTradeDirection(m_AskSize, m_BidSize, askDiff, bidDiff, m_CaseNoChange); } else if(DoubleLessEqual(absDiffDiff, m_priceTick * 2)) { return CalcTradeDirection(m_AskSize, m_BidSize, askDiff, bidDiff, m_CaseLE2Tick); } else if(DoubleLessEqual(absDiffDiff, m_priceTick * 3)) { return CalcTradeDirection(m_AskSize, m_BidSize, askDiff, bidDiff, m_CaseLE3Tick); } else if(DoubleGreaterEqual(absDiffDiff, m_priceTick * 4)) { return CalcTradeDirection(m_AskSize, m_BidSize, askDiff, bidDiff, m_CaseGE4Tick); } else { return m_AskSize < m_BidSize ? trade::SHORT : trade::LONG; } }
BOOL PrivateAssertDouble(double fExpected, double fActual, int iDecimals, int iLine, char* szFile) { char szExpected[32]; char szActual[32]; double fTolerance; fTolerance = DoubleToleranceForDecimals(iDecimals); if (!DoubleEqual(fExpected, fActual, fTolerance)) { ToDoubleString(fExpected, szExpected, iDecimals); ToDoubleString(fActual, szActual, iDecimals); return Fail(szExpected, szActual, iLine, szFile); } else { return Pass(); } }
double AngleFromStartByClockInCircle(double start_x, double start_y, double center_x, double center_y, double angle_x, double angle_y) { double a = center_x; double b = center_y; double r_square = pow(center_y - start_y, 2) + pow(center_x - start_x, 2); double select_angle = 0; if (DoubleEqual(angle_x, center_x)) { double y1 = b + sqrt(a * a + r_square); double y2 = b - sqrt(a * a + r_square); if (fabs(y1 - angle_y) > fabs(y2 - angle_y)) y1 = y2; if (y1 - center_y > 0) select_angle = T_PI / 2.0; else select_angle = 3.0 * T_PI / 2.0; } else { double c = angle_y - ((angle_y - center_y) / (angle_x - center_x)) * angle_x; double k = (angle_y - center_y) / (angle_x - center_x); double l = 1 + k * k; double m = 2 * (c * k - a - b * k); double n = a * a + (c - b) * (c - b) - r_square; double x1 = (-m + sqrt(m * m - 4 * n * l)) / 2 / l; double y1 = k * x1 + c; double x2 = (-m - sqrt(m * m - 4 * n * l)) / 2 / l; double y2 = k * x2 + c; if (fabs(angle_x - x1) > fabs(angle_x - x2)) { x1 = x2; y1 = y2; } select_angle = AngleInCircle(x1 - center_x, y1 - center_y); } double start_angle = AngleInCircle(start_x - center_x, start_y - center_y); double delta_angle = start_angle - select_angle; if (delta_angle < 0) delta_angle += 2 * T_PI; assert(delta_angle >= 0.0 && delta_angle <= 2 * T_PI); return delta_angle; }
double AngleInCircle(double x, double y) { assert(!(DoubleEqual(x, 0.0) && DoubleEqual(y, 0.0))); if (DoubleEqual(x, 0.0) && y > 0.0) return T_PI / 2; if (DoubleEqual(x, 0.0) && y < 0.0) return 3 * T_PI / 2; if (DoubleEqual(y, 0.0) && x > 0.0) return 0.0; if (DoubleEqual(y, 0.0 ) && x < 0.0) return T_PI; if ( x > 0.0 && y > 0.0 ) return atan(y / x); if (x < 0.0 && y > 0.0) return T_PI + atan(y / x); if (x < 0.0 && y < 0.0 ) return T_PI + atan(y / x); if(x > 0.0 && y < 0.0 ) return 2 * T_PI + atan(y / x); return 0.0; }
bool cFemonSymbolCache::Populate(void) { debug1("%s xFactor=%.02f yFactor=%.02f", __PRETTY_FUNCTION__, xFactorM, yFactorM); if (!DoubleEqual(0.0, xFactorM) || !DoubleEqual(0.0, yFactorM)) { Flush(); // pushing order must follow the enumeration - keep original proportions except for frontend status ones cacheM.Append(bmOnePixel.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_ONEPIXEL cacheM.Append(bmStereo.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_STEREO cacheM.Append(bmMonoLeft.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_MONO_LEFT cacheM.Append(bmMonoRight.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_MONO_RIGHT cacheM.Append(bmDolbyDigital.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_DD cacheM.Append(bmDolbyDigital20.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_DD20 cacheM.Append(bmDolbyDigital51.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_DD51 cacheM.Append(bmMpeg2.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_MPEG2 cacheM.Append(bmH264.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_H264 cacheM.Append(bmH265.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_H265 cacheM.Append(bmPal.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_PAL cacheM.Append(bmNtsc.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_NTSC cacheM.Append(bmEncrypted.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_ENCRYPTED cacheM.Append(bmSvdrp.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_SVDRP cacheM.Append(bmLock.Scaled(xFactorM, yFactorM, antiAliasM)); // SYMBOL_LOCK cacheM.Append(bmSignal.Scaled(xFactorM, yFactorM, antiAliasM)); // SYMBOL_SIGNAL cacheM.Append(bmCarrier.Scaled(xFactorM, yFactorM, antiAliasM)); // SYMBOL_CARRIER cacheM.Append(bmViterbi.Scaled(xFactorM, yFactorM, antiAliasM)); // SYMBOL_VITERBI cacheM.Append(bmSync.Scaled(xFactorM, yFactorM, antiAliasM)); // SYMBOL_SYNC cacheM.Append(bmAspectRatio11.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_AR_1_1 cacheM.Append(bmAspectRatio169.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_AR_16_9 cacheM.Append(bmAspectRatio2211.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_AR_2_21_1 cacheM.Append(bmAspectRatio43.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_AR_4_3 cacheM.Append(bmDevice.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_DEVICE cacheM.Append(bmZero.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_ZERO cacheM.Append(bmOne.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_ONE cacheM.Append(bmTwo.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_TWO cacheM.Append(bmThree.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_THREE cacheM.Append(bmFour.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FOUR cacheM.Append(bmFive.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FIVE cacheM.Append(bmSix.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_SIX cacheM.Append(bmSeven.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_SEVEN cacheM.Append(bmEight.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_EIGHT cacheM.Append(bmFormat2160.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FORMAT_2160 cacheM.Append(bmFormat2160i.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FORMAT_2160i cacheM.Append(bmFormat2160p.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FORMAT_2160p cacheM.Append(bmFormat1080.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FORMAT_1080 cacheM.Append(bmFormat1080i.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FORMAT_1080i cacheM.Append(bmFormat1080p.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FORMAT_1080p cacheM.Append(bmFormat720.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FORMAT_720 cacheM.Append(bmFormat720i.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FORMAT_720i cacheM.Append(bmFormat720p.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FORMAT_720p cacheM.Append(bmFormat576.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FORMAT_576 cacheM.Append(bmFormat576i.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FORMAT_576i cacheM.Append(bmFormat576p.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FORMAT_576p cacheM.Append(bmFormat480.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FORMAT_480 cacheM.Append(bmFormat480i.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FORMAT_480i cacheM.Append(bmFormat480p.Scaled(yFactorM, yFactorM, antiAliasM)); // SYMBOL_FORMAT_480p return true; } return false; }
// Analytical solution to quadratic polynomials exists. This function could return the optimal solution to quadratic polynomials with one or two variables. // Return value: indicator variable for solution status, NOOPT int PolyNomial::Optimize2(Array<double>* vars, double* optValue) { vars->clear(); if (1 == numVar_) // There is only 1 variable in the polynomial. { double a = 0, b = 0; // Get parameters for the Gaussian representation. for(int i = 0; i < items_.size(); ++i) { map<int, double>::const_iterator citer = items_[i].begin(); if (DoubleEqual(citer->second, 2.0, DOUBLE_ZERO_THRESHOLD)) { a = coef_[i]; } if (DoubleEqual(citer->second, 1.0, DOUBLE_ZERO_THRESHOLD)) { b = coef_[i]; } } // ERROR: The quadratic term is empty. if (fabs(a) < DOUBLE_ZERO_THRESHOLD) { cout << "The quadratic term is empty" << endl; exit(0); } vars->append(-b/(2*a)); *optValue = ComputePlValue(*vars); return 0; } // Two-var quadratic polynomial representation: a*x1^2 + b*x2^2 + c*x1*x2 + d*x1 + e*x2. double a = 0, b = 0, c = 0, d = 0, e = 0; //normalize and assume each polynomial are 2-var poly. for(int i = 0; i < items_.size(); ++i) { map<int, double>::const_iterator citer = items_[i].begin(); if (citer->first == 0 && DoubleEqual(citer->second, 2.0, DOUBLE_ZERO_THRESHOLD)) //x1^2 { a = coef_[i]; } if (citer->first == 1 && DoubleEqual(citer->second, 2.0, DOUBLE_ZERO_THRESHOLD)) //x2^2 { b = coef_[i]; } if (citer->first == 0 && DoubleEqual(citer->second, 1.0, DOUBLE_ZERO_THRESHOLD) && items_[i].size() == 2) //x1*x2 { c = coef_[i]; } if (citer->first == 0 && DoubleEqual(citer->second, 1.0, DOUBLE_ZERO_THRESHOLD) && items_[i].size() == 1) //x1 { d = coef_[i]; } if (citer->first == 1 && DoubleEqual(citer->second, 1.0, DOUBLE_ZERO_THRESHOLD) && items_[i].size() == 1)//x2 { e = coef_[i]; } if (citer->first == 1 && DoubleEqual(citer->second, 1.0, DOUBLE_ZERO_THRESHOLD) && items_[i].size() > 1) //wrong { cout << "shouldn't be here," << endl; } } vars->clear(); double delta = 4 * a * b - c * c; //cout << "delta: " << delta << endl; // delta == 0, |a| > 0, |b| > 0 if (fabs(delta) < DOUBLE_ZERO_THRESHOLD) { if (fabs(a)> DOUBLE_ZERO_THRESHOLD) { vars->append(-d / 2 * a); vars->append(0.0); } else if (fabs(a)> DOUBLE_ZERO_THRESHOLD) { vars->append(0.0); vars->append(-e / 2 * b); } else { // In this case, there is no appropriate optimum PrintTo(cout); cout << endl; cout << "delta = 0, no optimums2" << endl; exit(0); } *optValue = ComputePlValue(*vars); return NOOPT; } vars->append((e * c-2 * b * d)/delta); vars->append((d * c-2 * a * e)/delta); *optValue = ComputePlValue(*vars); return 0; }
bool cRecorder::NextFile(void) { if (recordFile && frameDetector->IndependentFrame()) { // every file shall start with an independent frame #ifdef USE_HARDLINKCUTTER if (fileSize > fileName->MaxFileSize() || RunningLowOnDiskSpace()) { #else if (fileSize > MEGABYTE(off_t(Setup.MaxVideoFileSize)) || RunningLowOnDiskSpace()) { #endif /* HARDLINKCUTTER */ recordFile = fileName->NextFile(); fileSize = 0; } } return recordFile != NULL; } void cRecorder::Activate(bool On) { if (On) Start(); else Cancel(3); } void cRecorder::Receive(uchar *Data, int Length) { if (Running()) { int p = ringBuffer->Put(Data, Length); if (p != Length && Running()) ringBuffer->ReportOverflow(Length - p); } } void cRecorder::Action(void) { time_t t = time(NULL); bool InfoWritten = false; bool FirstIframeSeen = false; #ifdef USE_LIVEBUFFER double fps = DEFAULTFRAMESPERSECOND; #endif /*USE_LIVEBUFFER*/ while (Running()) { int r; uchar *b = ringBuffer->Get(r); if (b) { int Count = frameDetector->Analyze(b, r); if (Count) { if (!Running() && frameDetector->IndependentFrame()) // finish the recording before the next independent frame break; if (frameDetector->Synced()) { #ifdef USE_LIVEBUFFER if(index && (frameDetector->FramesPerSecond() != fps)) { fps = frameDetector->FramesPerSecond(); index->SetFramesPerSecond(fps); } // if #endif /*USE_LIVEBUFFER*/ if (!InfoWritten) { cRecordingInfo RecordingInfo(recordingName); if (RecordingInfo.Read()) { if (frameDetector->FramesPerSecond() > 0 && DoubleEqual(RecordingInfo.FramesPerSecond(), DEFAULTFRAMESPERSECOND) && !DoubleEqual(RecordingInfo.FramesPerSecond(), frameDetector->FramesPerSecond())) { RecordingInfo.SetFramesPerSecond(frameDetector->FramesPerSecond()); RecordingInfo.Write(); Recordings.UpdateByName(recordingName); } } InfoWritten = true; } /* if (frameDetector->NewPayload()) { // We're at the first TS packet of a new payload... if (Buffering) esyslog("ERROR: encountered new payload while buffering - dropping some data!"); if (!frameDetector->NewFrame()) { // ...but the frame type is yet unknown, so we need to buffer packets until we see the frame type if (!Buffer) { dsyslog("frame type not in first packet of payload - buffering"); if (!(Buffer = MALLOC(uchar, BUFFERSIZE))) { esyslog("ERROR: can't allocate frame type buffer"); break; } } BufferIndex = 0; Buffering = true; } } else if (frameDetector->NewFrame()) // now we know the frame type, so stop buffering Buffering = false; if (Buffering) { if (BufferIndex + Count <= BUFFERSIZE) { memcpy(Buffer + BufferIndex, b, Count); BufferIndex += Count; } else esyslog("ERROR: too many bytes for frame type buffer (%d > %d) - dropped %d bytes", BufferIndex + Count, int(BUFFERSIZE), Count); } else if (FirstIframeSeen || frameDetector->IndependentFrame()) { */ #ifdef USE_LIVEBUFFER if(!FirstIframeSeen) FillInitialData(b, r); #endif /*USE_LIVEBUFFER*/ if (FirstIframeSeen || frameDetector->IndependentFrame()) { FirstIframeSeen = true; // start recording with the first I-frame if (!NextFile()) break; if (index && frameDetector->NewFrame()) index->Write(frameDetector->IndependentFrame(), fileName->Number(), fileSize); if (frameDetector->IndependentFrame()) { recordFile->Write(patPmtGenerator.GetPat(), TS_SIZE); fileSize += TS_SIZE; int Index = 0; while (uchar *pmt = patPmtGenerator.GetPmt(Index)) { recordFile->Write(pmt, TS_SIZE); fileSize += TS_SIZE; } } if (recordFile->Write(b, Count) < 0) { LOG_ERROR_STR(fileName->Name()); break; } fileSize += Count; t = time(NULL); } } ringBuffer->Del(Count); } } #ifdef USE_LIVEBUFFER if (handleError && (time(NULL) - t > MAXBROKENTIMEOUT)) { #else if (time(NULL) - t > MAXBROKENTIMEOUT) { #endif #if REELVDR Skins.QueueMessage(mtError, tr("can't record - check your configuration")); #else esyslog("ERROR: video data stream broken. Requesting Emergency Exit."); ShutdownHandler.RequestEmergencyExit(); #endif /*REELVDR*/ t = time(NULL); } } }