14#ifndef FFMPEGVIDEOCURSOR_H
15#define FFMPEGVIDEOCURSOR_H
30struct AVFormatContext;
40class EXPCL_FFMPEG FfmpegVideoCursor :
public MovieVideoCursor {
43 void init_from(FfmpegVideo *src);
46 FfmpegVideoCursor(FfmpegVideo *src);
47 virtual ~FfmpegVideoCursor();
60 virtual bool set_time(
double timestamp,
int loop_count);
61 virtual PT(
Buffer) fetch_buffer();
65 class EXPCL_FFMPEG FfmpegBuffer :
public Buffer {
67 ALLOC_DELETED_CHAIN(FfmpegBuffer);
68 INLINE FfmpegBuffer(
size_t block_size,
double video_timebase);
74 double _video_timebase;
80 static void init_type() {
82 register_type(_type_handle,
"FfmpegVideoCursor::FfmpegBuffer",
83 Buffer::get_class_type());
86 return get_class_type();
88 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
95 virtual PT(
Buffer) make_new_buffer();
103 std::string _sync_name;
104 int _max_readahead_frames;
105 ThreadPriority _thread_priority;
120 Buffers _readahead_frames;
129 ThreadStatus _thread_status;
133 PT(FfmpegBuffer) _current_frame_buffer;
137 static void st_thread_main(
void *self);
141 PT(FfmpegBuffer) do_alloc_frame();
142 void do_clear_all_frames();
144 bool fetch_packet(
int default_frame);
145 bool do_fetch_packet(
int default_frame);
146 void fetch_frame(
int frame);
147 void decode_frame(
int &finished);
148 void do_decode_frame(
int &finished);
149 void seek(
int frame,
bool backward);
150 void do_seek(
int frame,
bool backward);
151 int binary_seek(
int min_frame,
int max_frame,
int target_frame,
int num_iterations);
152 void advance_to_frame(
int frame);
154 void export_frame(FfmpegBuffer *buffer);
159 AVFormatContext *_format_ctx;
160 AVCodecContext *_video_ctx;
161 SwsContext *_convert_ctx;
165 double _video_timebase;
182 static void register_with_read_factory();
195 static void init_type() {
196 MovieVideoCursor::init_type();
198 MovieVideoCursor::get_class_type());
199 FfmpegBuffer::init_type();
201 virtual TypeHandle get_type()
const {
202 return get_class_type();
204 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
207 static TypeHandle _type_handle;
209 friend class FfmpegVideo;
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
A condition variable, usually used to communicate information about changing state to a thread that i...
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 ...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
virtual int compare_timestamp(const Buffer *other) const
Used to sort different buffers to ensure they correspond to the same source frame,...
virtual double get_timestamp() const
Returns the nearest timestamp value of this particular buffer.
void set_max_readahead_frames(int max_readahead_frames)
Specifies the maximum number of frames that a sub-thread will attempt to read ahead of the current fr...
int get_max_readahead_frames() const
Returns the maximum number of frames that a sub-thread will attempt to read ahead of the current fram...
bool is_thread_started() const
Returns true if the thread has been started, false if not.
void start_thread()
Explicitly starts the ffmpeg decoding thread after it has been stopped by a call to stop_thread().
void stop_thread()
Explicitly stops the ffmpeg decoding thread.
ThreadPriority get_thread_priority() const
Returns the current thread priority of the thread that decodes the ffmpeg video stream (if max_readah...
void set_thread_priority(ThreadPriority thread_priority)
Changes the thread priority of the thread that decodes the ffmpeg video stream (if max_readahead_fram...
Enables ffmpeg to access panda's VFS.
The name of a file, such as a texture file or an Egg file.
A generic thread type that allows calling a C-style thread function without having to subclass.
virtual bool set_time(double timestamp, int loop_count)
Updates the cursor to the indicated time.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
A standard mutex, or mutual exclusion lock.
A lightweight class that represents a single element that may be timed and/or counted via stats.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
This is our own Panda specialization on the default STL deque.
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.
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.