From f47de0be0d0d60971c0b80ce27d28635c63900f0 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 26 Jun 2019 16:48:14 -0700 Subject: [PATCH] folded decoder hierarchy back in --- app/CMakeLists.txt | 2 +- app/project/item/footage/CMakeLists.txt | 2 + app/project/item/footage/audiostream.cpp | 18 ++------- app/project/item/footage/audiostream.h | 12 ++---- app/project/item/footage/footage.cpp | 14 +++++++ app/project/item/footage/footage.h | 10 ++--- app/project/item/footage/stream.cpp | 46 ++++++++++++++++++++++ app/project/item/footage/stream.h | 50 ++++++++++++++++++++++++ app/project/item/footage/videostream.cpp | 40 ++----------------- app/project/item/footage/videostream.h | 20 ++-------- 10 files changed, 130 insertions(+), 84 deletions(-) create mode 100644 app/project/item/footage/stream.cpp create mode 100644 app/project/item/footage/stream.h diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index dbc42a041..7fc0b9e4f 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -23,7 +23,7 @@ set(OLIVE_SOURCES rational.cpp ) -#add_subdirectory(decoder) +add_subdirectory(decoder) add_subdirectory(panel) add_subdirectory(project) add_subdirectory(render) diff --git a/app/project/item/footage/CMakeLists.txt b/app/project/item/footage/CMakeLists.txt index a6972cbd0..5482cce07 100644 --- a/app/project/item/footage/CMakeLists.txt +++ b/app/project/item/footage/CMakeLists.txt @@ -21,6 +21,8 @@ set(OLIVE_SOURCES project/item/footage/audiostream.cpp project/item/footage/footage.h project/item/footage/footage.cpp + project/item/footage/stream.h + project/item/footage/stream.cpp project/item/footage/videostream.h project/item/footage/videostream.cpp PARENT_SCOPE diff --git a/app/project/item/footage/audiostream.cpp b/app/project/item/footage/audiostream.cpp index bbf96b0bf..a4ccb9b65 100644 --- a/app/project/item/footage/audiostream.cpp +++ b/app/project/item/footage/audiostream.cpp @@ -20,26 +20,14 @@ #include "audiostream.h" -AudioStream::AudioStream(Footage* footage, - const int& channels, - const int& layout, - const int& sample_rate) : - footage_(footage), - channels_(channels), - layout_(layout), - sample_rate_(sample_rate) +AudioStream::AudioStream() { } -Footage *AudioStream::footage() +Stream::Type AudioStream::type() { - return footage_; -} - -void AudioStream::set_footage(Footage *f) -{ - footage_ = f; + return kAudio; } const int &AudioStream::channels() diff --git a/app/project/item/footage/audiostream.h b/app/project/item/footage/audiostream.h index 8e0339007..7ca176d03 100644 --- a/app/project/item/footage/audiostream.h +++ b/app/project/item/footage/audiostream.h @@ -22,16 +22,14 @@ #define AUDIOSTREAM_H #include "rational.h" +#include "stream.h" -class Footage; - -class AudioStream +class AudioStream : public Stream { public: - AudioStream(Footage* footage, const int& channels, const int& layout, const int& sample_rate); + AudioStream(); - Footage* footage(); - void set_footage(Footage* f); + virtual Type type() override; const int& channels(); void set_channels(const int& channels); @@ -43,8 +41,6 @@ public: void set_sample_rate(const int& sample_rate); private: - Footage* footage_; - int channels_; int layout_; int sample_rate_; diff --git a/app/project/item/footage/footage.cpp b/app/project/item/footage/footage.cpp index a2d159488..492138b23 100644 --- a/app/project/item/footage/footage.cpp +++ b/app/project/item/footage/footage.cpp @@ -45,6 +45,20 @@ void Footage::set_timestamp(const QDateTime &t) timestamp_ = t; } +void Footage::add_stream(const Stream &s) +{ + // Add a copy of this stream to the list + streams_.append(s); + + // Set its footage parent to this + streams_.last().set_footage(this); +} + +const Stream *Footage::stream(int index) +{ + return &streams_.at(index); +} + Item::Type Footage::type() const { return kFootage; diff --git a/app/project/item/footage/footage.h b/app/project/item/footage/footage.h index 183871554..3dab2ba7f 100644 --- a/app/project/item/footage/footage.h +++ b/app/project/item/footage/footage.h @@ -40,11 +40,8 @@ public: const QDateTime& timestamp(); void set_timestamp(const QDateTime& t); - void add_audio_stream(const AudioStream& as); - void add_video_stream(const VideoStream& vs); - - const AudioStream* audio_stream(int index); - const VideoStream* video_stream(int index); + void add_stream(const Stream& s); + const Stream* stream(int index); virtual Type type() const override; @@ -53,8 +50,7 @@ private: QDateTime timestamp_; - QList video_streams_; - QList audio_streams_; + QList streams_; }; #endif // FOOTAGE_H diff --git a/app/project/item/footage/stream.cpp b/app/project/item/footage/stream.cpp new file mode 100644 index 000000000..58bbcd060 --- /dev/null +++ b/app/project/item/footage/stream.cpp @@ -0,0 +1,46 @@ +#include "stream.h" + +Stream::Stream() : + footage_(nullptr) +{ + +} + +Stream::~Stream() +{ +} + +Footage *Stream::footage() +{ + return footage_; +} + +void Stream::set_footage(Footage *f) +{ + footage_ = f; +} + +Stream::Type Stream::type() +{ + return kUnknown; +} + +const rational &Stream::timebase() +{ + return timebase_; +} + +void Stream::set_timebase(const rational &timebase) +{ + timebase_ = timebase; +} + +const int &Stream::index() +{ + return index_; +} + +void Stream::set_index(const int &index) +{ + index_ = index; +} diff --git a/app/project/item/footage/stream.h b/app/project/item/footage/stream.h new file mode 100644 index 000000000..efb9b563a --- /dev/null +++ b/app/project/item/footage/stream.h @@ -0,0 +1,50 @@ +#ifndef STREAM_H +#define STREAM_H + +#include "rational.h" + +class Footage; + +class Stream +{ +public: + enum Type { + kUnknown, + kVideo, + kAudio, + kData, + kSubtitle, + kAttachment + }; + + /** + * @brief Stream constructor + */ + Stream(); + + /** + * @brief Required virtual destructor, serves no purpose + */ + virtual ~Stream(); + + virtual Type type(); + + Footage* footage(); + void set_footage(Footage* f); + + const rational& timebase(); + void set_timebase(const rational& timebase); + + const int& index(); + void set_index(const int& index); + +private: + Footage* footage_; + + rational timebase_; + + int index_; + +}; + +#endif // STREAM_H diff --git a/app/project/item/footage/videostream.cpp b/app/project/item/footage/videostream.cpp index a4bcf3ee7..3633577a1 100644 --- a/app/project/item/footage/videostream.cpp +++ b/app/project/item/footage/videostream.cpp @@ -20,37 +20,13 @@ #include "videostream.h" -VideoStream::VideoStream(Footage *footage, - const int &index, - const int &width, - const int &height, - const rational &timebase) : - footage_(footage), - index_(index), - width_(width), - height_(height), - timebase_(timebase) +VideoStream::VideoStream() { } -Footage *VideoStream::footage() +Stream::Type VideoStream::type() { - return footage_; -} - -void VideoStream::set_footage(Footage *f) -{ - footage_ = f; -} - -const int &VideoStream::index() -{ - return index_; -} - -void VideoStream::set_index(const int &index) -{ - index_ = index; + return kVideo; } const int &VideoStream::width() @@ -72,13 +48,3 @@ void VideoStream::set_height(const int &height) { height_ = height; } - -const rational &VideoStream::timebase() -{ - return timebase_; -} - -void VideoStream::set_timebase(const rational &timebase) -{ - timebase_ = timebase; -} diff --git a/app/project/item/footage/videostream.h b/app/project/item/footage/videostream.h index e6d22f944..24d5c8f40 100644 --- a/app/project/item/footage/videostream.h +++ b/app/project/item/footage/videostream.h @@ -22,19 +22,14 @@ #define VIDEOSTREAM_H #include "rational.h" +#include "stream.h" -class Footage; - -class VideoStream +class VideoStream : public Stream { public: - VideoStream(Footage* footage, const int& index, const int& width, const int& height, const rational& timebase); + VideoStream(); - Footage* footage(); - void set_footage(Footage* f); - - const int& index(); - void set_index(const int& index); + virtual Type type() override; const int& width(); void set_width(const int& width); @@ -42,16 +37,9 @@ public: const int& height(); void set_height(const int& height); - const rational& timebase(); - void set_timebase(const rational& timebase); - private: - Footage* footage_; - - int index_; int width_; int height_; - rational timebase_; }; #endif // VIDEOSTREAM_H