summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-04-15 16:24:03 +0100
committerCarl Hetherington <cth@carlh.net>2013-04-15 16:24:03 +0100
commit3f2365fcf3a1ffc50901eb2e4af246aa4c83e272 (patch)
tree289a2fdbea44d1f5d8326601972e259e65aa0d80 /src/lib
parenta00ebbc68438e84076c65e99d0e70403afb4407d (diff)
Repair very bad merge. Mysterious.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ab_transcoder.cc4
-rw-r--r--src/lib/audio_decoder.h2
-rw-r--r--src/lib/audio_sink.h7
-rw-r--r--src/lib/audio_source.cc6
-rw-r--r--src/lib/audio_source.h12
-rw-r--r--src/lib/combiner.cc8
-rw-r--r--src/lib/combiner.h6
-rw-r--r--src/lib/delay_line.cc4
-rw-r--r--src/lib/delay_line.h4
-rw-r--r--src/lib/matcher.cc2
-rw-r--r--src/lib/matcher.h6
-rw-r--r--src/lib/processor.h17
-rw-r--r--src/lib/sndfile_decoder.cc5
-rw-r--r--src/lib/transcoder.cc9
-rw-r--r--src/lib/video_decoder.h2
-rw-r--r--src/lib/video_sink.h12
-rw-r--r--src/lib/video_source.cc6
-rw-r--r--src/lib/video_source.h23
18 files changed, 103 insertions, 32 deletions
diff --git a/src/lib/ab_transcoder.cc b/src/lib/ab_transcoder.cc
index 7db13afcc..6eef397c2 100644
--- a/src/lib/ab_transcoder.cc
+++ b/src/lib/ab_transcoder.cc
@@ -70,8 +70,8 @@ ABTranscoder::ABTranscoder (
_db.video->set_subtitle_stream (_film_a->subtitle_stream ());
_da.audio->set_audio_stream (_film_a->audio_stream ());
- _da.video->Video.connect (bind (&Combiner::process_video, _combiner, _1, _2, _3));
- _db.video->Video.connect (bind (&Combiner::process_video_b, _combiner, _1, _2, _3));
+ _da.video->Video.connect (bind (&Combiner::process_video, _combiner, _1, _2, _3, _4));
+ _db.video->Video.connect (bind (&Combiner::process_video_b, _combiner, _1, _2, _3, _4));
_combiner->connect_video (_delay_line);
_delay_line->connect_video (_matcher);
diff --git a/src/lib/audio_decoder.h b/src/lib/audio_decoder.h
index 9bef8e0e7..cfe94b528 100644
--- a/src/lib/audio_decoder.h
+++ b/src/lib/audio_decoder.h
@@ -31,7 +31,7 @@
/** @class AudioDecoder.
* @brief Parent class for audio decoders.
*/
-class AudioDecoder : public AudioSource, public virtual Decoder
+class AudioDecoder : public TimedAudioSource, public virtual Decoder
{
public:
AudioDecoder (boost::shared_ptr<Film>, DecodeOptions);
diff --git a/src/lib/audio_sink.h b/src/lib/audio_sink.h
index 11d578a60..f34b24f88 100644
--- a/src/lib/audio_sink.h
+++ b/src/lib/audio_sink.h
@@ -27,4 +27,11 @@ public:
virtual void process_audio (boost::shared_ptr<AudioBuffers>) = 0;
};
+class TimedAudioSink
+{
+public:
+ /** Call with some audio data */
+ virtual void process_audio (boost::shared_ptr<AudioBuffers>, double t) = 0;
+};
+
#endif
diff --git a/src/lib/audio_source.cc b/src/lib/audio_source.cc
index 53b0dda15..bca3562cf 100644
--- a/src/lib/audio_source.cc
+++ b/src/lib/audio_source.cc
@@ -28,3 +28,9 @@ AudioSource::connect_audio (shared_ptr<AudioSink> s)
{
Audio.connect (bind (&AudioSink::process_audio, s, _1));
}
+
+void
+TimedAudioSource::connect_audio (shared_ptr<TimedAudioSink> s)
+{
+ Audio.connect (bind (&TimedAudioSink::process_audio, s, _1, _2));
+}
diff --git a/src/lib/audio_source.h b/src/lib/audio_source.h
index 5a1510d3c..3dc998cca 100644
--- a/src/lib/audio_source.h
+++ b/src/lib/audio_source.h
@@ -28,6 +28,7 @@
class AudioBuffers;
class AudioSink;
+class TimedAudioSink;
/** A class that emits audio data */
class AudioSource
@@ -39,4 +40,15 @@ public:
void connect_audio (boost::shared_ptr<AudioSink>);
};
+
+/** A class that emits audio data with timestamps */
+class TimedAudioSource
+{
+public:
+ /** Emitted when some audio data is ready */
+ boost::signals2::signal<void (boost::shared_ptr<AudioBuffers>, double)> Audio;
+
+ void connect_audio (boost::shared_ptr<TimedAudioSink>);
+};
+
#endif
diff --git a/src/lib/combiner.cc b/src/lib/combiner.cc
index 12ce4a96e..006dd2697 100644
--- a/src/lib/combiner.cc
+++ b/src/lib/combiner.cc
@@ -23,7 +23,7 @@
using boost::shared_ptr;
Combiner::Combiner (shared_ptr<Log> log)
- : VideoProcessor (log)
+ : TimedVideoProcessor (log)
{
}
@@ -33,7 +33,7 @@ Combiner::Combiner (shared_ptr<Log> log)
* @param image Frame image.
*/
void
-Combiner::process_video (shared_ptr<Image> image, bool, shared_ptr<Subtitle>)
+Combiner::process_video (shared_ptr<Image> image, bool, shared_ptr<Subtitle>, double t)
{
_image = image;
}
@@ -43,7 +43,7 @@ Combiner::process_video (shared_ptr<Image> image, bool, shared_ptr<Subtitle>)
* @param sub Subtitle (which will be put onto the whole frame)
*/
void
-Combiner::process_video_b (shared_ptr<Image> image, bool, shared_ptr<Subtitle> sub)
+Combiner::process_video_b (shared_ptr<Image> image, bool, shared_ptr<Subtitle> sub, double t)
{
/* Copy the right half of this image into our _image */
/* XXX: this should probably be in the Image class */
@@ -62,6 +62,6 @@ Combiner::process_video_b (shared_ptr<Image> image, bool, shared_ptr<Subtitle> s
}
}
- Video (_image, false, sub);
+ Video (_image, false, sub, t);
_image.reset ();
}
diff --git a/src/lib/combiner.h b/src/lib/combiner.h
index 68026eaff..a8f1fa804 100644
--- a/src/lib/combiner.h
+++ b/src/lib/combiner.h
@@ -28,13 +28,13 @@
* one image used for the left half of the screen and the other for
* the right.
*/
-class Combiner : public VideoProcessor
+class Combiner : public TimedVideoProcessor
{
public:
Combiner (boost::shared_ptr<Log> log);
- void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s);
- void process_video_b (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s);
+ void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s, double);
+ void process_video_b (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s, double);
private:
/** The image that we are currently working on */
diff --git a/src/lib/delay_line.cc b/src/lib/delay_line.cc
index c8e593a18..9e6baeba8 100644
--- a/src/lib/delay_line.cc
+++ b/src/lib/delay_line.cc
@@ -30,14 +30,14 @@ using boost::shared_ptr;
/* @param seconds Delay in seconds, +ve to move audio later.
*/
DelayLine::DelayLine (shared_ptr<Log> log, double seconds)
- : Processor (log)
+ : TimedAudioVideoProcessor (log)
, _seconds (seconds)
{
}
void
-DelayLine::process_audio (shared_ptr<AudioBuffers> data)
+DelayLine::process_audio (shared_ptr<AudioBuffers> data, double t)
{
if (_seconds > 0) {
t += _seconds;
diff --git a/src/lib/delay_line.h b/src/lib/delay_line.h
index 7a8b11c69..90f1dcfa7 100644
--- a/src/lib/delay_line.h
+++ b/src/lib/delay_line.h
@@ -20,8 +20,8 @@
#include <boost/shared_ptr.hpp>
#include "processor.h"
-/** A delay line for audio */
-class DelayLine : public Processor, public TimedAudioSink, public TimedAudioSource, public TimedVideoSink, public TimedVideoSource
+/** A delay line */
+class DelayLine : public TimedAudioVideoProcessor
{
public:
DelayLine (boost::shared_ptr<Log> log, double);
diff --git a/src/lib/matcher.cc b/src/lib/matcher.cc
index 69d12e2c4..34ddc86d6 100644
--- a/src/lib/matcher.cc
+++ b/src/lib/matcher.cc
@@ -29,7 +29,7 @@ using std::list;
using boost::shared_ptr;
Matcher::Matcher (shared_ptr<Log> log, int sample_rate, float frames_per_second)
- : AudioVideoProcessor (log)
+ : Processor (log)
, _sample_rate (sample_rate)
, _frames_per_second (frames_per_second)
, _video_frames (0)
diff --git a/src/lib/matcher.h b/src/lib/matcher.h
index 4ec0a3e96..f54aa4b6a 100644
--- a/src/lib/matcher.h
+++ b/src/lib/matcher.h
@@ -21,12 +21,12 @@
#include "processor.h"
#include "ffmpeg_compatibility.h"
-class Matcher : public AudioVideoProcessor
+class Matcher : public Processor, public TimedAudioSink, public TimedVideoSink, public AudioSource, public VideoSource
{
public:
Matcher (boost::shared_ptr<Log> log, int sample_rate, float frames_per_second);
- void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s);
- void process_audio (boost::shared_ptr<AudioBuffers>);
+ void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s, double);
+ void process_audio (boost::shared_ptr<AudioBuffers>, double);
void process_end ();
private:
diff --git a/src/lib/processor.h b/src/lib/processor.h
index 1ba396f2f..603239f8f 100644
--- a/src/lib/processor.h
+++ b/src/lib/processor.h
@@ -67,6 +67,15 @@ public:
{}
};
+class TimedAudioVideoProcessor : public Processor, public TimedVideoSource, public TimedVideoSink, public TimedAudioSource, public TimedAudioSink
+{
+public:
+ TimedAudioVideoProcessor (boost::shared_ptr<Log> log)
+ : Processor (log)
+ {}
+};
+
+
/** @class AudioProcessor
* @brief A processor which handles just audio data.
*/
@@ -95,4 +104,12 @@ public:
{}
};
+class TimedVideoProcessor : public Processor, public TimedVideoSource, public TimedVideoSink
+{
+public:
+ TimedVideoProcessor (boost::shared_ptr<Log> log)
+ : Processor (log)
+ {}
+};
+
#endif
diff --git a/src/lib/sndfile_decoder.cc b/src/lib/sndfile_decoder.cc
index 0e3e5e234..af59c049c 100644
--- a/src/lib/sndfile_decoder.cc
+++ b/src/lib/sndfile_decoder.cc
@@ -113,8 +113,8 @@ SndfileDecoder::pass ()
to what FFmpeg (and in particular the resampler) can cope with.
*/
sf_count_t const block = _audio_stream->sample_rate() / 2;
-
shared_ptr<AudioBuffers> audio (new AudioBuffers (_audio_stream->channels(), block));
+ sf_count_t done = 0;
while (frames > 0) {
sf_count_t const this_time = min (block, frames);
for (size_t i = 0; i < sndfiles.size(); ++i) {
@@ -126,7 +126,8 @@ SndfileDecoder::pass ()
}
audio->set_frames (this_time);
- Audio (audio);
+ Audio (audio, double(done) / _audio_stream->sample_rate());
+ done += this_time;
frames -= this_time;
}
diff --git a/src/lib/transcoder.cc b/src/lib/transcoder.cc
index 8046080de..23fb5b788 100644
--- a/src/lib/transcoder.cc
+++ b/src/lib/transcoder.cc
@@ -63,18 +63,9 @@ Transcoder::Transcoder (shared_ptr<Film> f, DecodeOptions o, Job* j, shared_ptr<
_decoders.video->set_subtitle_stream (f->subtitle_stream ());
_decoders.audio->set_audio_stream (f->audio_stream ());
-<<<<<<< HEAD
_decoders.video->connect_video (_delay_line);
_delay_line->connect_video (_matcher);
_matcher->connect_video (_encoder);
-=======
- if (_matcher) {
- _decoders.video->connect_video (_matcher);
- _matcher->connect_video (_encoder);
- } else {
- _decoders.video->connect_video (_encoder);
- }
->>>>>>> master
_decoders.audio->connect_audio (_delay_line);
_delay_line->connect_audio (_matcher);
diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h
index f8612dff2..6e4fd48c0 100644
--- a/src/lib/video_decoder.h
+++ b/src/lib/video_decoder.h
@@ -24,7 +24,7 @@
#include "stream.h"
#include "decoder.h"
-class VideoDecoder : public VideoSource, public virtual Decoder
+class VideoDecoder : public TimedVideoSource, public virtual Decoder
{
public:
VideoDecoder (boost::shared_ptr<Film>, DecodeOptions);
diff --git a/src/lib/video_sink.h b/src/lib/video_sink.h
index 7c128cf73..32c7f3b38 100644
--- a/src/lib/video_sink.h
+++ b/src/lib/video_sink.h
@@ -37,4 +37,16 @@ public:
virtual void process_video (boost::shared_ptr<Image> i, bool same, boost::shared_ptr<Subtitle> s) = 0;
};
+class TimedVideoSink
+{
+public:
+ /** Call with a frame of video.
+ * @param i Video frame image.
+ * @param same true if i is the same as last time we were called.
+ * @param s A subtitle that should be on this frame, or 0.
+ * @param t Source timestamp.
+ */
+ virtual void process_video (boost::shared_ptr<Image> i, bool same, boost::shared_ptr<Subtitle> s, double t) = 0;
+};
+
#endif
diff --git a/src/lib/video_source.cc b/src/lib/video_source.cc
index 56742e2b4..af6f941fd 100644
--- a/src/lib/video_source.cc
+++ b/src/lib/video_source.cc
@@ -28,3 +28,9 @@ VideoSource::connect_video (shared_ptr<VideoSink> s)
{
Video.connect (bind (&VideoSink::process_video, s, _1, _2, _3));
}
+
+void
+TimedVideoSource::connect_video (shared_ptr<TimedVideoSink> s)
+{
+ Video.connect (bind (&TimedVideoSink::process_video, s, _1, _2, _3, _4));
+}
diff --git a/src/lib/video_source.h b/src/lib/video_source.h
index 893629160..705b0023a 100644
--- a/src/lib/video_source.h
+++ b/src/lib/video_source.h
@@ -29,11 +29,12 @@
#include "util.h"
class VideoSink;
+class TimedVideoSink;
class Subtitle;
class Image;
-/** @class VideoSink
- * @param A class that emits video data.
+/** @class VideoSource
+ * @param A class that emits video data without timestamps.
*/
class VideoSource
{
@@ -49,4 +50,22 @@ public:
void connect_video (boost::shared_ptr<VideoSink>);
};
+/** @class TimedVideoSource
+ * @param A class that emits video data with timestamps.
+ */
+class TimedVideoSource
+{
+public:
+
+ /** Emitted when a video frame is ready.
+ * First parameter is the video image.
+ * Second parameter is true if the image is the same as the last one that was emitted.
+ * Third parameter is either 0 or a subtitle that should be on this frame.
+ * Fourth parameter is the source timestamp of this frame.
+ */
+ boost::signals2::signal<void (boost::shared_ptr<Image>, bool, boost::shared_ptr<Subtitle>, double)> Video;
+
+ void connect_video (boost::shared_ptr<TimedVideoSink>);
+};
+
#endif