Skip to content

Commit

Permalink
Merge pull request #4 from onvif/1.3
Browse files Browse the repository at this point in the history
1.3
  • Loading branch information
HansBusch authored Nov 19, 2021
2 parents 91fce3e + 0a24e35 commit fa76afe
Show file tree
Hide file tree
Showing 44 changed files with 465 additions and 1,347 deletions.
2 changes: 1 addition & 1 deletion player/proj/ONVIFPlayer-MinGW/ONVIFPlayer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ HEADERS += \
../../src/common/defines.h \
../../src/common/enums.h \
../../src/common/ffmpeg.h \
../../src/common/fragmentInfo.h \
../../src/common/segmentInfo.h \
../../src/common/ONVIFSignInfo.h \
../../src/common/queue.h \
../../src/common/signingInformation.h \
Expand Down
174 changes: 62 additions & 112 deletions player/proj/ONVIFPlayer-VS2019/ONVIFPlayer.vcxproj

Large diffs are not rendered by default.

33 changes: 9 additions & 24 deletions player/proj/ONVIFPlayer-VS2019/ONVIFPlayer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,7 @@
<ClCompile Include="..\..\src\player\controller.cpp">
<Filter>player</Filter>
</ClCompile>
<ClCompile Include="..\..\src\player\mainContext.cpp">
<Filter>player</Filter>
</ClCompile>
<ClCompile Include="..\..\src\player\nonqueuedAudioDecoder.cpp">
<Filter>player</Filter>
</ClCompile>
<ClCompile Include="..\..\src\player\nonqueuedVideoDecoder.cpp">
<ClCompile Include="..\..\src\player\streamReader.cpp">
<Filter>player</Filter>
</ClCompile>
<ClCompile Include="..\..\src\player\portAudioPlayback.cpp">
Expand Down Expand Up @@ -225,9 +219,6 @@
<ClCompile Include="..\..\src\common\fragmentInfo.cpp">
<Filter>verifier</Filter>
</ClCompile>
<ClCompile Include="..\..\src\playerUI\fragmentListWidget.cpp">
<Filter>verifier</Filter>
</ClCompile>
<ClCompile Include="..\..\src\parserUI\parserWidget.cpp">
<Filter>verifier</Filter>
</ClCompile>
Expand Down Expand Up @@ -279,6 +270,9 @@
<ClCompile Include="..\..\src\playerUI\movingOutArea.cpp">
<Filter>playerUI</Filter>
</ClCompile>
<ClCompile Include="..\..\src\playerUI\fragmentListWidget.cpp">
<Filter>playerUI</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\parser\signatureConfigurationBox.hpp">
Expand Down Expand Up @@ -398,16 +392,7 @@
<CustomBuild Include="..\..\src\player\decoder.h">
<Filter>player</Filter>
</CustomBuild>
<CustomBuild Include="..\..\src\player\mainContext.h">
<Filter>player</Filter>
</CustomBuild>
<CustomBuild Include="..\..\src\player\nonqueuedAudioDecoder.h">
<Filter>player</Filter>
</CustomBuild>
<CustomBuild Include="..\..\src\player\nonqueuedDecoder.h">
<Filter>player</Filter>
</CustomBuild>
<CustomBuild Include="..\..\src\player\nonqueuedVideoDecoder.h">
<CustomBuild Include="..\..\src\player\streamReader.h">
<Filter>player</Filter>
</CustomBuild>
<CustomBuild Include="..\..\src\player\portAudioPlayback.h">
Expand Down Expand Up @@ -461,10 +446,7 @@
<CustomBuild Include="..\..\src\parser\fragmentExtractor.h">
<Filter>verifier</Filter>
</CustomBuild>
<CustomBuild Include="..\..\src\common\fragmentInfo.h">
<Filter>verifier</Filter>
</CustomBuild>
<CustomBuild Include="..\..\src\playerUI\fragmentListWidget.h">
<CustomBuild Include="..\..\src\common\segmentInfo.h">
<Filter>verifier</Filter>
</CustomBuild>
<CustomBuild Include="..\..\src\parserUI\parserWidget.h">
Expand Down Expand Up @@ -614,6 +596,9 @@
<CustomBuild Include="..\..\src\parser\helpers\uint24.hpp">
<Filter>verifier</Filter>
</CustomBuild>
<CustomBuild Include="..\..\src\playerUI\fragmentListWidget.h">
<Filter>playerUI</Filter>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<Filter Include="boxes">
Expand Down
2 changes: 1 addition & 1 deletion player/proj/tests/tests.pro
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ HEADERS += \
../../src/common/defines.h \
../../src/common/enums.h \
../../src/common/ffmpeg.h \
../../src/common/fragmentInfo.h \
../../src/common/segmentInfo.h \
../../src/common/ONVIFSignInfo.h \
../../src/common/queue.h \
../../src/common/signingInformation.h \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
************************************************************************************/

