Skip to content
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

Fix tsdelay and troff #367

Merged
merged 12 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Development/cmake/NmosCppTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ set(NMOS_CPP_TEST_NMOS_TEST_SOURCES
nmos/test/jwt_validation_test.cpp
nmos/test/paging_utils_test.cpp
nmos/test/query_api_test.cpp
nmos/test/sdp_test_utils.cpp
nmos/test/sdp_utils_test.cpp
nmos/test/system_resources_test.cpp
nmos/test/video_jxsv_test.cpp
)
set(NMOS_CPP_TEST_NMOS_TEST_HEADERS
nmos/test/sdp_test_utils.h
)

set(NMOS_CPP_TEST_PPLX_TEST_SOURCES
Expand Down
12 changes: 6 additions & 6 deletions Development/nmos/sdp_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,11 +793,11 @@ namespace nmos
// additional parameters introduced by SMPTE specs since then...
if (!params.range.empty()) fmtp.push_back({ sdp::fields::range, params.range.name });
if (0 != params.par) fmtp.push_back({ sdp::fields::pixel_aspect_ratio, nmos::details::make_pixel_aspect_ratio(params.par) });
if (0 != params.troff) fmtp.push_back({ sdp::fields::TROFF, utility::ostringstreamed(params.troff) });
if (params.troff) fmtp.push_back({ sdp::fields::TROFF, utility::ostringstreamed(*params.troff) });
if (0 != params.cmax) fmtp.push_back({ sdp::fields::CMAX, utility::ostringstreamed(params.cmax) });
if (0 != params.maxudp) fmtp.push_back({ sdp::fields::max_udp_packet_size, utility::ostringstreamed(params.maxudp) });
if (!params.tsmode.empty()) fmtp.push_back({ sdp::fields::timestamp_mode, params.tsmode.name });
if (0 != params.tsdelay) fmtp.push_back({ sdp::fields::timestamp_delay, utility::ostringstreamed(params.tsdelay) });
if (params.tsdelay) fmtp.push_back({ sdp::fields::timestamp_delay, utility::ostringstreamed(*params.tsdelay) });

return{ session_name, sdp::media_types::video, rtpmap, fmtp, {}, {}, {}, {}, media_stream_ids, ts_refclk };
}
Expand All @@ -814,7 +814,7 @@ namespace nmos
sdp_parameters::fmtp_t fmtp = {};
if (!params.channel_order.empty()) fmtp.push_back({ sdp::fields::channel_order, params.channel_order });
if (!params.tsmode.empty()) fmtp.push_back({ sdp::fields::timestamp_mode, params.tsmode.name });
if (0 != params.tsdelay) fmtp.push_back({ sdp::fields::timestamp_delay, utility::ostringstreamed(params.tsdelay) });
if (params.tsdelay) fmtp.push_back({ sdp::fields::timestamp_delay, utility::ostringstreamed(*params.tsdelay) });

return{ session_name, sdp::media_types::audio, rtpmap, fmtp, {}, params.packet_time, {}, {}, media_stream_ids, ts_refclk };
}
Expand All @@ -836,9 +836,9 @@ namespace nmos
if (0 != params.exactframerate) fmtp.push_back({ sdp::fields::exactframerate, nmos::details::make_exactframerate(params.exactframerate) });
if (!params.tm.empty()) fmtp.push_back({ sdp::fields::TM, params.tm.name });
if (!params.ssn.empty()) fmtp.push_back({ sdp::fields::smpte_standard_number, params.ssn.name });
if (0 != params.troff) fmtp.push_back({ sdp::fields::TROFF, utility::ostringstreamed(params.troff) });
if (params.troff) fmtp.push_back({ sdp::fields::TROFF, utility::ostringstreamed(*params.troff) });
if (!params.tsmode.empty()) fmtp.push_back({ sdp::fields::timestamp_mode, params.tsmode.name });
if (0 != params.tsdelay) fmtp.push_back({ sdp::fields::timestamp_delay, utility::ostringstreamed(params.tsdelay) });
if (params.tsdelay) fmtp.push_back({ sdp::fields::timestamp_delay, utility::ostringstreamed(*params.tsdelay) });

return{ session_name, sdp::media_types::video, rtpmap, fmtp, {}, {}, {}, {}, media_stream_ids, ts_refclk };
}
Expand All @@ -854,7 +854,7 @@ namespace nmos
// See https://tools.ietf.org/html/rfc4566#section-6
sdp_parameters::fmtp_t fmtp = {};
if (!params.tp.empty()) fmtp.push_back({ sdp::fields::type_parameter, params.tp.name });
if (0 != params.troff) fmtp.push_back({ sdp::fields::TROFF, utility::ostringstreamed(params.troff) });
if (params.troff) fmtp.push_back({ sdp::fields::TROFF, utility::ostringstreamed(*params.troff) });

return{ session_name, sdp::media_types::video, rtpmap, fmtp, {}, {}, {}, {}, media_stream_ids, ts_refclk };
}
Expand Down
24 changes: 12 additions & 12 deletions Development/nmos/sdp_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,13 @@ namespace nmos

// additional fmtp parameters from ST 2110-21:2022
sdp::type_parameter tp;
uint32_t troff; // if omitted (zero), assume default
bst::optional<uint32_t> troff; // if omitted, assume default
garethsb marked this conversation as resolved.
Show resolved Hide resolved
uint32_t cmax; // if omitted (zero), assume max defined for tp

