浏览代码

Fixed compilation issues

Paul-Louis Ageneau 4 年之前
父节点
当前提交
b7a682cc50
共有 4 个文件被更改,包括 16 次插入16 次删除
  1. 3 3
      include/rtc/description.hpp
  2. 2 2
      include/rtc/rtp.hpp
  3. 8 8
      src/description.cpp
  4. 3 3
      src/peerconnection.cpp

+ 3 - 3
include/rtc/description.hpp

@@ -216,9 +216,9 @@ public:
 	int addVideo(string mid = "video", Direction dir = Direction::SendOnly);
 	int addAudio(string mid = "audio", Direction dir = Direction::SendOnly);
 
-	std::variant<Media *, Application *> media(int index);
-	std::variant<const Media *, const Application *> media(int index) const;
-	size_t mediaCount() const;
+	std::variant<Media *, Application *> media(unsigned int index);
+	std::variant<const Media *, const Application *> media(unsigned int index) const;
+	unsigned int mediaCount() const;
 
 	Application *application();
 

+ 2 - 2
include/rtc/rtp.hpp

@@ -367,7 +367,7 @@ struct RTCP_REMB {
         }
 
         // "length" in packet is one less than the number of 32 bit words in the packet.
-        header.header.setLength((offsetof(RTCP_REMB, ssrc) / sizeof(uint32_t)) - 1 + numSSRC);
+        header.header.setLength(uint16_t((offsetof(RTCP_REMB, ssrc) / sizeof(uint32_t)) - 1 + numSSRC));
 
         this->bitrate = htonl(
                 (numSSRC << (32u - 8u)) | (exp << (32u - 8u - 6u)) | bitrate
@@ -377,7 +377,7 @@ struct RTCP_REMB {
     void setSsrc(int iterator, SSRC newSssrc){
         ssrc[iterator] = htonl(newSssrc);
     }
-    
+
     size_t static inline sizeWithSSRCs(int count) {
         return sizeof(RTCP_REMB) + (count-1)*sizeof(SSRC);
     }

+ 8 - 8
src/description.cpp

@@ -25,8 +25,8 @@
 #include <chrono>
 #include <iostream>
 #include <random>
-//#include <sstream>
-//#include <unordered_map>
+#include <sstream>
+#include <unordered_map>
 
 using std::shared_ptr;
 using std::size_t;
@@ -385,8 +385,8 @@ int Description::addAudio(string mid, Direction dir) {
 	return addMedia(Audio(std::move(mid), dir));
 }
 
-std::variant<Description::Media *, Description::Application *> Description::media(int index) {
-	if (index < 0 || index >= int(mEntries.size()))
+std::variant<Description::Media *, Description::Application *> Description::media(unsigned int index) {
+	if (index >= mEntries.size())
 		throw std::out_of_range("Media index out of range");
 
 	const auto &entry = mEntries[index];
@@ -404,8 +404,8 @@ std::variant<Description::Media *, Description::Application *> Description::medi
 }
 
 std::variant<const Description::Media *, const Description::Application *>
-Description::media(int index) const {
-	if (index < 0 || index >= int(mEntries.size()))
+Description::media(unsigned int index) const {
+	if (index >= mEntries.size())
 		throw std::out_of_range("Media index out of range");
 
 	const auto &entry = mEntries[index];
@@ -422,7 +422,7 @@ Description::media(int index) const {
 	}
 }
 
-size_t Description::mediaCount() const { return mEntries.size(); }
+unsigned int Description::mediaCount() const { return unsigned(mEntries.size()); }
 
 Description::Entry::Entry(const string &mline, string mid, Direction dir)
     : mMid(std::move(mid)), mDirection(dir) {
@@ -691,7 +691,7 @@ void Description::Video::addVideoCodec(int payloadType, const string &codec) {
 		// https://developer.mozilla.org/en-US/docs/Web/Media/Formats/WebRTC_codecs#Supported_video_codecs
 		// TODO: Should be 42E0 but 42C0 appears to be more compatible. Investigate this.
 		map.fmtps.emplace_back("profile-level-id=4de01f;packetization-mode=1;level-asymmetry-allowed=1");
-		
+
 		// Because certain Android devices don't like me, let us just negotiate some random
 		{
 			RTPMap map(std::to_string(payloadType+1) + ' ' + codec + "/90000");

+ 3 - 3
src/peerconnection.cpp

@@ -684,7 +684,7 @@ void PeerConnection::forwardMedia(message_ptr message) {
 	// we have to do this monstrosity to distribute the report blocks
     std::optional<unsigned int> mediaLine;
     if (message->type == Message::Control) {
-        unsigned int offset = 0;
+        size_t offset = 0;
         std::vector<SSRC> ssrcsFound;
         bool hasFound = false;
 
@@ -1011,7 +1011,7 @@ void PeerConnection::validateRemoteDescription(const Description &description) {
 		throw std::invalid_argument("Remote description has no media line");
 
 	int activeMediaCount = 0;
-	for (size_t i = 0; i < description.mediaCount(); ++i)
+	for (unsigned int i = 0; i < description.mediaCount(); ++i)
 		std::visit(rtc::overloaded{[&](const Description::Application *) { ++activeMediaCount; },
 		                           [&](const Description::Media *media) {
 			                           if (media->direction() != Description::Direction::Inactive)
@@ -1034,7 +1034,7 @@ void PeerConnection::processLocalDescription(Description description) {
 
 	if (auto remote = remoteDescription()) {
 		// Reciprocate remote description
-		for (size_t i = 0; i < remote->mediaCount(); ++i)
+		for (unsigned int i = 0; i < remote->mediaCount(); ++i)
 			std::visit( // reciprocate each media
 			    rtc::overloaded{
 			        [&](Description::Application *remoteApp) {