@@ -1284,34 +1284,33 @@ namespace nmos
1284
1284
}
1285
1285
1286
1286
// Get additional "video/raw" parameters from the SDP parameters
1287
- video_raw_parameters get_video_raw_parameters (const sdp_parameters& sdp_params)
1287
+ template <typename MissingRequiredParameter>
1288
+ video_raw_parameters get_video_raw_parameters (const sdp_parameters& sdp_params, MissingRequiredParameter missing = MissingRequiredParameter{})
1288
1289
{
1289
1290
video_raw_parameters params;
1290
1291
1291
- if (sdp_params.fmtp .empty ()) throw details::sdp_processing_error (" missing attribute: fmtp" );
1292
-
1293
1292
// See SMPTE ST 2110-20:2017 Section 7.2 Required Media Type Parameters
1294
1293
// and Section 7.3 Media Type Parameters with default values
1295
1294
1296
1295
const auto sampling = details::find_fmtp (sdp_params.fmtp , sdp::fields::sampling);
1297
- if (sdp_params.fmtp .end () == sampling) throw details::sdp_processing_error ( " missing format parameter: sampling" ) ;
1298
- params. sampling = sdp::sampling{ sampling-> second } ;
1296
+ if (sdp_params.fmtp .end () != sampling) params. sampling = sdp::sampling{ sampling-> second } ;
1297
+ else missing ( sdp::fields:: sampling) ;
1299
1298
1300
1299
const auto depth = details::find_fmtp (sdp_params.fmtp , sdp::fields::depth);
1301
- if (sdp_params.fmtp .end () == depth) throw details::sdp_processing_error ( " missing format parameter: depth" );
1302
- params. depth = utility::istringstreamed< uint32_t >( depth-> second );
1300
+ if (sdp_params.fmtp .end () != depth) params. depth = utility::istringstreamed< uint32_t >( depth-> second );
1301
+ else missing (sdp::fields:: depth);
1303
1302
1304
1303
const auto width = details::find_fmtp (sdp_params.fmtp , sdp::fields::width);
1305
- if (sdp_params.fmtp .end () == width) throw details::sdp_processing_error ( " missing format parameter: width" );
1306
- params. width = utility::istringstreamed< uint32_t >( width-> second );
1304
+ if (sdp_params.fmtp .end () != width) params. width = utility::istringstreamed< uint32_t >( width-> second );
1305
+ else missing (sdp::fields:: width);
1307
1306
1308
1307
const auto height = details::find_fmtp (sdp_params.fmtp , sdp::fields::height);
1309
- if (sdp_params.fmtp .end () == height) throw details::sdp_processing_error ( " missing format parameter: height" );
1310
- params. height = utility::istringstreamed< uint32_t >( height-> second );
1308
+ if (sdp_params.fmtp .end () != height) params. height = utility::istringstreamed< uint32_t >( height-> second );
1309
+ else missing (sdp::fields:: height);
1311
1310
1312
1311
const auto exactframerate = details::find_fmtp (sdp_params.fmtp , sdp::fields::exactframerate);
1313
- if (sdp_params.fmtp .end () == exactframerate) throw details::sdp_processing_error ( " missing format parameter: exactframerate" );
1314
- params. exactframerate = nmos::details::parse_exactframerate ( exactframerate-> second );
1312
+ if (sdp_params.fmtp .end () != exactframerate) params. exactframerate = nmos:: details::parse_exactframerate ( exactframerate-> second );
1313
+ else missing (sdp::fields:: exactframerate);
1315
1314
1316
1315
// optional
1317
1316
const auto interlace = details::find_fmtp (sdp_params.fmtp , sdp::fields::interlace);
@@ -1326,8 +1325,8 @@ namespace nmos
1326
1325
if (sdp_params.fmtp .end () != tcs) params.tcs = sdp::transfer_characteristic_system{ tcs->second };
1327
1326
1328
1327
const auto colorimetry = details::find_fmtp (sdp_params.fmtp , sdp::fields::colorimetry);
1329
- if (sdp_params.fmtp .end () == colorimetry) throw details::sdp_processing_error ( " missing format parameter: colorimetry" ) ;
1330
- params. colorimetry = sdp::colorimetry{ colorimetry-> second } ;
1328
+ if (sdp_params.fmtp .end () != colorimetry) params. colorimetry = sdp::colorimetry{ colorimetry-> second } ;
1329
+ else missing ( sdp::fields:: colorimetry) ;
1331
1330
1332
1331
// optional
1333
1332
const auto range = details::find_fmtp (sdp_params.fmtp , sdp::fields::range);
@@ -1338,12 +1337,12 @@ namespace nmos
1338
1337
if (sdp_params.fmtp .end () != par) params.par = nmos::details::parse_pixel_aspect_ratio (par->second );
1339
1338
1340
1339
const auto pm = details::find_fmtp (sdp_params.fmtp , sdp::fields::packing_mode);
1341
- if (sdp_params.fmtp .end () == pm) throw details::sdp_processing_error ( " missing format parameter: PM " ) ;
1342
- params. pm = sdp::packing_mode{ pm-> second } ;
1340
+ if (sdp_params.fmtp .end () != pm) params. pm = sdp::packing_mode{ pm-> second } ;
1341
+ else missing ( sdp::fields:: packing_mode) ;
1343
1342
1344
1343
const auto ssn = details::find_fmtp (sdp_params.fmtp , sdp::fields::smpte_standard_number);
1345
- if (sdp_params.fmtp .end () == ssn) throw details::sdp_processing_error ( " missing format parameter: SSN " ) ;
1346
- params. ssn = sdp::smpte_standard_number{ ssn-> second } ;
1344
+ if (sdp_params.fmtp .end () != ssn) params. ssn = sdp::smpte_standard_number{ ssn-> second } ;
1345
+ else missing ( sdp::fields:: smpte_standard_number) ;
1347
1346
1348
1347
// "Senders and Receivers compliant to [ST 2110-20] shall comply with the provisions of SMPTE ST 2110-21."
1349
1348
// See SMPTE ST 2110-20:2017 Section 6.1.1
@@ -1378,6 +1377,18 @@ namespace nmos
1378
1377
return params;
1379
1378
}
1380
1379
1380
+ // Get additional "video/raw" parameters from the SDP parameters
1381
+ video_raw_parameters get_video_raw_parameters (const sdp_parameters& sdp_params)
1382
+ {
1383
+ return get_video_raw_parameters<details::throw_missing_fmtp>(sdp_params);
1384
+ }
1385
+
1386
+ // Get additional "video/raw" parameters from the SDP parameters
1387
+ video_raw_parameters get_video_raw_parameters_or_defaults (const sdp_parameters& sdp_params)
1388
+ {
1389
+ return get_video_raw_parameters<>(sdp_params, [](const utility::string_t &) {});
1390
+ }
1391
+
1381
1392
// Get additional "audio/L" parameters from the SDP parameters
1382
1393
audio_L_parameters get_audio_L_parameters (const sdp_parameters& sdp_params)
1383
1394
{
0 commit comments