Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(474)

Side by Side Diff: talk/app/webrtc/webrtcsession.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: google::int32 Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 if (cricket::IsMediaContent(&*iter)) { 256 if (cricket::IsMediaContent(&*iter)) {
257 MediaContentDescription* mdesc = 257 MediaContentDescription* mdesc =
258 static_cast<MediaContentDescription*> (iter->description); 258 static_cast<MediaContentDescription*> (iter->description);
259 if (mdesc) { 259 if (mdesc) {
260 mdesc->set_crypto_required(type); 260 mdesc->set_crypto_required(type);
261 } 261 }
262 } 262 }
263 } 263 }
264 } 264 }
265 265
266 static bool GetAudioSsrcByTrackId( 266 static bool GetAudioSsrcByTrackId(const SessionDescription* session_description,
267 const SessionDescription* session_description, 267 const std::string& track_id,
268 const std::string& track_id, uint32 *ssrc) { 268 uint32_t* ssrc) {
269 const cricket::ContentInfo* audio_info = 269 const cricket::ContentInfo* audio_info =
270 cricket::GetFirstAudioContent(session_description); 270 cricket::GetFirstAudioContent(session_description);
271 if (!audio_info) { 271 if (!audio_info) {
272 LOG(LS_ERROR) << "Audio not used in this call"; 272 LOG(LS_ERROR) << "Audio not used in this call";
273 return false; 273 return false;
274 } 274 }
275 275
276 const cricket::MediaContentDescription* audio_content = 276 const cricket::MediaContentDescription* audio_content =
277 static_cast<const cricket::MediaContentDescription*>( 277 static_cast<const cricket::MediaContentDescription*>(
278 audio_info->description); 278 audio_info->description);
279 const cricket::StreamParams* stream = 279 const cricket::StreamParams* stream =
280 cricket::GetStreamByIds(audio_content->streams(), "", track_id); 280 cricket::GetStreamByIds(audio_content->streams(), "", track_id);
281 if (!stream) { 281 if (!stream) {
282 return false; 282 return false;
283 } 283 }
284 284
285 *ssrc = stream->first_ssrc(); 285 *ssrc = stream->first_ssrc();
286 return true; 286 return true;
287 } 287 }
288 288
289 static bool GetTrackIdBySsrc(const SessionDescription* session_description, 289 static bool GetTrackIdBySsrc(const SessionDescription* session_description,
290 uint32 ssrc, std::string* track_id) { 290 uint32_t ssrc,
291 std::string* track_id) {
291 ASSERT(track_id != NULL); 292 ASSERT(track_id != NULL);
292 293
293 const cricket::ContentInfo* audio_info = 294 const cricket::ContentInfo* audio_info =
294 cricket::GetFirstAudioContent(session_description); 295 cricket::GetFirstAudioContent(session_description);
295 if (audio_info) { 296 if (audio_info) {
296 const cricket::MediaContentDescription* audio_content = 297 const cricket::MediaContentDescription* audio_content =
297 static_cast<const cricket::MediaContentDescription*>( 298 static_cast<const cricket::MediaContentDescription*>(
298 audio_info->description); 299 audio_info->description);
299 300
300 const auto* found = 301 const auto* found =
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 } 453 }
453 std::string string_value; 454 std::string string_value;
454 T value; 455 T value;
455 if (constraints->GetOptional().FindFirst(key, &string_value)) { 456 if (constraints->GetOptional().FindFirst(key, &string_value)) {
456 if (rtc::FromString(string_value, &value)) { 457 if (rtc::FromString(string_value, &value)) {
457 option->Set(value); 458 option->Set(value);
458 } 459 }
459 } 460 }
460 } 461 }
461 462
462 uint32 ConvertIceTransportTypeToCandidateFilter( 463 uint32_t ConvertIceTransportTypeToCandidateFilter(
463 PeerConnectionInterface::IceTransportsType type) { 464 PeerConnectionInterface::IceTransportsType type) {
464 switch (type) { 465 switch (type) {
465 case PeerConnectionInterface::kNone: 466 case PeerConnectionInterface::kNone:
466 return cricket::CF_NONE; 467 return cricket::CF_NONE;
467 case PeerConnectionInterface::kRelay: 468 case PeerConnectionInterface::kRelay:
468 return cricket::CF_RELAY; 469 return cricket::CF_RELAY;
469 case PeerConnectionInterface::kNoHost: 470 case PeerConnectionInterface::kNoHost:
470 return (cricket::CF_ALL & ~cricket::CF_HOST); 471 return (cricket::CF_ALL & ~cricket::CF_HOST);
471 case PeerConnectionInterface::kAll: 472 case PeerConnectionInterface::kAll:
472 return cricket::CF_ALL; 473 return cricket::CF_ALL;
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 1133
1133 return UseCandidate(candidate); 1134 return UseCandidate(candidate);
1134 } 1135 }
1135 1136
1136 bool WebRtcSession::SetIceTransports( 1137 bool WebRtcSession::SetIceTransports(
1137 PeerConnectionInterface::IceTransportsType type) { 1138 PeerConnectionInterface::IceTransportsType type) {
1138 return port_allocator()->set_candidate_filter( 1139 return port_allocator()->set_candidate_filter(
1139 ConvertIceTransportTypeToCandidateFilter(type)); 1140 ConvertIceTransportTypeToCandidateFilter(type));
1140 } 1141 }
1141 1142
1142 bool WebRtcSession::GetLocalTrackIdBySsrc(uint32 ssrc, std::string* track_id) { 1143 bool WebRtcSession::GetLocalTrackIdBySsrc(uint32_t ssrc,
1144 std::string* track_id) {
1143 if (!base_local_description()) 1145 if (!base_local_description())
1144 return false; 1146 return false;
1145 return webrtc::GetTrackIdBySsrc(base_local_description(), ssrc, track_id); 1147 return webrtc::GetTrackIdBySsrc(base_local_description(), ssrc, track_id);
1146 } 1148 }
1147 1149
1148 bool WebRtcSession::GetRemoteTrackIdBySsrc(uint32 ssrc, std::string* track_id) { 1150 bool WebRtcSession::GetRemoteTrackIdBySsrc(uint32_t ssrc,
1151 std::string* track_id) {
1149 if (!base_remote_description()) 1152 if (!base_remote_description())
1150 return false; 1153 return false;
1151 return webrtc::GetTrackIdBySsrc(base_remote_description(), ssrc, track_id); 1154 return webrtc::GetTrackIdBySsrc(base_remote_description(), ssrc, track_id);
1152 } 1155 }
1153 1156
1154 std::string WebRtcSession::BadStateErrMsg(State state) { 1157 std::string WebRtcSession::BadStateErrMsg(State state) {
1155 std::ostringstream desc; 1158 std::ostringstream desc;
1156 desc << "Called in wrong state: " << GetStateString(state); 1159 desc << "Called in wrong state: " << GetStateString(state);
1157 return desc.str(); 1160 return desc.str();
1158 } 1161 }
1159 1162
1160 void WebRtcSession::SetAudioPlayout(uint32 ssrc, bool enable, 1163 void WebRtcSession::SetAudioPlayout(uint32_t ssrc,
1164 bool enable,
1161 cricket::AudioRenderer* renderer) { 1165 cricket::AudioRenderer* renderer) {
1162 ASSERT(signaling_thread()->IsCurrent()); 1166 ASSERT(signaling_thread()->IsCurrent());
1163 if (!voice_channel_) { 1167 if (!voice_channel_) {
1164 LOG(LS_ERROR) << "SetAudioPlayout: No audio channel exists."; 1168 LOG(LS_ERROR) << "SetAudioPlayout: No audio channel exists.";
1165 return; 1169 return;
1166 } 1170 }
1167 if (!voice_channel_->SetRemoteRenderer(ssrc, renderer)) { 1171 if (!voice_channel_->SetRemoteRenderer(ssrc, renderer)) {
1168 // SetRenderer() can fail if the ssrc does not match any playout channel. 1172 // SetRenderer() can fail if the ssrc does not match any playout channel.
1169 LOG(LS_ERROR) << "SetAudioPlayout: ssrc is incorrect: " << ssrc; 1173 LOG(LS_ERROR) << "SetAudioPlayout: ssrc is incorrect: " << ssrc;
1170 return; 1174 return;
1171 } 1175 }
1172 if (!voice_channel_->SetOutputScaling(ssrc, enable ? 1 : 0, enable ? 1 : 0)) { 1176 if (!voice_channel_->SetOutputScaling(ssrc, enable ? 1 : 0, enable ? 1 : 0)) {
1173 // Allow that SetOutputScaling fail if |enable| is false but assert 1177 // Allow that SetOutputScaling fail if |enable| is false but assert
1174 // otherwise. This in the normal case when the underlying media channel has 1178 // otherwise. This in the normal case when the underlying media channel has
1175 // already been deleted. 1179 // already been deleted.
1176 ASSERT(enable == false); 1180 ASSERT(enable == false);
1177 } 1181 }
1178 } 1182 }
1179 1183
1180 void WebRtcSession::SetAudioSend(uint32 ssrc, bool enable, 1184 void WebRtcSession::SetAudioSend(uint32_t ssrc,
1185 bool enable,
1181 const cricket::AudioOptions& options, 1186 const cricket::AudioOptions& options,
1182 cricket::AudioRenderer* renderer) { 1187 cricket::AudioRenderer* renderer) {
1183 ASSERT(signaling_thread()->IsCurrent()); 1188 ASSERT(signaling_thread()->IsCurrent());
1184 if (!voice_channel_) { 1189 if (!voice_channel_) {
1185 LOG(LS_ERROR) << "SetAudioSend: No audio channel exists."; 1190 LOG(LS_ERROR) << "SetAudioSend: No audio channel exists.";
1186 return; 1191 return;
1187 } 1192 }
1188 if (!voice_channel_->SetAudioSend(ssrc, !enable, &options, renderer)) { 1193 if (!voice_channel_->SetAudioSend(ssrc, !enable, &options, renderer)) {
1189 LOG(LS_ERROR) << "SetAudioSend: ssrc is incorrect: " << ssrc; 1194 LOG(LS_ERROR) << "SetAudioSend: ssrc is incorrect: " << ssrc;
1190 } 1195 }
1191 } 1196 }
1192 1197
1193 void WebRtcSession::SetAudioPlayoutVolume(uint32 ssrc, double volume) { 1198 void WebRtcSession::SetAudioPlayoutVolume(uint32_t ssrc, double volume) {
1194 ASSERT(signaling_thread()->IsCurrent()); 1199 ASSERT(signaling_thread()->IsCurrent());
1195 ASSERT(volume >= 0 && volume <= 10); 1200 ASSERT(volume >= 0 && volume <= 10);
1196 if (!voice_channel_) { 1201 if (!voice_channel_) {
1197 LOG(LS_ERROR) << "SetAudioPlayoutVolume: No audio channel exists."; 1202 LOG(LS_ERROR) << "SetAudioPlayoutVolume: No audio channel exists.";
1198 return; 1203 return;
1199 } 1204 }
1200 1205
1201 if (!voice_channel_->SetOutputScaling(ssrc, volume, volume)) { 1206 if (!voice_channel_->SetOutputScaling(ssrc, volume, volume)) {
1202 ASSERT(false); 1207 ASSERT(false);
1203 } 1208 }
1204 } 1209 }
1205 1210
1206 bool WebRtcSession::SetCaptureDevice(uint32 ssrc, 1211 bool WebRtcSession::SetCaptureDevice(uint32_t ssrc,
1207 cricket::VideoCapturer* camera) { 1212 cricket::VideoCapturer* camera) {
1208 ASSERT(signaling_thread()->IsCurrent()); 1213 ASSERT(signaling_thread()->IsCurrent());
1209 1214
1210 if (!video_channel_) { 1215 if (!video_channel_) {
1211 // |video_channel_| doesnt't exist. Probably because the remote end doesnt't 1216 // |video_channel_| doesnt't exist. Probably because the remote end doesnt't
1212 // support video. 1217 // support video.
1213 LOG(LS_WARNING) << "Video not used in this call."; 1218 LOG(LS_WARNING) << "Video not used in this call.";
1214 return false; 1219 return false;
1215 } 1220 }
1216 if (!video_channel_->SetCapturer(ssrc, camera)) { 1221 if (!video_channel_->SetCapturer(ssrc, camera)) {
1217 // Allow that SetCapturer fail if |camera| is NULL but assert otherwise. 1222 // Allow that SetCapturer fail if |camera| is NULL but assert otherwise.
1218 // This in the normal case when the underlying media channel has already 1223 // This in the normal case when the underlying media channel has already
1219 // been deleted. 1224 // been deleted.
1220 ASSERT(camera == NULL); 1225 ASSERT(camera == NULL);
1221 return false; 1226 return false;
1222 } 1227 }
1223 return true; 1228 return true;
1224 } 1229 }
1225 1230
1226 void WebRtcSession::SetVideoPlayout(uint32 ssrc, 1231 void WebRtcSession::SetVideoPlayout(uint32_t ssrc,
1227 bool enable, 1232 bool enable,
1228 cricket::VideoRenderer* renderer) { 1233 cricket::VideoRenderer* renderer) {
1229 ASSERT(signaling_thread()->IsCurrent()); 1234 ASSERT(signaling_thread()->IsCurrent());
1230 if (!video_channel_) { 1235 if (!video_channel_) {
1231 LOG(LS_WARNING) << "SetVideoPlayout: No video channel exists."; 1236 LOG(LS_WARNING) << "SetVideoPlayout: No video channel exists.";
1232 return; 1237 return;
1233 } 1238 }
1234 if (!video_channel_->SetRenderer(ssrc, enable ? renderer : NULL)) { 1239 if (!video_channel_->SetRenderer(ssrc, enable ? renderer : NULL)) {
1235 // Allow that SetRenderer fail if |renderer| is NULL but assert otherwise. 1240 // Allow that SetRenderer fail if |renderer| is NULL but assert otherwise.
1236 // This in the normal case when the underlying media channel has already 1241 // This in the normal case when the underlying media channel has already
1237 // been deleted. 1242 // been deleted.
1238 ASSERT(renderer == NULL); 1243 ASSERT(renderer == NULL);
1239 } 1244 }
1240 } 1245 }
1241 1246
1242 void WebRtcSession::SetVideoSend(uint32 ssrc, bool enable, 1247 void WebRtcSession::SetVideoSend(uint32_t ssrc,
1248 bool enable,
1243 const cricket::VideoOptions* options) { 1249 const cricket::VideoOptions* options) {
1244 ASSERT(signaling_thread()->IsCurrent()); 1250 ASSERT(signaling_thread()->IsCurrent());
1245 if (!video_channel_) { 1251 if (!video_channel_) {
1246 LOG(LS_WARNING) << "SetVideoSend: No video channel exists."; 1252 LOG(LS_WARNING) << "SetVideoSend: No video channel exists.";
1247 return; 1253 return;
1248 } 1254 }
1249 if (!video_channel_->SetVideoSend(ssrc, !enable, options)) { 1255 if (!video_channel_->SetVideoSend(ssrc, !enable, options)) {
1250 // Allow that MuteStream fail if |enable| is false but assert otherwise. 1256 // Allow that MuteStream fail if |enable| is false but assert otherwise.
1251 // This in the normal case when the underlying media channel has already 1257 // This in the normal case when the underlying media channel has already
1252 // been deleted. 1258 // been deleted.
1253 ASSERT(enable == false); 1259 ASSERT(enable == false);
1254 } 1260 }
1255 } 1261 }
1256 1262
1257 bool WebRtcSession::CanInsertDtmf(const std::string& track_id) { 1263 bool WebRtcSession::CanInsertDtmf(const std::string& track_id) {
1258 ASSERT(signaling_thread()->IsCurrent()); 1264 ASSERT(signaling_thread()->IsCurrent());
1259 if (!voice_channel_) { 1265 if (!voice_channel_) {
1260 LOG(LS_ERROR) << "CanInsertDtmf: No audio channel exists."; 1266 LOG(LS_ERROR) << "CanInsertDtmf: No audio channel exists.";
1261 return false; 1267 return false;
1262 } 1268 }
1263 uint32 send_ssrc = 0; 1269 uint32_t send_ssrc = 0;
1264 // The Dtmf is negotiated per channel not ssrc, so we only check if the ssrc 1270 // The Dtmf is negotiated per channel not ssrc, so we only check if the ssrc
1265 // exists. 1271 // exists.
1266 if (!GetAudioSsrcByTrackId(base_local_description(), track_id, 1272 if (!GetAudioSsrcByTrackId(base_local_description(), track_id,
1267 &send_ssrc)) { 1273 &send_ssrc)) {
1268 LOG(LS_ERROR) << "CanInsertDtmf: Track does not exist: " << track_id; 1274 LOG(LS_ERROR) << "CanInsertDtmf: Track does not exist: " << track_id;
1269 return false; 1275 return false;
1270 } 1276 }
1271 return voice_channel_->CanInsertDtmf(); 1277 return voice_channel_->CanInsertDtmf();
1272 } 1278 }
1273 1279
1274 bool WebRtcSession::InsertDtmf(const std::string& track_id, 1280 bool WebRtcSession::InsertDtmf(const std::string& track_id,
1275 int code, int duration) { 1281 int code, int duration) {
1276 ASSERT(signaling_thread()->IsCurrent()); 1282 ASSERT(signaling_thread()->IsCurrent());
1277 if (!voice_channel_) { 1283 if (!voice_channel_) {
1278 LOG(LS_ERROR) << "InsertDtmf: No audio channel exists."; 1284 LOG(LS_ERROR) << "InsertDtmf: No audio channel exists.";
1279 return false; 1285 return false;
1280 } 1286 }
1281 uint32 send_ssrc = 0; 1287 uint32_t send_ssrc = 0;
1282 if (!VERIFY(GetAudioSsrcByTrackId(base_local_description(), 1288 if (!VERIFY(GetAudioSsrcByTrackId(base_local_description(),
1283 track_id, &send_ssrc))) { 1289 track_id, &send_ssrc))) {
1284 LOG(LS_ERROR) << "InsertDtmf: Track does not exist: " << track_id; 1290 LOG(LS_ERROR) << "InsertDtmf: Track does not exist: " << track_id;
1285 return false; 1291 return false;
1286 } 1292 }
1287 if (!voice_channel_->InsertDtmf(send_ssrc, code, duration, 1293 if (!voice_channel_->InsertDtmf(send_ssrc, code, duration,
1288 cricket::DF_SEND)) { 1294 cricket::DF_SEND)) {
1289 LOG(LS_ERROR) << "Failed to insert DTMF to channel."; 1295 LOG(LS_ERROR) << "Failed to insert DTMF to channel.";
1290 return false; 1296 return false;
1291 } 1297 }
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
2085 2091
2086 if (!srtp_cipher.empty()) { 2092 if (!srtp_cipher.empty()) {
2087 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); 2093 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher);
2088 } 2094 }
2089 if (!ssl_cipher.empty()) { 2095 if (!ssl_cipher.empty()) {
2090 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); 2096 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher);
2091 } 2097 }
2092 } 2098 }
2093 2099
2094 } // namespace webrtc 2100 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698