Panda3D
ffmpegVideo.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 ffmpegVideo.cxx
10 * @author jyelon
11 * @date 2007-08-01
12 */
13
14#include "ffmpegVideo.h"
15#include "ffmpegVideoCursor.h"
16#include "config_ffmpeg.h"
17#include "bamReader.h"
18#include "dcast.h"
19
20TypeHandle FfmpegVideo::_type_handle;
21
22/**
23 * Constructs an ffmpeg video that reads its contents from the indicate
24 * filename, which may be a file in the VFS.
25 */
27FfmpegVideo(const Filename &name) :
28 MovieVideo(name)
29{
30 _filename = name;
31}
32
33/**
34 * Constructs an ffmpeg video that reads its contents from the indicated
35 * subfile information. This is normally used for low-level purposes only;
36 * you would normally use the constructor that takes a filename.
37 */
39FfmpegVideo(const SubfileInfo &info) :
40 MovieVideo(info.get_filename())
41{
42 _filename = info.get_filename();
43 _subfile_info = info;
44}
45
46/**
47 * xxx
48 */
51}
52
53/**
54 * Open this video, returning a MovieVideoCursor.
55 */
56PT(MovieVideoCursor) FfmpegVideo::
57open() {
58 PT(FfmpegVideoCursor) result = new FfmpegVideoCursor(this);
59 if (result->_format_ctx == nullptr) {
60 ffmpeg_cat.error() << "Could not open " << _filename << "\n";
61 return nullptr;
62 } else {
63 return result;
64 }
65}
66
67/**
68 * Obtains a MovieVideo that references a file.
69 */
70PT(MovieVideo) FfmpegVideo::
71make(const Filename &name) {
72 return DCAST(MovieVideo, new FfmpegVideo(name));
73}
74
75/**
76 * Tells the BamReader how to create objects of type FfmpegVideo.
77 */
80 BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
81}
82
83/**
84 * Writes the contents of this object to the datagram for shipping out to a
85 * Bam file.
86 */
88write_datagram(BamWriter *manager, Datagram &dg) {
89 MovieVideo::write_datagram(manager, dg);
90}
91
92/**
93 * This function is called by the BamReader's factory when a new object of
94 * type FfmpegVideo is encountered in the Bam file. It should create the
95 * FfmpegVideo and extract its information from the file.
96 */
97TypedWritable *FfmpegVideo::
98make_from_bam(const FactoryParams &params) {
99 FfmpegVideo *video = new FfmpegVideo("");
100 DatagramIterator scan;
101 BamReader *manager;
102
103 parse_params(params, scan, manager);
104 video->fillin(scan, manager);
105
106 return video;
107}
108
109/**
110 * This internal function is called by make_from_bam to read in all of the
111 * relevant data from the BamFile for the new FfmpegVideo.
112 */
113void FfmpegVideo::
114fillin(DatagramIterator &scan, BamReader *manager) {
115 MovieVideo::fillin(scan, manager);
116}
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams &params, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
Definition: bamReader.I:275
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition: bamReader.I:177
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
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
Definition: factory.I:73
FfmpegVideo(const Filename &name)
Constructs an ffmpeg video that reads its contents from the indicate filename, which may be a file in...
Definition: ffmpegVideo.cxx:27
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: ffmpegVideo.cxx:88
virtual ~FfmpegVideo()
xxx
Definition: ffmpegVideo.cxx:50
static void register_with_read_factory()
Tells the BamReader how to create objects of type FfmpegVideo.
Definition: ffmpegVideo.cxx:79
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.
A MovieVideo is actually any source that provides a sequence of video frames.
Definition: movieVideo.h:38
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
This class records a particular byte sub-range within an existing file on disk.
Definition: subfileInfo.h:26
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.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.
PT(MovieVideoCursor) FfmpegVideo
Open this video, returning a MovieVideoCursor.
Definition: ffmpegVideo.cxx:56
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.