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 |
51 bool ParseDataChannelOpenMessage(const rtc::Buffer& payload, | 64 bool ParseDataChannelOpenMessage(const rtc::Buffer& payload, |
52 std::string* label, | 65 std::string* label, |
53 DataChannelInit* config) { | 66 DataChannelInit* config) { |
54 // Format defined at | 67 // Format defined at |
55 // http://tools.ietf.org/html/draft-jesup-rtcweb-data-protocol-04 | 68 // http://tools.ietf.org/html/draft-jesup-rtcweb-data-protocol-04 |
56 | 69 |
57 rtc::ByteBuffer buffer(payload); | 70 rtc::ByteBuffer buffer(payload); |
58 uint8_t message_type; | 71 uint8_t message_type; |
59 if (!buffer.ReadUInt8(&message_type)) { | 72 if (!buffer.ReadUInt8(&message_type)) { |
60 LOG(LS_WARNING) << "Could not read OPEN message type."; | 73 LOG(LS_WARNING) << "Could not read OPEN message type."; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 payload->SetData(buffer.Data(), buffer.Length()); | 196 payload->SetData(buffer.Data(), buffer.Length()); |
184 return true; | 197 return true; |
185 } | 198 } |
186 | 199 |
187 void WriteDataChannelOpenAckMessage(rtc::Buffer* payload) { | 200 void WriteDataChannelOpenAckMessage(rtc::Buffer* payload) { |
188 rtc::ByteBuffer buffer(rtc::ByteBuffer::ORDER_NETWORK); | 201 rtc::ByteBuffer buffer(rtc::ByteBuffer::ORDER_NETWORK); |
189 buffer.WriteUInt8(DATA_CHANNEL_OPEN_ACK_MESSAGE_TYPE); | 202 buffer.WriteUInt8(DATA_CHANNEL_OPEN_ACK_MESSAGE_TYPE); |
190 payload->SetData(buffer.Data(), buffer.Length()); | 203 payload->SetData(buffer.Data(), buffer.Length()); |
191 } | 204 } |
192 } // namespace webrtc | 205 } // namespace webrtc |
OLD | NEW |