Panda3D
movieAudioCursor.h
1 // Filename: movieAudioCursor.h
2 // Created by: jyelon (02Jul07)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef MOVIEAUDIOCURSOR_H
16 #define MOVIEAUDIOCURSOR_H
17 
18 #include "pandabase.h"
19 #include "namable.h"
20 #include "texture.h"
21 #include "pointerTo.h"
22 class MovieAudio;
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : MovieAudioCursor
26 // Description : A MovieAudio is actually any source that provides
27 // a sequence of audio samples. That could include an
28 // AVI file, a microphone, or an internet TV station.
29 // A MovieAudioCursor is a handle that lets you read
30 // data sequentially from a MovieAudio.
31 //
32 // Thread safety: each individual MovieAudioCursor
33 // must be owned and accessed by a single thread.
34 // It is OK for two different threads to open
35 // the same file at the same time, as long as they
36 // use separate MovieAudioCursor objects.
37 ////////////////////////////////////////////////////////////////////
38 class EXPCL_PANDA_MOVIES MovieAudioCursor : public TypedWritableReferenceCount {
39 
40 PUBLISHED:
42  virtual ~MovieAudioCursor();
43  INLINE PT(MovieAudio) get_source() const;
44  INLINE int audio_rate() const;
45  INLINE int audio_channels() const;
46  INLINE double length() const;
47  INLINE bool can_seek() const;
48  INLINE bool can_seek_fast() const;
49  INLINE double tell() const;
50  INLINE void skip_samples(int n);
51  INLINE bool aborted() const;
52  virtual int ready() const;
53  virtual void seek(double offset);
54  void read_samples(int n, Datagram *dg);
55  string read_samples(int n);
56 
57 public:
58  virtual void read_samples(int n, PN_int16 *data);
59 
60 protected:
61  PT(MovieAudio) _source;
62  int _audio_rate;
63  int _audio_channels;
64  double _length;
65  bool _can_seek;
66  bool _can_seek_fast;
67  bool _aborted;
68  double _last_seek;
69  PN_int64 _samples_read;
70 
71 public:
72  static TypeHandle get_class_type() {
73  return _type_handle;
74  }
75  static void init_type() {
76  TypedWritableReferenceCount::init_type();
77  register_type(_type_handle, "MovieAudioCursor",
78  TypedWritableReferenceCount::get_class_type());
79  }
80  virtual TypeHandle get_type() const {
81  return get_class_type();
82  }
83  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
84 
85 private:
86  static TypeHandle _type_handle;
87 };
88 
89 #include "movieAudioCursor.I"
90 #include "movieAudio.h"
91 
92 #endif
A MovieAudio is actually any source that provides a sequence of audio samples.
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A MovieAudio is actually any source that provides a sequence of audio samples.
Definition: movieAudio.h:48
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43