Panda3D

Loading...
Searching...
No Matches
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 */
28 MovieVideo::
29 MovieVideo(const std::string &name) :
30 Namable(name)
31{
32}
33
34/**
35 *
36 */
37MovieVideo::
38~MovieVideo() {
39}
40
41/**
42 * Open this video, returning a MovieVideoCursor of the appropriate type.
43 * Returns NULL on error.
44 */
45PT(MovieVideoCursor) MovieVideo::
46open() {
47 return nullptr;
48}
49
50/**
51 * Obtains a MovieVideo that references a file. Just calls
52 * MovieTypeRegistry::make_video().
53 */
54PT(MovieVideo) MovieVideo::
55get(const Filename &name) {
56 MovieTypeRegistry *reg = MovieTypeRegistry::get_global_ptr();
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::
65 write_datagram(BamWriter *manager, Datagram &dg) {
66 TypedWritableReferenceCount::write_datagram(manager, dg);
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::
98fillin(DatagramIterator &scan, BamReader *manager) {
99 TypedWritableReferenceCount::fillin(scan, 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}
bamReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bamWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
BamReader::read_file_data
void read_file_data(SubfileInfo &info)
Reads a block of auxiliary file data from the Bam file.
Definition bamReader.cxx:677
BamWriter::write_file_data
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
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition datagramIterator.h:30
DatagramIterator::get_bool
bool get_bool()
Extracts a boolean value.
Definition datagramIterator.I:48
DatagramIterator::get_string
std::string get_string()
Extracts a variable-length string.
Definition datagramIterator.cxx:26
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
Datagram::add_bool
void add_bool(bool value)
Adds a boolean value to the datagram.
Definition datagram.I:34
Datagram::add_string
void add_string(const std::string &str)
Adds a variable-length string to the datagram.
Definition datagram.I:219
Filename
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
MovieTypeRegistry
This class records the different types of MovieAudio and MovieVideo that are available for loading.
Definition movieTypeRegistry.h:28
MovieTypeRegistry::get_global_ptr
static MovieTypeRegistry * get_global_ptr()
Returns a pointer to the global MovieTypeRegistry instance.
Definition movieTypeRegistry.I:18
MovieVideoCursor
A MovieVideo is actually any source that provides a sequence of video frames.
Definition movieVideoCursor.h:41
MovieVideo
A MovieVideo is actually any source that provides a sequence of video frames.
Definition movieVideo.h:38
MovieVideo::write_datagram
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
MovieVideo::MovieVideo
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
SubfileInfo
This class records a particular byte sub-range within an existing file on disk.
Definition subfileInfo.h:26
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
TypedWritable::fillin
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...
Definition typedWritable.cxx:103
TypedWritable::write_datagram
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 typedWritable.cxx:54
config_movies.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
movieTypeRegistry.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
movieVideoCursor.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
movieVideo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.