mirror of https://github.com/odrling/Aegisub
Various fixes:
* svn:ignore * rename 'agi' namespace to 'media' * Remove some hacks required before bringing in provider code. Originally committed to SVN as r5298.
This commit is contained in:
parent
97abbf13ce
commit
f8b4b30cf8
|
@ -25,9 +25,10 @@
|
|||
#endif
|
||||
|
||||
#include "ffms_audio.h"
|
||||
#include "libmedia/exception.h"
|
||||
#include "libmedia/audio.h"
|
||||
|
||||
namespace agi {
|
||||
|
||||
namespace media {
|
||||
namespace ffms {
|
||||
|
||||
|
||||
|
@ -218,6 +219,5 @@ void Audio::GetAudio(void *Buf, int64_t Start, int64_t Count) const {
|
|||
throw AudioDecodeError(std::string("Failed to get audio samples: ") + ErrInfo.Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ffms
|
||||
} // namespace agi
|
||||
} // namespace media
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
/// @ingroup fmms audio
|
||||
|
||||
#include "../../libffms/include/ffms.h"
|
||||
#include <libaegisub/exception.h>
|
||||
#include <libmedia/audio.h>
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#ifdef WIN32
|
||||
|
@ -30,13 +30,12 @@
|
|||
#endif
|
||||
|
||||
#include "../common/ffms_common.h"
|
||||
|
||||
namespace agi {
|
||||
namespace media {
|
||||
namespace ffms {
|
||||
|
||||
/// @class Audio
|
||||
/// Audio file support.
|
||||
class Audio : public FFmpegSourceProvider {
|
||||
class Audio : public AudioProvider, FFmpegSourceProvider {
|
||||
FFMS_AudioSource *AudioSource; ///< audio source object
|
||||
bool COMInited; ///< COM initialization state
|
||||
|
||||
|
@ -46,11 +45,6 @@ class Audio : public FFmpegSourceProvider {
|
|||
void Close();
|
||||
void LoadAudio(std::string filename);
|
||||
|
||||
int channels;
|
||||
int64_t num_samples; // for one channel, ie. number of PCM frames
|
||||
int sample_rate;
|
||||
int bytes_per_sample;
|
||||
|
||||
Audio(std::string filename);
|
||||
virtual ~Audio();
|
||||
|
||||
|
@ -65,4 +59,4 @@ class Audio : public FFmpegSourceProvider {
|
|||
};
|
||||
|
||||
} // namespace ffms
|
||||
} // namespace agi
|
||||
} // namespace media
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
//#include "md5.h"
|
||||
//#include "standard_paths.h"
|
||||
|
||||
namespace agi {
|
||||
namespace media {
|
||||
namespace ffms {
|
||||
|
||||
/// @brief Callback function that updates the indexing progress dialog
|
||||
|
@ -389,4 +389,4 @@ wxThread::ExitCode FFmpegSourceCacheCleaner::Entry() {
|
|||
|
||||
|
||||
} // namespace ffms
|
||||
} // namespace agi
|
||||
} // namespace media
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
#include "../../libffms/include/ffms.h"
|
||||
|
||||
namespace agi {
|
||||
namespace media {
|
||||
namespace ffms {
|
||||
|
||||
//#include "dialog_progress.h"
|
||||
|
@ -111,4 +111,4 @@ public:
|
|||
#endif /* WITH_FFMPEGSOURCE */
|
||||
|
||||
} // namespace ffms
|
||||
} // namespace agi
|
||||
} // namespace media
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <string.h>
|
||||
#endif
|
||||
|
||||
namespace agi {
|
||||
namespace media {
|
||||
|
||||
void AegiVideoFrame::Reset() {
|
||||
|
@ -115,4 +114,3 @@ void AegiVideoFrame::SetTo(const unsigned char *source, unsigned int width, unsi
|
|||
}
|
||||
|
||||
} // namespace media
|
||||
} // namespace agi
|
||||
|
|
|
@ -36,12 +36,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <wx/string.h>
|
||||
#endif
|
||||
|
||||
#include <libaegisub/exception.h>
|
||||
#include "factory_manager.h"
|
||||
#include <libmedia/factory_manager.h>
|
||||
|
||||
namespace media {
|
||||
|
||||
/// @class AudioProvider
|
||||
/// @brief DOCME
|
||||
|
@ -72,13 +70,13 @@ protected:
|
|||
|
||||
|
||||
/// DOCME
|
||||
wxString filename;
|
||||
std::string filename;
|
||||
|
||||
public:
|
||||
AudioProvider();
|
||||
virtual ~AudioProvider();
|
||||
|
||||
virtual wxString GetFilename() const { return filename; };
|
||||
virtual std::string GetFilename() const { return filename; };
|
||||
virtual void GetAudio(void *buf, int64_t start, int64_t count) const = 0;
|
||||
void GetAudioWithVolume(void *buf, int64_t start, int64_t count, double volume) const;
|
||||
|
||||
|
@ -97,10 +95,10 @@ public:
|
|||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class AudioProviderFactory : public Factory1<AudioProvider, wxString> {
|
||||
class AudioProviderFactory : public Factory1<AudioProvider, std::string> {
|
||||
public:
|
||||
static void RegisterProviders();
|
||||
static AudioProvider *GetProvider(wxString filename, int cache=-1);
|
||||
static AudioProvider *GetProvider(std::string filename, int cache=-1);
|
||||
};
|
||||
|
||||
DEFINE_BASE_EXCEPTION_NOINNER(AudioProviderError, agi::Exception);
|
||||
|
@ -108,3 +106,5 @@ DEFINE_SIMPLE_EXCEPTION_NOINNER(AudioOpenError, AudioProviderError, "audio/open/
|
|||
|
||||
/// Error of some sort occurred while decoding a frame
|
||||
DEFINE_SIMPLE_EXCEPTION_NOINNER(AudioDecodeError, AudioProviderError, "audio/error");
|
||||
|
||||
} // namespace media
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
// Copyright (c) 2010, Thomas Goyne <plorkyeran@aegisub.org>
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither the name of the Aegisub Group nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Aegisub Project http://www.aegisub.org/
|
||||
//
|
||||
// $Id$
|
||||
|
||||
/// @file factory_manager.h
|
||||
/// @brief Template/base-class for factory classes
|
||||
/// @ingroup utility
|
||||
///
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef MAGI_PRE
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#endif
|
||||
|
||||
namespace media {
|
||||
|
||||
template <class func>
|
||||
class FactoryBase {
|
||||
protected:
|
||||
typedef std::map<std::string, std::pair<bool, func> > map;
|
||||
typedef typename map::iterator iterator;
|
||||
|
||||
static map *classes;
|
||||
|
||||
static void DoRegister(func function, std::string name, bool hide, std::vector<std::string> &subtypes) {
|
||||
if (!classes) classes = new map;
|
||||
|
||||
if (subtypes.empty()) {
|
||||
classes->insert(std::make_pair(name, std::make_pair(hide, function)));
|
||||
}
|
||||
else {
|
||||
for (size_t i = 0; i < subtypes.size(); i++) {
|
||||
classes->insert(std::make_pair(name + '/' + subtypes[i], std::make_pair(hide, function)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func Find(std::string name) {
|
||||
if (!classes) return NULL;
|
||||
|
||||
iterator factory = classes->find(name);
|
||||
if (factory != classes->end()) return factory->second.second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public:
|
||||
static void Clear() {
|
||||
delete classes;
|
||||
}
|
||||
static std::vector<std::string> GetClasses(std::string favourite="") {
|
||||
std::vector<std::string> list;
|
||||
if (!classes) return list;
|
||||
std::string cmp;
|
||||
std::transform(favourite.begin(), favourite.end(), favourite.begin(), ::tolower);
|
||||
for (iterator cur=classes->begin();cur!=classes->end();cur++) {
|
||||
cmp.clear();
|
||||
std::transform(cur->first.begin(), cur->first.end(), std::back_inserter(cmp), ::tolower);
|
||||
if (cmp == favourite) list.insert(list.begin(), cur->first);
|
||||
else if (!cur->second.first) list.push_back(cur->first);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
virtual ~FactoryBase() {
|
||||
delete classes;
|
||||
}
|
||||
};
|
||||
|
||||
template<class Base>
|
||||
class Factory0 : public FactoryBase<Base *(*)()> {
|
||||
typedef Base *(*func)();
|
||||
template<class T>
|
||||
static Base* create() {
|
||||
return new T;
|
||||
}
|
||||
public:
|
||||
static Base* Create(std::string name) {
|
||||
func factory = FactoryBase<func>::Find(name);
|
||||
if (factory) {
|
||||
return factory();
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static void Register(std::string name, bool hide = false, std::vector<std::string> subTypes = std::vector<std::string>()) {
|
||||
DoRegister(&Factory0<Base>::template create<T>, name, hide, subTypes);
|
||||
}
|
||||
};
|
||||
|
||||
template<class Base, class Arg1>
|
||||
class Factory1 : public FactoryBase<Base *(*)(Arg1)> {
|
||||
typedef Base *(*func)(Arg1);
|
||||
template<class T>
|
||||
static Base* create(Arg1 a1) {
|
||||
return new T(a1);
|
||||
}
|
||||
public:
|
||||
static Base* Create(std::string name, Arg1 a1) {
|
||||
func factory = FactoryBase<func>::Find(name);
|
||||
if (factory) {
|
||||
return factory(a1);
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static void Register(std::string name, bool hide = false, std::vector<std::string> subTypes = std::vector<std::string>()) {
|
||||
DoRegister(&Factory1<Base, Arg1>::template create<T>, name, hide, subTypes);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace media
|
|
@ -36,10 +36,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "video_frame.h"
|
||||
#include <libmedia/video_frame.h>
|
||||
#include <libaegisub/exception.h>
|
||||
#include <libaegisub/vfr.h>
|
||||
|
||||
|
||||
namespace media {
|
||||
|
||||
/// @class VideoProvider
|
||||
/// @brief DOCME
|
||||
///
|
||||
|
@ -61,10 +64,10 @@ public:
|
|||
|
||||
|
||||
/// @brief Use this to set any post-loading warnings, such as "being loaded with unreliable seeking"
|
||||
virtual wxString GetWarning() const { return L""; }
|
||||
virtual std::string GetWarning() const { return ""; }
|
||||
|
||||
/// @brief Name of decoder, e.g. "Avisynth/FFMpegSource"
|
||||
virtual wxString GetDecoderName() const = 0;
|
||||
virtual std::string GetDecoderName() const = 0;
|
||||
|
||||
/// @brief Does this provider want Aegisub to cache video frames?
|
||||
/// @return Returns true if caching is desired, false otherwise.
|
||||
|
@ -79,3 +82,6 @@ DEFINE_SIMPLE_EXCEPTION_NOINNER(VideoOpenError, VideoProviderError, "video/open/
|
|||
|
||||
/// Error of some sort occurred while decoding a frame
|
||||
DEFINE_SIMPLE_EXCEPTION_NOINNER(VideoDecodeError, VideoProviderError, "video/error");
|
||||
|
||||
// namespace media
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#ifndef LAGI_PRE
|
||||
#endif
|
||||
|
||||
namespace agi {
|
||||
namespace media {
|
||||
|
||||
/// DOCME
|
||||
|
@ -86,4 +85,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace media
|
||||
} // namespace agi
|
||||
|
|
Loading…
Reference in New Issue