Diff of /doc/tutorial.cpp [cd2f01] .. [02c08c]  Maximize  Restore

Switch to unified view

a/doc/tutorial.cpp b/doc/tutorial.cpp
1
/*! \page tutorial A libdvdnav Tutorial
1
/*! \page tutorial A libdvdnav Tutorial
2
2
3
The <tt>libdvdnav</tt> library provides a powerful API allowing your
3
The <tt>libdvdnav</tt> library provides a powerful API allowing your
4
programs to take advantage of the sophisticated navigation features
4
programs to take advantage of the sophisticated navigation features
5
on DVDs. 
5
on DVDs.
6
6
7
\subsection wherenow Tutorial sections
7
\subsection wherenow Tutorial sections
8
8
9
  - For an introduction to the navigation features of DVDs look in section
9
  - For an introduction to the navigation features of DVDs look in section
10
    \ref dvdnavissues . This also provides an overview of the concepts
10
    \ref dvdnavissues . This also provides an overview of the concepts
11
    required to understand DVD navigation.
11
    required to understand DVD navigation.
12
  - For a step-by step walkthrough of a simple program look in
12
  - For a step-by step walkthrough of a simple program look in
13
    section \ref firstprog .
13
    section \ref firstprog .
14
  - FIXME: More sections :)
14
  - FIXME: More sections :)
15
  
15
16
*/
16
*/
17
17
18
/*! \page dvdnavissues An introduction to DVD navigation
18
/*! \page dvdnavissues An introduction to DVD navigation
19
19
20
The DVD format represents a radical departure from the traditional
20
The DVD format represents a radical departure from the traditional
21
form of video home-entertainment. Instead of just being a linear 
21
form of video home-entertainment. Instead of just being a linear
22
programme which is watched from beginning to end like a novel
22
programme which is watched from beginning to end like a novel
23
DVD allows the user to jump about at will (much like those
23
DVD allows the user to jump about at will (much like those
24
'Choose your own adventure' or 'Which Way' books which were
24
'Choose your own adventure' or 'Which Way' books which were
25
popular a while back).
25
popular a while back).
26
26
...
...
40
  .
40
  .
41
  |-- Title 1
41
  |-- Title 1
42
  |   |-- Chapter 1
42
  |   |-- Chapter 1
43
  |   |   |-- Cell 1
43
  |   |   |-- Cell 1
44
  |   |   |   |-- VOBU 1
44
  |   |   |   |-- VOBU 1
45
  |   |   |   |-- ... 
45
  |   |   |   |-- ...
46
  |   |   |   `-- VOBU n
46
  |   |   |   `-- VOBU n
47
  |   |   |-- ...
47
  |   |   |-- ...
48
  |   |   `-- Cell n
48
  |   |   `-- Cell n
49
  |   |-- ...
49
  |   |-- ...
50
  |   `-- Chapter 2
50
  |   `-- Chapter 2
51
  |       |-- Cell 1
51
  |       |-- Cell 1
52
  |       |   |-- VOBU 1
52
  |       |   |-- VOBU 1
53
  |       |   |-- ... 
53
  |       |   |-- ...
54
  |       |   `-- VOBU n
54
  |       |   `-- VOBU n
55
  |       |-- ...
55
  |       |-- ...
56
  |       `-- Cell n
56
  |       `-- Cell n
57
  |-- ...
57
  |-- ...
58
  `-- Title m
58
  `-- Title m
59
      |-- Chapter 1
59
      |-- Chapter 1
60
      |   |-- Cell 1
60
      |   |-- Cell 1
61
      |   |   |-- VOBU 1
61
      |   |   |-- VOBU 1
62
      |   |   |-- ... 
62
      |   |   |-- ...
63
      |   |   `-- VOBU n
63
      |   |   `-- VOBU n
64
      |   |-- ...
64
      |   |-- ...
65
      |   `-- Cell n
65
      |   `-- Cell n
66
      |-- ...
66
      |-- ...
67
      `-- Chapter 2
67
      `-- Chapter 2
68
          |-- Cell 1
68
          |-- Cell 1
69
          |   |-- VOBU 1
69
          |   |-- VOBU 1
70
          |   |-- ... 
70
          |   |-- ...
71
          |   `-- VOBU n
71
          |   `-- VOBU n
72
          |-- ...
72
          |-- ...
73
          `-- Cell n
73
          `-- Cell n
74
\endverbatim
74
\endverbatim
75
75
...
...
94
to occurr at a VOBU boundary so that the decoder need not be restarted and that
94
to occurr at a VOBU boundary so that the decoder need not be restarted and that
95
the location jumped to is always the start of a valid MPEG stream. For multiple-angle
95
the location jumped to is always the start of a valid MPEG stream. For multiple-angle
96
DVDs VOBUs for each angle can be interleaved into one Interleaved Video Unit (ILVU).
96
DVDs VOBUs for each angle can be interleaved into one Interleaved Video Unit (ILVU).
97
In this case when the player get to the end of the VOBU for angle <i>n</i> instead of
97
In this case when the player get to the end of the VOBU for angle <i>n</i> instead of
98
jumping to the next VOBU the player will move forward to the VOBU for angle <i>n</i>
98
jumping to the next VOBU the player will move forward to the VOBU for angle <i>n</i>
99
in the next ILVU. 
99
in the next ILVU.
100
100
101
This is summarised in the following diagram showing how the VOBUs are actually
101
This is summarised in the following diagram showing how the VOBUs are actually
102
laid out on disc.
102
laid out on disc.
103
103
104
\verbatim
104
\verbatim
...
...
115
115
116
If the layout of the DVD were the only feature of the format the DVD
116
If the layout of the DVD were the only feature of the format the DVD
117
would only have a limited amount of interactivity, you could jump
117
would only have a limited amount of interactivity, you could jump
118
around between Titles, Parts and Cells but not much else.
118
around between Titles, Parts and Cells but not much else.
119
119
120
The feature most people associate with DVDs is its ability to 
120
The feature most people associate with DVDs is its ability to
121
present the user with full-motion interactive menus. To provide
121
present the user with full-motion interactive menus. To provide
122
these features the DVD format includes a specification for a 
122
these features the DVD format includes a specification for a
123
DVD 'virtual machine'.
123
DVD 'virtual machine'.
124
124
125
To a first order approximation x86 programs can only be run on
125
To a first order approximation x86 programs can only be run on
126
x86-based machines, PowerPC programs on PowerPC-based machines and so on.
126
x86-based machines, PowerPC programs on PowerPC-based machines and so on.
127
Java, however, is an exception in that programs are compiled into
127
Java, however, is an exception in that programs are compiled into
...
...
159
159
160
int main(int argc, char **argv) {
160
int main(int argc, char **argv) {
161
  dvdnav_t *dvdnav;
161
  dvdnav_t *dvdnav;
162
  int finished, len, event;
162
  int finished, len, event;
163
  uint8_t buf[2050];
163
  uint8_t buf[2050];
164
 
164
165
  /* Open the DVD */