#include "fragmentInfo.h"
#include "segmentInfo.h"

FragmentInfo::FragmentInfo(QString file_name /*= QString()*/)
: m_fragment_number(0)
SegmentInfo::SegmentInfo(QString file_name /*= QString()*/)
: m_segment_number(0)
, m_file_name(file_name)
, m_duration(0)
, m_samples(0)
Expand All @@ -39,45 +39,45 @@ FragmentInfo::FragmentInfo(QString file_name /*= QString()*/)
{
}

FragmentInfo::~FragmentInfo()
SegmentInfo::~SegmentInfo()
{
}

void FragmentInfo::readMovieHeaderBox(MovieHeaderBox *box)
void SegmentInfo::readMovieHeaderBox(MovieHeaderBox *box)
{
m_timescale = box->getTimeScale();
int64_t delta = box->getDuration() * 1000 / m_timescale;
m_fragment_start = box->getCreationTime().addMSecs(-delta);
m_segment_start = box->getCreationTime().addMSecs(-delta);
}

void FragmentInfo::read(MediaHeaderBox*box)
void SegmentInfo::read(MediaHeaderBox*box)
{
// assume that first track is Video
if (m_videoTimescale == 0) m_videoTimescale = box->getTimeScale();
}

void FragmentInfo::readAfIdentificationBox(AFIdentificationBox *box)
void SegmentInfo::readAfIdentificationBox(AFIdentificationBox *box)
{
m_duration = box->getDuration() / m_videoTimescale;
m_predecessor_uuid = box->getPredecessorUUID().toString();
m_fragment_uuid = box->getFragmentUUID().toString();
m_segment_uuid = box->getFragmentUUID().toString();
m_successor_uuid = box->getSuccessorUUID().toString();
m_fragment_start = box->getStartTime();
m_segment_start = box->getStartTime();
}

void FragmentInfo::readTrackHeaderBox(TrackHeaderBox *box)
void SegmentInfo::readTrackHeaderBox(TrackHeaderBox *box)
{
m_currentParserTrackId = box->getTrackID();
if (m_valid_stream_ids.count() == 0) m_firstTrackId = m_currentParserTrackId;
m_valid_stream_ids << m_currentParserTrackId;
}

void FragmentInfo::readCorrectionStartTimeBox(CorrectStartTimeBox * box)
void SegmentInfo::readCorrectionStartTimeBox(CorrectStartTimeBox * box)
{
m_fragment_start = box->getStartTime();
m_segment_start = box->getStartTime();
}

void FragmentInfo::read(TimeToSampleBox* box)
void SegmentInfo::read(TimeToSampleBox* box)
{
if (m_currentParserTrackId != m_firstTrackId) return; // only accumulate first track
QListIterator<TimeToSampleEntry> it(box->getTable());
Expand All @@ -88,7 +88,7 @@ void FragmentInfo::read(TimeToSampleBox* box)
}
}

void FragmentInfo::read(TrackRunBox* box)
void SegmentInfo::read(TrackRunBox* box)
{
if (m_currentParserTrackId != m_firstTrackId) return; // only accumulate first track
QListIterator<TrackRunEntry> it(box->getTable());
Expand All @@ -101,15 +101,15 @@ void FragmentInfo::read(TrackRunBox* box)
}
}

