Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: webrtc/media/base/fakemediaengine.h

Issue 1646253004: Split out dscp option from VideoOptions to new struct MediaChannelOptions. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/session/media/channelmanager_unittest.cc ('k') | webrtc/media/base/mediachannel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 namespace cricket { 46 namespace cricket {
47 47
48 class FakeMediaEngine; 48 class FakeMediaEngine;
49 class FakeVideoEngine; 49 class FakeVideoEngine;
50 class FakeVoiceEngine; 50 class FakeVoiceEngine;
51 51
52 // A common helper class that handles sending and receiving RTP/RTCP packets. 52 // A common helper class that handles sending and receiving RTP/RTCP packets.
53 template <class Base> class RtpHelper : public Base { 53 template <class Base> class RtpHelper : public Base {
54 public: 54 public:
55 RtpHelper() 55 RtpHelper(const MediaChannelOptions& options)
56 : sending_(false), 56 : Base(options),
57 sending_(false),
57 playout_(false), 58 playout_(false),
58 fail_set_send_codecs_(false), 59 fail_set_send_codecs_(false),
59 fail_set_recv_codecs_(false), 60 fail_set_recv_codecs_(false),
60 send_ssrc_(0), 61 send_ssrc_(0),
61 ready_to_send_(false) {} 62 ready_to_send_(false) {}
62 const std::vector<RtpHeaderExtension>& recv_extensions() { 63 const std::vector<RtpHeaderExtension>& recv_extensions() {
63 return recv_extensions_; 64 return recv_extensions_;
64 } 65 }
65 const std::vector<RtpHeaderExtension>& send_extensions() { 66 const std::vector<RtpHeaderExtension>& send_extensions() {
66 return send_extensions_; 67 return send_extensions_;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 struct DtmfInfo { 233 struct DtmfInfo {
233 DtmfInfo(uint32_t ssrc, int event_code, int duration) 234 DtmfInfo(uint32_t ssrc, int event_code, int duration)
234 : ssrc(ssrc), 235 : ssrc(ssrc),
235 event_code(event_code), 236 event_code(event_code),
236 duration(duration) {} 237 duration(duration) {}
237 uint32_t ssrc; 238 uint32_t ssrc;
238 int event_code; 239 int event_code;
239 int duration; 240 int duration;
240 }; 241 };
241 explicit FakeVoiceMediaChannel(FakeVoiceEngine* engine, 242 explicit FakeVoiceMediaChannel(FakeVoiceEngine* engine,
242 const AudioOptions& options) 243 const MediaChannelOptions& options,
243 : engine_(engine), 244 const AudioOptions& audio_options)
245 : RtpHelper<VoiceMediaChannel>(options),
246 engine_(engine),
244 time_since_last_typing_(-1) { 247 time_since_last_typing_(-1) {
245 output_scalings_[0] = 1.0; // For default channel. 248 output_scalings_[0] = 1.0; // For default channel.
246 SetOptions(options); 249 SetOptions(audio_options);
247 } 250 }
248 ~FakeVoiceMediaChannel(); 251 ~FakeVoiceMediaChannel();
252 // TODO(nisse): Move to the VoiceMediaChannel base class? Currently
253 // duplicated in WebRtcVoiceMediaChannel.
254 rtc::DiffServCodePoint MediaTypeDscpValue() const override {
255 return rtc::DSCP_EF;
256 }
257
249 const std::vector<AudioCodec>& recv_codecs() const { return recv_codecs_; } 258 const std::vector<AudioCodec>& recv_codecs() const { return recv_codecs_; }
250 const std::vector<AudioCodec>& send_codecs() const { return send_codecs_; } 259 const std::vector<AudioCodec>& send_codecs() const { return send_codecs_; }
251 const std::vector<AudioCodec>& codecs() const { return send_codecs(); } 260 const std::vector<AudioCodec>& codecs() const { return send_codecs(); }
252 const std::vector<DtmfInfo>& dtmf_info_queue() const { 261 const std::vector<DtmfInfo>& dtmf_info_queue() const {
253 return dtmf_info_queue_; 262 return dtmf_info_queue_;
254 } 263 }
255 const AudioOptions& options() const { return options_; } 264 const AudioOptions& options() const { return options_; }
256 265
257 virtual bool SetSendParameters(const AudioSendParameters& params) { 266 virtual bool SetSendParameters(const AudioSendParameters& params) {
258 return (SetSendCodecs(params.codecs) && 267 return (SetSendCodecs(params.codecs) &&
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 uint32_t ssrc, 442 uint32_t ssrc,
434 int event_code, 443 int event_code,
435 int duration) { 444 int duration) {
436 return (info.duration == duration && info.event_code == event_code && 445 return (info.duration == duration && info.event_code == event_code &&
437 info.ssrc == ssrc); 446 info.ssrc == ssrc);
438 } 447 }
439 448
440 class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> { 449 class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
441 public: 450 public:
442 explicit FakeVideoMediaChannel(FakeVideoEngine* engine, 451 explicit FakeVideoMediaChannel(FakeVideoEngine* engine,
443 const VideoOptions& options) 452 const MediaChannelOptions& options,
444 : engine_(engine), max_bps_(-1) { 453 const VideoOptions& video_options)
445 SetOptions(options); 454 : RtpHelper<VideoMediaChannel>(options),
455 engine_(engine),
456 max_bps_(-1) {
457 SetOptions(video_options);
446 } 458 }
447 459
448 ~FakeVideoMediaChannel(); 460 ~FakeVideoMediaChannel();
449 461 // TODO(nisse): Move to the VideoMediaChannel base class? Currently
462 // duplicated in WebRtcVideoChannel2.
463 rtc::DiffServCodePoint MediaTypeDscpValue() const override {
464 return rtc::DSCP_AF41;
465 }
450 const std::vector<VideoCodec>& recv_codecs() const { return recv_codecs_; } 466 const std::vector<VideoCodec>& recv_codecs() const { return recv_codecs_; }
451 const std::vector<VideoCodec>& send_codecs() const { return send_codecs_; } 467 const std::vector<VideoCodec>& send_codecs() const { return send_codecs_; }
452 const std::vector<VideoCodec>& codecs() const { return send_codecs(); } 468 const std::vector<VideoCodec>& codecs() const { return send_codecs(); }
453 bool rendering() const { return playout(); } 469 bool rendering() const { return playout(); }
454 const VideoOptions& options() const { return options_; } 470 const VideoOptions& options() const { return options_; }
455 const std::map<uint32_t, rtc::VideoSinkInterface<VideoFrame>*>& sinks() 471 const std::map<uint32_t, rtc::VideoSinkInterface<VideoFrame>*>& sinks()
456 const { 472 const {
457 return sinks_; 473 return sinks_;
458 } 474 }
459 int max_bps() const { return max_bps_; } 475 int max_bps() const { return max_bps_; }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 std::vector<VideoCodec> recv_codecs_; 573 std::vector<VideoCodec> recv_codecs_;
558 std::vector<VideoCodec> send_codecs_; 574 std::vector<VideoCodec> send_codecs_;
559 std::map<uint32_t, rtc::VideoSinkInterface<VideoFrame>*> sinks_; 575 std::map<uint32_t, rtc::VideoSinkInterface<VideoFrame>*> sinks_;
560 std::map<uint32_t, VideoCapturer*> capturers_; 576 std::map<uint32_t, VideoCapturer*> capturers_;
561 VideoOptions options_; 577 VideoOptions options_;
562 int max_bps_; 578 int max_bps_;
563 }; 579 };
564 580
565 class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> { 581 class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> {
566 public: 582 public:
567 explicit FakeDataMediaChannel(void* unused, const DataOptions& options) 583 explicit FakeDataMediaChannel(void* unused,
568 : send_blocked_(false), max_bps_(-1) {} 584 const MediaChannelOptions& options,
585 const DataOptions& data_options)
586 : RtpHelper<DataMediaChannel>(options),
587 send_blocked_(false), max_bps_(-1) {}
569 ~FakeDataMediaChannel() {} 588 ~FakeDataMediaChannel() {}
570 const std::vector<DataCodec>& recv_codecs() const { return recv_codecs_; } 589 const std::vector<DataCodec>& recv_codecs() const { return recv_codecs_; }
571 const std::vector<DataCodec>& send_codecs() const { return send_codecs_; } 590 const std::vector<DataCodec>& send_codecs() const { return send_codecs_; }
572 const std::vector<DataCodec>& codecs() const { return send_codecs(); } 591 const std::vector<DataCodec>& codecs() const { return send_codecs(); }
573 int max_bps() const { return max_bps_; } 592 int max_bps() const { return max_bps_; }
574 593
575 virtual bool SetSendParameters(const DataSendParameters& params) { 594 virtual bool SetSendParameters(const DataSendParameters& params) {
576 return (SetSendCodecs(params.codecs) && 595 return (SetSendCodecs(params.codecs) &&
577 SetMaxSendBandwidth(params.max_bandwidth_bps)); 596 SetMaxSendBandwidth(params.max_bandwidth_bps));
578 } 597 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 // sanity checks against that. 694 // sanity checks against that.
676 codecs_.push_back(AudioCodec(101, "fake_audio_codec", 0, 0, 1, 0)); 695 codecs_.push_back(AudioCodec(101, "fake_audio_codec", 0, 0, 1, 0));
677 } 696 }
678 bool Init(rtc::Thread* worker_thread) { return true; } 697 bool Init(rtc::Thread* worker_thread) { return true; }
679 void Terminate() {} 698 void Terminate() {}
680 rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const { 699 rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const {
681 return rtc::scoped_refptr<webrtc::AudioState>(); 700 return rtc::scoped_refptr<webrtc::AudioState>();
682 } 701 }
683 702
684 VoiceMediaChannel* CreateChannel(webrtc::Call* call, 703 VoiceMediaChannel* CreateChannel(webrtc::Call* call,
685 const AudioOptions& options) { 704 const MediaChannelOptions& options,
705 const AudioOptions& audio_options) {
686 if (fail_create_channel_) { 706 if (fail_create_channel_) {
687 return nullptr; 707 return nullptr;
688 } 708 }
689 709
690 FakeVoiceMediaChannel* ch = new FakeVoiceMediaChannel(this, options); 710 FakeVoiceMediaChannel* ch =
711 new FakeVoiceMediaChannel(this, options, audio_options);
691 channels_.push_back(ch); 712 channels_.push_back(ch);
692 return ch; 713 return ch;
693 } 714 }
694 FakeVoiceMediaChannel* GetChannel(size_t index) { 715 FakeVoiceMediaChannel* GetChannel(size_t index) {
695 return (channels_.size() > index) ? channels_[index] : NULL; 716 return (channels_.size() > index) ? channels_[index] : NULL;
696 } 717 }
697 void UnregisterChannel(VoiceMediaChannel* channel) { 718 void UnregisterChannel(VoiceMediaChannel* channel) {
698 channels_.erase(std::find(channels_.begin(), channels_.end(), channel)); 719 channels_.erase(std::find(channels_.begin(), channels_.end(), channel));
699 } 720 }
700 721
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 codecs_.push_back(VideoCodec(0, "fake_video_codec", 0, 0, 0, 0)); 759 codecs_.push_back(VideoCodec(0, "fake_video_codec", 0, 0, 0, 0));
739 } 760 }
740 void Init() {} 761 void Init() {}
741 bool SetOptions(const VideoOptions& options) { 762 bool SetOptions(const VideoOptions& options) {
742 options_ = options; 763 options_ = options;
743 options_changed_ = true; 764 options_changed_ = true;
744 return true; 765 return true;
745 } 766 }
746 767
747 VideoMediaChannel* CreateChannel(webrtc::Call* call, 768 VideoMediaChannel* CreateChannel(webrtc::Call* call,
748 const VideoOptions& options) { 769 const MediaChannelOptions& options,
770 const VideoOptions& video_options) {
749 if (fail_create_channel_) { 771 if (fail_create_channel_) {
750 return NULL; 772 return NULL;
751 } 773 }
752 774
753 FakeVideoMediaChannel* ch = new FakeVideoMediaChannel(this, options); 775 FakeVideoMediaChannel* ch =
776 new FakeVideoMediaChannel(this, options, video_options);
754 channels_.push_back(ch); 777 channels_.push_back(ch);
755 return ch; 778 return ch;
756 } 779 }
757 FakeVideoMediaChannel* GetChannel(size_t index) { 780 FakeVideoMediaChannel* GetChannel(size_t index) {
758 return (channels_.size() > index) ? channels_[index] : NULL; 781 return (channels_.size() > index) ? channels_[index] : NULL;
759 } 782 }
760 void UnregisterChannel(VideoMediaChannel* channel) { 783 void UnregisterChannel(VideoMediaChannel* channel) {
761 channels_.erase(std::find(channels_.begin(), channels_.end(), channel)); 784 channels_.erase(std::find(channels_.begin(), channels_.end(), channel));
762 } 785 }
763 786
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 engine_->UnregisterChannel(this); 876 engine_->UnregisterChannel(this);
854 } 877 }
855 } 878 }
856 879
857 class FakeDataEngine : public DataEngineInterface { 880 class FakeDataEngine : public DataEngineInterface {
858 public: 881 public:
859 FakeDataEngine() : last_channel_type_(DCT_NONE) {} 882 FakeDataEngine() : last_channel_type_(DCT_NONE) {}
860 883
861 virtual DataMediaChannel* CreateChannel(DataChannelType data_channel_type) { 884 virtual DataMediaChannel* CreateChannel(DataChannelType data_channel_type) {
862 last_channel_type_ = data_channel_type; 885 last_channel_type_ = data_channel_type;
863 FakeDataMediaChannel* ch = new FakeDataMediaChannel(this, DataOptions()); 886 FakeDataMediaChannel* ch =
887 new FakeDataMediaChannel(this, MediaChannelOptions(), DataOptions());
864 channels_.push_back(ch); 888 channels_.push_back(ch);
865 return ch; 889 return ch;
866 } 890 }
867 891
868 FakeDataMediaChannel* GetChannel(size_t index) { 892 FakeDataMediaChannel* GetChannel(size_t index) {
869 return (channels_.size() > index) ? channels_[index] : NULL; 893 return (channels_.size() > index) ? channels_[index] : NULL;
870 } 894 }
871 895
872 void UnregisterChannel(DataMediaChannel* channel) { 896 void UnregisterChannel(DataMediaChannel* channel) {
873 channels_.erase(std::find(channels_.begin(), channels_.end(), channel)); 897 channels_.erase(std::find(channels_.begin(), channels_.end(), channel));
874 } 898 }
875 899
876 virtual void SetDataCodecs(const std::vector<DataCodec>& data_codecs) { 900 virtual void SetDataCodecs(const std::vector<DataCodec>& data_codecs) {
877 data_codecs_ = data_codecs; 901 data_codecs_ = data_codecs;
878 } 902 }
879 903
880 virtual const std::vector<DataCodec>& data_codecs() { return data_codecs_; } 904 virtual const std::vector<DataCodec>& data_codecs() { return data_codecs_; }
881 905
882 DataChannelType last_channel_type() const { return last_channel_type_; } 906 DataChannelType last_channel_type() const { return last_channel_type_; }
883 907
884 private: 908 private:
885 std::vector<FakeDataMediaChannel*> channels_; 909 std::vector<FakeDataMediaChannel*> channels_;
886 std::vector<DataCodec> data_codecs_; 910 std::vector<DataCodec> data_codecs_;
887 DataChannelType last_channel_type_; 911 DataChannelType last_channel_type_;
888 }; 912 };
889 913
890 } // namespace cricket 914 } // namespace cricket
891 915
892 #endif // WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_ 916 #endif // WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_
OLDNEW
« no previous file with comments | « talk/session/media/channelmanager_unittest.cc ('k') | webrtc/media/base/mediachannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698