[matroska] r905 - trunk/DvdMenuXtractor

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: robux4
Date: 2004-10-23 14:04:52 +0400 (Sat, 23 Oct 2004)
New Revision: 905

Modified:
   trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
   trunk/DvdMenuXtractor/IFOFile.cpp
   trunk/DvdMenuXtractor/IFOFile.h
Log:
prepare for better stream handling

Modified: trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
===================================================================
--- trunk/DvdMenuXtractor/DvdMenuXtractor.cpp	2004-10-22 19:49:54 UTC (rev 904)
+++ trunk/DvdMenuXtractor/DvdMenuXtractor.cpp	2004-10-23 10:04:52 UTC (rev 905)
@@ -564,7 +564,11 @@
 
                         demuxer = new CompositeDemuxWriter();
                         demuxer->AddDemuxer(new VideoDemuxWriter(m2vDirectory+newFilename));
+
+						// _TODO_ decide which audio streams to process
                         demuxer->AddDemuxer(new AC3DemuxWriter(ac3Directory+newFilename));
+
+						// _TODO_ decide which subs streams to process
 						if(aVobParser.m_pci.btn_ns > 0)
 						{
 							demuxer->AddDemuxer(new SubDemuxWriter(subDirectory+newFilename));

Modified: trunk/DvdMenuXtractor/IFOFile.cpp
===================================================================
--- trunk/DvdMenuXtractor/IFOFile.cpp	2004-10-22 19:49:54 UTC (rev 904)
+++ trunk/DvdMenuXtractor/IFOFile.cpp	2004-10-23 10:04:52 UTC (rev 905)
@@ -7,12 +7,16 @@
 // ----------------------------------------------------------------------------
 
 #include "wx/listimpl.cpp"
-//WX_DEFINE_LIST(ButtonsListType);
+
 WX_DEFINE_LIST(CellsListType);
 WX_DEFINE_LIST(IfoHandleList);
+WX_DEFINE_LIST(AudioTrackList);
+WX_DEFINE_LIST(SubtitleTrackList);
 
 // ----------------------------------------------------------------------------
 
+extern "C" void myfprintf(FILE * f, const char * format, ...);
+
 // Macro to convert Binary Coded Decimal to Decimal
 #define BCD2D(__x__) (((__x__ & 0xf0) >> 4) * 10 + (__x__ & 0x0f))
 
@@ -46,15 +50,29 @@
 	{
 		throw IFOInvalidFileFormatException();
 	}
-	m_ifos.Append(ifoOpen(m_dvd,0));
 
-	if (m_ifos.GetCount() && m_ifos.Item(0)->GetData()->vmgi_mat)
+	try {
+		m_ifos.Append(new IfoContent(m_dvd,0));
+	}
+	catch (...)
 	{
-		for (int i=1; i<=m_ifos.Item(0)->GetData()->vmgi_mat->vmg_nr_of_title_sets; i++)
+		myfprintf(stderr, "Cannot open VIDEO_TS.IFO");
+	}
+
+	if (m_ifos.GetCount() && m_ifos.Item(0)->GetData()->Handle().vmgi_mat)
+	{
+		for (int i=1; i<=m_ifos.Item(0)->GetData()->Handle().vmgi_mat->vmg_nr_of_title_sets; i++)
 		{
-			m_ifos.Append(ifoOpen(m_dvd,i));
+			try {
+				m_ifos.Append(new IfoContent(m_dvd,i));
+			}
+			catch (...)
+			{
+				myfprintf(stderr, "Cannot open VTS_%02d_X.IFO", i);
+			}
 		}
 	}
+
 	if (m_ifos.GetCount() < 2)
 	{
 		throw IFOInvalidFileFormatException();
@@ -67,7 +85,7 @@
 IFOFile::~IFOFile()
 {
 	for (unsigned int i=0; i<m_ifos.GetCount(); i++)
-		ifoClose(m_ifos.Item(i)->GetData());
+		delete m_ifos.Item(i)->GetData();
 	if (m_dvd)
 	{
 		DVDClose(m_dvd);
@@ -81,9 +99,9 @@
 {
 	m_languageList.Clear();
 
-	for(int i=0; i < m_ifos.Item(title)->GetData()->pgci_ut->nr_of_lus; i++)
+	for(int i=0; i < m_ifos.Item(title)->GetData()->Handle().pgci_ut->nr_of_lus; i++)
 	{
-		pgci_lu_t& lu = m_ifos.Item(title)->GetData()->pgci_ut->lu[i];
+		pgci_lu_t& lu = m_ifos.Item(title)->GetData()->Handle().pgci_ut->lu[i];
 		m_languageList.Add(DecodeLanguage(lu.lang_code));
 		m_SelectionTab[i] = 1;
 	}
@@ -103,7 +121,7 @@
 
 void IFOFile::ClearLanguageSelection()
 {
-	for(int i = 0; i < m_ifos.Item(0)->GetData()->pgci_ut->nr_of_lus; i++)
+	for(int i = 0; i < m_ifos.Item(0)->GetData()->Handle().pgci_ut->nr_of_lus; i++)
 	{
 		m_SelectionTab[i] = 0;
 	}
@@ -114,7 +132,7 @@
 const pgc_t *IFOFile::FirstPlayPGC() const
 {
 	if (m_ifos.Item(0))
-		return m_ifos.Item(0)->GetData()->first_play_pgc;
+		return m_ifos.Item(0)->GetData()->Handle().first_play_pgc;
 	else
 		return NULL;
 }
@@ -126,7 +144,7 @@
 	if (title < m_ifos.GetCount())
 	{
 		if (m_ifos.Item(title))
-			return m_ifos.Item(title)->GetData()->pgci_ut;
+			return m_ifos.Item(title)->GetData()->Handle().pgci_ut;
 	}
 		
 	return NULL;
@@ -138,7 +156,7 @@
 {
 	if (title && title < m_ifos.GetCount())
 	{
-		return m_ifos.Item(title)->GetData()->vts_ptt_srpt;
+		return m_ifos.Item(title)->GetData()->Handle().vts_ptt_srpt;
 	}
 	return NULL;
 }
@@ -149,7 +167,7 @@
 {
 	if (title && title < m_ifos.GetCount())
 	{
-		return m_ifos.Item(title)->GetData()->vts_pgcit;
+		return m_ifos.Item(title)->GetData()->Handle().vts_pgcit;
 	}
 	return NULL;
 }
@@ -158,8 +176,8 @@
 
 const int16_t IFOFile::NumberOfTitles() const
 {
-	if (m_ifos.GetCount() && m_ifos.Item(0)->GetData()->vmgi_mat)
-		return m_ifos.Item(0)->GetData()->vmgi_mat->vmg_nr_of_title_sets;
+	if (m_ifos.GetCount() && m_ifos.Item(0)->GetData()->Handle().vmgi_mat)
+		return m_ifos.Item(0)->GetData()->Handle().vmgi_mat->vmg_nr_of_title_sets;
 	return 0;
 }
 
@@ -230,15 +248,15 @@
 	if (title >= m_ifos.GetCount())
 		return NULL;
 	
-	ifo_handle_t *_ifo = m_ifos.Item(title)->GetData(); 
+	ifo_handle_t &_ifo = m_ifos.Item(title)->GetData()->Handle(); 
 	
 	if (language)
 	{
-		if (_ifo->pgci_ut)
+		if (_ifo.pgci_ut)
 		{
-			for(int i = 0; i < _ifo->pgci_ut->nr_of_lus; i++)
+			for(int i = 0; i < _ifo.pgci_ut->nr_of_lus; i++)
 			{
-				pgci_lu_t& lu = _ifo->pgci_ut->lu[i];
+				pgci_lu_t& lu = _ifo.pgci_ut->lu[i];
 				GetPGCCells(*lu.pgcit, &CellsHash);
 			}
 		}
@@ -246,9 +264,9 @@
 	else
 	{
 		// handle non-language unit cells
-		if (_ifo->vts_pgcit)
+		if (_ifo.vts_pgcit)
 		{
-			GetPGCCells(*_ifo->vts_pgcit, &CellsHash);
+			GetPGCCells(*_ifo.vts_pgcit, &CellsHash);
 		}
 	}
 
@@ -289,3 +307,25 @@
 }
 
 // ----------------------------------------------------------------------------
+
+const AudioTrackList & IFOFile::AudioTracks(unsigned int title, bool language) const
+{
+	if (!title || title > m_ifos.GetCount())
+		throw;
+
+	if (language)
+		return m_ifos.Item(title)->GetData()->m_langAudio;
+	else
+		return m_ifos.Item(title)->GetData()->m_Audio;
+}
+
+const SubtitleTrackList & IFOFile::SubsTracks(unsigned int title, bool language) const
+{
+	if (!title || title > m_ifos.GetCount())
+		throw;
+
+	if (language)
+		return m_ifos.Item(title)->GetData()->m_langSubs;
+	else
+		return m_ifos.Item(title)->GetData()->m_Subs;
+}

Modified: trunk/DvdMenuXtractor/IFOFile.h
===================================================================
--- trunk/DvdMenuXtractor/IFOFile.h	2004-10-22 19:49:54 UTC (rev 904)
+++ trunk/DvdMenuXtractor/IFOFile.h	2004-10-23 10:04:52 UTC (rev 905)
@@ -8,18 +8,15 @@
 #include "dvdread/ifo_read.h"
 
 // ----------------------------------------------------------------------------
-/*
+
+class IFOException { };
+class IFOFileIOException : public IFOException { };
+class IFOInvalidFileFormatException : public IFOException { };
+
+// ----------------------------------------------------------------------------
+
 typedef struct 
 {
-	int x1;
-	int y1;
-	int x2;
-	int y2;
-} ButtonListElem;
-WX_DECLARE_LIST(ButtonListElem, ButtonsListType);
-*/
-typedef struct 
-{
 	unsigned int vobid;
 	unsigned int cellid;
 	unsigned int start_frame;
@@ -31,8 +28,41 @@
 } CellListElem;
 WX_DECLARE_LIST(CellListElem, CellsListType);
 
-WX_DECLARE_LIST(ifo_handle_t, IfoHandleList);
+WX_DECLARE_LIST(audio_attr_t, AudioTrackList);
+WX_DECLARE_LIST(subp_attr_t, SubtitleTrackList);
 
+class IfoContent 
+{
+public:
+	IfoContent(dvd_reader_t *dvdr, int title)
+	{
+		m_handle = ifoOpen(dvdr,title);
+		if (!m_handle)
+			throw IFOInvalidFileFormatException();
+	}
+
+	~IfoContent()
+	{
+		ifoClose(m_handle);
+	}
+
+	ifo_handle_t & Handle()
+	{
+		assert(m_handle != NULL);
+		return *m_handle;
+	}
+
+	AudioTrackList m_langAudio;
+	AudioTrackList m_Audio;
+	SubtitleTrackList m_langSubs;
+	SubtitleTrackList m_Subs;
+
+protected:
+	ifo_handle_t *m_handle;
+};
+
+WX_DECLARE_LIST(IfoContent, IfoHandleList);
+
 class CellsHashType;
 
 // ----------------------------------------------------------------------------
@@ -52,6 +82,8 @@
 	const vts_ptt_srpt_t *VtsTitles(unsigned int title) const;
 	const pgcit_t *VtsPGCs(unsigned int title) const;
 	const int16_t NumberOfTitles() const;
+	const AudioTrackList & AudioTracks(unsigned int title, bool language) const;
+	const SubtitleTrackList & SubsTracks(unsigned int title, bool language) const;
 
 protected:
 	void GetPGCCells(const pgcit_t & pgc, CellsHashType * CellsHash);
@@ -65,11 +97,5 @@
 };
 
 // ----------------------------------------------------------------------------
-
-class IFOException { };
-class IFOFileIOException : public IFOException { };
-class IFOInvalidFileFormatException : public IFOException { };
-
-// ----------------------------------------------------------------------------
 #endif
 // ----------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.