double FragmentInfo::getFpsFromSamples() const
double SegmentInfo::getFpsFromSamples() const
{
if (m_samples == 0 || m_videoTimescale == 0) return 0.0;
double duration = (double)(m_accumulatedSampleDuration + m_lastSampleCompositionOffset - m_firstSampleCompositionOffset) / (double)m_videoTimescale;
return (double)m_samples / duration;
}


void FragmentInfo::read(CompositionOffsetBox* box)
void SegmentInfo::read(CompositionOffsetBox* box)
{
if (m_currentParserTrackId != m_firstTrackId) return; // only accumulate first track
CompositionOffsetEntry last = box->getTable().last();
Expand All @@ -118,34 +118,34 @@ void FragmentInfo::read(CompositionOffsetBox* box)
m_firstSampleCompositionOffset = std::get<1>(first);
}

bool FragmentInfo::isSurveillanceFragment() const
bool SegmentInfo::isSurveillanceFragment() const
{
return !(m_predecessor_uuid.isEmpty() || m_fragment_uuid.isEmpty() || m_successor_uuid.isEmpty());
return !(m_predecessor_uuid.isEmpty() || m_segment_uuid.isEmpty() || m_successor_uuid.isEmpty());
}

QDateTime FragmentInfo::getStartTime() const
QDateTime SegmentInfo::getStartTime() const
{
return m_fragment_start.addMSecs(m_firstSampleCompositionOffset * 1000 / m_videoTimescale);
return m_segment_start.addMSecs(m_firstSampleCompositionOffset * 1000 / m_videoTimescale);
}

QDateTime FragmentInfo::getFinishTime() const
QDateTime SegmentInfo::getFinishTime() const
{
return m_fragment_start.addMSecs(getDuration());
return m_segment_start.addMSecs(getDuration());
}

QString FragmentInfo::getFileName() const
QString SegmentInfo::getFileName() const
{
return m_file_name;
}

QString FragmentInfo::getName() const
QString SegmentInfo::getName() const
{
if(m_name.isEmpty())
createName();
return m_name;
}

uint64_t FragmentInfo::getDuration() const
uint64_t SegmentInfo::getDuration() const
{
// Will return 0 for non-surveillance files
// In this case duration will be determined with the use of FFMpeg methods
Expand All @@ -154,45 +154,45 @@ uint64_t FragmentInfo::getDuration() const
return 0;
}

void FragmentInfo::setDuration(uint64_t duration)
void SegmentInfo::setDuration(uint64_t duration)
{
if(!duration)
return;

m_duration = duration * m_timescale / 1000;
}

bool FragmentInfo::isBeginning() const
bool SegmentInfo::isBeginning() const
{
return (m_predecessor_uuid == m_fragment_uuid);
return (m_predecessor_uuid == m_segment_uuid);
}

bool FragmentInfo::isEnd() const
bool SegmentInfo::isEnd() const
{
return (m_successor_uuid == m_fragment_uuid);
return (m_successor_uuid == m_segment_uuid);
}

bool FragmentInfo::isSuccessor(const FragmentInfo & right) const
bool SegmentInfo::isSuccessor(const SegmentInfo & right) const
{
return (m_successor_uuid == right.m_fragment_uuid);
return (m_successor_uuid == right.m_segment_uuid);
}

void FragmentInfo::setFragmentNumber(uint32_t fragment_number)
void SegmentInfo::setFragmentNumber(uint32_t fragment_number)
{
m_fragment_number = fragment_number;
m_segment_number = fragment_number;
}

uint32_t FragmentInfo::getFragmentNumber() const
uint32_t SegmentInfo::getFragmentNumber() const
{
return m_fragment_number;
return m_segment_number;
}

QSet<int> FragmentInfo::getValidMediaStreamIds() const
QSet<int> SegmentInfo::getValidMediaStreamIds() const
{
return m_valid_stream_ids;
}

