decoder source documentation and license boilerplate

This commit is contained in:
itsmattkc
2019-06-27 09:37:38 -07:00
parent 955f80c622
commit ff17c5d167
12 changed files with 380 additions and 7 deletions
+20
View File
@@ -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 <http://www.gnu.org/licenses/>.
***/
#include "decoder.h"
Decoder::Decoder() :
+20
View File
@@ -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 <http://www.gnu.org/licenses/>.
***/
#ifndef DECODER_H
#define DECODER_H
+20
View File
@@ -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 <http://www.gnu.org/licenses/>.
***/
#include "ffmpegdecoder.h"
extern "C" {
+20
View File
@@ -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 <http://www.gnu.org/licenses/>.
***/
#ifndef FFMPEGDECODER_H
#define FFMPEGDECODER_H
+20
View File
@@ -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 <http://www.gnu.org/licenses/>.
***/
#include "frame.h"
#include <QtGlobal>
+20
View File
@@ -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 <http://www.gnu.org/licenses/>.
***/
#ifndef FRAME_H
#define FRAME_H
+44 -3
View File
@@ -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 <http://www.gnu.org/licenses/>.
***/
#include "probeserver.h"
#include <QApplication>
#include <QDebug>
#include <QFileInfo>
#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*> decoder_list;
decoder_list.append(&ff_dec);
// Pass Footage through each Decoder's probe function
for (int i=0;i<decoder_list.size();i++) {
if (decoder_list.at(i)->Probe(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;
+39
View File
@@ -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 <http://www.gnu.org/licenses/>.
***/
#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);
}
+22 -3
View File
@@ -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;i<streams_.size();i++) {
delete streams_.at(i);
+115 -1
View File
@@ -1,4 +1,3 @@
/***
Olive - Non-Linear Video Editor
@@ -32,8 +31,16 @@
class Footage : public Item
{
public:
/**
* @brief Footage Constructor
*/
Footage();
/**
* @brief Footage Destructor
*
* Makes sure Stream objects are cleared properly
*/
virtual ~Footage() override;
/**
@@ -56,27 +63,134 @@ public:
*/
Footage& operator=(Footage&& other) = delete;
/**
* @brief Check the ready state of this Footage object
*
* @return
*
* If the Footage has been successfully probed, this will return TRUE.
*/
bool ready();
/**
* @brief Set ready state
*
* This should only be set by olive::ProbeMedia. Sets the ready state (see ready()).
*/
void set_ready(const bool& ready);
/**
* @brief Reset Footage state ready for running through Probe() again
*
* If a Footage object needs to be re-probed (e.g. source file changes or Footage is linked to a new file), its
* state needs to be reset so the Decoder::Probe() function can accurately mirror the source file. Clear() will
* reset the Footage object's state to being freshly created (keeping the filename).
*
* In most cases, you'll be using olive::ProbeMedia() for re-probing which already runs Clear(), so you won't need
* to worry about this.
*/
void Clear();
/**
* @brief Return the current filename of this Footage object
*/
const QString& filename();
/**
* @brief Set the filename
*
* NOTE: This does not automtaically clear the old streams and re-probe for new ones. If the file link has been
* changed, this will need to be done manually.
*
* @param s
*
* New filename
*/
void set_filename(const QString& s);
/**
* @brief Retrieve the last modified time/date
*
* The file's last modified timestamp is stored for potential organization in the ProjectExplorer. It can be
* retrieved here.
*/
const QDateTime& timestamp();
/**
* @brief Set the last modified time/date
*
* This should probably only be done on import or replace.
*
* @param t
*
* New last modified time/date
*/
void set_timestamp(const QDateTime& t);
/**
* @brief Add a stream metadata object to this footage
*
* Usually done during a Decoder::Probe() function for retrieving metadata about the video/audio/other streams
* inside a container. Streams can have non-video/audio types so that they can be equivalent to the file's actual
* stream list, though the only streams officially supported are video and audio streams.
*
* @param s
*
* A pointer to a stream object. The Footage takes ownership of this object and will free it when it's deleted.
*/
void add_stream(Stream* s);
/**
* @brief Retrieve a stream at the given index.
*
* @param index
*
* The index will be equivalent to the stream's index in the file (or in FFmpeg
* terms AVStream->file_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<Stream*> streams_;
/**
* @brief Internal ready setting
*/
bool ready_;
};
#endif // FOOTAGE_H
+20
View File
@@ -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 <http://www.gnu.org/licenses/>.
***/
#include "stream.h"
Stream::Stream() :
+20
View File
@@ -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 <http://www.gnu.org/licenses/>.
***/
#ifndef STREAM_H
#define STREAM_H