RTCSctpTransport.h (1968B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef _RTCSctpTransport_h_ 6 #define _RTCSctpTransport_h_ 7 8 #include "RTCDtlsTransport.h" 9 #include "js/RootingAPI.h" 10 #include "mozilla/DOMEventTargetHelper.h" 11 #include "mozilla/RefPtr.h" 12 13 class nsPIDOMWindowInner; 14 15 namespace mozilla::dom { 16 17 enum class RTCSctpTransportState : uint8_t; 18 19 class RTCSctpTransport : public DOMEventTargetHelper { 20 public: 21 explicit RTCSctpTransport(nsPIDOMWindowInner* aWindow, 22 RTCDtlsTransport& aDtlsTransport, 23 double aMaxMessageSize, 24 const Nullable<uint16_t>& aMaxChannels); 25 26 // nsISupports 27 NS_DECL_ISUPPORTS_INHERITED 28 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(RTCSctpTransport, 29 DOMEventTargetHelper) 30 31 // webidl 32 JSObject* WrapObject(JSContext* aCx, 33 JS::Handle<JSObject*> aGivenProto) override; 34 IMPL_EVENT_HANDLER(statechange) 35 36 RTCDtlsTransport* Transport() const { return mDtlsTransport; } 37 RTCSctpTransportState State() const { return mState; } 38 double MaxMessageSize() const { return mMaxMessageSize; } 39 Nullable<uint16_t> GetMaxChannels() const { return mMaxChannels; } 40 41 void SetTransport(RTCDtlsTransport& aTransport) { 42 mDtlsTransport = &aTransport; 43 } 44 45 void SetMaxMessageSize(double aMaxMessageSize) { 46 mMaxMessageSize = aMaxMessageSize; 47 } 48 49 void SetMaxChannels(const Nullable<uint16_t>& aMaxChannels) { 50 mMaxChannels = aMaxChannels; 51 } 52 53 void UpdateState(RTCSctpTransportState aState); 54 55 private: 56 virtual ~RTCSctpTransport() = default; 57 58 RTCSctpTransportState mState; 59 RefPtr<RTCDtlsTransport> mDtlsTransport; 60 double mMaxMessageSize; 61 Nullable<uint16_t> mMaxChannels; 62 }; 63 64 } // namespace mozilla::dom 65 #endif // _RTCSctpTransport_h_