Bläddra i källkod

Define methods inside namespace instead of using namespace

Filip Klembara 4 år sedan
förälder
incheckning
735cb538f7

+ 7 - 2
src/h264packetizationhandler.cpp

@@ -20,8 +20,11 @@
 
 #include "h264packetizationhandler.hpp"
 
-using namespace rtc;
-using namespace std;
+namespace rtc {
+
+using std::shared_ptr;
+using std::make_shared;
+using std::function;
 
 typedef enum {
     NUSM_noMatch,
@@ -161,4 +164,6 @@ H264PacketizationHandler::H264PacketizationHandler(Separator separator,
     };
 }
 
+} // namespace
+
 #endif /* RTC_ENABLE_MEDIA */

+ 3 - 2
src/h264rtppacketizer.cpp

@@ -20,9 +20,10 @@
 
 #include "h264rtppacketizer.hpp"
 
-using namespace std;
-using namespace rtc;
+namespace rtc {
 
 H264RTPPacketizer::H264RTPPacketizer(std::shared_ptr<RTPPacketizationConfig> rtpConfig): RTPPacketizer(rtpConfig) { }
 
+} // namespace
+
 #endif /* RTC_ENABLE_MEDIA */

+ 5 - 4
src/nalunit.cpp

@@ -21,8 +21,7 @@
 #include "nalunit.hpp"
 #include <cmath>
 
-using namespace std;
-using namespace rtc;
+namespace rtc {
 
 NalUnitFragmentA::NalUnitFragmentA(FragmentType type, bool forbiddenBit, uint8_t nri, uint8_t unitType, binary data): NalUnit(data.size() + 2) {
     setForbiddenBit(forbiddenBit);
@@ -33,7 +32,7 @@ NalUnitFragmentA::NalUnitFragmentA(FragmentType type, bool forbiddenBit, uint8_t
     copy(data.begin(), data.end(), begin() + 2);
 }
 
-vector<NalUnitFragmentA> NalUnitFragmentA::fragmentsFrom(NalUnit nalu, uint16_t maximumFragmentSize) {
+std::vector<NalUnitFragmentA> NalUnitFragmentA::fragmentsFrom(NalUnit nalu, uint16_t maximumFragmentSize) {
     assert(nalu.size() > maximumFragmentSize);
     if (nalu.size() <= maximumFragmentSize) {
         // we need to change `maximum_fragment_size` to have at least two fragments
@@ -88,7 +87,7 @@ void NalUnitFragmentA::setFragmentType(FragmentType type) {
     }
 }
 
-vector<binary> NalUnits::generateFragments(uint16_t maximumFragmentSize) {
+std::vector<binary> NalUnits::generateFragments(uint16_t maximumFragmentSize) {
     vector<binary> result{};
     for (auto nalu: *this) {
         if (nalu.size() > maximumFragmentSize) {
@@ -101,4 +100,6 @@ vector<binary> NalUnits::generateFragments(uint16_t maximumFragmentSize) {
     return result;
 }
 
+} // namespace
+
 #endif /* RTC_ENABLE_MEDIA */

+ 3 - 1
src/opuspacketizationhandler.cpp

@@ -20,7 +20,7 @@
 
 #include "opuspacketizationhandler.hpp"
 
-using namespace rtc;
+namespace rtc {
 
 OpusPacketizationHandler::OpusPacketizationHandler(std::shared_ptr<OpusRTPPacketizer> packetizer): RtcpHandler(), RTCPSenderReportable(packetizer->rtpConfig), packetizer(packetizer) {
     senderReportOutgoingCallback = [this](message_ptr msg) {
@@ -43,4 +43,6 @@ message_ptr OpusPacketizationHandler::outgoing(message_ptr ptr) {
     return ptr;
 }
 
+} // namespace
+
 #endif /* RTC_ENABLE_MEDIA */

+ 3 - 2
src/opusrtppacketizer.cpp

@@ -20,8 +20,7 @@
 
 #include "opusrtppacketizer.hpp"
 
-using namespace std;
-using namespace rtc;
+namespace rtc {
 
 OpusRTPPacketizer::OpusRTPPacketizer(std::shared_ptr<RTPPacketizationConfig> rtpConfig): RTPPacketizer(rtpConfig) { }
 
@@ -30,4 +29,6 @@ message_ptr OpusRTPPacketizer::packetize(binary payload, bool setMark) {
     return RTPPacketizer::packetize(payload, false);
 }
 
+} // namespace
+
 #endif /* RTC_ENABLE_MEDIA */

+ 3 - 2
src/rtcpsenderreportable.cpp

@@ -20,8 +20,7 @@
 
 #include "rtcpsenderreportable.hpp"
 
-using namespace rtc;
-using namespace std;
+namespace rtc {
 
 void RTCPSenderReportable::startRecording() {
     _previousReportedTimestamp = rtpConfig->timestamp;
@@ -71,4 +70,6 @@ message_ptr RTCPSenderReportable::getSenderReport(uint32_t timestamp) {
     return msg;
 }
 
+} // namespace
+
 #endif /* RTC_ENABLE_MEDIA */

+ 5 - 4
src/rtppacketizationconfig.cpp

@@ -20,15 +20,14 @@
 
 #include "rtppacketizationconfig.hpp"
 
-using namespace rtc;
-using namespace std;
+namespace rtc {
 
 RTPPacketizationConfig::RTPPacketizationConfig(SSRC ssrc,
                                                string cname,
                                                uint8_t payloadType,
                                                uint32_t clockRate,
-                                               optional<uint16_t> sequenceNumber,
-                                               optional<uint32_t> timestamp): ssrc(ssrc), cname(cname), payloadType(payloadType), clockRate(clockRate) {
+                                               std::optional<uint16_t> sequenceNumber,
+                                               std::optional<uint32_t> timestamp): ssrc(ssrc), cname(cname), payloadType(payloadType), clockRate(clockRate) {
     assert(clockRate > 0);
     srand((unsigned)time(NULL));
     if (sequenceNumber.has_value()) {
@@ -70,4 +69,6 @@ uint32_t RTPPacketizationConfig::secondsToTimestamp(double seconds) {
     return RTPPacketizationConfig::getTimestampFromSeconds(seconds, clockRate);
 }
 
+} // namespace
+
 #endif /* RTC_ENABLE_MEDIA */

+ 4 - 3
src/rtppacketizer.cpp

@@ -20,10 +20,9 @@
 
 #include "rtppacketizer.hpp"
 
-using namespace std;
-using namespace rtc;
+namespace rtc {
 
-RTPPacketizer::RTPPacketizer(shared_ptr<RTPPacketizationConfig> rtpConfig): rtpConfig(rtpConfig) { }
+RTPPacketizer::RTPPacketizer(std::shared_ptr<RTPPacketizationConfig> rtpConfig): rtpConfig(rtpConfig) { }
 
 message_ptr RTPPacketizer::packetize(binary payload, bool setMark) {
     auto msg = make_message(rtpHeaderSize + payload.size());
@@ -41,4 +40,6 @@ message_ptr RTPPacketizer::packetize(binary payload, bool setMark) {
     return msg;
 }
 
+} // namespace
+
 #endif /* RTC_ENABLE_MEDIA */