vdr 2.7.9
recording.c File Reference
#include "recording.h"
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "channels.h"
#include "cutter.h"
#include "i18n.h"
#include "interface.h"
#include "menu.h"
#include "ringbuffer.h"
#include "skins.h"
#include "svdrp.h"
#include "tools.h"
#include "videodir.h"

Go to the source code of this file.

Classes

class  cRemoveDeletedRecordingsThread
 
struct  tCharExchange
 
class  cVideoDirectoryScannerThread
 
class  cDirCopier
 
class  cRecordingsHandlerEntry
 
class  cIndexFileGenerator
 

Macros

#define __STDC_FORMAT_MACROS
 
#define SUMMARYFALLBACK
 
#define RECEXT   ".rec"
 
#define DELEXT   ".del"
 
#define DATAFORMATPES   "%4d-%02d-%02d.%02d%*c%02d.%02d.%02d" RECEXT
 
#define NAMEFORMATPES   "%s/%s/" "%4d-%02d-%02d.%02d.%02d.%02d.%02d" RECEXT
 
#define DATAFORMATTS   "%4d-%02d-%02d.%02d.%02d.%d-%d" RECEXT
 
#define NAMEFORMATTS   "%s/%s/" DATAFORMATTS
 
#define RESUMEFILESUFFIX   "/resume%s%s"
 
#define SUMMARYFILESUFFIX   "/summary.vdr"
 
#define INFOFILESUFFIX   "/info"
 
#define MARKSFILESUFFIX   "/marks"
 
#define SORTMODEFILE   ".sort"
 
#define TIMERRECFILE   ".timer"
 
#define MINDISKSPACE   1024
 
#define REMOVECHECKDELTA   60
 
#define DELETEDLIFETIME   300
 
#define DISKCHECKDELTA   100
 
#define REMOVELATENCY   10
 
#define MARKSUPDATEDELTA   10
 
#define MAXREMOVETIME   10
 
#define MAX_LINK_LEVEL   6
 
#define LIMIT_SECS_PER_MB_RADIO   5
 
#define RESUME_NOT_INITIALIZED   (-2)
 
#define IFG_BUFFER_SIZE   KILOBYTE(100)
 
#define INDEXFILESUFFIX   "/index"
 
#define MAXINDEXCATCHUP   8
 
#define INDEXCATCHUPWAIT   100
 
#define MAXWAITFORINDEXFILE   10
 
#define INDEXFILECHECKINTERVAL   500
 
#define INDEXFILETESTINTERVAL   10
 
#define MAXFILESPERRECORDINGPES   255
 
#define RECORDFILESUFFIXPES   "/%03d.vdr"
 
#define MAXFILESPERRECORDINGTS   65535
 
#define RECORDFILESUFFIXTS   "/%05d.ts"
 
#define RECORDFILESUFFIXLEN   20
 

Functions

void RemoveDeletedRecordings (void)
 
void AssertFreeDiskSpace (int Priority, bool Force)
 
bool NeedsConversion (const char *p)
 
char * ExchangeChars (char *s, bool ToFileSystem)
 
char * LimitNameLengths (char *s, int PathMax, int NameMax)
 
static bool StillRecording (const char *Directory)
 
struct __attribute__ ((packed))
 
bool GenerateIndex (const char *FileName)
 
static const char * SkipFuzzyChars (const char *s)
 
cString IndexToHMSF (int Index, bool WithFrame, double FramesPerSecond)
 
int HMSFToIndex (const char *HMSF, double FramesPerSecond)
 
int SecondsToFrames (int Seconds, double FramesPerSecond)
 
int ReadFrame (cUnbufferedFile *f, uchar *b, int Length, int Max)
 
bool HasRecordingsSortMode (const char *Directory)
 
void GetRecordingsSortMode (const char *Directory)
 
void SetRecordingsSortMode (const char *Directory, eRecordingsSortMode SortMode)
 
void IncRecordingsSortMode (const char *Directory)
 
void SetRecordingTimerId (const char *Directory, const char *TimerId)
 
cString GetRecordingTimerId (const char *Directory)
 
int FileSizeMBafterEdit (const char *FileName)
 
bool EnoughFreeDiskSpaceForEdit (const char *FileName)
 

Variables

int DirectoryPathMax = PATH_MAX - 1
 
int DirectoryNameMax = NAME_MAX
 
