#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}
+#include <dcp/raw_convert.h>
#include "ffmpeg.h"
#include "ffmpeg_content.h"
#include "exceptions.h"
using std::cout;
using std::stringstream;
using boost::shared_ptr;
-using boost::lexical_cast;
+using dcp::raw_convert;
-/* This should not really be a pointer, but I find that __cxa_finalize tries
- * to destroy the mutex while a call to ~FFmpeg is in progress; this crashes
- * with a failure of assert (!posix::pthread_mutex_destroy(&m));
- *
- * The hacky work-around is never to destroy the mutex...
- */
-boost::mutex* FFmpeg::_mutex;
+boost::mutex FFmpeg::_mutex;
FFmpeg::FFmpeg (boost::shared_ptr<const FFmpegContent> c)
: _ffmpeg_content (c)
, _frame (0)
, _video_stream (-1)
{
- if (!_mutex) {
- _mutex = new boost::mutex ();
- }
-
setup_general ();
setup_video ();
setup_audio ();
FFmpeg::~FFmpeg ()
{
- boost::mutex::scoped_lock lm (*_mutex);
+ boost::mutex::scoped_lock lm (_mutex);
for (uint32_t i = 0; i < _format_context->nb_streams; ++i) {
AVCodecContext* context = _format_context->streams[i]->codec;
/* These durations are in microseconds, and represent how far into the content file
we will look for streams.
*/
- av_dict_set (&options, "analyzeduration", lexical_cast<string> (5 * 60 * 1e6).c_str(), 0);
- av_dict_set (&options, "probesize", lexical_cast<string> (5 * 60 * 1e6).c_str(), 0);
+ av_dict_set (&options, "analyzeduration", raw_convert<string> (5 * 60 * 1000000).c_str(), 0);
+ av_dict_set (&options, "probesize", raw_convert<string> (5 * 60 * 1000000).c_str(), 0);
if (avformat_open_input (&_format_context, 0, 0, &options) < 0) {
throw OpenFileError (_ffmpeg_content->path(0).string ());
void
FFmpeg::setup_video ()
{
- boost::mutex::scoped_lock lm (*_mutex);
+ boost::mutex::scoped_lock lm (_mutex);
assert (_video_stream >= 0);
AVCodecContext* context = _format_context->streams[_video_stream]->codec;
void
FFmpeg::setup_audio ()
{
- boost::mutex::scoped_lock lm (*_mutex);
+ boost::mutex::scoped_lock lm (_mutex);
for (uint32_t i = 0; i < _format_context->nb_streams; ++i) {
AVCodecContext* context = _format_context->streams[i]->codec;