summaryrefslogtreecommitdiff
path: root/dvbplayer.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <kls (at) cadsoft (dot) de>2009-01-06 20:31:53 +0100
committerKlaus Schmidinger <kls (at) cadsoft (dot) de>2009-01-06 20:31:53 +0100
commitc2966475942fcb9d4b8d41dbf026ff57630a1ad6 (patch)
tree1b41925820073ddee361c5acb0fd68fbadcd11a8 /dvbplayer.c
parent1834751c4510edb66c96d0b741def5922738e74c (diff)
downloadvdr-patch-lnbsharing-c2966475942fcb9d4b8d41dbf026ff57630a1ad6.tar.gz
vdr-patch-lnbsharing-c2966475942fcb9d4b8d41dbf026ff57630a1ad6.tar.bz2
Version 1.7.3vdr-1.7.3
- Updated the Russian OSD texts (thanks to Oleg Roitburd). - Fixed handling the 'pointer field' in generating and parsing PAT/PMT (thanks to Frank Schmirler). - Fixed handling modulation types for DVB-S transponders when processing the NIT. - Changed cDvbDevice::GrabImage() to use V4L2 (thanks to Marco Schlüßler). - Added a poll to cDvbDevice::PlayVideo() and cDvbDevice::PlayAudio() to avoid excessive CPU load (this is just a makeshift solution until the FF DVB cards can play TS directly). - The recording format is now Transport Stream. Existing recordings in PES format can still be replayed and edited, but new recordings are done in TS. All code for recording in PES has been removed. The following changes were made to switch to TS recording format: + The index file format has been changed to support file sizes of up to 1TB (previously 2GB), and up to 65535 separate files per recording (previously 255). + The recording file names are now of the form 00001.ts (previously 001.vdr). + The frame rate is now detected by looking at two subsequent PTS values. The "frame duration" (in multiples of 1/90000) is stored in the info.vdr file using the new tag F (thanks to Artur Skawina for helping to get the IndexToHMSF() calculation right). + Several functions now have an additional parameter FramesPerSecond. + Several functions now have an additional parameter IsPesRecording. + The functionality of cFileWriter was moved into cRecorder, and cRemux is now obsolete. This also avoids one level of data copying while recording. + cRemux, cRingBufferLinearPes, cTS2PES and all c*Repacker classes have been removed. + A PAT/PMT is inserted before every independent frame, so that no extra measures need to be taken when editing a recording. + The directory name for a recording has been changed from YYYY-MM-DD-hh[.:]mm.pr.lt.rec (pr=priority, lt=lifetime) to YYYY-MM-DD-hh.mm.ch-ri.rec (ch=channel, ri=resumeId). Priority and Lifetime are now stored in the info.vdr file with the new tags P and L (if no such file exists, the maximum values are assumed by default, which avoids inadvertently deleting a recording if disk space is low). No longer storing Priority and Lifetime in the directory name avoids starting a new recording if one of these is changed in the timer and the recording is re-started for some reason. Instead of Priority and Lifetime, the directory name now contains the channel number from which the recording was made, and the "resume id" of this instance of VDR. This avoids problems if several VDR instances record the same show on different channels, or even on the same channel. The '-' between channel number and resumeId prevents older versions of VDR from "seeing" these recordings, which makes sure they won't even try to replay them, or remove them in case the disk runs full. + The semantics of PlayTs*() have been changed. These functions are now required to return the given Length (which is TS_SIZE) if they have processed the TS packet. + The files "index", "info", "marks" and "resume" within a TS recording directory are now created without the ".vdr" extension. + The "resume" file is no longer a binary file, but contains tagged lines to be able to store additional information, like the selected audio or subtitle track. + cDevice::StillPicture() will now be called with either TS or PES data. + cDvbPlayer::Goto() no longer appends a "sequence end code" to the data. If the output device needs this, it has to take care of it by itself. - Fixed cPatPmtParser::ParsePmt() to reset vpid and vtype when switching from a video to an audio channel (thanks to Reinhard Nissl). - cDvbDevice now uses the FE_CAN_2G_MODULATION flag to determine whether a device can handle DVB-S2. The #define is still there to allow people with older drivers who don't need DVB-S2 to use this version without pathcing.
Diffstat (limited to 'dvbplayer.c')
-rw-r--r--dvbplayer.c80
1 files changed, 36 insertions, 44 deletions
diff --git a/dvbplayer.c b/dvbplayer.c
index 0fe8d34..9de7e48 100644
--- a/dvbplayer.c
+++ b/dvbplayer.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: dvbplayer.c 2.0 2008/02/09 15:10:54 kls Exp $
+ * $Id: dvbplayer.c 2.1 2009/01/05 16:52:40 kls Exp $
*/
#include "dvbplayer.h"
@@ -182,8 +182,8 @@ bool cNonBlockingFileReader::WaitForDataMs(int msToWait)
#define PLAYERBUFSIZE MEGABYTE(1)
-// The number of frames to back up when resuming an interrupted replay session:
-#define RESUMEBACKUP (10 * FRAMESPERSEC)
+// The number of seconds to back up when resuming an interrupted replay session:
+#define RESUMEBACKUP 10
class cDvbPlayer : public cPlayer, cThread {
private:
@@ -196,6 +196,8 @@ private:
cFileName *fileName;
cIndexFile *index;
cUnbufferedFile *replayFile;
+ double framesPerSecond;
+ bool isPesRecording;
bool eof;
bool firstPacket;
ePlayModes playMode;
@@ -223,6 +225,7 @@ public:
int SkipFrames(int Frames);
void SkipSeconds(int Seconds);
void Goto(int Position, bool Still = false);
+ virtual double FramesPerSecond(void) { return framesPerSecond; }
virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame = false);
virtual bool GetReplayMode(bool &Play, bool &Forward, int &Speed);
};
@@ -240,6 +243,9 @@ cDvbPlayer::cDvbPlayer(const char *FileName)
ringBuffer = NULL;
backTrace = NULL;
index = NULL;
+ cRecording Recording(FileName);
+ framesPerSecond = Recording.FramesPerSecond();
+ isPesRecording = Recording.IsPesRecording();
eof = false;
firstPacket = true;
playMode = pmPlay;
@@ -249,13 +255,13 @@ cDvbPlayer::cDvbPlayer(const char *FileName)
readFrame = NULL;
playFrame = NULL;
isyslog("replay %s", FileName);
- fileName = new cFileName(FileName, false);
+ fileName = new cFileName(FileName, false, false, isPesRecording);
replayFile = fileName->Open();
if (!replayFile)
return;
ringBuffer = new cRingBufferFrame(PLAYERBUFSIZE);
// Create the index file:
- index = new cIndexFile(FileName, false);
+ index = new cIndexFile(FileName, false, isPesRecording);
if (!index)
esyslog("ERROR: can't allocate index");
else if (!index->Ok()) {
@@ -327,8 +333,8 @@ int cDvbPlayer::Resume(void)
if (index) {
int Index = index->GetResume();
if (Index >= 0) {
- uchar FileNumber;
- int FileOffset;
+ uint16_t FileNumber;
+ off_t FileOffset;
if (index->Get(Index, &FileNumber, &FileOffset) && NextFile(FileNumber, FileOffset))
return Index;
}
@@ -341,7 +347,7 @@ bool cDvbPlayer::Save(void)
if (index) {
int Index = writeIndex;
if (Index >= 0) {
- Index -= RESUMEBACKUP;
+ Index -= RESUMEBACKUP * framesPerSecond;
if (Index > 0)
Index = index->GetNextIFrame(Index, false);
else
@@ -371,7 +377,7 @@ void cDvbPlayer::Action(void)
readIndex = Resume();
if (readIndex >= 0)
- isyslog("resuming replay at index %d (%s)", readIndex, *IndexToHMSF(readIndex, true));
+ isyslog("resuming replay at index %d (%s)", readIndex, *IndexToHMSF(readIndex, true, framesPerSecond));
nonBlockingFileReader = new cNonBlockingFileReader;
int Length = 0;
@@ -397,8 +403,8 @@ void cDvbPlayer::Action(void)
if (!readFrame && (replayFile || readIndex >= 0)) {
if (!nonBlockingFileReader->Reading()) {
if (playMode == pmFast || (playMode == pmSlow && playDir == pdBackward)) {
- uchar FileNumber;
- int FileOffset;
+ uint16_t FileNumber;
+ off_t FileOffset;
bool TimeShiftMode = index->IsStillRecording();
int Index = -1;
if (DeviceHasIBPTrickSpeed() && playDir == pdForward) {
@@ -435,8 +441,8 @@ void cDvbPlayer::Action(void)
readIndex = Index;
}
else if (index) {
- uchar FileNumber;
- int FileOffset;
+ uint16_t FileNumber;
+ off_t FileOffset;
readIndex++;
if (!(index->Get(readIndex, &FileNumber, &FileOffset, NULL, &Length) && NextFile(FileNumber, FileOffset))) {
readIndex = -1;
@@ -496,14 +502,22 @@ void cDvbPlayer::Action(void)
pc = playFrame->Count();
if (p) {
if (firstPacket) {
- PlayPes(NULL, 0);
- cRemux::SetBrokenLink(p, pc);
+ if (isPesRecording) {
+ PlayPes(NULL, 0);
+ cRemux::SetBrokenLink(p, pc);
+ }
+ else
+ PlayTs(NULL, 0);
firstPacket = false;
}
}
}
if (p) {
- int w = PlayPes(p, pc, playMode != pmPlay);
+ int w;
+ if (isPesRecording)
+ w = PlayPes(p, pc, playMode != pmPlay);
+ else
+ w = PlayTs(p, TS_SIZE, playMode != pmPlay);
if (w > 0) {
p += w;
pc -= w;
@@ -513,7 +527,7 @@ void cDvbPlayer::Action(void)
break;
}
}
- if (pc == 0) {
+ if (pc <= 0) {
writeIndex = playFrame->Index();
backTrace->Add(playFrame->Index(), playFrame->Count());
ringBuffer->Drop(playFrame);
@@ -678,7 +692,7 @@ void cDvbPlayer::SkipSeconds(int Seconds)
Empty();
int Index = writeIndex;
if (Index >= 0) {
- Index = max(Index + Seconds * FRAMESPERSEC, 0);
+ Index = max(Index + SecondsToFrames(Seconds, framesPerSecond), 0);
if (Index > 0)
Index = index->GetNextIFrame(Index, false, NULL, NULL, NULL, true);
if (Index >= 0)
@@ -695,38 +709,16 @@ void cDvbPlayer::Goto(int Index, bool Still)
Empty();
if (++Index <= 0)
Index = 1; // not '0', to allow GetNextIFrame() below to work!
- uchar FileNumber;
- int FileOffset, Length;
+ uint16_t FileNumber;
+ off_t FileOffset;
+ int Length;
Index = index->GetNextIFrame(Index, false, &FileNumber, &FileOffset, &Length);
if (Index >= 0 && NextFile(FileNumber, FileOffset) && Still) {
- uchar b[MAXFRAMESIZE + 4 + 5 + 4];
+ uchar b[MAXFRAMESIZE];
int r = ReadFrame(replayFile, b, Length, sizeof(b));
if (r > 0) {
if (playMode == pmPause)
DevicePlay();
- // append sequence end code to get the image shown immediately with softdevices
- if (r > 6 && (b[3] & 0xF0) == 0xE0) { // make sure to append it only to a video packet
- b[r++] = 0x00;
- b[r++] = 0x00;
- b[r++] = 0x01;
- b[r++] = b[3];
- if (b[6] & 0x80) { // MPEG 2
- b[r++] = 0x00;
- b[r++] = 0x07;
- b[r++] = 0x80;
- b[r++] = 0x00;
- b[r++] = 0x00;
- }
- else { // MPEG 1
- b[r++] = 0x00;
- b[r++] = 0x05;
- b[r++] = 0x0F;
- }
- b[r++] = 0x00;
- b[r++] = 0x00;
- b[r++] = 0x01;
- b[r++] = 0xB7;
- }
DeviceStillPicture(b, r);
}
playMode = pmStill;