bool DirectoryEncoding = false
 
int InstanceId = 0
 
static cRemoveDeletedRecordingsThread RemoveDeletedRecordingsThread
 
tCharExchange CharExchange []
 
const char * InvalidChars = "\"\\/:*?|<>#"
 
cRecordingsHandler RecordingsHandler
 
double MarkFramesPerSecond = DEFAULTFRAMESPERSECOND
 
cMutex MutexMarkFramesPerSecond
 
cDoneRecordings DoneRecordingsPattern
 
static const char * FuzzyChars = " -:/"
 
eRecordingsSortMode RecordingsSortMode = rsmTime
 

Macro Definition Documentation

◆ __STDC_FORMAT_MACROS

#define __STDC_FORMAT_MACROS

Definition at line 15 of file recording.c.

◆ DATAFORMATPES

#define DATAFORMATPES   "%4d-%02d-%02d.%02d%*c%02d.%02d.%02d" RECEXT

Definition at line 46 of file recording.c.

Referenced by cRecording::cRecording().

◆ DATAFORMATTS

#define DATAFORMATTS   "%4d-%02d-%02d.%02d.%02d.%d-%d" RECEXT

Definition at line 48 of file recording.c.

Referenced by cRecording::cRecording().

◆ DELETEDLIFETIME

#define DELETEDLIFETIME   300

Definition at line 64 of file recording.c.

Referenced by cRecording::RetentionExpired().

◆ DELEXT

◆ DISKCHECKDELTA

#define DISKCHECKDELTA   100

Definition at line 65 of file recording.c.

Referenced by AssertFreeDiskSpace().

◆ IFG_BUFFER_SIZE

#define IFG_BUFFER_SIZE   KILOBYTE(100)

Definition at line 2596 of file recording.c.

Referenced by cIndexFileGenerator::Action().

◆ INDEXCATCHUPWAIT

#define INDEXCATCHUPWAIT   100

Definition at line 2792 of file recording.c.

Referenced by cIndexFile::CatchUp().

◆ INDEXFILECHECKINTERVAL

#define INDEXFILECHECKINTERVAL   500

Definition at line 2820 of file recording.c.

Referenced by cIndexFile::cIndexFile(), and GenerateIndex().

◆ INDEXFILESUFFIX

#define INDEXFILESUFFIX   "/index"

Definition at line 2788 of file recording.c.

Referenced by GenerateIndex(), and cIndexFile::IndexFileName().

◆ INDEXFILETESTINTERVAL

#define INDEXFILETESTINTERVAL   10

Definition at line 2821 of file recording.c.

Referenced by cIndexFile::cIndexFile().

◆ INFOFILESUFFIX

#define INFOFILESUFFIX   "/info"

◆ LIMIT_SECS_PER_MB_RADIO

#define LIMIT_SECS_PER_MB_RADIO   5

Definition at line 72 of file recording.c.

Referenced by cRecordings::MBperMinute().

◆ MARKSFILESUFFIX

#define MARKSFILESUFFIX   "/marks"

Definition at line 56 of file recording.c.

Referenced by cMarks::Load(), and cMarks::MarksFileName().

◆ MARKSUPDATEDELTA

#define MARKSUPDATEDELTA   10

Definition at line 67 of file recording.c.

◆ MAX_LINK_LEVEL

#define MAX_LINK_LEVEL   6

Definition at line 70 of file recording.c.

Referenced by cVideoDirectoryScannerThread::ScanVideoDir().

◆ MAXFILESPERRECORDINGPES

#define MAXFILESPERRECORDINGPES   255

Definition at line 3200 of file recording.c.

Referenced by cFileName::SetOffset().

◆ MAXFILESPERRECORDINGTS

#define MAXFILESPERRECORDINGTS   65535

Definition at line 3202 of file recording.c.

Referenced by cFileName::GetLastPatPmtVersions(), and cFileName::SetOffset().

◆ MAXINDEXCATCHUP

#define MAXINDEXCATCHUP   8

Definition at line 2791 of file recording.c.

Referenced by cIndexFile::CatchUp().

◆ MAXREMOVETIME

#define MAXREMOVETIME   10

Definition at line 68 of file recording.c.

Referenced by cRemoveDeletedRecordingsThread::Action().

◆ MAXWAITFORINDEXFILE

#define MAXWAITFORINDEXFILE   10

