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

Side by Side Diff: talk/session/media/mediasession.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: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… Created 5 years, 2 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
« no previous file with comments | « talk/session/media/mediasession.h ('k') | talk/session/media/mediasession_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 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 27 matching lines...) Expand all
38 #include "talk/session/media/srtpfilter.h" 38 #include "talk/session/media/srtpfilter.h"
39 #include "webrtc/base/helpers.h" 39 #include "webrtc/base/helpers.h"
40 #include "webrtc/base/logging.h" 40 #include "webrtc/base/logging.h"
41 #include "webrtc/base/scoped_ptr.h" 41 #include "webrtc/base/scoped_ptr.h"
42 #include "webrtc/base/stringutils.h" 42 #include "webrtc/base/stringutils.h"
43 #include "webrtc/p2p/base/constants.h" 43 #include "webrtc/p2p/base/constants.h"
44 44
45 #ifdef HAVE_SCTP 45 #ifdef HAVE_SCTP
46 #include "talk/media/sctp/sctpdataengine.h" 46 #include "talk/media/sctp/sctpdataengine.h"
47 #else 47 #else
48 static const uint32 kMaxSctpSid = 1023; 48 static const uint32_t kMaxSctpSid = 1023;
49 #endif 49 #endif
50 50
51 namespace { 51 namespace {
52 const char kInline[] = "inline:"; 52 const char kInline[] = "inline:";
53 } 53 }
54 54
55 namespace cricket { 55 namespace cricket {
56 56
57 using rtc::scoped_ptr; 57 using rtc::scoped_ptr;
58 58
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } while (FindFirstStreamParamsByCname(params_vec, *cname)); 243 } while (FindFirstStreamParamsByCname(params_vec, *cname));
244 244
245 return true; 245 return true;
246 } 246 }
247 247
248 // Generate random SSRC values that are not already present in |params_vec|. 248 // Generate random SSRC values that are not already present in |params_vec|.
249 // The generated values are added to |ssrcs|. 249 // The generated values are added to |ssrcs|.
250 // |num_ssrcs| is the number of the SSRC will be generated. 250 // |num_ssrcs| is the number of the SSRC will be generated.
251 static void GenerateSsrcs(const StreamParamsVec& params_vec, 251 static void GenerateSsrcs(const StreamParamsVec& params_vec,
252 int num_ssrcs, 252 int num_ssrcs,
253 std::vector<uint32>* ssrcs) { 253 std::vector<uint32_t>* ssrcs) {
254 for (int i = 0; i < num_ssrcs; i++) { 254 for (int i = 0; i < num_ssrcs; i++) {
255 uint32 candidate; 255 uint32_t candidate;
256 do { 256 do {
257 candidate = rtc::CreateRandomNonZeroId(); 257 candidate = rtc::CreateRandomNonZeroId();
258 } while (GetStreamBySsrc(params_vec, candidate) || 258 } while (GetStreamBySsrc(params_vec, candidate) ||
259 std::count(ssrcs->begin(), ssrcs->end(), candidate) > 0); 259 std::count(ssrcs->begin(), ssrcs->end(), candidate) > 0);
260 ssrcs->push_back(candidate); 260 ssrcs->push_back(candidate);
261 } 261 }
262 } 262 }
263 263
264 // Returns false if we exhaust the range of SIDs. 264 // Returns false if we exhaust the range of SIDs.
265 static bool GenerateSctpSid(const StreamParamsVec& params_vec, 265 static bool GenerateSctpSid(const StreamParamsVec& params_vec, uint32_t* sid) {
266 uint32* sid) {
267 if (params_vec.size() > kMaxSctpSid) { 266 if (params_vec.size() > kMaxSctpSid) {
268 LOG(LS_WARNING) << 267 LOG(LS_WARNING) <<
269 "Could not generate an SCTP SID: too many SCTP streams."; 268 "Could not generate an SCTP SID: too many SCTP streams.";
270 return false; 269 return false;
271 } 270 }
272 while (true) { 271 while (true) {
273 uint32 candidate = rtc::CreateRandomNonZeroId() % kMaxSctpSid; 272 uint32_t candidate = rtc::CreateRandomNonZeroId() % kMaxSctpSid;
274 if (!GetStreamBySsrc(params_vec, candidate)) { 273 if (!GetStreamBySsrc(params_vec, candidate)) {
275 *sid = candidate; 274 *sid = candidate;
276 return true; 275 return true;
277 } 276 }
278 } 277 }
279 } 278 }
280 279
281 static bool GenerateSctpSids(const StreamParamsVec& params_vec, 280 static bool GenerateSctpSids(const StreamParamsVec& params_vec,
282 std::vector<uint32>* sids) { 281 std::vector<uint32_t>* sids) {
283 uint32 sid; 282 uint32_t sid;
284 if (!GenerateSctpSid(params_vec, &sid)) { 283 if (!GenerateSctpSid(params_vec, &sid)) {
285 LOG(LS_WARNING) << "Could not generated an SCTP SID."; 284 LOG(LS_WARNING) << "Could not generated an SCTP SID.";
286 return false; 285 return false;
287 } 286 }
288 sids->push_back(sid); 287 sids->push_back(sid);
289 return true; 288 return true;
290 } 289 }
291 290
292 // Finds all StreamParams of all media types and attach them to stream_params. 291 // Finds all StreamParams of all media types and attach them to stream_params.
293 static void GetCurrentStreamParams(const SessionDescription* sdesc, 292 static void GetCurrentStreamParams(const SessionDescription* sdesc,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 MediaType media_type, 433 MediaType media_type,
435 const MediaSessionOptions::Streams& streams, 434 const MediaSessionOptions::Streams& streams,
436 StreamParamsVec* current_streams, 435 StreamParamsVec* current_streams,
437 MediaContentDescriptionImpl<C>* content_description, 436 MediaContentDescriptionImpl<C>* content_description,
438 const bool add_legacy_stream) { 437 const bool add_legacy_stream) {
439 const bool include_rtx_streams = 438 const bool include_rtx_streams =
440 ContainsRtxCodec(content_description->codecs()); 439 ContainsRtxCodec(content_description->codecs());
441 440
442 if (streams.empty() && add_legacy_stream) { 441 if (streams.empty() && add_legacy_stream) {
443 // TODO(perkj): Remove this legacy stream when all apps use StreamParams. 442 // TODO(perkj): Remove this legacy stream when all apps use StreamParams.
444 std::vector<uint32> ssrcs; 443 std::vector<uint32_t> ssrcs;
445 if (IsSctp(content_description)) { 444 if (IsSctp(content_description)) {
446 GenerateSctpSids(*current_streams, &ssrcs); 445 GenerateSctpSids(*current_streams, &ssrcs);
447 } else { 446 } else {
448 int num_ssrcs = include_rtx_streams ? 2 : 1; 447 int num_ssrcs = include_rtx_streams ? 2 : 1;
449 GenerateSsrcs(*current_streams, num_ssrcs, &ssrcs); 448 GenerateSsrcs(*current_streams, num_ssrcs, &ssrcs);
450 } 449 }
451 if (include_rtx_streams) { 450 if (include_rtx_streams) {
452 content_description->AddLegacyStream(ssrcs[0], ssrcs[1]); 451 content_description->AddLegacyStream(ssrcs[0], ssrcs[1]);
453 content_description->set_multistream(true); 452 content_description->set_multistream(true);
454 } else { 453 } else {
(...skipping 14 matching lines...) Expand all
469 // MediaSessionDescriptionFactory. 468 // MediaSessionDescriptionFactory.
470 if (!param) { 469 if (!param) {
471 // This is a new stream. 470 // This is a new stream.
472 // Get a CNAME. Either new or same as one of the other synched streams. 471 // Get a CNAME. Either new or same as one of the other synched streams.
473 std::string cname; 472 std::string cname;
474 if (!GenerateCname(*current_streams, streams, stream_it->sync_label, 473 if (!GenerateCname(*current_streams, streams, stream_it->sync_label,
475 &cname)) { 474 &cname)) {
476 return false; 475 return false;
477 } 476 }
478 477
479 std::vector<uint32> ssrcs; 478 std::vector<uint32_t> ssrcs;
480 if (IsSctp(content_description)) { 479 if (IsSctp(content_description)) {
481 GenerateSctpSids(*current_streams, &ssrcs); 480 GenerateSctpSids(*current_streams, &ssrcs);
482 } else { 481 } else {
483 GenerateSsrcs(*current_streams, stream_it->num_sim_layers, &ssrcs); 482 GenerateSsrcs(*current_streams, stream_it->num_sim_layers, &ssrcs);
484 } 483 }
485 StreamParams stream_param; 484 StreamParams stream_param;
486 stream_param.id = stream_it->id; 485 stream_param.id = stream_it->id;
487 // Add the generated ssrc. 486 // Add the generated ssrc.
488 for (size_t i = 0; i < ssrcs.size(); ++i) { 487 for (size_t i = 0; i < ssrcs.size(); ++i) {
489 stream_param.ssrcs.push_back(ssrcs[i]); 488 stream_param.ssrcs.push_back(ssrcs[i]);
490 } 489 }
491 if (stream_it->num_sim_layers > 1) { 490 if (stream_it->num_sim_layers > 1) {
492 SsrcGroup group(kSimSsrcGroupSemantics, stream_param.ssrcs); 491 SsrcGroup group(kSimSsrcGroupSemantics, stream_param.ssrcs);
493 stream_param.ssrc_groups.push_back(group); 492 stream_param.ssrc_groups.push_back(group);
494 } 493 }
495 // Generate extra ssrcs for include_rtx_streams case. 494 // Generate extra ssrcs for include_rtx_streams case.
496 if (include_rtx_streams) { 495 if (include_rtx_streams) {
497 // Generate an RTX ssrc for every ssrc in the group. 496 // Generate an RTX ssrc for every ssrc in the group.
498 std::vector<uint32> rtx_ssrcs; 497 std::vector<uint32_t> rtx_ssrcs;
499 GenerateSsrcs(*current_streams, static_cast<int>(ssrcs.size()), 498 GenerateSsrcs(*current_streams, static_cast<int>(ssrcs.size()),
500 &rtx_ssrcs); 499 &rtx_ssrcs);
501 for (size_t i = 0; i < ssrcs.size(); ++i) { 500 for (size_t i = 0; i < ssrcs.size(); ++i) {
502 stream_param.AddFidSsrc(ssrcs[i], rtx_ssrcs[i]); 501 stream_param.AddFidSsrc(ssrcs[i], rtx_ssrcs[i]);
503 } 502 }
504 content_description->set_multistream(true); 503 content_description->set_multistream(true);
505 } 504 }
506 stream_param.cname = cname; 505 stream_param.cname = cname;
507 stream_param.sync_label = stream_it->sync_label; 506 stream_param.sync_label = stream_it->sync_label;
508 content_description->AddStream(stream_param); 507 content_description->AddStream(stream_param);
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); 1901 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO));
1903 } 1902 }
1904 1903
1905 const DataContentDescription* GetFirstDataContentDescription( 1904 const DataContentDescription* GetFirstDataContentDescription(
1906 const SessionDescription* sdesc) { 1905 const SessionDescription* sdesc) {
1907 return static_cast<const DataContentDescription*>( 1906 return static_cast<const DataContentDescription*>(
1908 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); 1907 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA));
1909 } 1908 }
1910 1909
1911 } // namespace cricket 1910 } // namespace cricket
OLDNEW
« no previous file with comments | « talk/session/media/mediasession.h ('k') | talk/session/media/mediasession_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698