Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions Development/nmos/json_fields.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ namespace nmos
const web::json::field_as_integer width{ U("width") };
const web::json::field_as_integer height{ U("height") };
const web::json::field_as_integer bit_depth{ U("bit_depth") }; // also used in flow_audio_raw
//flow_video_h265
const web::json::field_as_integer profile_id{ U("profile_id") };
const web::json::field_as_integer level_id{ U("level_id") };
const web::json::field_as_integer interop_constraints{ U("interop_constraints") };

Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
// flow_audio
const web::json::field_as_value sample_rate{ U("sample_rate") };
// flow_sdianc_data
Expand Down
100 changes: 100 additions & 0 deletions Development/nmos/video_h265.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#include "nmos/video_h265.h"
#include "json_fields.h"
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated

namespace nmos
{

Comment thread
diegonunes4 marked this conversation as resolved.
Outdated

Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
// Construct additional "video/H265" parameters from the IS-04 resources
video_h265_parameters make_video_h265_parameters(const web::json::value& node, const web::json::value& source, const web::json::value& flow, const web::json::value& sender, const utility::string_t& sprop_parameter_sets)
{
video_h265_parameters params;

params.profile_id = nmos::fields::profile_id(flow);

params.level_id = nmos::fields::level_id(flow);

Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
params.interop_constraints = nmos::fields::interop_constraints(flow);

return params;
}

// Construct SDP parameters for "video/H265", with sensible defaults for unspecified fields
sdp_parameters make_video_H265_sdp_parameters(const utility::string_t& session_name, const video_h265_parameters& params, uint64_t payload_type, const std::vector<utility::string_t>& media_stream_ids, const std::vector<sdp_parameters::ts_refclk_t>& ts_refclk)
{
// a=rtpmap:<payload type> <encoding name>/<clock rate>[/<encoding parameters>]
sdp_parameters::rtpmap_t rtpmap = { payload_type, U("H265"), 90000 };



Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
// a=fmtp:<format> <format specific parameters>
// for simplicity, following the order of parameters given in VSF TR-05:2017
// See https://tools.ietf.org/html/rfc4566#section-6
sdp_parameters::fmtp_t fmtp = {
{ sdp::fields::profile_id, utility::ostringstreamed(params.profile_id) },
{ sdp::fields::level_id, utility::ostringstreamed(params.level_id) },
{ sdp::fields::interop_constraints, utility::ostringstreamed(params.interop_constraints) },
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
{ sdp::fields::sprop_vps, params.sprop_vps },
{ sdp::fields::sprop_sps, params.sprop_sps },
{ sdp::fields::sprop_pps, params.sprop_pps }
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
};

return{ session_name, sdp::media_types::video, rtpmap, fmtp, {}, {}, {}, {}, media_stream_ids, ts_refclk };
}


Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
namespace details
{
// ought to be declared in nmos/sdp_utils.h
std::runtime_error sdp_processing_error(const std::string& message);

// ought to be declared in nmos/sdp_utils.h (definition currently has internal linkage)
sdp_parameters::fmtp_t::const_iterator find_fmtp(const sdp_parameters::fmtp_t& fmtp, const utility::string_t& param_name)
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
{
return std::find_if(fmtp.begin(), fmtp.end(), [&](const sdp_parameters::fmtp_t::value_type& param)
{
return param.first == param_name;
});
}
}

// Get additional "video/h265" parameters from the SDP parameters
video_h265_parameters get_video_h265_parameters(const sdp_parameters& sdp_params)
{
video_h265_parameters params;

if (sdp_params.fmtp.empty()) throw details::sdp_processing_error("missing attribute: fmtp");
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated

// optional
const auto profile_id = details::find_fmtp(sdp_params.fmtp, sdp::fields::profile_id);
if(sdp_params.fmtp.end() != profile_id ) throw details::sdp_processing_error("missing format parameter: profile-id");
params.profile_id = utility::istringstreamed<uint32_t>( profile_id->second );
Comment thread
diegonunes4 marked this conversation as resolved.

// optional
const auto level_id = details::find_fmtp(sdp_params.fmtp, sdp::fields::level_id);
if (sdp_params.fmtp.end() == level_id) throw details::sdp_processing_error("missing format parameter: level_id");
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
params.level_id = utility::istringstreamed<uint32_t>( level_id->second );

//optional
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
const auto interop_constraints = details::find_fmtp(sdp_params.fmtp, sdp::fields::interop_constraints);
if (sdp_params.fmtp.end() == interop_constraints) throw details::sdp_processing_error("missing format parameter: interop_constraints");
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
params.interop_constraints = utility::istringstreamed<uint32_t>( interop_constraints->second );

//optional
const auto sprop_vps = details::find_fmtp(sdp_params.fmtp, sdp::fields::sprop_vps);
if (sdp_params.fmtp.end() == sprop_vps) throw details::sdp_processing_error("missing format parameter: sprop_vps");
params.sprop_vps = sprop_vps->second;

//optional
const auto sprop_sps = details::find_fmtp(sdp_params.fmtp, sdp::fields::sprop_sps);
if (sdp_params.fmtp.end() == sprop_sps) throw details::sdp_processing_error("missing format parameter: sprop_sps");
params.sprop_sps = sprop_sps->second;

//optional
const auto sprop_pps = details::find_fmtp(sdp_params.fmtp, sdp::fields::sprop_pps);
if (sdp_params.fmtp.end() == sprop_pps) throw details::sdp_processing_error("missing format parameter: sprop_pps");
params.sprop_pps = sprop_pps->second;
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated

return params;
}
}
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
67 changes: 67 additions & 0 deletions Development/nmos/video_h265.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#ifndef NMOS_VIDEO_H265_H
#define NMOS_VIDEO_H265_H

