summaryrefslogtreecommitdiffstats
path: root/dom/media/webrtc/jsapi/RTCSctpTransport.h
blob: 8e21db5e73e37a333acc032eefcce7b2d8eca40a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef _RTCSctpTransport_h_
#define _RTCSctpTransport_h_

#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/RefPtr.h"
#include "js/RootingAPI.h"
#include "RTCDtlsTransport.h"

class nsPIDOMWindowInner;

namespace mozilla::dom {

enum class RTCSctpTransportState : uint8_t;

class RTCSctpTransport : public DOMEventTargetHelper {
 public:
  explicit RTCSctpTransport(nsPIDOMWindowInner* aWindow,
                            RTCDtlsTransport& aDtlsTransport,
                            double aMaxMessageSize,
                            const Nullable<uint16_t>& aMaxChannels);

  // nsISupports
  NS_DECL_ISUPPORTS_INHERITED
  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(RTCSctpTransport,
                                           DOMEventTargetHelper)

  // webidl
  JSObject* WrapObject(JSContext* aCx,
                       JS::Handle<JSObject*> aGivenProto) override;
  IMPL_EVENT_HANDLER(statechange)

  RTCDtlsTransport* Transport() const { return mDtlsTransport; }
  RTCSctpTransportState State() const { return mState; }
  double MaxMessageSize() const { return mMaxMessageSize; }
  Nullable<uint16_t> GetMaxChannels() const { return mMaxChannels; }

  void SetTransport(RTCDtlsTransport& aTransport) {
    mDtlsTransport = &aTransport;
  }

  void SetMaxMessageSize(double aMaxMessageSize) {
    mMaxMessageSize = aMaxMessageSize;
  }

  void SetMaxChannels(const Nullable<uint16_t>& aMaxChannels) {
    mMaxChannels = aMaxChannels;
  }

  void UpdateState(RTCSctpTransportState aState);

 private:
  virtual ~RTCSctpTransport() = default;

  RTCSctpTransportState mState;
  RefPtr<RTCDtlsTransport> mDtlsTransport;
  double mMaxMessageSize;
  Nullable<uint16_t> mMaxChannels;
};

}  // namespace mozilla::dom
#endif  // _RTCSctpTransport_h_