Skip to content

Commit 9af269c

Browse files
committed
1.2.4: add support for encrypted header extensions (RFC 6904)
1 parent 09990bc commit 9af269c

5 files changed

Lines changed: 81 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.0)
22

3-
project(sdptransform VERSION 1.2.3)
3+
project(sdptransform VERSION 1.2.4)
44

55
# For CMake >= 3.1.
66
set(CMAKE_CXX_STANDARD 11)

doc/Grammar.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ if (
230230

231231
`a=extmap:2 urn:ietf:params:rtp-hdrext:toffset`
232232

233+
`a=extmap:3 urn:ietf:params:rtp-hdrext:encrypt urn:ietf:params:rtp-hdrext:smpte-tc 25@600/24`
234+
233235
* multiple
234236
* type: object
235237

@@ -238,6 +240,7 @@ if (
238240
| value | integer | 1
239241
| direction | string | "recvonly"
240242
| uri | string | "URI-gps-string"
243+
| encrypt-uri | string | "urn:ietf:params:rtp-hdrext:encrypt"
241244
| config | string |
242245

243246

src/grammar.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,24 +418,26 @@ namespace sdptransform
418418

419419
// a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
420420
// a=extmap:1/recvonly URI-gps-string
421+
// a=extmap:3 urn:ietf:params:rtp-hdrext:encrypt urn:ietf:params:rtp-hdrext:smpte-tc 25@600/24
421422
{
422423
// name:
423424
"",
424425
// push:
425426
"ext",
426427
// reg:
427-
std::regex("^extmap:(\\d+)(?:\\/(\\w+))? (\\S*)(?: (\\S*))?"),
428+
std::regex("^extmap:(\\d+)(?:\\/(\\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\\S*)(?: (\\S*))?"),
428429
// names:
429-
{ "value", "direction", "uri", "config" },
430+
{ "value", "direction", "encrypt-uri", "uri", "config" },
430431
// types:
431-
{ 'd', 's', 's', 's' },
432+
{ 'd', 's', 's', 's', 's' },
432433
// format:
433434
"",
434435
// formatFunc:
435436
[](const json& o)
436437
{
437438
return std::string("extmap:%d") +
438439
(hasValue(o, "direction") ? "/%s" : "%v") +
440+
(hasValue(o, "encrypt-uri") ? " %s" : "%v") +
439441
" %s" +
440442
(hasValue(o, "config") ? " %s" : "");
441443
}

test/data/extmap-encrypt.sdp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
v=0
2+
o=- 20518 0 IN IP4 203.0.113.1
3+
s=
4+
c=IN IP4 203.0.113.1
5+
t=0 0
6+
m=audio 54400 RTP/SAVPF 96
7+
a=rtpmap:96 opus/48000
8+
a=extmap:1/sendonly URI-toffset
9+
a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
10+
a=extmap:3 urn:ietf:params:rtp-hdrext:encrypt urn:ietf:params:rtp-hdrext:smpte-tc 25@600/24
11+
a=extmap:4/recvonly urn:ietf:params:rtp-hdrext:encrypt URI-gps-string

test/parse.test.cpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,3 +967,64 @@ SCENARIO("multicastttlSdp", "[parse]")
967967

968968
REQUIRE(newSdp == sdp);
969969
}
970+
971+
SCENARIO("extmapEncryptSdp", "[parse]")
972+
{
973+
auto sdp = helpers::readFile("test/data/extmap-encrypt.sdp");
974+
auto session = sdptransform::parse(sdp);
975+
976+
REQUIRE(session.size() > 0);
977+
REQUIRE(session.find("media") != session.end());
978+
979+
auto& media = session.at("media");
980+
auto& audio = media[0];
981+
auto audioPayloads = sdptransform::parsePayloads(audio.at("payloads"));
982+
983+
REQUIRE(audioPayloads == R"([ 96 ])"_json);
984+
985+
REQUIRE(audio.at("type") == "audio");
986+
REQUIRE(audio.at("port") == 54400);
987+
REQUIRE(audio.at("protocol") == "RTP/SAVPF");
988+
REQUIRE(audio.at("rtp")[0].at("payload") == 96);
989+
REQUIRE(audio.at("rtp")[0].at("codec") == "opus");
990+
REQUIRE(audio.at("rtp")[0].at("rate") == 48000);
991+
REQUIRE(
992+
audio.at("ext")[0] ==
993+
R"({
994+
"value" : 1,
995+
"direction" : "sendonly",
996+
"uri" : "URI-toffset"
997+
})"_json
998+
);
999+
REQUIRE(
1000+
audio.at("ext")[1] ==
1001+
R"({
1002+
"value" : 2,
1003+
"uri" : "urn:ietf:params:rtp-hdrext:toffset"
1004+
})"_json
1005+
);
1006+
REQUIRE(
1007+
audio.at("ext")[2] ==
1008+
R"({
1009+
"value" : 3,
1010+
"encrypt-uri" : "urn:ietf:params:rtp-hdrext:encrypt",
1011+
"uri" : "urn:ietf:params:rtp-hdrext:smpte-tc",
1012+
"config" : "25@600/24"
1013+
})"_json
1014+
);
1015+
REQUIRE(
1016+
audio.at("ext")[3] ==
1017+
R"({
1018+
"value" : 4,
1019+
"direction" : "recvonly",
1020+
"encrypt-uri" : "urn:ietf:params:rtp-hdrext:encrypt",
1021+
"uri" : "URI-gps-string"
1022+
})"_json
1023+
);
1024+
1025+
REQUIRE(media.size() == 1);
1026+
1027+
auto newSdp = sdptransform::write(session);
1028+
1029+
REQUIRE(newSdp == sdp);
1030+
}

0 commit comments

Comments
 (0)