Forwarding design based AES encryption RTSP / RTMP multiplex

Many developers recently consulting us, in addition to audio and video data we collect end-coded push Windows to encrypt, the other RTSP / RTMP stream if you want a more secure Retweet to RTMP server or CDN corresponding change how to do?

In fact, we are doing when RTMP overall encryption scheme has been taken into account this situation, SmartStreamRelayDemo take RTSP or RTMP streams in pull Retweet RTMP, they can select the encrypted video, audio or audio and video encryption is encrypted , not much nonsense He said, referring to the code:

bool nt_stream_relay_wrapper::StartPush(const std::string& url)
{
	if ( is_pushing_ ) return false; if ( url.empty() ) return false; if ( !OpenPushHandle() ) return false; auto push_handle = GetPushHandle(); ASSERT(push_handle != nullptr); ASSERT(push_api_ != NULL); if ( NT_ERC_OK != push_api_->SetURL(push_handle, url.c_str(), NULL) ) { if ( !is_started_rtsp_stream_ ) { push_api_->Close(push_handle); SetPushHandle(nullptr); } return false; } // 加密测试 +++ push_api_->SetRtmpEncryptionOption(push_handle, url.c_str(), 1, 1); NT_BYTE test_key[16] = {'1', '2', '3'}; push_api_->SetRtmpEncryptionKey(push_handle, url.c_str(), test_key, 16); // 加密测试 -- if ( NT_ERC_OK != push_api_->StartPublisher(push_handle, NULL) ) { if ( !is_started_rtsp_stream_ ) { push_api_->Close(push_handle); SetPushHandle(nullptr); } return false; } // // test push rtsp ++ // push_api_->SetPushRtspTransportProtocol(push_handle, 1); // // push_api_->SetPushRtspTransportProtocol(push_handle, 2); // push_api_->SetPushRtspURL(push_handle, "rtsp://player.daniulive.com:554/liverelay111.sdp"); // push_api_->StartPushRtsp(push_handle, 0); // // test push rtsp-- is_pushing_ = true; return true; }

Above:

This time, enter the forwarding settings Key (support aes 128, aes 192, aes 256 encryption, encryption upcoming SM4), before normal play audio and video data.

Advantages of this approach is that AES-based audio and video frame by frame data encrypted audio and video data, even if the third party is to break the URL, we are unable to play, crawl into the data packet capture tool, we are unable to display properly.

Guess you like

Origin www.cnblogs.com/daniulivesdk/p/10960823.html