Definition at line 2819 of file recording.c.

Referenced by cIndexFile::cIndexFile().

◆ MINDISKSPACE

#define MINDISKSPACE   1024

Definition at line 61 of file recording.c.

Referenced by AssertFreeDiskSpace(), and EnoughFreeDiskSpaceForEdit().

◆ NAMEFORMATPES

#define NAMEFORMATPES   "%s/%s/" "%4d-%02d-%02d.%02d.%02d.%02d.%02d" RECEXT

Definition at line 47 of file recording.c.

Referenced by cRecording::FileName().

◆ NAMEFORMATTS

#define NAMEFORMATTS   "%s/%s/" DATAFORMATTS

Definition at line 49 of file recording.c.

Referenced by cRecording::FileName().

◆ RECEXT

#define RECEXT   ".rec"

◆ RECORDFILESUFFIXLEN

#define RECORDFILESUFFIXLEN   20

Definition at line 3204 of file recording.c.

Referenced by cFileName::cFileName().

◆ RECORDFILESUFFIXPES

#define RECORDFILESUFFIXPES   "/%03d.vdr"

Definition at line 3201 of file recording.c.

Referenced by cFileName::SetOffset().

◆ RECORDFILESUFFIXTS

#define RECORDFILESUFFIXTS   "/%05d.ts"

Definition at line 3203 of file recording.c.

Referenced by cFileName::GetLastPatPmtVersions(), and cFileName::SetOffset().

◆ REMOVECHECKDELTA

#define REMOVECHECKDELTA   60

Definition at line 63 of file recording.c.

Referenced by RemoveDeletedRecordings().

◆ REMOVELATENCY

#define REMOVELATENCY   10

Definition at line 66 of file recording.c.

Referenced by AssertFreeDiskSpace().

◆ RESUME_NOT_INITIALIZED

#define RESUME_NOT_INITIALIZED   (-2)

◆ RESUMEFILESUFFIX

#define RESUMEFILESUFFIX   "/resume%s%s"

Definition at line 51 of file recording.c.

Referenced by cResumeFile::cResumeFile().

◆ SORTMODEFILE

#define SORTMODEFILE   ".sort"

◆ SUMMARYFALLBACK

#define SUMMARYFALLBACK

Definition at line 33 of file recording.c.

◆ SUMMARYFILESUFFIX

#define SUMMARYFILESUFFIX   "/summary.vdr"

Definition at line 53 of file recording.c.

Referenced by cRecording::cRecording().

◆ TIMERRECFILE

#define TIMERRECFILE   ".timer"

Function Documentation

◆ __attribute__()

struct __attribute__ ( (packed) )

Definition at line 2621 of file recording.c.

Referenced by get_unaligned(), put_unaligned(), and syslog_with_tid().

◆ AssertFreeDiskSpace()

void AssertFreeDiskSpace ( int Priority = 0,
bool Force = false )

◆ EnoughFreeDiskSpaceForEdit()

◆ ExchangeChars()

◆ FileSizeMBafterEdit()

int FileSizeMBafterEdit ( const char * FileName)

◆ GenerateIndex()

bool GenerateIndex ( const char * FileName)

Generates the index of the existing recording with the given FileName.

An existing index file will be removed before a new one is generated.

Definition at line 3171 of file recording.c.

References cThread::Active(), AddDirectory(), DirectoryOk(), INDEXFILECHECKINTERVAL, INDEXFILESUFFIX, cRecording::IsPesRecording(), cRecording::Name(), and cCondWait::SleepMs().

Referenced by GenerateIndex(), and main().

◆ GetRecordingsSortMode()

void GetRecordingsSortMode ( const char * Directory)

◆ GetRecordingTimerId()

cString GetRecordingTimerId ( const char * Directory)

Definition at line 3562 of file recording.c.

References AddDirectory(), stripspace(), and TIMERRECFILE.

Referenced by TimerStillRecording().

◆ HasRecordingsSortMode()

bool HasRecordingsSortMode ( const char * Directory)

Definition at line 3509 of file recording.c.

References AddDirectory(), and SORTMODEFILE.

◆ HMSFToIndex()

int HMSFToIndex ( const char * HMSF,
double FramesPerSecond )

Definition at line 3473 of file recording.c.

Referenced by cSVDRPServer::CmdPLAY(), and cMark::Parse().

