| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 uint32_t ssrc) override; | 96 uint32_t ssrc) override; |
| 97 | 97 |
| 98 VideoRenderer* GetDefaultRenderer() const; | 98 VideoRenderer* GetDefaultRenderer() const; |
| 99 void SetDefaultRenderer(VideoMediaChannel* channel, VideoRenderer* renderer); | 99 void SetDefaultRenderer(VideoMediaChannel* channel, VideoRenderer* renderer); |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 uint32_t default_recv_ssrc_; | 102 uint32_t default_recv_ssrc_; |
| 103 VideoRenderer* default_renderer_; | 103 VideoRenderer* default_renderer_; |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 // CallFactory, overridden for testing to verify that webrtc::Call is configured | 106 // WebRtcVideoEngine2 is used for the new native WebRTC Video API (webrtc:1667). |
| 107 // properly. | 107 class WebRtcVideoEngine2 { |
| 108 class WebRtcCallFactory { | |
| 109 public: | 108 public: |
| 110 virtual ~WebRtcCallFactory(); | 109 WebRtcVideoEngine2(); |
| 111 virtual webrtc::Call* CreateCall(const webrtc::Call::Config& config); | 110 ~WebRtcVideoEngine2(); |
| 112 }; | |
| 113 | |
| 114 // WebRtcVideoEngine2 is used for the new native WebRTC Video API (webrtc:1667). | |
| 115 class WebRtcVideoEngine2 : public sigslot::has_slots<> { | |
| 116 public: | |
| 117 explicit WebRtcVideoEngine2(WebRtcVoiceEngine* voice_engine); | |
| 118 virtual ~WebRtcVideoEngine2(); | |
| 119 | |
| 120 // Used for testing to be able to check and use the webrtc::Call config. | |
| 121 void SetCallFactory(WebRtcCallFactory* call_factory); | |
| 122 | 111 |
| 123 // Basic video engine implementation. | 112 // Basic video engine implementation. |
| 124 void Init(); | 113 void Init(); |
| 125 | 114 |
| 126 int GetCapabilities(); | 115 int GetCapabilities(); |
| 127 bool SetDefaultEncoderConfig(const VideoEncoderConfig& config); | 116 bool SetDefaultEncoderConfig(const VideoEncoderConfig& config); |
| 128 | 117 |
| 129 WebRtcVideoChannel2* CreateChannel(const VideoOptions& options, | 118 WebRtcVideoChannel2* CreateChannel(webrtc::Call* call, |
| 130 VoiceMediaChannel* voice_channel); | 119 const VideoOptions& options); |
| 131 | 120 |
| 132 const std::vector<VideoCodec>& codecs() const; | 121 const std::vector<VideoCodec>& codecs() const; |
| 133 const std::vector<RtpHeaderExtension>& rtp_header_extensions() const; | 122 const std::vector<RtpHeaderExtension>& rtp_header_extensions() const; |
| 134 void SetLogging(int min_sev, const char* filter); | 123 void SetLogging(int min_sev, const char* filter); |
| 135 | 124 |
| 136 // Set a WebRtcVideoDecoderFactory for external decoding. Video engine does | 125 // Set a WebRtcVideoDecoderFactory for external decoding. Video engine does |
| 137 // not take the ownership of |decoder_factory|. The caller needs to make sure | 126 // not take the ownership of |decoder_factory|. The caller needs to make sure |
| 138 // that |decoder_factory| outlives the video engine. | 127 // that |decoder_factory| outlives the video engine. |
| 139 void SetExternalDecoderFactory(WebRtcVideoDecoderFactory* decoder_factory); | 128 void SetExternalDecoderFactory(WebRtcVideoDecoderFactory* decoder_factory); |
| 140 // Set a WebRtcVideoEncoderFactory for external encoding. Video engine does | 129 // Set a WebRtcVideoEncoderFactory for external encoding. Video engine does |
| 141 // not take the ownership of |encoder_factory|. The caller needs to make sure | 130 // not take the ownership of |encoder_factory|. The caller needs to make sure |
| 142 // that |encoder_factory| outlives the video engine. | 131 // that |encoder_factory| outlives the video engine. |
| 143 virtual void SetExternalEncoderFactory( | 132 virtual void SetExternalEncoderFactory( |
| 144 WebRtcVideoEncoderFactory* encoder_factory); | 133 WebRtcVideoEncoderFactory* encoder_factory); |
| 145 | 134 |
| 146 bool EnableTimedRender(); | 135 bool EnableTimedRender(); |
| 147 | 136 |
| 148 bool FindCodec(const VideoCodec& in); | 137 bool FindCodec(const VideoCodec& in); |
| 149 bool CanSendCodec(const VideoCodec& in, | 138 bool CanSendCodec(const VideoCodec& in, |
| 150 const VideoCodec& current, | 139 const VideoCodec& current, |
| 151 VideoCodec* out); | 140 VideoCodec* out); |
| 152 // Check whether the supplied trace should be ignored. | 141 // Check whether the supplied trace should be ignored. |
| 153 bool ShouldIgnoreTrace(const std::string& trace); | 142 bool ShouldIgnoreTrace(const std::string& trace); |
| 154 | 143 |
| 155 private: | 144 private: |
| 156 std::vector<VideoCodec> GetSupportedCodecs() const; | 145 std::vector<VideoCodec> GetSupportedCodecs() const; |
| 157 | 146 |
| 158 WebRtcVoiceEngine* voice_engine_; | |
| 159 std::vector<VideoCodec> video_codecs_; | 147 std::vector<VideoCodec> video_codecs_; |
| 160 std::vector<RtpHeaderExtension> rtp_header_extensions_; | 148 std::vector<RtpHeaderExtension> rtp_header_extensions_; |
| 161 | 149 |
| 162 bool initialized_; | 150 bool initialized_; |
| 163 | 151 |
| 164 WebRtcCallFactory default_call_factory_; | |
| 165 WebRtcCallFactory* call_factory_; | |
| 166 | |
| 167 WebRtcVideoDecoderFactory* external_decoder_factory_; | 152 WebRtcVideoDecoderFactory* external_decoder_factory_; |
| 168 WebRtcVideoEncoderFactory* external_encoder_factory_; | 153 WebRtcVideoEncoderFactory* external_encoder_factory_; |
| 169 rtc::scoped_ptr<WebRtcVideoEncoderFactory> simulcast_encoder_factory_; | 154 rtc::scoped_ptr<WebRtcVideoEncoderFactory> simulcast_encoder_factory_; |
| 170 }; | 155 }; |
| 171 | 156 |
| 172 class WebRtcVideoChannel2 : public rtc::MessageHandler, | 157 class WebRtcVideoChannel2 : public rtc::MessageHandler, |
| 173 public VideoMediaChannel, | 158 public VideoMediaChannel, |
| 174 public webrtc::newapi::Transport, | 159 public webrtc::newapi::Transport, |
| 175 public webrtc::LoadObserver { | 160 public webrtc::LoadObserver { |
| 176 public: | 161 public: |
| 177 WebRtcVideoChannel2(WebRtcCallFactory* call_factory, | 162 WebRtcVideoChannel2(webrtc::Call* call, |
| 178 WebRtcVoiceEngine* voice_engine, | |
| 179 WebRtcVoiceMediaChannel* voice_channel, | |
| 180 const VideoOptions& options, | 163 const VideoOptions& options, |
| 181 WebRtcVideoEncoderFactory* external_encoder_factory, | 164 WebRtcVideoEncoderFactory* external_encoder_factory, |
| 182 WebRtcVideoDecoderFactory* external_decoder_factory); | 165 WebRtcVideoDecoderFactory* external_decoder_factory); |
| 183 ~WebRtcVideoChannel2(); | 166 ~WebRtcVideoChannel2() override; |
| 184 bool Init(); | |
| 185 | 167 |
| 186 // VideoMediaChannel implementation | 168 // VideoMediaChannel implementation |
| 187 void DetachVoiceChannel() override; | |
| 188 bool SetSendParameters(const VideoSendParameters& params) override; | 169 bool SetSendParameters(const VideoSendParameters& params) override; |
| 189 bool SetRecvParameters(const VideoRecvParameters& params) override; | 170 bool SetRecvParameters(const VideoRecvParameters& params) override; |
| 190 bool SetRecvCodecs(const std::vector<VideoCodec>& codecs) override; | 171 bool SetRecvCodecs(const std::vector<VideoCodec>& codecs) override; |
| 191 bool SetSendCodecs(const std::vector<VideoCodec>& codecs) override; | 172 bool SetSendCodecs(const std::vector<VideoCodec>& codecs) override; |
| 192 bool GetSendCodec(VideoCodec* send_codec) override; | 173 bool GetSendCodec(VideoCodec* send_codec) override; |
| 193 bool SetSendStreamFormat(uint32 ssrc, const VideoFormat& format) override; | 174 bool SetSendStreamFormat(uint32 ssrc, const VideoFormat& format) override; |
| 194 bool SetRender(bool render) override; | 175 bool SetRender(bool render) override; |
| 195 bool SetSend(bool send) override; | 176 bool SetSend(bool send) override; |
| 196 bool SetVideoSend(uint32 ssrc, bool mute, | 177 bool SetVideoSend(uint32 ssrc, bool mute, |
| 197 const VideoOptions* options) override; | 178 const VideoOptions* options) override; |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 481 |
| 501 void FillSenderStats(VideoMediaInfo* info); | 482 void FillSenderStats(VideoMediaInfo* info); |
| 502 void FillReceiverStats(VideoMediaInfo* info); | 483 void FillReceiverStats(VideoMediaInfo* info); |
| 503 void FillBandwidthEstimationStats(const webrtc::Call::Stats& stats, | 484 void FillBandwidthEstimationStats(const webrtc::Call::Stats& stats, |
| 504 VideoMediaInfo* info); | 485 VideoMediaInfo* info); |
| 505 | 486 |
| 506 rtc::ThreadChecker thread_checker_; | 487 rtc::ThreadChecker thread_checker_; |
| 507 | 488 |
| 508 uint32_t rtcp_receiver_report_ssrc_; | 489 uint32_t rtcp_receiver_report_ssrc_; |
| 509 bool sending_; | 490 bool sending_; |
| 510 rtc::scoped_ptr<webrtc::Call> call_; | 491 webrtc::Call* const call_; |
| 511 WebRtcCallFactory* call_factory_; | |
| 512 | 492 |
| 513 uint32_t default_send_ssrc_; | 493 uint32_t default_send_ssrc_; |
| 514 | 494 |
| 515 DefaultUnsignalledSsrcHandler default_unsignalled_ssrc_handler_; | 495 DefaultUnsignalledSsrcHandler default_unsignalled_ssrc_handler_; |
| 516 UnsignalledSsrcHandler* const unsignalled_ssrc_handler_; | 496 UnsignalledSsrcHandler* const unsignalled_ssrc_handler_; |
| 517 | 497 |
| 518 // Separate list of set capturers used to signal CPU adaptation. These should | 498 // Separate list of set capturers used to signal CPU adaptation. These should |
| 519 // not be locked while calling methods that take other locks to prevent | 499 // not be locked while calling methods that take other locks to prevent |
| 520 // lock-order inversions. | 500 // lock-order inversions. |
| 521 rtc::CriticalSection capturer_crit_; | 501 rtc::CriticalSection capturer_crit_; |
| 522 bool signal_cpu_adaptation_ GUARDED_BY(capturer_crit_); | 502 bool signal_cpu_adaptation_ GUARDED_BY(capturer_crit_); |
| 523 std::map<uint32, VideoCapturer*> capturers_ GUARDED_BY(capturer_crit_); | 503 std::map<uint32, VideoCapturer*> capturers_ GUARDED_BY(capturer_crit_); |
| 524 | 504 |
| 525 rtc::CriticalSection stream_crit_; | 505 rtc::CriticalSection stream_crit_; |
| 526 // Using primary-ssrc (first ssrc) as key. | 506 // Using primary-ssrc (first ssrc) as key. |
| 527 std::map<uint32, WebRtcVideoSendStream*> send_streams_ | 507 std::map<uint32, WebRtcVideoSendStream*> send_streams_ |
| 528 GUARDED_BY(stream_crit_); | 508 GUARDED_BY(stream_crit_); |
| 529 std::map<uint32, WebRtcVideoReceiveStream*> receive_streams_ | 509 std::map<uint32, WebRtcVideoReceiveStream*> receive_streams_ |
| 530 GUARDED_BY(stream_crit_); | 510 GUARDED_BY(stream_crit_); |
| 531 std::set<uint32> send_ssrcs_ GUARDED_BY(stream_crit_); | 511 std::set<uint32> send_ssrcs_ GUARDED_BY(stream_crit_); |
| 532 std::set<uint32> receive_ssrcs_ GUARDED_BY(stream_crit_); | 512 std::set<uint32> receive_ssrcs_ GUARDED_BY(stream_crit_); |
| 533 | 513 |
| 534 Settable<VideoCodecSettings> send_codec_; | 514 Settable<VideoCodecSettings> send_codec_; |
| 535 std::vector<webrtc::RtpExtension> send_rtp_extensions_; | 515 std::vector<webrtc::RtpExtension> send_rtp_extensions_; |
| 536 | 516 |
| 537 WebRtcVoiceMediaChannel* voice_channel_; | |
| 538 const int voice_channel_id_; | |
| 539 WebRtcVideoEncoderFactory* const external_encoder_factory_; | 517 WebRtcVideoEncoderFactory* const external_encoder_factory_; |
| 540 WebRtcVideoDecoderFactory* const external_decoder_factory_; | 518 WebRtcVideoDecoderFactory* const external_decoder_factory_; |
| 541 std::vector<VideoCodecSettings> recv_codecs_; | 519 std::vector<VideoCodecSettings> recv_codecs_; |
| 542 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 520 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
| 543 webrtc::Call::Config::BitrateConfig bitrate_config_; | 521 webrtc::Call::Config::BitrateConfig bitrate_config_; |
| 544 VideoOptions options_; | 522 VideoOptions options_; |
| 545 }; | 523 }; |
| 546 | 524 |
| 547 } // namespace cricket | 525 } // namespace cricket |
| 548 | 526 |
| 549 #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_H_ | 527 #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_H_ |
| OLD | NEW |