Browse Source

Merge branch 'api_updates' of https://github.com/stazio/libdatachannel into api_updates

Staz M 4 years ago
parent
commit
68bb97b3a3
1 changed files with 19 additions and 0 deletions
  1. 19 0
      src/description.cpp

+ 19 - 0
src/description.cpp

@@ -611,6 +611,23 @@ void Description::Media::removeFormat(const string &fmt) {
 			it++;
 	}
 }
+std::string random_string(std::size_t length)
+{
+    const std::string CHARACTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+    std::random_device random_device;
+    std::mt19937 generator(random_device());
+    std::uniform_int_distribution<> distribution(0, CHARACTERS.size() - 1);
+
+    std::string random_string;
+
+    for (std::size_t i = 0; i < length; ++i)
+    {
+        random_string += CHARACTERS[distribution(generator)];
+    }
+
+    return random_string;
+}
 
 void Description::Video::addVideoCodec(int payloadType, const string &codec) {
 	RTPMap map(std::to_string(payloadType) + ' ' + codec + "/90000");
@@ -623,6 +640,7 @@ void Description::Video::addVideoCodec(int payloadType, const string &codec) {
 		// TODO: Should be 42E0 but 42C0 appears to be more compatible. Investigate this.
 		map.fmtps.emplace_back("profile-level-id=42E02A;packetization-mode=1;level-asymmetry-allowed=1");
 	}
+	map.fmtps.emplace_back("literally-a-random-identifier=" + random_string(12));
 	addRTPMap(map);
 
 //	// RTX Packets
@@ -642,6 +660,7 @@ void Description::Video::addVideoCodec(int payloadType, const string &codec) {
 void Description::Audio::addAudioCodec(int payloadType, const string &codec) {
     // TODO This 48000/2 should be parameterized
     RTPMap map(std::to_string(payloadType) + ' ' + codec + "/48000/2");
+    map.fmtps.emplace_back("maxaveragebitrate=510000; stereo=1; sprop-stereo=1; useinbandfec=1");
     addRTPMap(map);
 }