summaryrefslogtreecommitdiffstats
path: root/libk9copy/k9dvdbackup.h
blob: 71d9595bfb875aa9160eea9285a43ca625a40497 (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
/***************************************************************************
*   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 K9DVDBACKUP_H
#define K9DVDBACKUP_H

#include "k9common.h"
#include "k9cell.h"
#include "k9cellcopylist.h"
#include "k9dvdread.h"
#include <tqptrqueue.h>
#include <tqmutex.h>
#include <tqfile.h>
/**
@author Jean-Michel Petit
*/

class k9BackupDlg;
class k9Ifo2;

class k9TitleSet : public TQObject {
    Q_OBJECT
  
public:
    k9TitleSet(int _VTS);
    ~k9TitleSet();
    uint32_t startSector;
    uint32_t lastSector;
    int VTS;
	uint32_t menuSize;
    k9CellList cells,menuCells;
    k9Cell*addCell(int _vts,int _pgc, int _vob);
    uint32_t getSize();
    k9Ifo2 *ifoTitle;
private:
};

class k9TitleSetList:public TQPtrList <k9TitleSet> {
protected:
	 int compareItems ( TQPtrCollection::Item item1, TQPtrCollection::Item item2 );
};

class k9CadtList:public TQPtrList<cell_adr_t> {
protected:
   int compareItems(TQPtrCollection::Item item1,TQPtrCollection::Item item2);
};

class k9vamps;

class k9DVDBackup : public TQObject {
    Q_OBJECT
  
public:
    k9DVDBackup(TQObject  *_dvd,const char* name=0,const TQStringList& args=0) ;

    ~k9DVDBackup();
    virtual void setDevice(TQString _device);
    virtual void setOutput(TQString _output);
    virtual TQString getErrMsg();
    virtual void execute();
    virtual bool geterror();
    virtual void setWithMenus(bool _value);
    virtual TQWidget *getDialog() {return (TQWidget*)backupDlg;};
public  slots:
    void getOutput(uchar *buffer,uint32_t size);

protected:
    TQString device;
    TQString output;
    bool wrote;
private:
    k9DVDRead *m_dvdread;
    bool m_copyMenu;
    bool m_withMenu;
    bool m_forcedFactor;
    k9DVD *DVD;
    TQString errMsg;
    TQString vampsMsg;
    TQFile* outputFile;
    long cellSize;
    long currVTS;
    k9TitleSet *currTS;
    int currVOB;
    ifo_handle_t *m_ifo;
    k9Cell *currCell,*cellOut;//,*currCopyCell;
    k9CellCopyList *m_cellCopyList;
    uint32_t m_position,m_vmgSize;
    bool m_preserve;
    //uint64_t m_inbytes,m_outbytes;
    k9TitleSetList titleSets;
    float argFactor;
    uint64_t argSize;
    void prepareVTS(int VTS);
    void playCell (int vts_num, k9Cell *_cell,bool _empty=false);
    uint32_t findNextVobu(uint32_t _sector);
    uint32_t copyVobu(k9DVDFile  *_fileHandle,uint32_t _startSector,k9Vobu *_vobu,bool _empty=false);
    void copyCell(int VTS, k9Cell *_cell,bool _empty);
//    void copyAngleBlock(k9CellCopyList *_list,uint _num);
    void copyEmptyPgc(int _vts,k9Cell *_cell);
    void updateVob(k9CellList *_cells);
    
    void updateIfo();
    void updateMainIfo();
    void updatePgci_ut(ifo_handle_t *_hifo);
    void update4Menu(ifo_handle_t *_hifo);
    void setDummyPack(uchar *_buffer);
    void setDummyNavPack(uchar *_buffer,uint32_t _sector);
    uint32_t copyMenu2(int _vts);
    k9CellList vmgCells;

    k9Vobu * remapVobu(uint32_t *value);
    k9Vobu * remapOffset(uint32_t _sector,uint32_t *offset,int dir);
    k9BackupDlg *backupDlg;
    uint  getLastCell(k9CellCopyList *_cellCopyList,uint _index);
    void calcFactor();
    void forceFactor(double _factor);
    bool error;
    void seterror(const TQString &_msg);
    k9vamps *vamps;
    TQPtrQueue <k9Vobu> vobuQueue;
    TQMutex mutex;
};



#endif