From 0db016f90ae722fc8b72d465e21d9f153f72b340 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 10 May 2013 23:31:25 +0100 Subject: [PATCH] Remove Timed*Sink and Timed*Source> --- src/lib/audio_decoder.h | 2 +- src/lib/audio_sink.h | 9 +-------- src/lib/audio_source.cc | 26 +++----------------------- src/lib/audio_source.h | 16 ++-------------- src/lib/combiner.cc | 2 +- src/lib/combiner.h | 6 +++--- src/lib/encoder.cc | 4 ++-- src/lib/encoder.h | 4 ++-- src/lib/player.h | 2 +- src/lib/processor.h | 17 ----------------- src/lib/video_decoder.h | 2 +- src/lib/video_sink.h | 14 +------------- src/lib/video_source.cc | 26 +++----------------------- src/lib/video_source.h | 22 +--------------------- 14 files changed, 22 insertions(+), 130 deletions(-) diff --git a/src/lib/audio_decoder.h b/src/lib/audio_decoder.h index 8db16e369..1c7287a55 100644 --- a/src/lib/audio_decoder.h +++ b/src/lib/audio_decoder.h @@ -35,7 +35,7 @@ class AudioContent; /** @class AudioDecoder. * @brief Parent class for audio decoders. */ -class AudioDecoder : public TimedAudioSource, public virtual Decoder +class AudioDecoder : public AudioSource, public virtual Decoder { public: AudioDecoder (boost::shared_ptr, boost::shared_ptr); diff --git a/src/lib/audio_sink.h b/src/lib/audio_sink.h index ee39f9ee7..2e3ead005 100644 --- a/src/lib/audio_sink.h +++ b/src/lib/audio_sink.h @@ -24,14 +24,7 @@ class AudioSink { public: /** Call with some audio data */ - virtual void process_audio (boost::shared_ptr) = 0; -}; - -class TimedAudioSink -{ -public: - /** Call with some audio data */ - virtual void process_audio (boost::shared_ptr, double t) = 0; + virtual void process_audio (boost::shared_ptr, Time) = 0; }; #endif diff --git a/src/lib/audio_source.cc b/src/lib/audio_source.cc index 2867bcc24..e61721646 100644 --- a/src/lib/audio_source.cc +++ b/src/lib/audio_source.cc @@ -25,38 +25,18 @@ using boost::weak_ptr; using boost::bind; static void -process_audio_proxy (weak_ptr sink, shared_ptr audio) +process_audio_proxy (weak_ptr sink, shared_ptr audio, Time time) { shared_ptr p = sink.lock (); if (p) { - p->process_audio (audio); + p->process_audio (audio, time); } } void AudioSource::connect_audio (shared_ptr s) { - Audio.connect (bind (process_audio_proxy, weak_ptr (s), _1)); + Audio.connect (bind (process_audio_proxy, weak_ptr (s), _1, _2)); } -void -TimedAudioSource::connect_audio (shared_ptr s) -{ - Audio.connect (bind (process_audio_proxy, weak_ptr (s), _1)); -} - -static void -timed_process_audio_proxy (weak_ptr sink, shared_ptr audio, double t) -{ - shared_ptr p = sink.lock (); - if (p) { - p->process_audio (audio, t); - } -} - -void -TimedAudioSource::connect_audio (shared_ptr s) -{ - Audio.connect (bind (timed_process_audio_proxy, weak_ptr (s), _1, _2)); -} diff --git a/src/lib/audio_source.h b/src/lib/audio_source.h index c7f0a09ed..ef47e969b 100644 --- a/src/lib/audio_source.h +++ b/src/lib/audio_source.h @@ -25,31 +25,19 @@ #define DCPOMATIC_AUDIO_SOURCE_H #include +#include "types.h" class AudioBuffers; class AudioSink; -class TimedAudioSink; /** A class that emits audio data */ class AudioSource { public: /** Emitted when some audio data is ready */ - boost::signals2::signal)> Audio; + boost::signals2::signal, Time)> Audio; void connect_audio (boost::shared_ptr); }; - -/** A class that emits audio data with timestamps */ -class TimedAudioSource -{ -public: - /** Emitted when some audio data is ready */ - boost::signals2::signal, double)> Audio; - - void connect_audio (boost::shared_ptr); - void connect_audio (boost::shared_ptr); -}; - #endif diff --git a/src/lib/combiner.cc b/src/lib/combiner.cc index 367cefa7f..9f9461ec2 100644 --- a/src/lib/combiner.cc +++ b/src/lib/combiner.cc @@ -23,7 +23,7 @@ using boost::shared_ptr; Combiner::Combiner (shared_ptr log) - : TimedVideoProcessor (log) + : VideoProcessor (log) { } diff --git a/src/lib/combiner.h b/src/lib/combiner.h index 7ed316e26..062297f0d 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 TimedVideoProcessor +class Combiner : public VideoProcessor { public: Combiner (boost::shared_ptr log); - void process_video (boost::shared_ptr i, bool, boost::shared_ptr s, double); - void process_video_b (boost::shared_ptr i, bool, boost::shared_ptr s, double); + void process_video (boost::shared_ptr i, bool, boost::shared_ptr s, Time); + void process_video_b (boost::shared_ptr i, bool, boost::shared_ptr s, Time); private: /** The image that we are currently working on */ diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index f91a2c4e2..6cb384e20 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -178,7 +178,7 @@ Encoder::frame_done () } void -Encoder::process_video (shared_ptr image, bool same, shared_ptr sub) +Encoder::process_video (shared_ptr image, bool same, shared_ptr sub, Time) { FrameRateConversion frc (_film->video_frame_rate(), _film->dcp_frame_rate()); @@ -241,7 +241,7 @@ Encoder::process_video (shared_ptr image, bool same, shared_ptr data) +Encoder::process_audio (shared_ptr data, Time) { _writer->write (data); } diff --git a/src/lib/encoder.h b/src/lib/encoder.h index cce26efc8..b6d3663fd 100644 --- a/src/lib/encoder.h +++ b/src/lib/encoder.h @@ -70,10 +70,10 @@ public: * @param same true if i is the same as the last time we were called. * @param s A subtitle that should be on this frame, or 0. */ - void process_video (boost::shared_ptr i, bool same, boost::shared_ptr s); + void process_video (boost::shared_ptr i, bool same, boost::shared_ptr s, Time); /** Call with some audio data */ - void process_audio (boost::shared_ptr); + void process_audio (boost::shared_ptr, Time); /** Called when a processing run has finished */ void process_end (); diff --git a/src/lib/player.h b/src/lib/player.h index b6fb41f6e..b1be2f456 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -39,7 +39,7 @@ class AudioContent; * @brief A class which can `play' a Playlist; emitting its audio and video. */ -class Player : public TimedVideoSource, public TimedAudioSource, public TimedVideoSink, public boost::enable_shared_from_this +class Player : public VideoSource, public AudioSource, public VideoSink, public boost::enable_shared_from_this { public: Player (boost::shared_ptr, boost::shared_ptr); diff --git a/src/lib/processor.h b/src/lib/processor.h index 7b7735faa..5dbafab7f 100644 --- a/src/lib/processor.h +++ b/src/lib/processor.h @@ -67,15 +67,6 @@ public: {} }; -class TimedAudioVideoProcessor : public Processor, public TimedVideoSource, public TimedVideoSink, public TimedAudioSource, public TimedAudioSink -{ -public: - TimedAudioVideoProcessor (boost::shared_ptr log) - : Processor (log) - {} -}; - - /** @class AudioProcessor * @brief A processor which handles just audio data. */ @@ -104,12 +95,4 @@ public: {} }; -class TimedVideoProcessor : public Processor, public TimedVideoSource, public TimedVideoSink -{ -public: - TimedVideoProcessor (boost::shared_ptr log) - : Processor (log) - {} -}; - #endif diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h index 0b05b2f71..88730f518 100644 --- a/src/lib/video_decoder.h +++ b/src/lib/video_decoder.h @@ -25,7 +25,7 @@ class VideoContent; -class VideoDecoder : public TimedVideoSource, public virtual Decoder +class VideoDecoder : public VideoSource, public virtual Decoder { public: VideoDecoder (boost::shared_ptr); diff --git a/src/lib/video_sink.h b/src/lib/video_sink.h index 6239bc557..2da42528c 100644 --- a/src/lib/video_sink.h +++ b/src/lib/video_sink.h @@ -34,19 +34,7 @@ public: * @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. */ - virtual void process_video (boost::shared_ptr i, bool same, boost::shared_ptr 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 i, bool same, boost::shared_ptr s, double t) = 0; + virtual void process_video (boost::shared_ptr i, bool same, boost::shared_ptr s, Time) = 0; }; #endif diff --git a/src/lib/video_source.cc b/src/lib/video_source.cc index 4d505f9fe..39043c860 100644 --- a/src/lib/video_source.cc +++ b/src/lib/video_source.cc @@ -25,11 +25,11 @@ using boost::weak_ptr; using boost::bind; static void -process_video_proxy (weak_ptr sink, shared_ptr i, bool same, shared_ptr s) +process_video_proxy (weak_ptr sink, shared_ptr image, bool same, shared_ptr sub, Time time) { shared_ptr p = sink.lock (); if (p) { - p->process_video (i, same, s); + p->process_video (image, same, sub, time); } } @@ -39,26 +39,6 @@ VideoSource::connect_video (shared_ptr s) /* If we bind, say, a Player (as the VideoSink) to a Decoder (which is owned by the Player) we create a cycle. Use a weak_ptr to break it. */ - Video.connect (bind (process_video_proxy, weak_ptr (s), _1, _2, _3)); + Video.connect (bind (process_video_proxy, weak_ptr (s), _1, _2, _3, _4)); } -void -TimedVideoSource::connect_video (shared_ptr s) -{ - Video.connect (bind (process_video_proxy, weak_ptr (s), _1, _2, _3)); -} - -static void -timed_process_video_proxy (weak_ptr sink, shared_ptr i, bool same, shared_ptr s, double t) -{ - shared_ptr p = sink.lock (); - if (p) { - p->process_video (i, same, s, t); - } -} - -void -TimedVideoSource::connect_video (shared_ptr s) -{ - Video.connect (bind (timed_process_video_proxy, weak_ptr (s), _1, _2, _3, _4)); -} diff --git a/src/lib/video_source.h b/src/lib/video_source.h index 9b4c9b4a2..7ad554480 100644 --- a/src/lib/video_source.h +++ b/src/lib/video_source.h @@ -29,7 +29,6 @@ #include "util.h" class VideoSink; -class TimedVideoSink; class Subtitle; class Image; @@ -45,28 +44,9 @@ public: * 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. */ - boost::signals2::signal, bool, boost::shared_ptr)> Video; + boost::signals2::signal, bool, boost::shared_ptr, Time)> Video; void connect_video (boost::shared_ptr); }; -/** @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, bool, boost::shared_ptr, double)> Video; - - void connect_video (boost::shared_ptr); - void connect_video (boost::shared_ptr); -}; - #endif -- 2.30.2