OLD | NEW |
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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 SetOptions(options); | 445 SetOptions(options); |
446 } | 446 } |
447 | 447 |
448 ~FakeVideoMediaChannel(); | 448 ~FakeVideoMediaChannel(); |
449 | 449 |
450 const std::vector<VideoCodec>& recv_codecs() const { return recv_codecs_; } | 450 const std::vector<VideoCodec>& recv_codecs() const { return recv_codecs_; } |
451 const std::vector<VideoCodec>& send_codecs() const { return send_codecs_; } | 451 const std::vector<VideoCodec>& send_codecs() const { return send_codecs_; } |
452 const std::vector<VideoCodec>& codecs() const { return send_codecs(); } | 452 const std::vector<VideoCodec>& codecs() const { return send_codecs(); } |
453 bool rendering() const { return playout(); } | 453 bool rendering() const { return playout(); } |
454 const VideoOptions& options() const { return options_; } | 454 const VideoOptions& options() const { return options_; } |
455 const std::map<uint32_t, VideoRenderer*>& renderers() const { | 455 const std::map<uint32_t, rtc::VideoSinkInterface<VideoFrame>*>& sinks() |
456 return renderers_; | 456 const { |
| 457 return sinks_; |
457 } | 458 } |
458 int max_bps() const { return max_bps_; } | 459 int max_bps() const { return max_bps_; } |
459 virtual bool SetSendParameters(const VideoSendParameters& params) { | 460 virtual bool SetSendParameters(const VideoSendParameters& params) { |
460 return (SetSendCodecs(params.codecs) && | 461 return (SetSendCodecs(params.codecs) && |
461 SetSendRtpHeaderExtensions(params.extensions) && | 462 SetSendRtpHeaderExtensions(params.extensions) && |
462 SetMaxSendBandwidth(params.max_bandwidth_bps) && | 463 SetMaxSendBandwidth(params.max_bandwidth_bps) && |
463 SetOptions(params.options)); | 464 SetOptions(params.options)); |
464 } | 465 } |
465 | 466 |
466 virtual bool SetRecvParameters(const VideoRecvParameters& params) { | 467 virtual bool SetRecvParameters(const VideoRecvParameters& params) { |
467 return (SetRecvCodecs(params.codecs) && | 468 return (SetRecvCodecs(params.codecs) && |
468 SetRecvRtpHeaderExtensions(params.extensions)); | 469 SetRecvRtpHeaderExtensions(params.extensions)); |
469 } | 470 } |
470 virtual bool AddSendStream(const StreamParams& sp) { | 471 virtual bool AddSendStream(const StreamParams& sp) { |
471 return RtpHelper<VideoMediaChannel>::AddSendStream(sp); | 472 return RtpHelper<VideoMediaChannel>::AddSendStream(sp); |
472 } | 473 } |
473 virtual bool RemoveSendStream(uint32_t ssrc) { | 474 virtual bool RemoveSendStream(uint32_t ssrc) { |
474 return RtpHelper<VideoMediaChannel>::RemoveSendStream(ssrc); | 475 return RtpHelper<VideoMediaChannel>::RemoveSendStream(ssrc); |
475 } | 476 } |
476 | 477 |
477 virtual bool GetSendCodec(VideoCodec* send_codec) { | 478 virtual bool GetSendCodec(VideoCodec* send_codec) { |
478 if (send_codecs_.empty()) { | 479 if (send_codecs_.empty()) { |
479 return false; | 480 return false; |
480 } | 481 } |
481 *send_codec = send_codecs_[0]; | 482 *send_codec = send_codecs_[0]; |
482 return true; | 483 return true; |
483 } | 484 } |
484 virtual bool SetRenderer(uint32_t ssrc, VideoRenderer* r) { | 485 bool SetSink(uint32_t ssrc, |
485 if (ssrc != 0 && renderers_.find(ssrc) == renderers_.end()) { | 486 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override { |
| 487 if (ssrc != 0 && sinks_.find(ssrc) == sinks_.end()) { |
486 return false; | 488 return false; |
487 } | 489 } |
488 if (ssrc != 0) { | 490 if (ssrc != 0) { |
489 renderers_[ssrc] = r; | 491 sinks_[ssrc] = sink; |
490 } | 492 } |
491 return true; | 493 return true; |
492 } | 494 } |
493 | 495 |
494 virtual bool SetSend(bool send) { return set_sending(send); } | 496 virtual bool SetSend(bool send) { return set_sending(send); } |
495 virtual bool SetVideoSend(uint32_t ssrc, bool enable, | 497 virtual bool SetVideoSend(uint32_t ssrc, bool enable, |
496 const VideoOptions* options) { | 498 const VideoOptions* options) { |
497 if (!RtpHelper<VideoMediaChannel>::MuteStream(ssrc, !enable)) { | 499 if (!RtpHelper<VideoMediaChannel>::MuteStream(ssrc, !enable)) { |
498 return false; | 500 return false; |
499 } | 501 } |
500 if (enable && options) { | 502 if (enable && options) { |
501 return SetOptions(*options); | 503 return SetOptions(*options); |
502 } | 504 } |
503 return true; | 505 return true; |
504 } | 506 } |
505 virtual bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) { | 507 virtual bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) { |
506 capturers_[ssrc] = capturer; | 508 capturers_[ssrc] = capturer; |
507 return true; | 509 return true; |
508 } | 510 } |
509 bool HasCapturer(uint32_t ssrc) const { | 511 bool HasCapturer(uint32_t ssrc) const { |
510 return capturers_.find(ssrc) != capturers_.end(); | 512 return capturers_.find(ssrc) != capturers_.end(); |
511 } | 513 } |
512 virtual bool AddRecvStream(const StreamParams& sp) { | 514 virtual bool AddRecvStream(const StreamParams& sp) { |
513 if (!RtpHelper<VideoMediaChannel>::AddRecvStream(sp)) | 515 if (!RtpHelper<VideoMediaChannel>::AddRecvStream(sp)) |
514 return false; | 516 return false; |
515 renderers_[sp.first_ssrc()] = NULL; | 517 sinks_[sp.first_ssrc()] = NULL; |
516 return true; | 518 return true; |
517 } | 519 } |
518 virtual bool RemoveRecvStream(uint32_t ssrc) { | 520 virtual bool RemoveRecvStream(uint32_t ssrc) { |
519 if (!RtpHelper<VideoMediaChannel>::RemoveRecvStream(ssrc)) | 521 if (!RtpHelper<VideoMediaChannel>::RemoveRecvStream(ssrc)) |
520 return false; | 522 return false; |
521 renderers_.erase(ssrc); | 523 sinks_.erase(ssrc); |
522 return true; | 524 return true; |
523 } | 525 } |
524 | 526 |
525 virtual bool GetStats(VideoMediaInfo* info) { return false; } | 527 virtual bool GetStats(VideoMediaInfo* info) { return false; } |
526 | 528 |
527 private: | 529 private: |
528 bool SetRecvCodecs(const std::vector<VideoCodec>& codecs) { | 530 bool SetRecvCodecs(const std::vector<VideoCodec>& codecs) { |
529 if (fail_set_recv_codecs()) { | 531 if (fail_set_recv_codecs()) { |
530 // Fake the failure in SetRecvCodecs. | 532 // Fake the failure in SetRecvCodecs. |
531 return false; | 533 return false; |
(...skipping 15 matching lines...) Expand all Loading... |
547 return true; | 549 return true; |
548 } | 550 } |
549 bool SetMaxSendBandwidth(int bps) { | 551 bool SetMaxSendBandwidth(int bps) { |
550 max_bps_ = bps; | 552 max_bps_ = bps; |
551 return true; | 553 return true; |
552 } | 554 } |
553 | 555 |
554 FakeVideoEngine* engine_; | 556 FakeVideoEngine* engine_; |
555 std::vector<VideoCodec> recv_codecs_; | 557 std::vector<VideoCodec> recv_codecs_; |
556 std::vector<VideoCodec> send_codecs_; | 558 std::vector<VideoCodec> send_codecs_; |
557 std::map<uint32_t, VideoRenderer*> renderers_; | 559 std::map<uint32_t, rtc::VideoSinkInterface<VideoFrame>*> sinks_; |
558 std::map<uint32_t, VideoCapturer*> capturers_; | 560 std::map<uint32_t, VideoCapturer*> capturers_; |
559 VideoOptions options_; | 561 VideoOptions options_; |
560 int max_bps_; | 562 int max_bps_; |
561 }; | 563 }; |
562 | 564 |
563 class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> { | 565 class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> { |
564 public: | 566 public: |
565 explicit FakeDataMediaChannel(void* unused, const DataOptions& options) | 567 explicit FakeDataMediaChannel(void* unused, const DataOptions& options) |
566 : send_blocked_(false), max_bps_(-1) {} | 568 : send_blocked_(false), max_bps_(-1) {} |
567 ~FakeDataMediaChannel() {} | 569 ~FakeDataMediaChannel() {} |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 | 891 |
890 private: | 892 private: |
891 std::vector<FakeDataMediaChannel*> channels_; | 893 std::vector<FakeDataMediaChannel*> channels_; |
892 std::vector<DataCodec> data_codecs_; | 894 std::vector<DataCodec> data_codecs_; |
893 DataChannelType last_channel_type_; | 895 DataChannelType last_channel_type_; |
894 }; | 896 }; |
895 | 897 |
896 } // namespace cricket | 898 } // namespace cricket |
897 | 899 |
898 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_ | 900 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_ |
OLD | NEW |