165
  /* Open the DVD */
166
  dvdnav_open(&dvdnav, "/dev/dvd");
166
  dvdnav_open(&dvdnav, "/dev/dvd");
167
167
168
  fprintf(stderr, "Reading...\n");
168
  fprintf(stderr, "Reading...\n");
169
  finished = 0;
169
  finished = 0;
170
  while(!finished) {  
170
  while(!finished) {
171
    int result = dvdnav_get_next_block(dvdnav, buf,
171
    int result = dvdnav_get_next_block(dvdnav, buf,
172
                                       &event, &len);
172
                                       &event, &len);
173
173
174
    if(result == DVDNAV_STATUS_ERR) {
174
    if(result == DVDNAV_STATUS_ERR) {
175
      fprintf(stderr, "Error getting next block (%s)\n",
175
      fprintf(stderr, "Error getting next block (%s)\n",
...
...
180
    switch(event) {
180
    switch(event) {
181
     case DVDNAV_BLOCK_OK:
181
     case DVDNAV_BLOCK_OK:
182
        /* Write output to stdout */
182
        /* Write output to stdout */
183
        fwrite(buf, len, 1, stdout);
183
        fwrite(buf, len, 1, stdout);
184
      break;
184
      break;
185
     case DVDNAV_STILL_FRAME: 
185
     case DVDNAV_STILL_FRAME:
186
       {
186
       {
187
        fprintf(stderr, "Skipping still frame\n");
187
        fprintf(stderr, "Skipping still frame\n");
188
        dvdnav_still_skip(dvdnav);
188
        dvdnav_still_skip(dvdnav);
189
       }
189
       }
190
      break;
190
      break;
...
...
196
      fprintf(stderr, "Unhandled event (%i)\n", event);
196
      fprintf(stderr, "Unhandled event (%i)\n", event);
197
      finished = 1;
197
      finished = 1;
198
      break;
198
      break;
199
    }
199
    }
200
  }
200
  }
201
  
201
202
  dvdnav_close(dvdnav);
202
  dvdnav_close(dvdnav);
203
  
203
204
  return 0;
204
  return 0;
205
} 
205
}
206
\endverbatim
206
\endverbatim
207
207
208
If you have correctly installled <tt>libdvdnav</tt>, you should have the
208
If you have correctly installled <tt>libdvdnav</tt>, you should have the
209
command 'dvdnav-config' in your path. If so you can compile this program
209
command 'dvdnav-config' in your path. If so you can compile this program
210
with
210
with

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks