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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, VideoRenderer*>& renderers() const { |
456 return renderers_; | 456 return renderers_; |
457 } | 457 } |
458 int max_bps() const { return max_bps_; } | 458 int max_bps() const { return max_bps_; } |
459 bool GetSendStreamFormat(uint32_t ssrc, VideoFormat* format) { | |
460 if (send_formats_.find(ssrc) == send_formats_.end()) { | |
461 return false; | |
462 } | |
463 *format = send_formats_[ssrc]; | |
464 return true; | |
465 } | |
466 virtual bool SetSendStreamFormat(uint32_t ssrc, const VideoFormat& format) { | |
467 if (send_formats_.find(ssrc) == send_formats_.end()) { | |
468 return false; | |
469 } | |
470 send_formats_[ssrc] = format; | |
471 return true; | |
472 } | |
473 virtual bool SetSendParameters(const VideoSendParameters& params) { | 459 virtual bool SetSendParameters(const VideoSendParameters& params) { |
474 return (SetSendCodecs(params.codecs) && | 460 return (SetSendCodecs(params.codecs) && |
475 SetSendRtpHeaderExtensions(params.extensions) && | 461 SetSendRtpHeaderExtensions(params.extensions) && |
476 SetMaxSendBandwidth(params.max_bandwidth_bps) && | 462 SetMaxSendBandwidth(params.max_bandwidth_bps) && |
477 SetOptions(params.options)); | 463 SetOptions(params.options)); |
478 } | 464 } |
479 | 465 |
480 virtual bool SetRecvParameters(const VideoRecvParameters& params) { | 466 virtual bool SetRecvParameters(const VideoRecvParameters& params) { |
481 return (SetRecvCodecs(params.codecs) && | 467 return (SetRecvCodecs(params.codecs) && |
482 SetRecvRtpHeaderExtensions(params.extensions)); | 468 SetRecvRtpHeaderExtensions(params.extensions)); |
483 } | 469 } |
484 virtual bool AddSendStream(const StreamParams& sp) { | 470 virtual bool AddSendStream(const StreamParams& sp) { |
485 if (!RtpHelper<VideoMediaChannel>::AddSendStream(sp)) { | 471 return RtpHelper<VideoMediaChannel>::AddSendStream(sp); |
486 return false; | |
487 } | |
488 SetSendStreamDefaultFormat(sp.first_ssrc()); | |
489 return true; | |
490 } | 472 } |
491 virtual bool RemoveSendStream(uint32_t ssrc) { | 473 virtual bool RemoveSendStream(uint32_t ssrc) { |
492 send_formats_.erase(ssrc); | |
493 return RtpHelper<VideoMediaChannel>::RemoveSendStream(ssrc); | 474 return RtpHelper<VideoMediaChannel>::RemoveSendStream(ssrc); |
494 } | 475 } |
495 | 476 |
496 virtual bool GetSendCodec(VideoCodec* send_codec) { | 477 virtual bool GetSendCodec(VideoCodec* send_codec) { |
497 if (send_codecs_.empty()) { | 478 if (send_codecs_.empty()) { |
498 return false; | 479 return false; |
499 } | 480 } |
500 *send_codec = send_codecs_[0]; | 481 *send_codec = send_codecs_[0]; |
501 return true; | 482 return true; |
502 } | 483 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 recv_codecs_ = codecs; | 533 recv_codecs_ = codecs; |
553 return true; | 534 return true; |
554 } | 535 } |
555 bool SetSendCodecs(const std::vector<VideoCodec>& codecs) { | 536 bool SetSendCodecs(const std::vector<VideoCodec>& codecs) { |
556 if (fail_set_send_codecs()) { | 537 if (fail_set_send_codecs()) { |
557 // Fake the failure in SetSendCodecs. | 538 // Fake the failure in SetSendCodecs. |
558 return false; | 539 return false; |
559 } | 540 } |
560 send_codecs_ = codecs; | 541 send_codecs_ = codecs; |
561 | 542 |
562 for (std::vector<StreamParams>::const_iterator it = send_streams().begin(); | |
563 it != send_streams().end(); ++it) { | |
564 SetSendStreamDefaultFormat(it->first_ssrc()); | |
565 } | |
566 return true; | 543 return true; |
567 } | 544 } |
568 bool SetOptions(const VideoOptions& options) { | 545 bool SetOptions(const VideoOptions& options) { |
569 options_ = options; | 546 options_ = options; |
570 return true; | 547 return true; |
571 } | 548 } |
572 bool SetMaxSendBandwidth(int bps) { | 549 bool SetMaxSendBandwidth(int bps) { |
573 max_bps_ = bps; | 550 max_bps_ = bps; |
574 return true; | 551 return true; |
575 } | 552 } |
576 | 553 |
577 // Be default, each send stream uses the first send codec format. | |
578 void SetSendStreamDefaultFormat(uint32_t ssrc) { | |
579 if (!send_codecs_.empty()) { | |
580 send_formats_[ssrc] = VideoFormat( | |
581 send_codecs_[0].width, send_codecs_[0].height, | |
582 cricket::VideoFormat::FpsToInterval(send_codecs_[0].framerate), | |
583 cricket::FOURCC_I420); | |
584 } | |
585 } | |
586 | |
587 FakeVideoEngine* engine_; | 554 FakeVideoEngine* engine_; |
588 std::vector<VideoCodec> recv_codecs_; | 555 std::vector<VideoCodec> recv_codecs_; |
589 std::vector<VideoCodec> send_codecs_; | 556 std::vector<VideoCodec> send_codecs_; |
590 std::map<uint32_t, VideoRenderer*> renderers_; | 557 std::map<uint32_t, VideoRenderer*> renderers_; |
591 std::map<uint32_t, VideoFormat> send_formats_; | |
592 std::map<uint32_t, VideoCapturer*> capturers_; | 558 std::map<uint32_t, VideoCapturer*> capturers_; |
593 VideoOptions options_; | 559 VideoOptions options_; |
594 int max_bps_; | 560 int max_bps_; |
595 }; | 561 }; |
596 | 562 |
597 class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> { | 563 class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> { |
598 public: | 564 public: |
599 explicit FakeDataMediaChannel(void* unused, const DataOptions& options) | 565 explicit FakeDataMediaChannel(void* unused, const DataOptions& options) |
600 : send_blocked_(false), max_bps_(-1) {} | 566 : send_blocked_(false), max_bps_(-1) {} |
601 ~FakeDataMediaChannel() {} | 567 ~FakeDataMediaChannel() {} |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 | 889 |
924 private: | 890 private: |
925 std::vector<FakeDataMediaChannel*> channels_; | 891 std::vector<FakeDataMediaChannel*> channels_; |
926 std::vector<DataCodec> data_codecs_; | 892 std::vector<DataCodec> data_codecs_; |
927 DataChannelType last_channel_type_; | 893 DataChannelType last_channel_type_; |
928 }; | 894 }; |
929 | 895 |
930 } // namespace cricket | 896 } // namespace cricket |
931 | 897 |
932 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_ | 898 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_ |
OLD | NEW |