Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FFCodec.cpp
Go to the documentation of this file.
1 //
2 // C++ Implementation: Audio::FFCodec
3 //
4 
5 #include "config.h"
6 
7 #ifdef HAVE_FFMPEG
8 
9 #include "../CodecRegistry.h"
10 
11 #include "FFCodec.h"
12 #include "FFStream.h"
13 #include "config.h"
14 
15 namespace Audio {
16 
17  FFCodec::FFCodec() : Codec("ffmpeg")
18  {
19  }
20 
22  {
23  }
24 
25  bool FFCodec::canHandle(const std::string& path, bool canOpen, VSFileSystem::VSFileType type) throw()
26  {
27  if (canOpen) {
28  // I don't really know a way to test files in ffmpeg
29  // TODO: find out
30  return true;
31  } else {
32  // Can't know for sure
33  return true;
34  }
35  }
36 
37  Stream* FFCodec::open(const std::string& path, VSFileSystem::VSFileType type) throw(Exception)
38  {
39  size_t sep = path.find_last_of('|');
40  int streamIndex = (sep != std::string::npos) ? atoi(path.c_str() + sep + 1) : 0;
41  std::string filepath = path.substr(0, sep);
42 
43  return new FFStream(filepath, streamIndex, type);
44  }
45 
46  static CodecRegistration registration(new FFCodec());
47 
48 };
49 
50 #endif