| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/pc/mediasession.h" | 11 #include "webrtc/pc/mediasession.h" |
| 12 | 12 |
| 13 #include <algorithm> // For std::find_if, std::sort. | 13 #include <algorithm> // For std::find_if, std::sort. |
| 14 #include <functional> | 14 #include <functional> |
| 15 #include <map> | 15 #include <map> |
| 16 #include <memory> | 16 #include <memory> |
| 17 #include <set> | 17 #include <set> |
| 18 #include <unordered_map> | 18 #include <unordered_map> |
| 19 #include <utility> | 19 #include <utility> |
| 20 | 20 |
| 21 #include "webrtc/base/base64.h" | 21 #include "webrtc/base/base64.h" |
| 22 #include "webrtc/base/checks.h" |
| 22 #include "webrtc/base/helpers.h" | 23 #include "webrtc/base/helpers.h" |
| 23 #include "webrtc/base/logging.h" | 24 #include "webrtc/base/logging.h" |
| 24 #include "webrtc/base/stringutils.h" | 25 #include "webrtc/base/stringutils.h" |
| 25 #include "webrtc/common_video/h264/profile_level_id.h" | 26 #include "webrtc/common_video/h264/profile_level_id.h" |
| 26 #include "webrtc/media/base/cryptoparams.h" | 27 #include "webrtc/media/base/cryptoparams.h" |
| 27 #include "webrtc/media/base/mediaconstants.h" | 28 #include "webrtc/media/base/mediaconstants.h" |
| 28 #include "webrtc/p2p/base/p2pconstants.h" | 29 #include "webrtc/p2p/base/p2pconstants.h" |
| 29 #include "webrtc/pc/channelmanager.h" | 30 #include "webrtc/pc/channelmanager.h" |
| 30 #include "webrtc/pc/srtpfilter.h" | 31 #include "webrtc/pc/srtpfilter.h" |
| 31 | 32 |
| (...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 case MEDIA_TYPE_AUDIO: | 1199 case MEDIA_TYPE_AUDIO: |
| 1199 type_str = "audio"; | 1200 type_str = "audio"; |
| 1200 break; | 1201 break; |
| 1201 case MEDIA_TYPE_VIDEO: | 1202 case MEDIA_TYPE_VIDEO: |
| 1202 type_str = "video"; | 1203 type_str = "video"; |
| 1203 break; | 1204 break; |
| 1204 case MEDIA_TYPE_DATA: | 1205 case MEDIA_TYPE_DATA: |
| 1205 type_str = "data"; | 1206 type_str = "data"; |
| 1206 break; | 1207 break; |
| 1207 default: | 1208 default: |
| 1208 ASSERT(false); | 1209 RTC_NOTREACHED(); |
| 1209 break; | 1210 break; |
| 1210 } | 1211 } |
| 1211 return type_str; | 1212 return type_str; |
| 1212 } | 1213 } |
| 1213 | 1214 |
| 1214 std::string MediaContentDirectionToString(MediaContentDirection direction) { | 1215 std::string MediaContentDirectionToString(MediaContentDirection direction) { |
| 1215 std::string dir_str; | 1216 std::string dir_str; |
| 1216 switch (direction) { | 1217 switch (direction) { |
| 1217 case MD_INACTIVE: | 1218 case MD_INACTIVE: |
| 1218 dir_str = "inactive"; | 1219 dir_str = "inactive"; |
| 1219 break; | 1220 break; |
| 1220 case MD_SENDONLY: | 1221 case MD_SENDONLY: |
| 1221 dir_str = "sendonly"; | 1222 dir_str = "sendonly"; |
| 1222 break; | 1223 break; |
| 1223 case MD_RECVONLY: | 1224 case MD_RECVONLY: |
| 1224 dir_str = "recvonly"; | 1225 dir_str = "recvonly"; |
| 1225 break; | 1226 break; |
| 1226 case MD_SENDRECV: | 1227 case MD_SENDRECV: |
| 1227 dir_str = "sendrecv"; | 1228 dir_str = "sendrecv"; |
| 1228 break; | 1229 break; |
| 1229 default: | 1230 default: |
| 1230 ASSERT(false); | 1231 RTC_NOTREACHED(); |
| 1231 break; | 1232 break; |
| 1232 } | 1233 } |
| 1233 | 1234 |
| 1234 return dir_str; | 1235 return dir_str; |
| 1235 } | 1236 } |
| 1236 | 1237 |
| 1237 void MediaSessionOptions::AddSendStream(MediaType type, | 1238 void MediaSessionOptions::AddSendStream(MediaType type, |
| 1238 const std::string& id, | 1239 const std::string& id, |
| 1239 const std::string& sync_label) { | 1240 const std::string& sync_label) { |
| 1240 AddSendStreamInternal(type, id, sync_label, 1); | 1241 AddSendStreamInternal(type, id, sync_label, 1); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1262 | 1263 |
| 1263 void MediaSessionOptions::RemoveSendStream(MediaType type, | 1264 void MediaSessionOptions::RemoveSendStream(MediaType type, |
| 1264 const std::string& id) { | 1265 const std::string& id) { |
| 1265 Streams::iterator stream_it = streams.begin(); | 1266 Streams::iterator stream_it = streams.begin(); |
| 1266 for (; stream_it != streams.end(); ++stream_it) { | 1267 for (; stream_it != streams.end(); ++stream_it) { |
| 1267 if (stream_it->type == type && stream_it->id == id) { | 1268 if (stream_it->type == type && stream_it->id == id) { |
| 1268 streams.erase(stream_it); | 1269 streams.erase(stream_it); |
| 1269 return; | 1270 return; |
| 1270 } | 1271 } |
| 1271 } | 1272 } |
| 1272 ASSERT(false); | 1273 RTC_NOTREACHED(); |
| 1273 } | 1274 } |
| 1274 | 1275 |
| 1275 bool MediaSessionOptions::HasSendMediaStream(MediaType type) const { | 1276 bool MediaSessionOptions::HasSendMediaStream(MediaType type) const { |
| 1276 Streams::const_iterator stream_it = streams.begin(); | 1277 Streams::const_iterator stream_it = streams.begin(); |
| 1277 for (; stream_it != streams.end(); ++stream_it) { | 1278 for (; stream_it != streams.end(); ++stream_it) { |
| 1278 if (stream_it->type == type) { | 1279 if (stream_it->type == type) { |
| 1279 return true; | 1280 return true; |
| 1280 } | 1281 } |
| 1281 } | 1282 } |
| 1282 return false; | 1283 return false; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 it->description))) { | 1392 it->description))) { |
| 1392 options_copy.data_channel_type = DCT_SCTP; | 1393 options_copy.data_channel_type = DCT_SCTP; |
| 1393 } | 1394 } |
| 1394 if (!AddDataContentForOffer(options_copy, current_description, | 1395 if (!AddDataContentForOffer(options_copy, current_description, |
| 1395 &data_codecs, ¤t_streams, | 1396 &data_codecs, ¤t_streams, |
| 1396 offer.get())) { | 1397 offer.get())) { |
| 1397 return NULL; | 1398 return NULL; |
| 1398 } | 1399 } |
| 1399 data_added = true; | 1400 data_added = true; |
| 1400 } else { | 1401 } else { |
| 1401 ASSERT(false); | 1402 RTC_NOTREACHED(); |
| 1402 } | 1403 } |
| 1403 } | 1404 } |
| 1404 } | 1405 } |
| 1405 | 1406 |
| 1406 // Append contents that are not in |current_description|. | 1407 // Append contents that are not in |current_description|. |
| 1407 if (!audio_added && options.has_audio() && | 1408 if (!audio_added && options.has_audio() && |
| 1408 !AddAudioContentForOffer(options, current_description, | 1409 !AddAudioContentForOffer(options, current_description, |
| 1409 audio_rtp_extensions, audio_codecs, | 1410 audio_rtp_extensions, audio_codecs, |
| 1410 ¤t_streams, offer.get())) { | 1411 ¤t_streams, offer.get())) { |
| 1411 return NULL; | 1412 return NULL; |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2186 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); | 2187 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
| 2187 } | 2188 } |
| 2188 | 2189 |
| 2189 DataContentDescription* GetFirstDataContentDescription( | 2190 DataContentDescription* GetFirstDataContentDescription( |
| 2190 SessionDescription* sdesc) { | 2191 SessionDescription* sdesc) { |
| 2191 return static_cast<DataContentDescription*>( | 2192 return static_cast<DataContentDescription*>( |
| 2192 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); | 2193 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
| 2193 } | 2194 } |
| 2194 | 2195 |
| 2195 } // namespace cricket | 2196 } // namespace cricket |
| OLD | NEW |