{"id":663,"date":"2022-03-24T14:49:51","date_gmt":"2022-03-24T06:49:51","guid":{"rendered":"https:\/\/www.fanyamin.com\/wordpress\/?p=663"},"modified":"2022-03-24T14:49:51","modified_gmt":"2022-03-24T06:49:51","slug":"how-to-disable-srtp-in-webrtc-library","status":"publish","type":"post","link":"https:\/\/www.fanyamin.com\/wordpress\/?p=663","title":{"rendered":"How to disable SRTP in WebRTC library"},"content":{"rendered":"<p>Take peerconnection_client as example<\/p>\n<pre><code>  webrtc::PeerConnectionFactoryInterface::Options options;\n  options.disable_encryption = this-&gt;disable_srtp_;\n  peer_connection_factory_-&gt;SetOptions(options);<\/code><\/pre>\n<h1>step 1<\/h1>\n<p>change C:\\webrtc-checkout\\src\\examples\\peerconnection\\client\\flag_defs.h<\/p>\n<pre><code class=\"language-cpp\">ABSL_FLAG(bool, disable_srtp, false, &quot;disable srtp or not: false-enable srtp, true-disable srtp&quot;);\n<\/code><\/pre>\n<h1>step 2<\/h1>\n<p>change C:\\webrtc-checkout\\src\\examples\\peerconnection\\client\\conductor.h<\/p>\n<pre><code class=\"language-cpp\">class Conductor : public webrtc::PeerConnectionObserver,\n                  public webrtc::CreateSessionDescriptionObserver,\n                  public PeerConnectionClientObserver,\n                  public MainWndCallback {\n public:\n void DisableSrtp(bool flag);\n\n   bool disable_srtp_;\n};\n\nvoid Conductor::DisableSrtp(bool flag) {\n  this-&gt;disable_srtp_ = flag;\n}\n<\/code><\/pre>\n<h1>step 3<\/h1>\n<p>change C:\\webrtc-checkout\\src\\examples\\peerconnection\\client\\conductor.cc<\/p>\n<pre><code class=\"language-cpp\">\nbool Conductor::InitializePeerConnection() {\n  RTC_DCHECK(!peer_connection_factory_);\n  RTC_DCHECK(!peer_connection_);\n\n  if (!signaling_thread_.get()) {\n    signaling_thread_ = rtc::Thread::CreateWithSocketServer();\n    signaling_thread_-&gt;Start();\n  }\n  peer_connection_factory_ = webrtc::CreatePeerConnectionFactory(\n      nullptr \/* network_thread *\/, nullptr \/* worker_thread *\/,\n      signaling_thread_.get(), nullptr \/* default_adm *\/,\n      webrtc::CreateBuiltinAudioEncoderFactory(),\n      webrtc::CreateBuiltinAudioDecoderFactory(),\n      webrtc::CreateBuiltinVideoEncoderFactory(),\n      webrtc::CreateBuiltinVideoDecoderFactory(), nullptr \/* audio_mixer *\/,\n      nullptr \/* audio_processing *\/);\n\n  if (!peer_connection_factory_) {\n    main_wnd_-&gt;MessageBox(&quot;Error&quot;, &quot;Failed to initialize PeerConnectionFactory&quot;,\n                          true);\n    DeletePeerConnection();\n    return false;\n  }\n\n  webrtc::PeerConnectionFactoryInterface::Options options;\n  options.disable_encryption = this-&gt;disable_srtp_;\n  peer_connection_factory_-&gt;SetOptions(options);\n\n  if (!CreatePeerConnection()) {\n    main_wnd_-&gt;MessageBox(&quot;Error&quot;, &quot;CreatePeerConnection failed&quot;, true);\n    DeletePeerConnection();\n  }\n\n  if (videoSourceType_ != VideoSourceType::NOSEND) {\n    AddTracks();\n  } else {\n    main_wnd_-&gt;SwitchToStreamingUI();\n  }\n\n  return peer_connection_ != nullptr;\n}<\/code><\/pre>\n<h1>Step 4<\/h1>\n<p>change C:\\webrtc-checkout\\src\\examples\\peerconnection\\client\\main.cc<\/p>\n<pre><code>  bool disable_srtp = absl::GetFlag(FLAGS_disable_srtp);\n  conductor-&gt;DisableSrtp(disable_srtp);\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Take peerconnection_client as example webrtc::PeerConnectionFactoryInterface::Options options; options.disable_encryption = this-&gt;disable_srtp_; peer_connection_factory_-&gt;SetOptions(options); step 1 change C:\\webrtc-checkout\\src\\examples\\peerconnection\\client\\flag_defs.h ABSL_FLAG(bool, disable_srtp, false, &quot;disable srtp or not: false-enable srtp, true-disable srtp&quot;); step 2 change C:\\webrtc-checkout\\src\\examples\\peerconnection\\client\\conductor.h class Conductor : public webrtc::PeerConnectionObserver, public webrtc::CreateSessionDescriptionObserver, public PeerConnectionClientObserver, public MainWndCallback { public: void DisableSrtp(bool flag); bool disable_srtp_; }; void Conductor::DisableSrtp(bool flag) { this-&gt;disable_srtp_ = flag; [&hellip;] <a class=\"read-more\" href=\"https:\/\/www.fanyamin.com\/wordpress\/?p=663\" title=\"Permanent Link to: How to disable SRTP in WebRTC library\">&rarr;Read&nbsp;more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-663","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/663"}],"collection":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=663"}],"version-history":[{"count":1,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/663\/revisions"}],"predecessor-version":[{"id":664,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/663\/revisions\/664"}],"wp:attachment":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}