// additional fmtp parameters from ST 2110-10:2022
uint32_t maxudp; // if omitted (zero), assume the Standard UP Size Limit
sdp::timestamp_mode tsmode; // if omitted (empty), assume sdp::timestamp_modes::NEW
uint32_t tsdelay;
bst::optional<uint32_t> tsdelay;

video_raw_parameters() : depth(), width(), height(), interlace(), segmented(), troff(), cmax(), maxudp(), tsdelay() {}

Expand All @@ -341,11 +341,11 @@ namespace nmos
sdp::packing_mode pm,
sdp::smpte_standard_number ssn,
sdp::type_parameter tp,
uint32_t troff,
bst::optional<uint32_t> troff,
uint32_t cmax,
uint32_t maxudp,
sdp::timestamp_mode tsmode,
uint32_t tsdelay
bst::optional<uint32_t> tsdelay
)
: sampling(std::move(sampling))
, depth(depth)
Expand Down Expand Up @@ -393,7 +393,7 @@ namespace nmos

// additional fmtp parameters from ST 2110-10:2022
sdp::timestamp_mode tsmode; // if omitted (empty), assume sdp::timestamp_modes::NEW
uint32_t tsdelay;
bst::optional<uint32_t> tsdelay;

// ptime
double packet_time;
Expand All @@ -406,7 +406,7 @@ namespace nmos
uint64_t sample_rate,
utility::string_t channel_order,
sdp::timestamp_mode tsmode,
uint32_t tsdelay,
bst::optional<uint32_t> tsdelay,
double packet_time
)
: channel_count(channel_count)
Expand Down Expand Up @@ -442,11 +442,11 @@ namespace nmos
sdp::smpte_standard_number ssn;

// additional fmtp parameters from ST 2110-21:2022
uint32_t troff; // if omitted (zero), assume default
bst::optional<uint32_t> troff; // if omitted, assume default

// additional fmtp parameters from ST 2110-10:2022
sdp::timestamp_mode tsmode; // if omitted (empty), assume sdp::timestamp_modes::NEW
uint32_t tsdelay;
bst::optional<uint32_t> tsdelay;

video_smpte291_parameters() : vpid_code(), troff(), tsdelay() {}

Expand All @@ -456,9 +456,9 @@ namespace nmos
nmos::rational exactframerate,
sdp::transmission_model tm,
sdp::smpte_standard_number ssn,
uint32_t troff,
bst::optional<uint32_t> troff,
sdp::timestamp_mode tsmode,
uint32_t tsdelay
bst::optional<uint32_t> tsdelay
)
: did_sdids(std::move(did_sdids))
, vpid_code(vpid_code)
Expand All @@ -482,13 +482,13 @@ namespace nmos
{
// additional fmtp parameters from ST 2110-21:2017
sdp::type_parameter tp;
uint32_t troff; // if omitted (zero), assume default
bst::optional<uint32_t> troff; // if omitted, assume default

video_SMPTE2022_6_parameters() : troff() {}

video_SMPTE2022_6_parameters(
sdp::type_parameter tp,
uint32_t troff
bst::optional<uint32_t> troff
)
: tp(std::move(tp))
, troff(troff)
Expand Down
31 changes: 31 additions & 0 deletions Development/nmos/test/sdp_test_utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "nmos/test/sdp_test_utils.h"

#include "bst/test/test.h"
#include "nmos/sdp_utils.h"

namespace nmos
{
typedef std::multimap<utility::string_t, utility::string_t> comparable_fmtp_t;

inline comparable_fmtp_t comparable_fmtp(const nmos::sdp_parameters::fmtp_t& fmtp)
{
return comparable_fmtp_t{ fmtp.begin(), fmtp.end() };
}

void check_sdp_parameters(const nmos::sdp_parameters& lhs, const nmos::sdp_parameters& rhs)
{
BST_REQUIRE_EQUAL(lhs.session_name, rhs.session_name);
BST_REQUIRE_EQUAL(lhs.rtpmap.payload_type, rhs.rtpmap.payload_type);
BST_REQUIRE_EQUAL(lhs.rtpmap.encoding_name, rhs.rtpmap.encoding_name);
BST_REQUIRE_EQUAL(lhs.rtpmap.clock_rate, rhs.rtpmap.clock_rate);
if (0 != lhs.rtpmap.encoding_parameters)
BST_REQUIRE_EQUAL(lhs.rtpmap.encoding_parameters, rhs.rtpmap.encoding_parameters);
else
BST_REQUIRE((0 == rhs.rtpmap.encoding_parameters || 1 == rhs.rtpmap.encoding_parameters));
BST_REQUIRE_EQUAL(comparable_fmtp(lhs.fmtp), comparable_fmtp(rhs.fmtp));
BST_REQUIRE_EQUAL(lhs.packet_time, rhs.packet_time);
BST_REQUIRE_EQUAL(lhs.max_packet_time, rhs.max_packet_time);
BST_REQUIRE_EQUAL(lhs.bandwidth.bandwidth_type, rhs.bandwidth.bandwidth_type);
BST_REQUIRE_EQUAL(lhs.bandwidth.bandwidth, rhs.bandwidth.bandwidth);
}
}
11 changes: 11 additions & 0 deletions Development/nmos/test/sdp_test_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef NMOS_SDP_TEST_UTILS_H
#define NMOS_SDP_TEST_UTILS_H

namespace nmos
{
struct sdp_parameters;

void check_sdp_parameters(const nmos::sdp_parameters& lhs, const nmos::sdp_parameters& rhs);
}

#endif
Loading
Loading