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