Browse Source

Use dedicated method to send media

Paul-Louis Ageneau 5 years ago
parent
commit
62e6954949
3 changed files with 8 additions and 3 deletions
  1. 6 1
      src/dtlssrtptransport.cpp
  2. 1 1
      src/dtlssrtptransport.hpp
  3. 1 1
      src/peerconnection.cpp

+ 6 - 1
src/dtlssrtptransport.cpp

@@ -63,13 +63,18 @@ DtlsSrtpTransport::~DtlsSrtpTransport() {
 		srtp_dealloc(mSrtp);
 		srtp_dealloc(mSrtp);
 }
 }
 
 
-bool DtlsSrtpTransport::send(message_ptr message) {
+bool DtlsSrtpTransport::sendMedia(message_ptr message) {
 	if (!message)
 	if (!message)
 		return false;
 		return false;
 
 
 	int size = message->size();
 	int size = message->size();
 	PLOG_VERBOSE << "Send size=" << size;
 	PLOG_VERBOSE << "Send size=" << size;
 
 
+	if (!mCreated) {
+		PLOG_WARNING << "SRTP media sent before keys are derived";
+		return false;
+	}
+
 	// srtp_protect() assumes that it can write SRTP_MAX_TRAILER_LEN (for the authentication tag)
 	// srtp_protect() assumes that it can write SRTP_MAX_TRAILER_LEN (for the authentication tag)
 	// into the location in memory immediately following the RTP packet.
 	// into the location in memory immediately following the RTP packet.
 	message->resize(size + SRTP_MAX_TRAILER_LEN);
 	message->resize(size + SRTP_MAX_TRAILER_LEN);

+ 1 - 1
src/dtlssrtptransport.hpp

@@ -38,7 +38,7 @@ public:
 	                  state_callback stateChangeCallback);
 	                  state_callback stateChangeCallback);
 	~DtlsSrtpTransport();
 	~DtlsSrtpTransport();
 
 
-	bool send(message_ptr message) override;
+	bool sendMedia(message_ptr message);
 
 
 private:
 private:
 	void incoming(message_ptr message) override;
 	void incoming(message_ptr message) override;

+ 1 - 1
src/peerconnection.cpp

@@ -244,7 +244,7 @@ void PeerConnection::outgoingMedia(message_ptr message) {
 	if (!transport)
 	if (!transport)
 		throw std::runtime_error("PeerConnection is not open");
 		throw std::runtime_error("PeerConnection is not open");
 
 
-	std::dynamic_pointer_cast<DtlsSrtpTransport>(transport)->send(message);
+	std::dynamic_pointer_cast<DtlsSrtpTransport>(transport)->sendMedia(message);
 #else
 #else
 	PLOG_WARNING << "Ignoring sent media (not compiled with SRTP support)";
 	PLOG_WARNING << "Ignoring sent media (not compiled with SRTP support)";
 #endif
 #endif