OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. and Robin Seggelmann | 3 * Copyright 2012 Google Inc. and Robin Seggelmann |
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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 #include <stdarg.h> | 30 #include <stdarg.h> |
31 #include <stdio.h> | 31 #include <stdio.h> |
32 #include <sstream> | 32 #include <sstream> |
33 #include <vector> | 33 #include <vector> |
34 | 34 |
35 #include "talk/media/base/codec.h" | 35 #include "talk/media/base/codec.h" |
36 #include "talk/media/base/constants.h" | 36 #include "talk/media/base/constants.h" |
37 #include "talk/media/base/streamparams.h" | 37 #include "talk/media/base/streamparams.h" |
38 #include "usrsctplib/usrsctp.h" | 38 #include "usrsctplib/usrsctp.h" |
| 39 #include "webrtc/base/arraysize.h" |
39 #include "webrtc/base/buffer.h" | 40 #include "webrtc/base/buffer.h" |
40 #include "webrtc/base/helpers.h" | 41 #include "webrtc/base/helpers.h" |
41 #include "webrtc/base/logging.h" | 42 #include "webrtc/base/logging.h" |
42 #include "webrtc/base/safe_conversions.h" | 43 #include "webrtc/base/safe_conversions.h" |
43 | 44 |
44 namespace { | 45 namespace { |
45 typedef cricket::SctpDataMediaChannel::StreamSet StreamSet; | 46 typedef cricket::SctpDataMediaChannel::StreamSet StreamSet; |
46 // Returns a comma-separated, human-readable list of the stream IDs in 's' | 47 // Returns a comma-separated, human-readable list of the stream IDs in 's' |
47 std::string ListStreams(const StreamSet& s) { | 48 std::string ListStreams(const StreamSet& s) { |
48 std::stringstream result; | 49 std::stringstream result; |
(...skipping 20 matching lines...) Expand all Loading... |
69 int value; | 70 int value; |
70 const char* name; | 71 const char* name; |
71 } flaginfo[] = { | 72 } flaginfo[] = { |
72 MAKEFLAG(SCTP_STREAM_RESET_INCOMING_SSN), | 73 MAKEFLAG(SCTP_STREAM_RESET_INCOMING_SSN), |
73 MAKEFLAG(SCTP_STREAM_RESET_OUTGOING_SSN), | 74 MAKEFLAG(SCTP_STREAM_RESET_OUTGOING_SSN), |
74 MAKEFLAG(SCTP_STREAM_RESET_DENIED), | 75 MAKEFLAG(SCTP_STREAM_RESET_DENIED), |
75 MAKEFLAG(SCTP_STREAM_RESET_FAILED), | 76 MAKEFLAG(SCTP_STREAM_RESET_FAILED), |
76 MAKEFLAG(SCTP_STREAM_CHANGE_DENIED) | 77 MAKEFLAG(SCTP_STREAM_CHANGE_DENIED) |
77 }; | 78 }; |
78 #undef MAKEFLAG | 79 #undef MAKEFLAG |
79 for (int i = 0; i < ARRAY_SIZE(flaginfo); ++i) { | 80 for (int i = 0; i < arraysize(flaginfo); ++i) { |
80 if (flags & flaginfo[i].value) { | 81 if (flags & flaginfo[i].value) { |
81 if (!first) result << " | "; | 82 if (!first) result << " | "; |
82 result << flaginfo[i].name; | 83 result << flaginfo[i].name; |
83 first = false; | 84 first = false; |
84 } | 85 } |
85 } | 86 } |
86 return result.str(); | 87 return result.str(); |
87 } | 88 } |
88 | 89 |
89 // Returns a comma-separated, human-readable list of the integers in 'array'. | 90 // Returns a comma-separated, human-readable list of the integers in 'array'. |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 | 467 |
467 // Subscribe to SCTP event notifications. | 468 // Subscribe to SCTP event notifications. |
468 int event_types[] = {SCTP_ASSOC_CHANGE, | 469 int event_types[] = {SCTP_ASSOC_CHANGE, |
469 SCTP_PEER_ADDR_CHANGE, | 470 SCTP_PEER_ADDR_CHANGE, |
470 SCTP_SEND_FAILED_EVENT, | 471 SCTP_SEND_FAILED_EVENT, |
471 SCTP_SENDER_DRY_EVENT, | 472 SCTP_SENDER_DRY_EVENT, |
472 SCTP_STREAM_RESET_EVENT}; | 473 SCTP_STREAM_RESET_EVENT}; |
473 struct sctp_event event = {0}; | 474 struct sctp_event event = {0}; |
474 event.se_assoc_id = SCTP_ALL_ASSOC; | 475 event.se_assoc_id = SCTP_ALL_ASSOC; |
475 event.se_on = 1; | 476 event.se_on = 1; |
476 for (size_t i = 0; i < ARRAY_SIZE(event_types); i++) { | 477 for (size_t i = 0; i < arraysize(event_types); i++) { |
477 event.se_type = event_types[i]; | 478 event.se_type = event_types[i]; |
478 if (usrsctp_setsockopt(sock_, IPPROTO_SCTP, SCTP_EVENT, &event, | 479 if (usrsctp_setsockopt(sock_, IPPROTO_SCTP, SCTP_EVENT, &event, |
479 sizeof(event)) < 0) { | 480 sizeof(event)) < 0) { |
480 LOG_ERRNO(LS_ERROR) << debug_name_ << "Failed to set SCTP_EVENT type: " | 481 LOG_ERRNO(LS_ERROR) << debug_name_ << "Failed to set SCTP_EVENT type: " |
481 << event.se_type; | 482 << event.se_type; |
482 return false; | 483 return false; |
483 } | 484 } |
484 } | 485 } |
485 | 486 |
486 // Register this class as an address for usrsctp. This is used by SCTP to | 487 // Register this class as an address for usrsctp. This is used by SCTP to |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 } | 1038 } |
1038 case MSG_SCTPOUTBOUNDPACKET: { | 1039 case MSG_SCTPOUTBOUNDPACKET: { |
1039 rtc::scoped_ptr<OutboundPacketMessage> pdata( | 1040 rtc::scoped_ptr<OutboundPacketMessage> pdata( |
1040 static_cast<OutboundPacketMessage*>(msg->pdata)); | 1041 static_cast<OutboundPacketMessage*>(msg->pdata)); |
1041 OnPacketFromSctpToNetwork(pdata->data().get()); | 1042 OnPacketFromSctpToNetwork(pdata->data().get()); |
1042 break; | 1043 break; |
1043 } | 1044 } |
1044 } | 1045 } |
1045 } | 1046 } |
1046 } // namespace cricket | 1047 } // namespace cricket |
OLD | NEW |