Panda3D
 All Classes Functions Variables Enumerations
ffmpegVirtualFile.h
1 // Filename: ffmpegVirtualFile.h
2 // Created by: jyelon (01Aug2007)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef FFMPEGVIRTUALFILE_H
16 #define FFMPEGVIRTUALFILE_H
17 
18 #include "pandabase.h"
19 #include "config_movies.h"
20 #include "filename.h"
21 #include "subfileInfo.h"
22 
23 #include <stdarg.h>
24 extern "C" {
25  #include "libavformat/avio.h"
26 }
27 
28 struct URLContext;
29 struct AVFormatContext;
30 
31 ////////////////////////////////////////////////////////////////////
32 // Class : FfmpegVirtualFile
33 // Description : Enables ffmpeg to access panda's VFS. Create an
34 // instance of the FfmpegVirtualFile for each ffmpeg
35 // stream you wish to open.
36 ////////////////////////////////////////////////////////////////////
37 class EXPCL_FFMPEG FfmpegVirtualFile {
38 public:
41 private:
43  void operator = (const FfmpegVirtualFile &copy);
44 
45 public:
46  bool open_vfs(const Filename &filename);
47  bool open_subfile(const SubfileInfo &info);
48  void close();
49 
50  INLINE bool is_open() const;
51  INLINE AVFormatContext *get_format_context() const;
52 
53  static void register_protocol();
54 
55 private:
56  // These are callbacks passed to ffmpeg and cannot change signature.
57  static int read_packet(void *opaque, uint8_t *buf, int buf_size);
58  static int64_t seek(void *opaque, int64_t offset, int whence);
59 
60  static void log_callback(void *ptr, int level, const char *fmt, va_list v1);
61 
62 private:
63  AVIOContext *_io_context;
64  AVFormatContext *_format_context;
65  streampos _start;
66  streamsize _size;
67  istream *_in;
68  pifstream _file_in;
69  bool _owns_in;
70  int _buffer_size;
71 };
72 
73 #include "ffmpegVirtualFile.I"
74 
75 #endif // FFMPEGVIRTUALFILE_H
Enables ffmpeg to access panda&#39;s VFS.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
This class records a particular byte sub-range within an existing file on disk.
Definition: subfileInfo.h:29