| 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 // Remote stream is no longer available. | 304 // Remote stream is no longer available. |
| 305 virtual void OnRemoveRemoteStream(MediaStreamInterface* remote_stream) { | 305 virtual void OnRemoveRemoteStream(MediaStreamInterface* remote_stream) { |
| 306 remote_media_streams_->RemoveStream(remote_stream); | 306 remote_media_streams_->RemoveStream(remote_stream); |
| 307 } | 307 } |
| 308 | 308 |
| 309 virtual void OnAddDataChannel(DataChannelInterface* data_channel) { | 309 virtual void OnAddDataChannel(DataChannelInterface* data_channel) { |
| 310 } | 310 } |
| 311 | 311 |
| 312 virtual void OnAddLocalAudioTrack(MediaStreamInterface* stream, | 312 virtual void OnAddLocalAudioTrack(MediaStreamInterface* stream, |
| 313 AudioTrackInterface* audio_track, | 313 AudioTrackInterface* audio_track, |
| 314 uint32 ssrc) { | 314 uint32_t ssrc) { |
| 315 AddTrack(&local_audio_tracks_, stream, audio_track, ssrc); | 315 AddTrack(&local_audio_tracks_, stream, audio_track, ssrc); |
| 316 } | 316 } |
| 317 | 317 |
| 318 virtual void OnAddLocalVideoTrack(MediaStreamInterface* stream, | 318 virtual void OnAddLocalVideoTrack(MediaStreamInterface* stream, |
| 319 VideoTrackInterface* video_track, | 319 VideoTrackInterface* video_track, |
| 320 uint32 ssrc) { | 320 uint32_t ssrc) { |
| 321 AddTrack(&local_video_tracks_, stream, video_track, ssrc); | 321 AddTrack(&local_video_tracks_, stream, video_track, ssrc); |
| 322 } | 322 } |
| 323 | 323 |
| 324 virtual void OnRemoveLocalAudioTrack(MediaStreamInterface* stream, | 324 virtual void OnRemoveLocalAudioTrack(MediaStreamInterface* stream, |
| 325 AudioTrackInterface* audio_track, | 325 AudioTrackInterface* audio_track, |
| 326 uint32 ssrc) { | 326 uint32_t ssrc) { |
| 327 RemoveTrack(&local_audio_tracks_, stream, audio_track); | 327 RemoveTrack(&local_audio_tracks_, stream, audio_track); |
| 328 } | 328 } |
| 329 | 329 |
| 330 virtual void OnRemoveLocalVideoTrack(MediaStreamInterface* stream, | 330 virtual void OnRemoveLocalVideoTrack(MediaStreamInterface* stream, |
| 331 VideoTrackInterface* video_track) { | 331 VideoTrackInterface* video_track) { |
| 332 RemoveTrack(&local_video_tracks_, stream, video_track); | 332 RemoveTrack(&local_video_tracks_, stream, video_track); |
| 333 } | 333 } |
| 334 | 334 |
| 335 virtual void OnAddRemoteAudioTrack(MediaStreamInterface* stream, | 335 virtual void OnAddRemoteAudioTrack(MediaStreamInterface* stream, |
| 336 AudioTrackInterface* audio_track, | 336 AudioTrackInterface* audio_track, |
| 337 uint32 ssrc) { | 337 uint32_t ssrc) { |
| 338 AddTrack(&remote_audio_tracks_, stream, audio_track, ssrc); | 338 AddTrack(&remote_audio_tracks_, stream, audio_track, ssrc); |
| 339 } | 339 } |
| 340 | 340 |
| 341 virtual void OnAddRemoteVideoTrack(MediaStreamInterface* stream, | 341 virtual void OnAddRemoteVideoTrack(MediaStreamInterface* stream, |
| 342 VideoTrackInterface* video_track, | 342 VideoTrackInterface* video_track, |
| 343 uint32 ssrc) { | 343 uint32_t ssrc) { |
| 344 AddTrack(&remote_video_tracks_, stream, video_track, ssrc); | 344 AddTrack(&remote_video_tracks_, stream, video_track, ssrc); |
| 345 } | 345 } |
| 346 | 346 |
| 347 virtual void OnRemoveRemoteAudioTrack(MediaStreamInterface* stream, | 347 virtual void OnRemoveRemoteAudioTrack(MediaStreamInterface* stream, |
| 348 AudioTrackInterface* audio_track) { | 348 AudioTrackInterface* audio_track) { |
| 349 RemoveTrack(&remote_audio_tracks_, stream, audio_track); | 349 RemoveTrack(&remote_audio_tracks_, stream, audio_track); |
| 350 } | 350 } |
| 351 | 351 |
| 352 virtual void OnRemoveRemoteVideoTrack(MediaStreamInterface* stream, | 352 virtual void OnRemoveRemoteVideoTrack(MediaStreamInterface* stream, |
| 353 VideoTrackInterface* video_track) { | 353 VideoTrackInterface* video_track) { |
| 354 RemoveTrack(&remote_video_tracks_, stream, video_track); | 354 RemoveTrack(&remote_video_tracks_, stream, video_track); |
| 355 } | 355 } |
| 356 | 356 |
| 357 virtual void OnRemoveLocalStream(MediaStreamInterface* stream) { | 357 virtual void OnRemoveLocalStream(MediaStreamInterface* stream) { |
| 358 } | 358 } |
| 359 | 359 |
| 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_t 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_t 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_t 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_t 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, | 402 TrackInfo(const std::string& stream_label, |
| 403 const std::string track_id, | 403 const std::string track_id, |
| 404 uint32 ssrc) | 404 uint32_t ssrc) |
| 405 : stream_label(stream_label), track_id(track_id), ssrc(ssrc) {} | 405 : stream_label(stream_label), track_id(track_id), ssrc(ssrc) {} |
| 406 std::string stream_label; | 406 std::string stream_label; |
| 407 std::string track_id; | 407 std::string track_id; |
| 408 uint32 ssrc; | 408 uint32_t ssrc; |
| 409 }; | 409 }; |
| 410 typedef std::vector<TrackInfo> TrackInfos; | 410 typedef std::vector<TrackInfo> TrackInfos; |
| 411 | 411 |
| 412 void AddTrack(TrackInfos* track_infos, | 412 void AddTrack(TrackInfos* track_infos, |
| 413 MediaStreamInterface* stream, | 413 MediaStreamInterface* stream, |
| 414 MediaStreamTrackInterface* track, | 414 MediaStreamTrackInterface* track, |
| 415 uint32 ssrc) { | 415 uint32_t ssrc) { |
| 416 (*track_infos).push_back(TrackInfo(stream->label(), track->id(), ssrc)); | 416 (*track_infos).push_back(TrackInfo(stream->label(), track->id(), ssrc)); |
| 417 } | 417 } |
| 418 | 418 |
| 419 void RemoveTrack(TrackInfos* track_infos, MediaStreamInterface* stream, | 419 void RemoveTrack(TrackInfos* track_infos, MediaStreamInterface* stream, |
| 420 MediaStreamTrackInterface* track) { | 420 MediaStreamTrackInterface* track) { |
| 421 for (TrackInfos::iterator it = track_infos->begin(); | 421 for (TrackInfos::iterator it = track_infos->begin(); |
| 422 it != track_infos->end(); ++it) { | 422 it != track_infos->end(); ++it) { |
| 423 if (it->stream_label == stream->label() && it->track_id == track->id()) { | 423 if (it->stream_label == stream->label() && it->track_id == track->id()) { |
| 424 track_infos->erase(it); | 424 track_infos->erase(it); |
| 425 return; | 425 return; |
| 426 } | 426 } |
| 427 } | 427 } |
| 428 ADD_FAILURE(); | 428 ADD_FAILURE(); |
| 429 } | 429 } |
| 430 | 430 |
| 431 const TrackInfo* FindTrackInfo(const TrackInfos& infos, | 431 const TrackInfo* FindTrackInfo(const TrackInfos& infos, |
| 432 const std::string& stream_label, | 432 const std::string& stream_label, |
| 433 const std::string track_id) const { | 433 const std::string track_id) const { |
| 434 for (TrackInfos::const_iterator it = infos.begin(); | 434 for (TrackInfos::const_iterator it = infos.begin(); |
| 435 it != infos.end(); ++it) { | 435 it != infos.end(); ++it) { |
| 436 if (it->stream_label == stream_label && it->track_id == track_id) | 436 if (it->stream_label == stream_label && it->track_id == track_id) |
| 437 return &*it; | 437 return &*it; |
| 438 } | 438 } |
| 439 return NULL; | 439 return NULL; |
| 440 } | 440 } |
| 441 | 441 |
| 442 void VerifyTrack(const TrackInfos& track_infos, | 442 void VerifyTrack(const TrackInfos& track_infos, |
| 443 const std::string& stream_label, | 443 const std::string& stream_label, |
| 444 const std::string& track_id, | 444 const std::string& track_id, |
| 445 uint32 ssrc) { | 445 uint32_t ssrc) { |
| 446 const TrackInfo* track_info = FindTrackInfo(track_infos, | 446 const TrackInfo* track_info = FindTrackInfo(track_infos, |
| 447 stream_label, | 447 stream_label, |
| 448 track_id); | 448 track_id); |
| 449 ASSERT_TRUE(track_info != NULL); | 449 ASSERT_TRUE(track_info != NULL); |
| 450 EXPECT_EQ(ssrc, track_info->ssrc); | 450 EXPECT_EQ(ssrc, track_info->ssrc); |
| 451 } | 451 } |
| 452 | 452 |
| 453 TrackInfos remote_audio_tracks_; | 453 TrackInfos remote_audio_tracks_; |
| 454 TrackInfos remote_video_tracks_; | 454 TrackInfos remote_video_tracks_; |
| 455 TrackInfos local_audio_tracks_; | 455 TrackInfos local_audio_tracks_; |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1332 webrtc::WriteDataChannelOpenMessage("a", config, &payload); | 1332 webrtc::WriteDataChannelOpenMessage("a", config, &payload); |
| 1333 cricket::ReceiveDataParams params; | 1333 cricket::ReceiveDataParams params; |
| 1334 params.ssrc = config.id; | 1334 params.ssrc = config.id; |
| 1335 EXPECT_TRUE(signaling_->AddDataChannelFromOpenMessage(params, payload)); | 1335 EXPECT_TRUE(signaling_->AddDataChannelFromOpenMessage(params, payload)); |
| 1336 EXPECT_TRUE(signaling_->HasDataChannels()); | 1336 EXPECT_TRUE(signaling_->HasDataChannels()); |
| 1337 | 1337 |
| 1338 // Removes the DataChannel and verifies that no DataChannel is left. | 1338 // Removes the DataChannel and verifies that no DataChannel is left. |
| 1339 signaling_->RemoveSctpDataChannel(config.id); | 1339 signaling_->RemoveSctpDataChannel(config.id); |
| 1340 EXPECT_FALSE(signaling_->HasDataChannels()); | 1340 EXPECT_FALSE(signaling_->HasDataChannels()); |
| 1341 } | 1341 } |
| OLD | NEW |