diff --git a/app/decoder/decoder.cpp b/app/decoder/decoder.cpp index 2b278d334..ab86c2fa6 100644 --- a/app/decoder/decoder.cpp +++ b/app/decoder/decoder.cpp @@ -1,3 +1,23 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 Olive Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + #include "decoder.h" Decoder::Decoder() : diff --git a/app/decoder/decoder.h b/app/decoder/decoder.h index 5aac398be..36abee4e4 100644 --- a/app/decoder/decoder.h +++ b/app/decoder/decoder.h @@ -1,3 +1,23 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 Olive Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + #ifndef DECODER_H #define DECODER_H diff --git a/app/decoder/ffmpeg/ffmpegdecoder.cpp b/app/decoder/ffmpeg/ffmpegdecoder.cpp index 56d957fad..046e61ade 100644 --- a/app/decoder/ffmpeg/ffmpegdecoder.cpp +++ b/app/decoder/ffmpeg/ffmpegdecoder.cpp @@ -1,3 +1,23 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 Olive Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + #include "ffmpegdecoder.h" extern "C" { diff --git a/app/decoder/ffmpeg/ffmpegdecoder.h b/app/decoder/ffmpeg/ffmpegdecoder.h index f0887041c..bc750dce8 100644 --- a/app/decoder/ffmpeg/ffmpegdecoder.h +++ b/app/decoder/ffmpeg/ffmpegdecoder.h @@ -1,3 +1,23 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 Olive Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + #ifndef FFMPEGDECODER_H #define FFMPEGDECODER_H diff --git a/app/decoder/frame.cpp b/app/decoder/frame.cpp index a1e9ae757..65db2dcb3 100644 --- a/app/decoder/frame.cpp +++ b/app/decoder/frame.cpp @@ -1,3 +1,23 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 Olive Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + #include "frame.h" #include diff --git a/app/decoder/frame.h b/app/decoder/frame.h index 77cf65273..df2e896ba 100644 --- a/app/decoder/frame.h +++ b/app/decoder/frame.h @@ -1,3 +1,23 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 Olive Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + #ifndef FRAME_H #define FRAME_H diff --git a/app/decoder/probeserver.cpp b/app/decoder/probeserver.cpp index 9891a36d7..02960f637 100644 --- a/app/decoder/probeserver.cpp +++ b/app/decoder/probeserver.cpp @@ -1,7 +1,28 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 Olive Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + #include "probeserver.h" #include #include +#include #include "decoder/ffmpeg/ffmpegdecoder.h" @@ -13,11 +34,31 @@ bool olive::ProbeMedia(Footage *f) return false; } + // Check file exists + if (!QFileInfo::exists(f->filename())) { + qWarning() << QCoreApplication::translate("ProbeMedia", "Tried to probe file that doesn't exist"); + return false; + } + + // Reset Footage state for probing + f->Clear(); + + // Create decoder instance FFmpegDecoder ff_dec; - // Pass footage through FFmpeg's probe function - if (ff_dec.Probe(f)) { - return true; + // Create list to iterate through + QList decoder_list; + decoder_list.append(&ff_dec); + + // Pass Footage through each Decoder's probe function + for (int i=0;iProbe(f)) { + + // TODO Some way of "attaching" the Footage to the Decoder without having to iterate through Decoders like this + + f->set_ready(true); + return true; + } } return false; diff --git a/app/decoder/probeserver.h b/app/decoder/probeserver.h index cc19e44dd..5a899d344 100644 --- a/app/decoder/probeserver.h +++ b/app/decoder/probeserver.h @@ -1,3 +1,23 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 Olive Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + #ifndef PROBESERVER_H #define PROBESERVER_H @@ -5,6 +25,25 @@ namespace olive { +/** + * @brief Try to probe a Footage file by passing it through all available Decoders + * + * This is a helper function designed to abstract the process of communicating with several Decoders from the rest of + * the application. This function will take a Footage file and manually pass it through the available Decoders' Probe() + * functions until one indicates that it can decode this file. That Decoder will then dump information about the file + * into the Footage object for use throughout the program. + * + * Probing may be a lengthy process and it's recommended to run this in a separate thread. + * + * @param f + * + * A Footage object with a valid filename. If the Footage does not have a valid filename (e.g. is empty or file doesn't + * exist), this function will return FALSE. + * + * @return + * + * TRUE if a Decoder was successfully able to parse and probe this file. FALSE if not. + */ bool ProbeMedia(Footage* f); } diff --git a/app/project/item/footage/footage.cpp b/app/project/item/footage/footage.cpp index 8ee418939..04cc8ca89 100644 --- a/app/project/item/footage/footage.cpp +++ b/app/project/item/footage/footage.cpp @@ -30,13 +30,23 @@ Footage::~Footage() ClearStreams(); } +bool Footage::ready() +{ + return ready_; +} + +void Footage::set_ready(const bool &ready) +{ + ready_ = ready; +} + void Footage::Clear() { - // Clear filename string - filename_.clear(); - // Clear all streams ClearStreams(); + + // Reset ready state + set_ready(false); } const QString &Footage::filename() @@ -73,6 +83,11 @@ const Stream *Footage::stream(int index) return streams_.at(index); } +int Footage::stream_count() +{ + return streams_.size(); +} + Item::Type Footage::type() const { return kFootage; @@ -80,6 +95,10 @@ Item::Type Footage::type() const void Footage::ClearStreams() { + if (streams_.empty()) { + return; + } + // Delete all streams for (int i=0;ifile_index). Must be < stream_count(). + * + * @return + * + * The stream at the index provided + */ const Stream* stream(int index); + /** + * @brief Retrieve total number of streams in this Footage file + */ + int stream_count(); + + /** + * @brief Item::Type() override + * + * @return kFootage + */ virtual Type type() const override; private: + /** + * @brief Internal function to delete all Stream children and empty the array + */ void ClearStreams(); + /** + * @brief Internal filename string + */ QString filename_; + /** + * @brief Internal timestamp object + */ QDateTime timestamp_; + /** + * @brief Internal streams array + */ QList streams_; + + /** + * @brief Internal ready setting + */ + bool ready_; }; #endif // FOOTAGE_H diff --git a/app/project/item/footage/stream.cpp b/app/project/item/footage/stream.cpp index aa0b31ee7..f90b0db6f 100644 --- a/app/project/item/footage/stream.cpp +++ b/app/project/item/footage/stream.cpp @@ -1,3 +1,23 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 Olive Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + #include "stream.h" Stream::Stream() : diff --git a/app/project/item/footage/stream.h b/app/project/item/footage/stream.h index 3a76e04a5..555e336a8 100644 --- a/app/project/item/footage/stream.h +++ b/app/project/item/footage/stream.h @@ -1,3 +1,23 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 Olive Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + #ifndef STREAM_H #define STREAM_H