/*
 * cal-mpeg.h: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id$
 */

#include <vdr/tools.h>

typedef uint64_t pts_t;

#define MAX_PTS     8589934591LL
#define NO_PTS      8589934592LL
#define NO_DTS      8589934592LL
#define INVALID_PTS 8589934593LL
#define INVALID_DTS 8589934593LL


// --- cCalPES ---------------------------------------------------------------

class cCalPES {
private:
  uchar *data;
  int length;
public:
  cCalPES(void);
  cCalPES(const uchar *Data, int Length);
  ~cCalPES();
  uchar *GetData(void) { return data; };
  int GetStreamID(void) { return (data) ? data[3] : -1; };
  int GetLength(void) { return (data) ? length : 0; };
  bool HasPTS(void) { return (data) ? (((data[7]>>7) & 1) == 1) : false; };
  bool HasDTS(void) { return (data) ? (((data[7]>>6) & 1) == 1) : false; };
  pts_t GetPTS(void);
  pts_t GetDTS(void);
  void GetPayload(uchar *Data, int& Length);
  void SetPTS(pts_t Pts);
  };


// ---------------------------------------------------------------------------

cString PTSToHMST(pts_t pts, bool withT = false);
cString PTSToHMSF(pts_t pts, bool withF = false);
