Panda3D

ffmpegVideo.cxx

00001 // Filename: ffmpegVideo.cxx
00002 // Created by: jyelon (01Aug2007)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "ffmpegVideo.h"
00016 
00017 #ifdef HAVE_FFMPEG
00018 
00019 #include "ffmpegVideoCursor.h"
00020 #include "config_movies.h"
00021 #include "bamReader.h"
00022 
00023 TypeHandle FfmpegVideo::_type_handle;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //     Function: FfmpegVideo::Constructor
00027 //       Access: Public
00028 //  Description: Constructs an ffmpeg video that reads its contents
00029 //               from the indicate filename, which may be a file in
00030 //               the VFS.
00031 ////////////////////////////////////////////////////////////////////
00032 FfmpegVideo::
00033 FfmpegVideo(const Filename &name) :
00034   MovieVideo(name)
00035 {
00036   _filename = name;
00037 }
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //     Function: FfmpegVideo::Constructor
00041 //       Access: Public
00042 //  Description: Constructs an ffmpeg video that reads its contents
00043 //               from the indicated subfile information.  This is
00044 //               normally used for low-level purposes only; you would
00045 //               normally use the constructor that takes a filename.
00046 ////////////////////////////////////////////////////////////////////
00047 FfmpegVideo::
00048 FfmpegVideo(const SubfileInfo &info) :
00049   MovieVideo(info.get_filename())
00050 {
00051   _filename = info.get_filename();
00052   _subfile_info = info;
00053 }
00054 
00055 ////////////////////////////////////////////////////////////////////
00056 //     Function: FfmpegVideo::Destructor
00057 //       Access: Public
00058 //  Description: xxx
00059 ////////////////////////////////////////////////////////////////////
00060 FfmpegVideo::
00061 ~FfmpegVideo() {
00062 }
00063 
00064 ////////////////////////////////////////////////////////////////////
00065 //     Function: FfmpegVideo::open
00066 //       Access: Published, Virtual
00067 //  Description: Open this video, returning a MovieVideoCursor.
00068 ////////////////////////////////////////////////////////////////////
00069 PT(MovieVideoCursor) FfmpegVideo::
00070 open() {
00071   PT(FfmpegVideoCursor) result = new FfmpegVideoCursor(this);
00072   if (result->_format_ctx == 0) {
00073     movies_cat.error() << "Could not open " << _filename << "\n";
00074     return NULL;
00075   } else {
00076     return result.p();
00077   }
00078 }
00079 
00080 ////////////////////////////////////////////////////////////////////
00081 //     Function: FfmpegVideo::register_with_read_factory
00082 //       Access: Public, Static
00083 //  Description: Tells the BamReader how to create objects of type
00084 //               FfmpegVideo.
00085 ////////////////////////////////////////////////////////////////////
00086 void FfmpegVideo::
00087 register_with_read_factory() {
00088   BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
00089 }
00090 
00091 ////////////////////////////////////////////////////////////////////
00092 //     Function: FfmpegVideo::write_datagram
00093 //       Access: Public, Virtual
00094 //  Description: Writes the contents of this object to the datagram
00095 //               for shipping out to a Bam file.
00096 ////////////////////////////////////////////////////////////////////
00097 void FfmpegVideo::
00098 write_datagram(BamWriter *manager, Datagram &dg) {
00099   MovieVideo::write_datagram(manager, dg);
00100 }
00101 
00102 ////////////////////////////////////////////////////////////////////
00103 //     Function: FfmpegVideo::make_from_bam
00104 //       Access: Protected, Static
00105 //  Description: This function is called by the BamReader's factory
00106 //               when a new object of type FfmpegVideo is encountered
00107 //               in the Bam file.  It should create the FfmpegVideo
00108 //               and extract its information from the file.
00109 ////////////////////////////////////////////////////////////////////
00110 TypedWritable *FfmpegVideo::
00111 make_from_bam(const FactoryParams &params) {
00112   FfmpegVideo *video = new FfmpegVideo("");
00113   DatagramIterator scan;
00114   BamReader *manager;
00115 
00116   parse_params(params, scan, manager);
00117   video->fillin(scan, manager);
00118 
00119   return video;
00120 }
00121 
00122 ////////////////////////////////////////////////////////////////////
00123 //     Function: FfmpegVideo::fillin
00124 //       Access: Protected
00125 //  Description: This internal function is called by make_from_bam to
00126 //               read in all of the relevant data from the BamFile for
00127 //               the new FfmpegVideo.
00128 ////////////////////////////////////////////////////////////////////
00129 void FfmpegVideo::
00130 fillin(DatagramIterator &scan, BamReader *manager) {
00131   MovieVideo::fillin(scan, manager);
00132 }
00133 
00134 ////////////////////////////////////////////////////////////////////
00135 
00136 #endif // HAVE_FFMPEG
 All Classes Functions Variables Enumerations