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