#include "nmos/media_type.h"
#include "nmos/sdp_utils.h"

namespace sdp
{
namespace fields
{
// See https://datatracker.ietf.org/doc/html/rfc7798#page-64
//H265 payload mapping
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// See https://datatracker.ietf.org/doc/html/rfc7798#page-64
//H265 payload mapping
// See https://www.iana.org/assignments/media-types/video/H265
// and https://tools.ietf.org/html/rfc7798#section-7.2

const web::json::field<uint32_t> profile_id{U("profile-id")};
const web::json::field<uint32_t> level_id{U("level-id")};
const web::json::field<uint32_t> interop_constraints{U("interop-constraints")};
const web::json::field_as_string sprop_vps{U("sprop-vps")};
const web::json::field_as_string sprop_sps{U("sprop-sps")};
const web::json::field_as_string sprop_pps{U("sprop-pps")};
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
}
}

namespace nmos
{
namespace media_types
{
// H.265 Video
// See https://datatracker.ietf.org/doc/html/rfc7798
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
const media_type video_H265{ U("video/H265") };
}


Comment thread
garethsb marked this conversation as resolved.
// Additional "video/H265" parameters
// See https://datatracker.ietf.org/doc/html/rfc7798#section-4.4
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
struct video_h265_parameters
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
{
// fmtp indicates format
uint32_t profile_id;
uint32_t level_id;
uint32_t interop_constraints;
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
utility::string_t sprop_vps;
utility::string_t sprop_sps;
utility::string_t sprop_pps;

video_h265_parameters() : profile_id(), level_id(), interop_constraints(), sprop_vps(), sprop_sps(), sprop_pps() {}
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated

video_h265_parameters(uint32_t profile_id, uint32_t level_id, uint32_t interop_constraints, utility::string_t sprop_vps,
utility::string_t sprop_sps, utility::string_t sprop_pps)
: profile_id(profile_id), level_id(level_id), interop_constraints(interop_constraints), sprop_vps(sprop_vps),
sprop_sps(sprop_sps), sprop_pps(sprop_pps) {}
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
};


Comment thread
diegonunes4 marked this conversation as resolved.
Outdated
// Construct additional "video/H265" parameters from the IS-04 resources
video_h265_parameters make_video_H265_parameters(const web::json::value& node, const web::json::value& source, const web::json::value& flow, const web::json::value& sender, const utility::string_t& sprop_parameter_sets);
// Construct SDP parameters for "video/H265"
sdp_parameters make_video_h265_sdp_parameters(const utility::string_t& session_name, const video_h265_parameters& params, uint64_t payload_type, const std::vector<utility::string_t>& media_stream_ids = {}, const std::vector<sdp_parameters::ts_refclk_t>& ts_refclk = {});
// Get additional "video/H265" parameters from the SDP parameters
video_h265_parameters get_video_H265_parameters(const sdp_parameters& sdp_params);

// Construct SDP parameters for "video/H265"
inline sdp_parameters make_sdp_parameters(const utility::string_t& session_name, const video_h265_parameters& params, uint64_t payload_type, const std::vector<utility::string_t>& media_stream_ids = {}, const std::vector<sdp_parameters::ts_refclk_t>& ts_refclk = {})
{
return make_video_h265_sdp_parameters(session_name, params, payload_type, media_stream_ids, ts_refclk);
}
}
Comment thread
diegonunes4 marked this conversation as resolved.

#endif
Comment thread
diegonunes4 marked this conversation as resolved.
Outdated