very early LAVC Audio provider
Originally committed to SVN as r319.
This commit is contained in:
parent
51dc36a8c9
commit
b51bd77d00
3 changed files with 79 additions and 5 deletions
|
@ -45,16 +45,32 @@
|
|||
//////////////
|
||||
// Constructor
|
||||
LAVCAudioProvider::LAVCAudioProvider(wxString _filename) {
|
||||
// Set filename
|
||||
filename = _filename;
|
||||
|
||||
// TODO
|
||||
// Init lavc variables
|
||||
codecContext = NULL;
|
||||
formatContext = NULL;
|
||||
codec = NULL;
|
||||
stream = NULL;
|
||||
frame = NULL;
|
||||
|
||||
// Register types
|
||||
static bool avRegistered = false;
|
||||
if (!avRegistered) {
|
||||
av_register_all();
|
||||
avRegistered = true;
|
||||
}
|
||||
|
||||
// Load audio
|
||||
LoadAudio(filename);
|
||||
}
|
||||
|
||||
|
||||
//////////////
|
||||
// Destructor
|
||||
LAVCAudioProvider::~LAVCAudioProvider() {
|
||||
// TODO
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,6 +81,42 @@ wxString LAVCAudioProvider::GetFilename() {
|
|||
}
|
||||
|
||||
|
||||
//////////////
|
||||
// Load audio
|
||||
void LAVCAudioProvider::LoadAudio(wxString file) {
|
||||
// Close first
|
||||
Close();
|
||||
|
||||
try {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Catch errors
|
||||
catch (...) {
|
||||
Close();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////
|
||||
// Unload
|
||||
void LAVCAudioProvider::Close() {
|
||||
// Clean frame
|
||||
if (frame) av_free(frame);
|
||||
frame = NULL;
|
||||
|
||||
// Close codec context
|
||||
if (codec && codecContext) avcodec_close(codecContext);
|
||||
codecContext = NULL;
|
||||
codec = NULL;
|
||||
|
||||
// Close format context
|
||||
if (formatContext) av_close_input_file(formatContext);
|
||||
formatContext = NULL;
|
||||
}
|
||||
|
||||
|
||||
/////////////
|
||||
// Get audio
|
||||
void LAVCAudioProvider::GetAudio(void *buf, __int64 start, __int64 count) {
|
||||
|
|
|
@ -37,8 +37,21 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
// Auto-enable LAVC on non-windows
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef USE_LAVC
|
||||
#define USE_LAVC
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#ifdef USE_LAVC
|
||||
#define EMULATE_INTTYPES
|
||||
#include <ffmpeg/avcodec.h>
|
||||
#include <ffmpeg/avformat.h>
|
||||
#include <wx/wxprec.h>
|
||||
#include "audio_provider.h"
|
||||
|
||||
|
@ -49,6 +62,16 @@ class LAVCAudioProvider : public AudioProvider {
|
|||
private:
|
||||
wxString filename;
|
||||
|
||||
AVFormatContext *formatContext;
|
||||
AVCodecContext *codecContext;
|
||||
AVStream *stream;
|
||||
AVCodec *codec;
|
||||
AVFrame *frame;
|
||||
int audStream;
|
||||
|
||||
void LoadAudio(wxString file);
|
||||
void Close();
|
||||
|
||||
public:
|
||||
LAVCAudioProvider(wxString _filename);
|
||||
~LAVCAudioProvider();
|
||||
|
@ -58,3 +81,5 @@ public:
|
|||
void GetAudio(void *buf, __int64 start, __int64 count);
|
||||
void GetWaveForm(int *min,int *peak,__int64 start,int w,int h,int samples,float scale);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -48,9 +48,6 @@
|
|||
///////////////
|
||||
// Constructor
|
||||
LAVCVideoProvider::LAVCVideoProvider(wxString filename, wxString subfilename) {
|
||||
char temp[1024];
|
||||
strcpy(temp,subfilename.mb_str(wxConvUTF8));
|
||||
|
||||
// Init variables
|
||||
codecContext = NULL;
|
||||
formatContext = NULL;
|
||||
|
|
Loading…
Reference in a new issue