OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 enum DataChannelOpenMessageChannelType { | 42 enum DataChannelOpenMessageChannelType { |
43 DCOMCT_ORDERED_RELIABLE = 0x00, | 43 DCOMCT_ORDERED_RELIABLE = 0x00, |
44 DCOMCT_ORDERED_PARTIAL_RTXS = 0x01, | 44 DCOMCT_ORDERED_PARTIAL_RTXS = 0x01, |
45 DCOMCT_ORDERED_PARTIAL_TIME = 0x02, | 45 DCOMCT_ORDERED_PARTIAL_TIME = 0x02, |
46 DCOMCT_UNORDERED_RELIABLE = 0x80, | 46 DCOMCT_UNORDERED_RELIABLE = 0x80, |
47 DCOMCT_UNORDERED_PARTIAL_RTXS = 0x81, | 47 DCOMCT_UNORDERED_PARTIAL_RTXS = 0x81, |
48 DCOMCT_UNORDERED_PARTIAL_TIME = 0x82, | 48 DCOMCT_UNORDERED_PARTIAL_TIME = 0x82, |
49 }; | 49 }; |
50 | 50 |
51 bool IsOpenMessage(const rtc::Buffer& payload) { | |
52 // Format defined at | |
53 // http://tools.ietf.org/html/draft-jesup-rtcweb-data-protocol-04 | |
54 | |
55 rtc::ByteBuffer buffer(payload); | |
56 uint8_t message_type; | |
57 if (!buffer.ReadUInt8(&message_type)) { | |
58 LOG(LS_WARNING) << "Could not read OPEN message type."; | |
59 return false; | |
60 } | |
61 return message_type == DATA_CHANNEL_OPEN_MESSAGE_TYPE; | |
62 } | |
63 | |
64 bool ParseDataChannelOpenMessage(const rtc::Buffer& payload, | 51 bool ParseDataChannelOpenMessage(const rtc::Buffer& payload, |
65 std::string* label, | 52 std::string* label, |
66 DataChannelInit* config) { | 53 DataChannelInit* config) { |
67 // Format defined at | 54 // Format defined at |
68 // http://tools.ietf.org/html/draft-jesup-rtcweb-data-protocol-04 | 55 // http://tools.ietf.org/html/draft-jesup-rtcweb-data-protocol-04 |
69 | 56 |
70 rtc::ByteBuffer buffer(payload); | 57 rtc::ByteBuffer buffer(payload); |
71 uint8_t message_type; | 58 uint8_t message_type; |
72 if (!buffer.ReadUInt8(&message_type)) { | 59 if (!buffer.ReadUInt8(&message_type)) { |
73 LOG(LS_WARNING) << "Could not read OPEN message type."; | 60 LOG(LS_WARNING) << "Could not read OPEN message type."; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 payload->SetData(buffer.Data(), buffer.Length()); | 183 payload->SetData(buffer.Data(), buffer.Length()); |
197 return true; | 184 return true; |
198 } | 185 } |
199 | 186 |
200 void WriteDataChannelOpenAckMessage(rtc::Buffer* payload) { | 187 void WriteDataChannelOpenAckMessage(rtc::Buffer* payload) { |
201 rtc::ByteBuffer buffer(rtc::ByteBuffer::ORDER_NETWORK); | 188 rtc::ByteBuffer buffer(rtc::ByteBuffer::ORDER_NETWORK); |
202 buffer.WriteUInt8(DATA_CHANNEL_OPEN_ACK_MESSAGE_TYPE); | 189 buffer.WriteUInt8(DATA_CHANNEL_OPEN_ACK_MESSAGE_TYPE); |
203 payload->SetData(buffer.Data(), buffer.Length()); | 190 payload->SetData(buffer.Data(), buffer.Length()); |
204 } | 191 } |
205 } // namespace webrtc | 192 } // namespace webrtc |
OLD | NEW |