~vanvugt/ubuntu/oneiric/mediatomb/fix-770964-784431

« back to all changes in this revision

Viewing changes to src/dvdnav_read.h

  • Committer: Bazaar Package Importer
  • Author(s): Andres Mejia
  • Date: 2009-04-22 21:39:19 UTC
  • mto: (4.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20090422213919-52m015y6gcpv1m1g
Tags: upstream-0.12.0~svn2018
ImportĀ upstreamĀ versionĀ 0.12.0~svn2018

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*MT*
 
2
    
 
3
    MediaTomb - http://www.mediatomb.cc/
 
4
    
 
5
    dvdnav_read.h - this file is part of MediaTomb.
 
6
    
 
7
    Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>,
 
8
                       Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
 
9
    
 
10
    Copyright (C) 2006-2009 Gena Batyan <bgeradz@mediatomb.cc>,
 
11
                            Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
 
12
                            Leonhard Wimmer <leo@mediatomb.cc>
 
13
    
 
14
    MediaTomb is free software; you can redistribute it and/or modify
 
15
    it under the terms of the GNU General Public License version 2
 
16
    as published by the Free Software Foundation.
 
17
    
 
18
    MediaTomb is distributed in the hope that it will be useful,
 
19
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
    GNU General Public License for more details.
 
22
    
 
23
    You should have received a copy of the GNU General Public License
 
24
    version 2 along with MediaTomb; if not, write to the Free Software
 
25
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
26
    
 
27
    $Id$
 
28
*/
 
29
 
 
30
/// \file dvdnav_read.h
 
31
/// \brief Definition of the FileIOHandler class.
 
32
#ifndef __DVDNAV_READ_H__
 
33
#define __DVDNAV_READ_H__
 
34
 
 
35
#include <stdint.h>
 
36
 
 
37
#include <sys/types.h>
 
38
#include <dvdnav/dvdnav.h>
 
39
#include "common.h"
 
40
#include "sync.h"
 
41
 
 
42
/// \brief Allows to read selected streams from a DVD image.
 
43
///
 
44
/// There are some constraints on the usage of this class:
 
45
/// First of all - you *must* call the selectPGC() function before you 
 
46
/// attempt to read data or get the stream length.
 
47
///
 
48
/// You must call selectPGC() each time when you want to reset read; calling
 
49
/// read consequently will return the stream data and advance further in the
 
50
/// stream.
 
51
/// 
 
52
/// The class is thread safe, meaning that locks are in place, however it's
 
53
/// design does not suggest multithreaded usage. selectPGC(), read(), 
 
54
/// getLength() will not work in parallel but block if one of the functions
 
55
/// is running.
 
56
class DVDNavReader : public zmm::Object
 
57
{
 
58
public:
 
59
    /// \brief Sets the filename to work with. Can be an ISO, device or
 
60
    /// directory.
 
61
    DVDNavReader(zmm::String path);
 
62
    ~DVDNavReader();
 
63
 
 
64
    /// \brief returns the number of titles on the DVD
 
65
    int titleCount();
 
66
 
 
67
    /// \brief returns the number of chapters for a given title
 
68
    /// \param title_idx index of the title
 
69
    int chapterCount(int title_idx);
 
70
 
 
71
    /// \brief Returns the number of audio streams for the selected PGC
 
72
    int audioTrackCount();
 
73
 
 
74
    /// \brief Selects the title, chapter and angle to play, returns the
 
75
    /// number of bytes for the selection.
 
76
    ///
 
77
    /// The DVD is divided into titles, each title is didvided into chapters
 
78
    /// and can have one or more angles. This function selects what data we
 
79
    /// want to retrieve from the DVD (i.e. what stream we want to watch),
 
80
    /// and returns the size of the stream in bytes. 
 
81
    /// Note, that we will always treat the chapter as "starting point", i.e.
 
82
    /// we will play from the given chapter to the very end, we will not stop
 
83
    /// at the end of the chapter.
 
84
    ///
 
85
    /// \param title_idx index of the title
 
86
    /// \param chapter_idx index of the chapter from where we start
 
87
    void selectPGC(int title_idx, int chapter_idx);
 
88
 
 
89
    /// \brief Reads the stream, specified by selectPGC from the DVD.
 
90
    ///
 
91
    /// \param buffer buffer to store the data
 
92
    /// \param length length of the buffer
 
93
    /// \return number of bytes read (can be shorter than buffer length), value
 
94
    ///  of 0 indicates end of stream.
 
95
    size_t readSector(unsigned char *buffer, size_t length);  
 
96
 
 
97
    /// \brief Returns a human readable language string of the audio stream
 
98
    zmm::String audioLanguage(int stream_idx);
 
99
 
 
100
    /// \brief Returns the sampling frequency of the given audio stream
 
101
    int audioSampleFrequency(int stream_idx);
 
102
 
 
103
    /// \brief Returns the number of channels for the given audio stream
 
104
    int audioChannels(int stream_idx);
 
105
 
 
106
    /// \brief Returns the id of the audio stream
 
107
    int audioStreamID(int stream_idx);
 
108
 
 
109
    /// \brief Returns a human readable name of the audio format
 
110
    zmm::String audioFormat(int stream_idx);
 
111
 
 
112
protected:
 
113
    /// \brief Name of the DVD file.
 
114
    zmm::String dvd_path;
 
115
 
 
116
    /// \brief DVD handle
 
117
    dvdnav_t *dvd;
 
118
 
 
119
    /// \brief end of title flag
 
120
    bool EOT;
 
121
 
 
122
    zmm::Ref<Mutex> mutex;
 
123
 
 
124
    zmm::String getLanguage(char *code);
 
125
};
 
126
 
 
127
 
 
128
#endif // __DVDNAV_READ_H__