Bug 1344556 - Part 2: Some helper functions for working with SDP direction attributes. Makes subsequent work simpler. r?drno draft
authorByron Campen [:bwc] <docfaraday@gmail.com>
Wed, 08 Mar 2017 13:49:12 -0600
changeset 495431 7ad4e288cddd920f0114f57605737b7696613fdf
parent 495430 e4a8bf781d17f64c78eb21354be0097f3621a6c5
child 495432 8e3dddfbb068fde1864921463f7ac927a5675ffe
push id48336
push userbcampen@mozilla.com
push dateWed, 08 Mar 2017 21:03:03 +0000
reviewersdrno
bugs1344556
milestone55.0a1
Bug 1344556 - Part 2: Some helper functions for working with SDP direction attributes. Makes subsequent work simpler. r?drno MozReview-Commit-ID: 177Sp8pj9kX
media/webrtc/signaling/src/sdp/SdpAttribute.h
--- a/media/webrtc/signaling/src/sdp/SdpAttribute.h
+++ b/media/webrtc/signaling/src/sdp/SdpAttribute.h
@@ -218,16 +218,47 @@ inline std::ostream& operator<<(std::ost
       break;
     default:
       MOZ_ASSERT(false);
       os << "?";
   }
   return os;
 }
 
+inline SdpDirectionAttribute::Direction
+operator~(SdpDirectionAttribute::Direction d)
+{
+  switch (d) {
+    case SdpDirectionAttribute::Direction::kInactive:
+      return SdpDirectionAttribute::Direction::kInactive;
+    case SdpDirectionAttribute::Direction::kSendonly:
+      return SdpDirectionAttribute::Direction::kRecvonly;
+    case SdpDirectionAttribute::Direction::kRecvonly:
+      return SdpDirectionAttribute::Direction::kSendonly;
+    case SdpDirectionAttribute::Direction::kSendrecv:
+      return SdpDirectionAttribute::Direction::kSendrecv;
+  }
+  MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("Invalid direction!");
+  MOZ_RELEASE_ASSERT(false);
+}
+
+inline SdpDirectionAttribute::Direction
+operator|(SdpDirectionAttribute::Direction d1,
+          SdpDirectionAttribute::Direction d2)
+{
+  return (SdpDirectionAttribute::Direction)((unsigned)d1 | (unsigned)d2);
+}
+
+inline SdpDirectionAttribute::Direction
+operator&(SdpDirectionAttribute::Direction d1,
+          SdpDirectionAttribute::Direction d2)
+{
+  return (SdpDirectionAttribute::Direction)((unsigned)d1 & (unsigned)d2);
+}
+
 ///////////////////////////////////////////////////////////////////////////
 // a=dtls-message, draft-rescorla-dtls-in-sdp
 //-------------------------------------------------------------------------
 //   attribute               =/   dtls-message-attribute
 //
 //   dtls-message-attribute  =    "dtls-message" ":" role SP value
 //
 //   role                    =    "client" / "server"