diff --git a/src/Color.cpp b/src/Color.cpp index e848f1f7..c877cbd4 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -28,6 +28,8 @@ * along with OpenShot Library. If not, see . */ +#include + #include "Color.h" #include "Exceptions.h" diff --git a/src/EffectBase.cpp b/src/EffectBase.cpp index b75a0820..a475c7eb 100644 --- a/src/EffectBase.cpp +++ b/src/EffectBase.cpp @@ -28,6 +28,9 @@ * along with OpenShot Library. If not, see . */ +#include +#include + #include "EffectBase.h" #include "Exceptions.h" @@ -57,16 +60,16 @@ void EffectBase::InitEffectInfo() } // Display file information -void EffectBase::DisplayInfo() { - std::cout << std::fixed << std::setprecision(2) << std::boolalpha; - std::cout << "----------------------------" << std::endl; - std::cout << "----- Effect Information -----" << std::endl; - std::cout << "----------------------------" << std::endl; - std::cout << "--> Name: " << info.name << std::endl; - std::cout << "--> Description: " << info.description << std::endl; - std::cout << "--> Has Video: " << info.has_video << std::endl; - std::cout << "--> Has Audio: " << info.has_audio << std::endl; - std::cout << "----------------------------" << std::endl; +void EffectBase::DisplayInfo(std::ostream* out) { + *out << std::fixed << std::setprecision(2) << std::boolalpha; + *out << "----------------------------" << std::endl; + *out << "----- Effect Information -----" << std::endl; + *out << "----------------------------" << std::endl; + *out << "--> Name: " << info.name << std::endl; + *out << "--> Description: " << info.description << std::endl; + *out << "--> Has Video: " << info.has_video << std::endl; + *out << "--> Has Audio: " << info.has_audio << std::endl; + *out << "----------------------------" << std::endl; } // Constrain a color value from 0 to 255 diff --git a/src/EffectBase.h b/src/EffectBase.h index dc78a7c9..05936500 100644 --- a/src/EffectBase.h +++ b/src/EffectBase.h @@ -87,7 +87,7 @@ namespace openshot EffectInfoStruct info; /// Display effect information in the standard output stream (stdout) - void DisplayInfo(); + void DisplayInfo(std::ostream* out=&std::cout); /// Constrain a color value from 0 to 255 int constrain(int color_value); diff --git a/src/FrameMapper.cpp b/src/FrameMapper.cpp index 0e3b0272..832f794a 100644 --- a/src/FrameMapper.cpp +++ b/src/FrameMapper.cpp @@ -28,6 +28,10 @@ * along with OpenShot Library. If not, see . */ +#include +#include +#include + #include "FrameMapper.h" #include "Exceptions.h" #include "Clip.h" @@ -611,7 +615,7 @@ std::shared_ptr FrameMapper::GetFrame(int64_t requested_frame) return final_cache.GetFrame(requested_frame); } -void FrameMapper::PrintMapping() +void FrameMapper::PrintMapping(std::ostream* out) { // Check if mappings are dirty (and need to be recalculated) if (is_dirty) @@ -622,8 +626,16 @@ void FrameMapper::PrintMapping() for (float map = 1; map <= frames.size(); map++) { MappedFrame frame = frames[map - 1]; - cout << "Target frame #: " << map << " mapped to original frame #:\t(" << frame.Odd.Frame << " odd, " << frame.Even.Frame << " even)" << endl; - cout << " - Audio samples mapped to frame " << frame.Samples.frame_start << ":" << frame.Samples.sample_start << " to frame " << frame.Samples.frame_end << ":" << frame.Samples.sample_end << endl; + *out << "Target frame #: " << map + << " mapped to original frame #:\t(" + << frame.Odd.Frame << " odd, " + << frame.Even.Frame << " even)" << std::endl; + + *out << " - Audio samples mapped to frame " + << frame.Samples.frame_start << ":" + << frame.Samples.sample_start << " to frame " + << frame.Samples.frame_end << ":" + << frame.Samples.sample_end << endl; } } diff --git a/src/FrameMapper.h b/src/FrameMapper.h index 62615cfb..813c644f 100644 --- a/src/FrameMapper.h +++ b/src/FrameMapper.h @@ -33,9 +33,9 @@ #include #include -#include #include #include + #include "CacheMemory.h" #include "ReaderBase.h" #include "Frame.h" @@ -211,7 +211,7 @@ namespace openshot void Open() override; /// Print all of the original frames and which new frames they map to - void PrintMapping(); + void PrintMapping(std::ostream* out=&std::cout); /// Get the current reader ReaderBase* Reader(); diff --git a/src/KeyFrame.cpp b/src/KeyFrame.cpp index 4107f2de..ef8b045e 100644 --- a/src/KeyFrame.cpp +++ b/src/KeyFrame.cpp @@ -28,9 +28,6 @@ * along with OpenShot Library. If not, see . */ -#include "KeyFrame.h" -#include "Exceptions.h" - #include #include #include @@ -38,6 +35,9 @@ #include // For std::cout #include // For std::setprecision +#include "KeyFrame.h" +#include "Exceptions.h" + using namespace std; using namespace openshot; @@ -559,21 +559,21 @@ void Keyframe::UpdatePoint(int64_t index, Point p) { AddPoint(p); } -void Keyframe::PrintPoints() const { - cout << fixed << setprecision(4); +void Keyframe::PrintPoints(std::ostream* out) const { + *out << std::fixed << std::setprecision(4); for (std::vector::const_iterator it = Points.begin(); it != Points.end(); it++) { Point p = *it; - cout << p.co.X << "\t" << p.co.Y << endl; + *out << p.co.X << "\t" << p.co.Y << std::endl; } } -void Keyframe::PrintValues() const { - cout << fixed << setprecision(4); - cout << "Frame Number (X)\tValue (Y)\tIs Increasing\tRepeat Numerator\tRepeat Denominator\tDelta (Y Difference)\n"; +void Keyframe::PrintValues(std::ostream* out) const { + *out << std::fixed << std::setprecision(4); + *out << "Frame Number (X)\tValue (Y)\tIs Increasing\tRepeat Numerator\tRepeat Denominator\tDelta (Y Difference)\n"; for (int64_t i = 1; i < GetLength(); ++i) { - cout << i << "\t" << GetValue(i) << "\t" << IsIncreasing(i) << "\t" ; - cout << GetRepeatFraction(i).num << "\t" << GetRepeatFraction(i).den << "\t" << GetDelta(i) << "\n"; + *out << i << "\t" << GetValue(i) << "\t" << IsIncreasing(i) << "\t" ; + *out << GetRepeatFraction(i).num << "\t" << GetRepeatFraction(i).den << "\t" << GetDelta(i) << "\n"; } } diff --git a/src/KeyFrame.h b/src/KeyFrame.h index 6da34cac..45624dd2 100644 --- a/src/KeyFrame.h +++ b/src/KeyFrame.h @@ -31,7 +31,7 @@ #ifndef OPENSHOT_KEYFRAME_H #define OPENSHOT_KEYFRAME_H -#include +#include #include #include "Fraction.h" @@ -160,10 +160,10 @@ namespace openshot { void UpdatePoint(int64_t index, Point p); /// Print a list of points - void PrintPoints() const; + void PrintPoints(std::ostream* out=&std::cout) const; /// Print just the Y value of the point's primary coordinate - void PrintValues() const; + void PrintValues(std::ostream* out=&std::cout) const; }; diff --git a/src/WriterBase.cpp b/src/WriterBase.cpp index fff93988..8faab981 100644 --- a/src/WriterBase.cpp +++ b/src/WriterBase.cpp @@ -28,6 +28,9 @@ * along with OpenShot Library. If not, see . */ +#include +#include + #include "WriterBase.h" #include "Exceptions.h" @@ -100,43 +103,43 @@ void WriterBase::CopyReaderInfo(ReaderBase* reader) } // Display file information -void WriterBase::DisplayInfo() { - std::cout << std::fixed << std::setprecision(2) << std::boolalpha; - std::cout << "----------------------------" << std::endl; - std::cout << "----- File Information -----" << std::endl; - std::cout << "----------------------------" << std::endl; - std::cout << "--> Has Video: " << info.has_video << std::endl; - std::cout << "--> Has Audio: " << info.has_audio << std::endl; - std::cout << "--> Has Single Image: " << info.has_single_image << std::endl; - std::cout << "--> Duration: " << info.duration << " Seconds" << std::endl; - std::cout << "--> File Size: " << double(info.file_size) / 1024 / 1024 << " MB" << std::endl; - std::cout << "----------------------------" << std::endl; - std::cout << "----- Video Attributes -----" << std::endl; - std::cout << "----------------------------" << std::endl; - std::cout << "--> Width: " << info.width << std::endl; - std::cout << "--> Height: " << info.height << std::endl; - std::cout << "--> Pixel Format: " << info.pixel_format << std::endl; - std::cout << "--> Frames Per Second: " << info.fps.ToDouble() << " (" << info.fps.num << "/" << info.fps.den << ")" << std::endl; - std::cout << "--> Video Bit Rate: " << info.video_bit_rate/1000 << " kb/s" << std::endl; - std::cout << "--> Pixel Ratio: " << info.pixel_ratio.ToDouble() << " (" << info.pixel_ratio.num << "/" << info.pixel_ratio.den << ")" << std::endl; - std::cout << "--> Display Aspect Ratio: " << info.display_ratio.ToDouble() << " (" << info.display_ratio.num << "/" << info.display_ratio.den << ")" << std::endl; - std::cout << "--> Video Codec: " << info.vcodec << std::endl; - std::cout << "--> Video Length: " << info.video_length << " Frames" << std::endl; - std::cout << "--> Video Stream Index: " << info.video_stream_index << std::endl; - std::cout << "--> Video Timebase: " << info.video_timebase.ToDouble() << " (" << info.video_timebase.num << "/" << info.video_timebase.den << ")" << std::endl; - std::cout << "--> Interlaced: " << info.interlaced_frame << std::endl; - std::cout << "--> Interlaced: Top Field First: " << info.top_field_first << std::endl; - std::cout << "----------------------------" << std::endl; - std::cout << "----- Audio Attributes -----" << std::endl; - std::cout << "----------------------------" << std::endl; - std::cout << "--> Audio Codec: " << info.acodec << std::endl; - std::cout << "--> Audio Bit Rate: " << info.audio_bit_rate/1000 << " kb/s" << std::endl; - std::cout << "--> Sample Rate: " << info.sample_rate << " Hz" << std::endl; - std::cout << "--> # of Channels: " << info.channels << std::endl; - std::cout << "--> Channel Layout: " << info.channel_layout << std::endl; - std::cout << "--> Audio Stream Index: " << info.audio_stream_index << std::endl; - std::cout << "--> Audio Timebase: " << info.audio_timebase.ToDouble() << " (" << info.audio_timebase.num << "/" << info.audio_timebase.den << ")" << std::endl; - std::cout << "----------------------------" << std::endl; +void WriterBase::DisplayInfo(std::ostream* out) { + *out << std::fixed << std::setprecision(2) << std::boolalpha; + *out << "----------------------------" << std::endl; + *out << "----- File Information -----" << std::endl; + *out << "----------------------------" << std::endl; + *out << "--> Has Video: " << info.has_video << std::endl; + *out << "--> Has Audio: " << info.has_audio << std::endl; + *out << "--> Has Single Image: " << info.has_single_image << std::endl; + *out << "--> Duration: " << info.duration << " Seconds" << std::endl; + *out << "--> File Size: " << double(info.file_size) / 1024 / 1024 << " MB" << std::endl; + *out << "----------------------------" << std::endl; + *out << "----- Video Attributes -----" << std::endl; + *out << "----------------------------" << std::endl; + *out << "--> Width: " << info.width << std::endl; + *out << "--> Height: " << info.height << std::endl; + *out << "--> Pixel Format: " << info.pixel_format << std::endl; + *out << "--> Frames Per Second: " << info.fps.ToDouble() << " (" << info.fps.num << "/" << info.fps.den << ")" << std::endl; + *out << "--> Video Bit Rate: " << info.video_bit_rate/1000 << " kb/s" << std::endl; + *out << "--> Pixel Ratio: " << info.pixel_ratio.ToDouble() << " (" << info.pixel_ratio.num << "/" << info.pixel_ratio.den << ")" << std::endl; + *out << "--> Display Aspect Ratio: " << info.display_ratio.ToDouble() << " (" << info.display_ratio.num << "/" << info.display_ratio.den << ")" << std::endl; + *out << "--> Video Codec: " << info.vcodec << std::endl; + *out << "--> Video Length: " << info.video_length << " Frames" << std::endl; + *out << "--> Video Stream Index: " << info.video_stream_index << std::endl; + *out << "--> Video Timebase: " << info.video_timebase.ToDouble() << " (" << info.video_timebase.num << "/" << info.video_timebase.den << ")" << std::endl; + *out << "--> Interlaced: " << info.interlaced_frame << std::endl; + *out << "--> Interlaced: Top Field First: " << info.top_field_first << std::endl; + *out << "----------------------------" << std::endl; + *out << "----- Audio Attributes -----" << std::endl; + *out << "----------------------------" << std::endl; + *out << "--> Audio Codec: " << info.acodec << std::endl; + *out << "--> Audio Bit Rate: " << info.audio_bit_rate/1000 << " kb/s" << std::endl; + *out << "--> Sample Rate: " << info.sample_rate << " Hz" << std::endl; + *out << "--> # of Channels: " << info.channels << std::endl; + *out << "--> Channel Layout: " << info.channel_layout << std::endl; + *out << "--> Audio Stream Index: " << info.audio_stream_index << std::endl; + *out << "--> Audio Timebase: " << info.audio_timebase.ToDouble() << " (" << info.audio_timebase.num << "/" << info.audio_timebase.den << ")" << std::endl; + *out << "----------------------------" << std::endl; } // Generate JSON string of this object diff --git a/src/WriterBase.h b/src/WriterBase.h index d18f329d..3939ca6e 100644 --- a/src/WriterBase.h +++ b/src/WriterBase.h @@ -32,7 +32,7 @@ #define OPENSHOT_WRITER_BASE_H #include -#include + #include "ChannelLayouts.h" #include "Fraction.h" #include "Frame.h" @@ -113,7 +113,7 @@ namespace openshot void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object /// Display file information in the standard output stream (stdout) - void DisplayInfo(); + void DisplayInfo(std::ostream* out=&std::cout); /// Open the writer (and start initializing streams) virtual void Open() = 0;