◆ IncRecordingsSortMode()

void IncRecordingsSortMode ( const char * Directory)

◆ IndexToHMSF()

cString IndexToHMSF ( int Index,
bool WithFrame,
double FramesPerSecond )

Definition at line 3457 of file recording.c.

References cString::sprintf().

Referenced by cDvbPlayer::Action(), cReplayControl::ShowProgress(), and cMark::ToText().

◆ LimitNameLengths()

char * LimitNameLengths ( char * s,
int PathMax,
int NameMax )

Definition at line 777 of file recording.c.

References FOLDERDELIMCHAR, NeedsConversion(), and Utf8CharLen().

Referenced by cRecording::FileName().

◆ NeedsConversion()

bool NeedsConversion ( const char * p)

Definition at line 699 of file recording.c.

References DirectoryEncoding, FOLDERDELIMCHAR, and InvalidChars.

Referenced by ExchangeChars(), and LimitNameLengths().

◆ ReadFrame()

int ReadFrame ( cUnbufferedFile * f,
uchar * b,
int Length,
int Max )

◆ RemoveDeletedRecordings()

void RemoveDeletedRecordings ( void )

◆ SecondsToFrames()

int SecondsToFrames ( int Seconds,
double FramesPerSecond )

◆ SetRecordingsSortMode()

void SetRecordingsSortMode ( const char * Directory,
eRecordingsSortMode SortMode )

Definition at line 3525 of file recording.c.

References AddDirectory(), SORTMODEFILE, and cString::sprintf().

Referenced by IncRecordingsSortMode().

◆ SetRecordingTimerId()

void SetRecordingTimerId ( const char * Directory,
const char * TimerId )

◆ SkipFuzzyChars()

static const char * SkipFuzzyChars ( const char * s)
static

Definition at line 3427 of file recording.c.

References FuzzyChars.

Referenced by cDoneRecordings::Contains().

◆ StillRecording()

static bool StillRecording ( const char * Directory)
static

Variable Documentation

◆ CharExchange

tCharExchange CharExchange[]
Initial value:
= {
{ FOLDERDELIMCHAR, '/' },
{ '/', FOLDERDELIMCHAR },
{ ' ', '_' },
{ '\'', '\'' },
{ '\'', '\x01' },
{ '/', '\x02' },
{ 0, 0 }
}
#define FOLDERDELIMCHAR
Definition recording.h:22

Definition at line 686 of file recording.c.

Referenced by ExchangeChars().

◆ DirectoryEncoding

bool DirectoryEncoding = false

Definition at line 76 of file recording.c.

Referenced by ExchangeChars(), main(), and NeedsConversion().

◆ DirectoryNameMax

int DirectoryNameMax = NAME_MAX

Definition at line 75 of file recording.c.

Referenced by cRecording::FileName(), and main().

◆ DirectoryPathMax

int DirectoryPathMax = PATH_MAX - 1

Definition at line 74 of file recording.c.

Referenced by cRecording::FileName(), and main().

◆ DoneRecordingsPattern

cDoneRecordings DoneRecordingsPattern

Definition at line 3364 of file recording.c.

Referenced by main(), cTimer::Matches(), and cRecordControl::Stop().

◆ FuzzyChars

const char* FuzzyChars = " -:/"
static

Definition at line 3425 of file recording.c.

Referenced by SkipFuzzyChars().

◆ InstanceId

int InstanceId = 0

Definition at line 77 of file recording.c.

Referenced by cRecording::cRecording(), and main().

◆ InvalidChars

const char* InvalidChars = "\"\\/:*?|<>#"

Definition at line 697 of file recording.c.

Referenced by NeedsConversion().

◆ MarkFramesPerSecond

double MarkFramesPerSecond = DEFAULTFRAMESPERSECOND

Definition at line 2329 of file recording.c.

Referenced by cMark::Parse(), and cMarks::Update().

◆ MutexMarkFramesPerSecond

cMutex MutexMarkFramesPerSecond

Definition at line 2330 of file recording.c.

Referenced by cMarks::Update().

◆ RecordingsHandler

◆ RecordingsSortMode

◆ RemoveDeletedRecordingsThread

cRemoveDeletedRecordingsThread RemoveDeletedRecordingsThread
static

Definition at line 131 of file recording.c.

Referenced by RemoveDeletedRecordings().