Panda3D
movieVideo.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file movieVideo.cxx
10  * @author jyelon
11  * @date 2007-07-02
12  */
13 
14 #include "movieVideo.h"
15 #include "movieVideoCursor.h"
16 #include "config_movies.h"
17 #include "movieTypeRegistry.h"
18 #include "bamReader.h"
19 #include "bamWriter.h"
20 
21 TypeHandle MovieVideo::_type_handle;
22 
23 /**
24  * This constructor returns a null video stream --- a stream of plain blue and
25  * white frames that last one second each. To get more interesting video, you
26  * need to construct a subclass of this class.
27  */
29 MovieVideo(const std::string &name) :
30  Namable(name)
31 {
32 }
33 
34 /**
35  *
36  */
37 MovieVideo::
38 ~MovieVideo() {
39 }
40 
41 /**
42  * Open this video, returning a MovieVideoCursor of the appropriate type.
43  * Returns NULL on error.
44  */
45 PT(MovieVideoCursor) MovieVideo::
46 open() {
47  return nullptr;
48 }
49 
50 /**
51  * Obtains a MovieVideo that references a file. Just calls
52  * MovieTypeRegistry::make_video().
53  */
54 PT(MovieVideo) MovieVideo::
55 get(const Filename &name) {
57  return reg->make_video(name);
58 }
59 
60 /**
61  * Writes the contents of this object to the datagram for shipping out to a
62  * Bam file.
63  */
64 void MovieVideo::
67  dg.add_string(_filename);
68 
69  // Now we record the raw movie data directly into the bam stream. We always
70  // do this, regardless of bam-texture-mode; we generally won't get to this
71  // codepath if bam-texture-mode isn't rawdata anyway.
72 
73  SubfileInfo result;
74  if (!_subfile_info.is_empty()) {
75  dg.add_bool(true);
76  manager->write_file_data(result, _subfile_info);
77  } else if (!_filename.empty()) {
78  dg.add_bool(true);
79  manager->write_file_data(result, _filename);
80  } else {
81  dg.add_bool(false);
82  }
83 
84  /* Not sure yet if this is a good idea.
85  if (!result.is_empty()) {
86  // If we've just copied the data to a local file, read it from there in
87  // the future.
88  _subfile_info = result;
89  }
90  */
91 }
92 
93 /**
94  * This internal function is called by make_from_bam to read in all of the
95  * relevant data from the BamFile for the new MovieVideo.
96  */
97 void MovieVideo::
98 fillin(DatagramIterator &scan, BamReader *manager) {
100  _filename = scan.get_string();
101 
102  bool got_info = scan.get_bool();
103  if (got_info) {
104  manager->read_file_data(_subfile_info);
105  }
106 }
void read_file_data(SubfileInfo &info)
Reads a block of auxiliary file data from the Bam file.
Definition: bamReader.cxx:677
bool get_bool()
Extracts a boolean value.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
This class records the different types of MovieAudio and MovieVideo that are available for loading.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
std::string get_string()
Extracts a variable-length string.
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_bool(bool value)
Adds a boolean value to the datagram.
Definition: datagram.I:34
A base class for all things which can have a name.
Definition: namable.h:26
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
A MovieVideo is actually any source that provides a sequence of video frames.
void add_string(const std::string &str)
Adds a variable-length string to the datagram.
Definition: datagram.I:219
bool is_empty() const
Returns true if this SubfileInfo doesn't define any file, false if it has real data.
Definition: subfileInfo.I:72
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: movieVideo.cxx:65
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
MovieVideo(const std::string &name="Blank Video")
This constructor returns a null video stream — a stream of plain blue and white frames that last one ...
Definition: movieVideo.cxx:29
static MovieTypeRegistry * get_global_ptr()
Returns a pointer to the global MovieTypeRegistry instance.
PT(MovieVideoCursor) MovieVideo
Open this video, returning a MovieVideoCursor of the appropriate type.
Definition: movieVideo.cxx:45
A MovieVideo is actually any source that provides a sequence of video frames.
Definition: movieVideo.h:38
This class records a particular byte sub-range within an existing file on disk.
Definition: subfileInfo.h:26
void write_file_data(SubfileInfo &result, const Filename &filename)
Writes a block of auxiliary file data from the indicated file (within the vfs).
Definition: bamWriter.cxx:363
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.