Panda3D

movieAudioCursor.I

00001 // Filename: movieAudioCursor.I
00002 // Created by: jyelon (02Jul07)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 ////////////////////////////////////////////////////////////////////
00016 //     Function: MovieAudioCursor::get_source
00017 //       Access: Public
00018 //  Description: Returns the MovieAudio which this cursor references.
00019 ////////////////////////////////////////////////////////////////////
00020 INLINE PT(MovieAudio) MovieAudioCursor::
00021 get_source() const {
00022   return _source;
00023 }
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //     Function: MovieAudioCursor::audio_rate
00027 //       Access: Public
00028 //  Description: Returns the audio sample rate.
00029 ////////////////////////////////////////////////////////////////////
00030 INLINE int MovieAudioCursor::
00031 audio_rate() const {
00032   return _audio_rate;
00033 }
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //     Function: MovieAudioCursor::audio_channels
00037 //       Access: Public
00038 //  Description: Returns the number of audio channels (ie, two for
00039 //               stereo, one for mono).
00040 ////////////////////////////////////////////////////////////////////
00041 INLINE int MovieAudioCursor::
00042 audio_channels() const {
00043   return _audio_channels;
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: MovieAudioCursor::length
00048 //       Access: Public
00049 //  Description: Returns the length of the movie.  Attempting to read
00050 //               audio samples beyond the specified length will produce 
00051 //               silent samples.
00052 //
00053 //               Some kinds of Movie, such as internet TV station, 
00054 //               might not have a predictable length.  In that case,
00055 //               the length will be set to a very large number: 1.0E10.
00056 //
00057 //               Some AVI files have incorrect length values encoded
00058 //               into them - they may be a second or two long or
00059 //               short.  When playing such an AVI using the Movie class,
00060 //               you may see a slightly truncated video, or a slightly
00061 //               elongated video (padded with black frames).  There are
00062 //               utilities out there to fix the length values in AVI
00063 //               files.
00064 //
00065 //               An audio consumer needs to check the length, the
00066 //               ready status, and the aborted flag.
00067 ////////////////////////////////////////////////////////////////////
00068 INLINE double MovieAudioCursor::
00069 length() const {
00070   return _length;
00071 }
00072 
00073 ////////////////////////////////////////////////////////////////////
00074 //     Function: MovieAudioCursor::can_seek
00075 //       Access: Public
00076 //  Description: Returns true if the movie can seek.  If this is
00077 //               true, seeking is still not guaranteed to be fast:
00078 //               for some movies, seeking is implemented by rewinding
00079 //               to the beginning and then fast-forwarding to the
00080 //               desired location.  Even if the movie cannot seek,
00081 //               the seek method can still advance to an arbitrary
00082 //               location by reading samples and discarding them.
00083 //               However, to move backward, can_seek must return true.
00084 ////////////////////////////////////////////////////////////////////
00085 INLINE bool MovieAudioCursor::
00086 can_seek() const {
00087   return _can_seek;
00088 }
00089 
00090 ////////////////////////////////////////////////////////////////////
00091 //     Function: MovieAudioCursor::can_seek_fast
00092 //       Access: Public
00093 //  Description: Returns true if seek operations are constant time.
00094 ////////////////////////////////////////////////////////////////////
00095 INLINE bool MovieAudioCursor::
00096 can_seek_fast() const {
00097   return _can_seek_fast;
00098 }
00099 
00100 ////////////////////////////////////////////////////////////////////
00101 //     Function: MovieAudioCursor::aborted
00102 //       Access: Public
00103 //  Description: If aborted is true, it means that the "ready" samples
00104 //               are not being replenished.  See the method "ready"
00105 //               for an explanation.
00106 ////////////////////////////////////////////////////////////////////
00107 INLINE bool MovieAudioCursor::
00108 aborted() const {
00109   return _aborted;
00110 }
00111 
00112 ////////////////////////////////////////////////////////////////////
00113 //     Function: MovieAudioCursor::tell
00114 //       Access: Public
00115 //  Description: Returns the current offset within the file.
00116 ////////////////////////////////////////////////////////////////////
00117 INLINE double MovieAudioCursor::
00118 tell() const {
00119   return _last_seek + ((_samples_read * 1.0) / _audio_rate);
00120 }
00121 
00122 ////////////////////////////////////////////////////////////////////
00123 //     Function: MovieAudioCursor::skip_samples
00124 //       Access: Published
00125 //  Description: Skip audio samples from the stream.  This is mostly
00126 //               for debugging purposes.
00127 ////////////////////////////////////////////////////////////////////
00128 INLINE void MovieAudioCursor::
00129 skip_samples(int n) {
00130   read_samples(n, (PN_int16*)0);
00131 }
00132  
 All Classes Functions Variables Enumerations