-
Notifications
You must be signed in to change notification settings - Fork 16
New BS.2076-3 features (tagList, profileList). #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
ee10f5c
814f02e
582c17a
bddab94
353aa56
5332c4d
878b852
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| #include <iostream> | ||
| #include <fstream> | ||
| #include <sstream> | ||
| #include "adm/common_definitions.hpp" | ||
| #include "adm/parse.hpp" | ||
| #include "adm/write.hpp" | ||
| #include "adm/segmenter.hpp" | ||
| #include "adm/utilities/id_assignment.hpp" | ||
| #include "adm/utilities/object_creation.hpp" | ||
|
|
||
| using namespace adm; | ||
|
|
||
| std::string genSadmFilename(std::string pref, uint32_t ind); | ||
| TrackUidList buildTrackList(std::shared_ptr<Document> document); | ||
|
|
||
| int main(int argc, char const *argv[]) { | ||
| std::string fout_pre = "/tmp/segmenter_output"; | ||
| int size = 1000; | ||
| int max_fr = 10; | ||
|
|
||
| auto document = parseXml("../tests/test_data/segmenter_input.xml"); | ||
|
|
||
| // Get file length | ||
| std::chrono::nanoseconds filelength((uint64_t)(max_fr * size) * 1000000L); | ||
| for (auto programme : document->getElements<AudioProgramme>()) { | ||
| if (programme->has<Start>() && programme->has<End>()) { | ||
| filelength = programme->get<End>().get().asNanoseconds() - programme->get<Start>().get().asNanoseconds(); | ||
| break; | ||
| } else if (programme->has<End>()) { | ||
| filelength = programme->get<End>().get().asNanoseconds(); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| auto trackUidList = buildTrackList(document); | ||
|
|
||
| Segmenter segmenter(document, Time(filelength)); | ||
| SegmentStart segment_start(std::chrono::milliseconds(0)); | ||
| SegmentDuration segment_size(std::chrono::milliseconds{size}); | ||
| int fr = 0; | ||
| while (segment_start < filelength && fr < max_fr) { | ||
| segmenter.buildFrame(segment_start, segment_size, fr); | ||
| auto transportTrackFormat = segmenter.generateTransportTrackFormat(trackUidList, | ||
| segment_start, segment_size); | ||
| auto frame = segmenter.getFrame(); | ||
| auto frameHeader = segmenter.getFrameHeader(); | ||
|
|
||
| std::stringstream xmlStream; | ||
| writeXml(xmlStream, frame, *frameHeader); | ||
|
|
||
| std::string fname = genSadmFilename(fout_pre, fr); | ||
| std::ofstream sfile(fname); | ||
|
|
||
| sfile << xmlStream.str(); | ||
|
|
||
| // Get ready for next frame | ||
| xmlStream.str(""); | ||
| segment_start = SegmentStart(segment_start.get() + segment_size.get()); | ||
| fr++; | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
|
|
||
| std::string genSadmFilename(std::string pref, uint32_t ind) { | ||
| char c[256]; | ||
| sprintf(c, "%s_%04d.xml", pref.c_str(), ind); | ||
| std::string s(c); | ||
| return s; | ||
| } | ||
|
|
||
| TrackUidList buildTrackList(std::shared_ptr<Document> document) { | ||
| TrackUidList trackUidList; | ||
|
|
||
| auto atus = document->getElements<AudioTrackUid>(); | ||
| uint16_t track_idx = 1; | ||
| for (auto atu : atus) { | ||
| TrackUid track_uid; | ||
| track_uid.uid = formatId(atu->get<AudioTrackUidId>()); | ||
| track_uid.trackIndex = track_idx; | ||
| trackUidList.trackUid.push_back(track_uid); | ||
| track_idx++; | ||
| } | ||
| return trackUidList; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,6 +80,10 @@ namespace adm { | |
| ADM_EXPORT bool add(std::shared_ptr<AudioTrackFormat> trackFormat); | ||
| /// @brief Add an AudioTrackUid | ||
| ADM_EXPORT bool add(std::shared_ptr<AudioTrackUid> trackUid); | ||
| /// @brief Add a profileList | ||
| ADM_EXPORT bool add(std::shared_ptr<ProfileList> profileList); | ||
| /// @brief Add a tagList | ||
| ADM_EXPORT bool add(std::shared_ptr<TagList> tagList); | ||
| ///@} | ||
|
|
||
| /** @name Remove ADM elements | ||
|
|
@@ -104,6 +108,10 @@ namespace adm { | |
| ADM_EXPORT bool remove(std::shared_ptr<AudioTrackFormat> trackFormat); | ||
| /// @brief Remove an AudioTrackUid | ||
| ADM_EXPORT bool remove(std::shared_ptr<AudioTrackUid> trackUid); | ||
| /// @brief Remove a profileList | ||
| ADM_EXPORT bool remove(std::shared_ptr<ProfileList> profileList); | ||
| /// @brief Remove a tagList | ||
| ADM_EXPORT bool remove(std::shared_ptr<TagList> tagList); | ||
| ///@} | ||
|
|
||
| /** | ||
|
|
@@ -126,6 +134,12 @@ namespace adm { | |
| template <typename Element> | ||
| ElementRange<Element> getElements(); | ||
|
|
||
| template <typename Element> | ||
| std::shared_ptr<const Element> getElement() const; | ||
|
|
||
| template <typename Element> | ||
| std::shared_ptr<Element> getElement(); | ||
|
|
||
|
Comment on lines
+137
to
+142
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless I'm missing something specific about |
||
| /** @name Lookup ADM elements by its Id | ||
| * | ||
| * Lookup the first ADM element with the given Id. | ||
|
|
@@ -257,6 +271,10 @@ namespace adm { | |
| detail::ParameterTraits<AudioTrackFormat>::tag) const; | ||
| ADM_EXPORT ElementRange<const AudioTrackUid> getElements( | ||
| detail::ParameterTraits<AudioTrackUid>::tag) const; | ||
| ADM_EXPORT std::shared_ptr<const ProfileList> getElement( | ||
| detail::ParameterTraits<ProfileList>::tag) const; | ||
| ADM_EXPORT std::shared_ptr<const TagList> getElement( | ||
| detail::ParameterTraits<TagList>::tag) const; | ||
| ADM_EXPORT ElementRange<AudioProgramme> getElements( | ||
| detail::ParameterTraits<AudioProgramme>::tag); | ||
| ADM_EXPORT ElementRange<AudioContent> getElements( | ||
|
|
@@ -273,6 +291,10 @@ namespace adm { | |
| detail::ParameterTraits<AudioTrackFormat>::tag); | ||
| ADM_EXPORT ElementRange<AudioTrackUid> getElements( | ||
| detail::ParameterTraits<AudioTrackUid>::tag); | ||
| ADM_EXPORT std::shared_ptr<ProfileList> getElement( | ||
| detail::ParameterTraits<ProfileList>::tag); | ||
| ADM_EXPORT std::shared_ptr<TagList> getElement( | ||
| detail::ParameterTraits<TagList>::tag); | ||
|
|
||
| /// check the parent of an element | ||
| /// | ||
|
|
@@ -300,6 +322,8 @@ namespace adm { | |
| std::vector<std::shared_ptr<AudioStreamFormat>> audioStreamFormats_; | ||
| std::vector<std::shared_ptr<AudioTrackFormat>> audioTrackFormats_; | ||
| std::vector<std::shared_ptr<AudioTrackUid>> audioTrackUids_; | ||
| std::shared_ptr<ProfileList> profileList_; | ||
| std::shared_ptr<TagList> tagList_; | ||
|
Comment on lines
+325
to
+326
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These probably want to be |
||
| detail::IdAssigner idAssigner_; | ||
| }; | ||
|
|
||
|
|
@@ -317,4 +341,16 @@ namespace adm { | |
| return getElements(Tag()); | ||
| } | ||
|
|
||
| template <typename Element> | ||
| std::shared_ptr<const Element> Document::getElement() const { | ||
| typedef typename detail::ParameterTraits<Element>::tag Tag; | ||
| return getElement(Tag()); | ||
| } | ||
|
|
||
| template <typename Element> | ||
| std::shared_ptr<Element> Document::getElement() { | ||
| typedef typename detail::ParameterTraits<Element>::tag Tag; | ||
| return getElement(Tag()); | ||
| } | ||
|
|
||
| } // namespace adm | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these should be
set()? (you can't have >1 profileList or tagList in a document)