void FragmentInfo::createName() const
void SegmentInfo::createName() const
{
if(isSurveillanceFragment())
m_name = QString("%1\n%2\n%3").arg(QFileInfo(m_file_name).fileName()).arg(getStartTime().toString(DATETIME_CONVERSION_FORMAT)).arg(getFinishTime().toString(DATETIME_CONVERSION_FORMAT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@
#include "helpers/optional.hpp"
#include "templateTableBoxes.hpp"

//! Class that descibes one frament in video.
class FragmentInfo
/**
* Class that descibes one MP4 file.
* Segments are either ISO 23000-10 fragments or CMAF segments.
* CMAF support tbd.
*/
class SegmentInfo
{
public:
FragmentInfo(QString file_name = QString());
SegmentInfo(QString file_name = QString());

~FragmentInfo();
~SegmentInfo();

//! Try to extract duration from movie header box
void readMovieHeaderBox(MovieHeaderBox * box);
Expand Down Expand Up @@ -98,7 +102,7 @@ class FragmentInfo
bool isEnd() const;

//! Checks, if a fragment is a successor of a fragment. Valid only for Surveillance files.
bool isSuccessor(const FragmentInfo & right) const;
bool isSuccessor(const SegmentInfo & right) const;

//! Sets the fragment number
void setFragmentNumber(uint32_t fragment_number);
Expand All @@ -116,18 +120,18 @@ class FragmentInfo
void createName() const;

private:
//! Fragment number
uint32_t m_fragment_number;
//! Segment number
uint32_t m_segment_number;
//! File name.
QString m_file_name;
//! Predecessor fragment UUID
QString m_predecessor_uuid;
//! Current fragment UUID
QString m_fragment_uuid;
QString m_segment_uuid;
//! Successor fragment UUID
QString m_successor_uuid;
//! Fragment start timestamp in UTC.
QDateTime m_fragment_start;
//! Segment start timestamp in UTC.
QDateTime m_segment_start;
//! Set of known media stream ids.
QSet<int> m_valid_stream_ids;
//! Timescale of the fragment.
Expand All @@ -151,6 +155,6 @@ class FragmentInfo
uint32_t m_currentParserTrackId; ///< track id currently beingparsed
};

typedef QList<FragmentInfo> FragmentsList;
typedef QList<SegmentInfo> SegmentList;

#endif // FRAGMENTINFO_H
12 changes: 6 additions & 6 deletions player/src/parser/mediaParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ MediaParser::MediaParser(QObject *parent) :
QObject::connect(this, &MediaParser::contentsCleared, &m_validator_oxf, &ValidatorOXF::onContentsCleared);
QObject::connect(&factory, &BoxFactory::boxCreated, &m_validator_oxf, &ValidatorOXF::onBoxCreated);

QObject::connect(this, &MediaParser::fileOpened, &m_fragment_extractor, &FragmentExtractor::onFileOpened);
QObject::connect(this, &MediaParser::fileClosed, &m_fragment_extractor, &FragmentExtractor::onFileClosed);
QObject::connect(this, &MediaParser::contentsCleared, &m_fragment_extractor, &FragmentExtractor::onContentsCleared);
QObject::connect(&factory, &BoxFactory::boxCreated, &m_fragment_extractor, &FragmentExtractor::onBoxCreated);
QObject::connect(this, &MediaParser::fileOpened, &m_segment_extractor, &SegmentExtractor::onFileOpened);
QObject::connect(this, &MediaParser::fileClosed, &m_segment_extractor, &SegmentExtractor::onFileClosed);
QObject::connect(this, &MediaParser::contentsCleared, &m_segment_extractor, &SegmentExtractor::onContentsCleared);
QObject::connect(&factory, &BoxFactory::boxCreated, &m_segment_extractor, &SegmentExtractor::onBoxCreated);

QObject::connect(this, &MediaParser::fileOpened, &m_signature_extractor, &SignatureExtractor::onFileAdded);
QObject::connect(this, &MediaParser::fileClosed, &m_signature_extractor, &SignatureExtractor::onFileClosed);
Expand Down Expand Up @@ -118,9 +118,9 @@ bool MediaParser::isValidISOFileset()
return m_validator_iso.isValidFileset();
}

FragmentsList MediaParser::getFragmentsList()
SegmentList MediaParser::getSegments()
{
return m_fragment_extractor.getFragmentsList();
return m_segment_extractor.getSegments();
}

SigningInformationMap MediaParser::getSignaturesMap() const
Expand Down
Loading

0 comments on commit fa76afe

Please sign in to comment.