Create routines for destroying RTP readers/writers
The RTP connection should be destroyed by calling context->destroy_* functions to ensure that the session is completely destroyed. These functions will call the writer's/reader's destructor, close the socket, release all common resources, remove them from the global hashmap and send RTCP BYE message to all other participants
This commit is contained in:
parent
6ea1f1fc7d
commit
50606cc6b4
10
src/conn.cc
10
src/conn.cc
|
|
@ -1,5 +1,6 @@
|
|||
#ifdef __linux__
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
|
@ -20,6 +21,15 @@ kvz_rtp::connection::connection(bool reader):
|
|||
|
||||
kvz_rtp::connection::~connection()
|
||||
{
|
||||
/* this is going to cause problems if config was allocated from stack... */
|
||||
if (config_)
|
||||
delete config_;
|
||||
|
||||
#ifdef __linux__
|
||||
close(socket_);
|
||||
#else
|
||||
/* TODO: close socket a la windows */
|
||||
#endif
|
||||
}
|
||||
|
||||
void kvz_rtp::connection::set_payload(rtp_format_t fmt)
|
||||
|
|
|
|||
16
src/lib.cc
16
src/lib.cc
|
|
@ -91,3 +91,19 @@ kvz_rtp::writer *kvz_rtp::context::create_writer(std::string dstAddr, int dstPor
|
|||
writer->set_payload(fmt);
|
||||
return writer;
|
||||
}
|
||||
|
||||
rtp_error_t kvz_rtp::context::destroy_writer(kvz_rtp::writer *writer)
|
||||
{
|
||||
conns_.erase(writer->get_ssrc());
|
||||
|
||||
/* TODO: rtcp bye */
|
||||
delete writer;
|
||||
}
|
||||
|
||||
rtp_error_t kvz_rtp::context::destroy_reader(kvz_rtp::reader *reader)
|
||||
{
|
||||
conns_.erase(reader->get_ssrc());
|
||||
|
||||
/* TODO: rtcp bye */
|
||||
delete reader;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ namespace kvz_rtp {
|
|||
kvz_rtp::writer *create_writer(std::string dst_addr, int dst_port, int src_port);
|
||||
kvz_rtp::writer *create_writer(std::string dst_addr, int dst_port, int src_port, rtp_format_t fmt);
|
||||
|
||||
/* call reader/writer-specific destroy functions, send an RTCP BYE message
|
||||
* and remove the connection from conns_ map */
|
||||
rtp_error_t destroy_writer(kvz_rtp::writer *writer);
|
||||
rtp_error_t destroy_reader(kvz_rtp::reader *reader);
|
||||
|
||||
private:
|
||||
std::map<uint32_t, connection *> conns_;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue