Panda3D
ffmpegVirtualFile.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 ffmpegVirtualFile.h
10  * @author jyelon
11  * @date 2007-08-01
12  */
13 
14 #ifndef FFMPEGVIRTUALFILE_H
15 #define FFMPEGVIRTUALFILE_H
16 
17 #include "pandabase.h"
18 #include "config_movies.h"
19 #include "filename.h"
20 #include "subfileInfo.h"
21 
22 #include <stdarg.h>
23 extern "C" {
24  #include <libavformat/avio.h>
25 }
26 
27 struct URLContext;
28 struct AVFormatContext;
29 
30 /**
31  * Enables ffmpeg to access panda's VFS. Create an instance of the
32  * FfmpegVirtualFile for each ffmpeg stream you wish to open.
33  */
34 class EXPCL_FFMPEG FfmpegVirtualFile {
35 public:
37  FfmpegVirtualFile(const FfmpegVirtualFile &copy) = delete;
39 
40  FfmpegVirtualFile &operator = (const FfmpegVirtualFile &copy) = delete;
41 
42  bool open_vfs(const Filename &filename);
43  bool open_subfile(const SubfileInfo &info);
44  void close();
45 
46  INLINE bool is_open() const;
47  INLINE AVFormatContext *get_format_context() const;
48 
49  static void register_protocol();
50 
51 private:
52  // These are callbacks passed to ffmpeg and cannot change signature.
53  static int read_packet(void *opaque, uint8_t *buf, int buf_size);
54  static int64_t seek(void *opaque, int64_t offset, int whence);
55 
56  static void log_callback(void *ptr, int level, const char *fmt, va_list v1);
57 
58 private:
59  AVIOContext *_io_context;
60  AVFormatContext *_format_context;
61  std::streampos _start;
62  std::streamsize _size;
63  std::istream *_in;
64  pifstream _file_in;
65  bool _owns_in;
66  int _buffer_size;
67 };
68 
69 #include "ffmpegVirtualFile.I"
70 
71 #endif // FFMPEGVIRTUALFILE_H
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Enables ffmpeg to access panda's VFS.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class records a particular byte sub-range within an existing file on disk.
Definition: subfileInfo.h:26
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.