summaryrefslogtreecommitdiffstats
path: root/libk9copy/k9dvd.h
blob: 55182df1202920db2ffff9df693db5a3c956fb65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/**************************************************************************
*   Copyright (C) 2005 by Jean-Michel Petit                               *
*   [email protected]                                                  *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         *
*   This program is distributed in the hope that it will be useful,       *
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
*   GNU General Public License for more details.                          *
*                                                                         *
*   You should have received a copy of the GNU General Public License     *
*   along with this program; if not, write to the                         *
*   Free Software Foundation, Inc.,                                       *
*   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
***************************************************************************/
#ifndef K9DVD_H
#define K9DVD_H
#include "k9common.h"
#include "k9dvdread.h"
#include <qstringlist.h>
#include <qdatetime.h>
#include <qvaluelist.h>


struct streamSize {
   unsigned char id;
   float size_mb;
   float percent;
};

struct stream_counter {
   unsigned char id;
   int count;
   float size_mb;
   float percent;
};

class k9DVDProgress;
class k9DVDChapter;
class k9DVDTitle;
class k9DVDTitleset;

/** get the DVD structure with titles lengths and streams lengths.
  *@author 
  */

class k9DVD : public QObject  {
Q_OBJECT  
private:
  QObjectList m_titles;
  QPtrList<k9DVDTitleset> m_titlesets;
  QString m_title;
  int m_titleCount;
  k9DVDTitle *m_longestTitle;
  QStringList m_lvideoFormat;
  QStringList m_laspectRatio;
  QStringList m_lquantization;
  QStringList m_lmpegVersion;
  QStringList m_lvideoHeight;
  QStringList m_lvideoWidth;
  QStringList m_lpermittedDf;
  QStringList m_laudioFormat;
  QStringList m_lsampleFreq;
  QStringList m_laudioType;
  QStringList m_lsubpType;
  QStringList m_langCode;
  QStringList m_langName;
  double m_frames_per_s[4];
  uint m_menuSize;
  k9DVDProgress *m_progressDlg; 
  QString m_Device;
  bool m_error;
  QString m_errMsg;
  bool m_opened;
  QString m_format;
  k9DVDTitle* m_start;
  int m_titlesetCount;
public: 
  k9DVD(QObject  *parent=0,const char *name=0,const QStringList args=0) ;
  ~k9DVD();

  /**
   * Opens and estimates the size of each stream
   * @param device input device
   * @return return code (0=ok)
   */
  virtual int scandvd (const QString & device,bool _quickScan);
 
  /**
   * gets the title of the DVD
   * @return DVD title
   */
  virtual const QString& getDVDTitle();
  
  /**
   * set the title of the DVD 
   * @param _newVal the new DVD title
   */
  virtual void setDVDTitle(const QString &_newVal);
  
  /**
   * 
   * @return returns the number of titles
   */
  virtual const int& gettitleCount();

  /**
   * 
   * @return returns the number of titlesets
   */
  virtual const int& gettitlesetCount();


  /**
   * returns a title of the DVD
   * @param num the title number
   * @return the title
   */
  virtual k9DVDTitle* gettitle(int num);
  
  /**
   * returns a title (which is in tt_srpt)  
   * @param num the title number 
   * @return the title
   */
  virtual k9DVDTitle* gettitleByNum(int num);
  virtual k9DVDTitle *getlongestTitle();
  virtual float getfactor(bool withMenus,bool _streams,bool _useDvdAuthor);
  virtual const QString& getDevice();
  virtual const bool& geterror();
  virtual const QString& geterrMsg();
  virtual const bool& getopened();
  virtual uint64_t getsizeSelected(bool _streams);
  virtual QString &getFormat();
  virtual k9DVDTitle* getstart();
  virtual void setstart(k9DVDTitle* title);
  virtual int getnewTitleNum(k9DVDTitle *title);
  virtual int getmenuSize();
  virtual void close();
  virtual k9DVDTitleset *gettitleset(int num);
  virtual k9DVDRead * getdvd() {return &m_dvd;}
  static QString lang_name(const QString & code,const QString & name);
private: // Private methods
  k9DVDRead  m_dvd;
  k9DVDTitle* addTitle(k9DVDTitleset *titleset,int id,int num,int _VTS,int _pgc,uint32_t _startSector, bool _indexed);
  float calcVobuSize(ifo_handle_t *_ifo,k9DVDChapter *_chapter);
  long stream_vob( int title, unsigned long startblock, unsigned long lastblock, struct stream_counter *sc);
  int identify_stream( unsigned char *buffer ) ;
  int dvdtime2msec(dvd_time_t *dt);
  int get_title_name(const char* dvd_device, char* title);
  void calcStreamSize(k9DVDTitle & title);
  void setError(const QString &err);
  int getVampsID(int type);
  int calcNumTitle(ifo_handle_t *ifo,int _vts,int _ttn);
public slots: // Public slots
  void slotVobProgress(unsigned int position,unsigned int total);
  void slotTitleProgress(unsigned int position,unsigned int total);
  void slotTitleText(QString &text);
  void slotTotalText(QString &text);
signals: // Signals
  void sigVobProgress(unsigned int position,unsigned int total);
  void sigTitleProgress(unsigned int position,unsigned int total);
  void sigTitleText(QString &text);
  void sigTotalText(QString &text);
};

typedef struct lng { char code[3];	QString name;};

#endif