Panda3D
Loading...
Searching...
No Matches
movieVideoCursor.h
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 movieVideoCursor.h
10 * @author jyelon
11 * @date 2007-07-02
12 */
13
14#ifndef MOVIEVIDEOCURSOR_H
15#define MOVIEVIDEOCURSOR_H
16
17#include "pandabase.h"
18#include "texture.h"
19#include "pointerTo.h"
20#include "memoryBase.h"
21#include "pStatCollector.h"
22#include "deletedChain.h"
23#include "typedReferenceCount.h"
24
25class MovieVideo;
26class FactoryParams;
27class BamWriter;
28class BamReader;
29
30/**
31 * A MovieVideo is actually any source that provides a sequence of video
32 * frames. That could include an AVI file, a digital camera, or an internet
33 * TV station. A MovieVideoCursor is a handle that lets you read data
34 * sequentially from a MovieVideo.
35 *
36 * Thread safety: each individual MovieVideoCursor must be owned and accessed
37 * by a single thread. It is OK for two different threads to open the same
38 * file at the same time, as long as they use separate MovieVideoCursor
39 * objects.
40 */
41class EXPCL_PANDA_MOVIES MovieVideoCursor : public TypedWritableReferenceCount {
42protected:
43 MovieVideoCursor(MovieVideo *src = nullptr);
44
45PUBLISHED:
46 virtual ~MovieVideoCursor();
47 PT(MovieVideo) get_source() const;
48 INLINE int size_x() const;
49 INLINE int size_y() const;
50 INLINE int get_num_components() const;
51 INLINE double length() const;
52 INLINE bool can_seek() const;
53 INLINE bool can_seek_fast() const;
54 INLINE bool aborted() const;
55
56 INLINE bool ready() const;
57 INLINE bool streaming() const;
58 void setup_texture(Texture *tex) const;
59
60 virtual bool set_time(double timestamp, int loop_count);
61
62 class EXPCL_PANDA_MOVIES Buffer : public TypedReferenceCount {
63 public:
64 ALLOC_DELETED_CHAIN(Buffer);
65 Buffer(size_t block_size);
66
67 PUBLISHED:
68 virtual ~Buffer();
69
70 virtual int compare_timestamp(const Buffer *other) const;
71 virtual double get_timestamp() const;
72
73 public:
74 unsigned char *_block;
75 size_t _block_size;
76
77 private:
78 DeletedBufferChain *_deleted_chain;
79
80 public:
81 static TypeHandle get_class_type() {
82 return _type_handle;
83 }
84 static void init_type() {
85 TypedReferenceCount::init_type();
86 register_type(_type_handle, "MovieVideoCursor::Buffer",
87 TypedReferenceCount::get_class_type());
88 }
89 virtual TypeHandle get_type() const {
90 return get_class_type();
91 }
92 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
93
94 private:
95 static TypeHandle _type_handle;
96 };
97 virtual PT(Buffer) fetch_buffer();
98
99 virtual void apply_to_texture(const Buffer *buffer, Texture *t, int page);
100 virtual void apply_to_texture_rgb(const Buffer *buffer, Texture *t, int page);
101 virtual void apply_to_texture_alpha(const Buffer *buffer, Texture *t, int page, int alpha_src);
102
103protected:
104 Buffer *get_standard_buffer();
105 virtual PT(Buffer) make_new_buffer();
106
107protected:
108 PT(MovieVideo) _source;
109 int _size_x;
110 int _size_y;
111 int _num_components;
112 double _length;
113 bool _can_seek;
114 bool _can_seek_fast;
115 bool _aborted;
116 bool _streaming;
117 bool _ready;
118
119 PT(Buffer) _standard_buffer;
120
121 static PStatCollector _copy_pcollector;
122 static PStatCollector _copy_pcollector_ram;
123 static PStatCollector _copy_pcollector_copy;
124
125public:
126 virtual void write_datagram(BamWriter *manager, Datagram &dg);
127 virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
128
129protected:
130 void fillin(DatagramIterator &scan, BamReader *manager);
131
132public:
133 static TypeHandle get_class_type() {
134 return _type_handle;
135 }
136 static void init_type() {
137 TypedWritableReferenceCount::init_type();
138 register_type(_type_handle, "MovieVideoCursor",
139 TypedWritableReferenceCount::get_class_type());
140 Buffer::init_type();
141 }
142 virtual TypeHandle get_type() const {
143 return get_class_type();
144 }
145 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
146
147private:
148 static TypeHandle _type_handle;
149};
150
151#include "movieVideoCursor.I"
152#include "movieVideo.h"
153
154#endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
This template class can be used to provide faster allocation/deallocation for many Panda objects.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
A MovieVideo is actually any source that provides a sequence of video frames.
A MovieVideo is actually any source that provides a sequence of video frames.
Definition movieVideo.h:38
A lightweight class that represents a single element that may be timed and/or counted via stats.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition texture.h:72
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
Base class for objects that can be written to and read from Bam files.
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.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
This is our own Panda specialization on the default STL list.
Definition plist.h:35
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.