1 /*
2  *  Copyright 2013 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef PC_SCTP_UTILS_H_
12 #define PC_SCTP_UTILS_H_
13 
14 #include <string>
15 
16 #include "api/data_channel_interface.h"
17 #include "api/transport/data_channel_transport_interface.h"
18 #include "media/base/media_channel.h"
19 
20 namespace rtc {
21 class CopyOnWriteBuffer;
22 }  // namespace rtc
23 
24 namespace webrtc {
25 struct DataChannelInit;
26 
27 // Read the message type and return true if it's an OPEN message.
28 bool IsOpenMessage(const rtc::CopyOnWriteBuffer& payload);
29 
30 bool ParseDataChannelOpenMessage(const rtc::CopyOnWriteBuffer& payload,
31                                  std::string* label,
32                                  DataChannelInit* config);
33 
34 bool ParseDataChannelOpenAckMessage(const rtc::CopyOnWriteBuffer& payload);
35 
36 bool WriteDataChannelOpenMessage(const std::string& label,
37                                  const DataChannelInit& config,
38                                  rtc::CopyOnWriteBuffer* payload);
39 
40 void WriteDataChannelOpenAckMessage(rtc::CopyOnWriteBuffer* payload);
41 
42 cricket::DataMessageType ToCricketDataMessageType(DataMessageType type);
43 
44 DataMessageType ToWebrtcDataMessageType(cricket::DataMessageType type);
45 
46 }  // namespace webrtc
47 
48 #endif  // PC_SCTP_UTILS_H_
49