| OLD | NEW |
| 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 MediaStreamInterface* RemoteStream(const std::string& label) { | 361 MediaStreamInterface* RemoteStream(const std::string& label) { |
| 362 return remote_media_streams_->find(label); | 362 return remote_media_streams_->find(label); |
| 363 } | 363 } |
| 364 | 364 |
| 365 StreamCollectionInterface* remote_streams() const { | 365 StreamCollectionInterface* remote_streams() const { |
| 366 return remote_media_streams_; | 366 return remote_media_streams_; |
| 367 } | 367 } |
| 368 | 368 |
| 369 size_t NumberOfRemoteAudioTracks() { return remote_audio_tracks_.size(); } | 369 size_t NumberOfRemoteAudioTracks() { return remote_audio_tracks_.size(); } |
| 370 | 370 |
| 371 void VerifyRemoteAudioTrack(const std::string& stream_label, | 371 void VerifyRemoteAudioTrack(const std::string& stream_label, |
| 372 const std::string& track_id, | 372 const std::string& track_id, |
| 373 uint32 ssrc) { | 373 uint32 ssrc) { |
| 374 VerifyTrack(remote_audio_tracks_, stream_label, track_id, ssrc); | 374 VerifyTrack(remote_audio_tracks_, stream_label, track_id, ssrc); |
| 375 } | 375 } |
| 376 | 376 |
| 377 size_t NumberOfRemoteVideoTracks() { return remote_video_tracks_.size(); } | 377 size_t NumberOfRemoteVideoTracks() { return remote_video_tracks_.size(); } |
| 378 | 378 |
| 379 void VerifyRemoteVideoTrack(const std::string& stream_label, | 379 void VerifyRemoteVideoTrack(const std::string& stream_label, |
| 380 const std::string& track_id, | 380 const std::string& track_id, |
| 381 uint32 ssrc) { | 381 uint32 ssrc) { |
| 382 VerifyTrack(remote_video_tracks_, stream_label, track_id, ssrc); | 382 VerifyTrack(remote_video_tracks_, stream_label, track_id, ssrc); |
| 383 } | 383 } |
| 384 | 384 |
| 385 size_t NumberOfLocalAudioTracks() { return local_audio_tracks_.size(); } | 385 size_t NumberOfLocalAudioTracks() { return local_audio_tracks_.size(); } |
| 386 void VerifyLocalAudioTrack(const std::string& stream_label, | 386 void VerifyLocalAudioTrack(const std::string& stream_label, |
| 387 const std::string& track_id, | 387 const std::string& track_id, |
| 388 uint32 ssrc) { | 388 uint32 ssrc) { |
| 389 VerifyTrack(local_audio_tracks_, stream_label, track_id, ssrc); | 389 VerifyTrack(local_audio_tracks_, stream_label, track_id, ssrc); |
| 390 } | 390 } |
| 391 | 391 |
| 392 size_t NumberOfLocalVideoTracks() { return local_video_tracks_.size(); } | 392 size_t NumberOfLocalVideoTracks() { return local_video_tracks_.size(); } |
| 393 | 393 |
| 394 void VerifyLocalVideoTrack(const std::string& stream_label, | 394 void VerifyLocalVideoTrack(const std::string& stream_label, |
| 395 const std::string& track_id, | 395 const std::string& track_id, |
| 396 uint32 ssrc) { | 396 uint32 ssrc) { |
| 397 VerifyTrack(local_video_tracks_, stream_label, track_id, ssrc); | 397 VerifyTrack(local_video_tracks_, stream_label, track_id, ssrc); |
| 398 } | 398 } |
| 399 | 399 |
| 400 private: | 400 private: |
| 401 struct TrackInfo { | 401 struct TrackInfo { |
| 402 TrackInfo() {} | 402 TrackInfo() {} |
| 403 TrackInfo(const std::string& stream_label, const std::string track_id, | 403 TrackInfo(const std::string& stream_label, |
| 404 const std::string track_id, |
| 404 uint32 ssrc) | 405 uint32 ssrc) |
| 405 : stream_label(stream_label), | 406 : stream_label(stream_label), track_id(track_id), ssrc(ssrc) {} |
| 406 track_id(track_id), | |
| 407 ssrc(ssrc) { | |
| 408 } | |
| 409 std::string stream_label; | 407 std::string stream_label; |
| 410 std::string track_id; | 408 std::string track_id; |
| 411 uint32 ssrc; | 409 uint32 ssrc; |
| 412 }; | 410 }; |
| 413 typedef std::vector<TrackInfo> TrackInfos; | 411 typedef std::vector<TrackInfo> TrackInfos; |
| 414 | 412 |
| 415 void AddTrack(TrackInfos* track_infos, MediaStreamInterface* stream, | 413 void AddTrack(TrackInfos* track_infos, |
| 414 MediaStreamInterface* stream, |
| 416 MediaStreamTrackInterface* track, | 415 MediaStreamTrackInterface* track, |
| 417 uint32 ssrc) { | 416 uint32 ssrc) { |
| 418 (*track_infos).push_back(TrackInfo(stream->label(), track->id(), | 417 (*track_infos).push_back(TrackInfo(stream->label(), track->id(), ssrc)); |
| 419 ssrc)); | |
| 420 } | 418 } |
| 421 | 419 |
| 422 void RemoveTrack(TrackInfos* track_infos, MediaStreamInterface* stream, | 420 void RemoveTrack(TrackInfos* track_infos, MediaStreamInterface* stream, |
| 423 MediaStreamTrackInterface* track) { | 421 MediaStreamTrackInterface* track) { |
| 424 for (TrackInfos::iterator it = track_infos->begin(); | 422 for (TrackInfos::iterator it = track_infos->begin(); |
| 425 it != track_infos->end(); ++it) { | 423 it != track_infos->end(); ++it) { |
| 426 if (it->stream_label == stream->label() && it->track_id == track->id()) { | 424 if (it->stream_label == stream->label() && it->track_id == track->id()) { |
| 427 track_infos->erase(it); | 425 track_infos->erase(it); |
| 428 return; | 426 return; |
| 429 } | 427 } |
| 430 } | 428 } |
| 431 ADD_FAILURE(); | 429 ADD_FAILURE(); |
| 432 } | 430 } |
| 433 | 431 |
| 434 const TrackInfo* FindTrackInfo(const TrackInfos& infos, | 432 const TrackInfo* FindTrackInfo(const TrackInfos& infos, |
| 435 const std::string& stream_label, | 433 const std::string& stream_label, |
| 436 const std::string track_id) const { | 434 const std::string track_id) const { |
| 437 for (TrackInfos::const_iterator it = infos.begin(); | 435 for (TrackInfos::const_iterator it = infos.begin(); |
| 438 it != infos.end(); ++it) { | 436 it != infos.end(); ++it) { |
| 439 if (it->stream_label == stream_label && it->track_id == track_id) | 437 if (it->stream_label == stream_label && it->track_id == track_id) |
| 440 return &*it; | 438 return &*it; |
| 441 } | 439 } |
| 442 return NULL; | 440 return NULL; |
| 443 } | 441 } |
| 444 | 442 |
| 445 | |
| 446 void VerifyTrack(const TrackInfos& track_infos, | 443 void VerifyTrack(const TrackInfos& track_infos, |
| 447 const std::string& stream_label, | 444 const std::string& stream_label, |
| 448 const std::string& track_id, | 445 const std::string& track_id, |
| 449 uint32 ssrc) { | 446 uint32 ssrc) { |
| 450 const TrackInfo* track_info = FindTrackInfo(track_infos, | 447 const TrackInfo* track_info = FindTrackInfo(track_infos, |
| 451 stream_label, | 448 stream_label, |
| 452 track_id); | 449 track_id); |
| 453 ASSERT_TRUE(track_info != NULL); | 450 ASSERT_TRUE(track_info != NULL); |
| 454 EXPECT_EQ(ssrc, track_info->ssrc); | 451 EXPECT_EQ(ssrc, track_info->ssrc); |
| 455 } | 452 } |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 webrtc::WriteDataChannelOpenMessage("a", config, &payload); | 1334 webrtc::WriteDataChannelOpenMessage("a", config, &payload); |
| 1338 cricket::ReceiveDataParams params; | 1335 cricket::ReceiveDataParams params; |
| 1339 params.ssrc = config.id; | 1336 params.ssrc = config.id; |
| 1340 EXPECT_TRUE(signaling_->AddDataChannelFromOpenMessage(params, payload)); | 1337 EXPECT_TRUE(signaling_->AddDataChannelFromOpenMessage(params, payload)); |
| 1341 EXPECT_TRUE(signaling_->HasDataChannels()); | 1338 EXPECT_TRUE(signaling_->HasDataChannels()); |
| 1342 | 1339 |
| 1343 // Removes the DataChannel and verifies that no DataChannel is left. | 1340 // Removes the DataChannel and verifies that no DataChannel is left. |
| 1344 signaling_->RemoveSctpDataChannel(config.id); | 1341 signaling_->RemoveSctpDataChannel(config.id); |
| 1345 EXPECT_FALSE(signaling_->HasDataChannels()); | 1342 EXPECT_FALSE(signaling_->HasDataChannels()); |
| 1346 } | 1343 } |
| OLD | NEW |