summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/uscxml/plugins')
-rw-r--r--src/uscxml/plugins/invoker/miles/MilesSessionInvoker.cpp51
-rw-r--r--src/uscxml/plugins/invoker/miles/MilesSessionInvoker.h4
2 files changed, 51 insertions, 4 deletions
diff --git a/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.cpp b/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.cpp
index 8bc352b..dcefc0f 100644
--- a/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.cpp
+++ b/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.cpp
@@ -41,12 +41,9 @@ bool pluginConnect(pluma::Host& host) {
#endif
MilesSessionInvoker::MilesSessionInvoker() {
- /* Initalize Miles */
+ /* Initialize Miles */
miles_init();
- /* set up media buffers */
- init_media_buffers();
-
_isRunning = false;
num_connected = 0;
}
@@ -112,6 +109,45 @@ void MilesSessionInvoker::free_media_buffers() {
text_msg_available = 0;
}
+void MilesSessionInvoker::free_video_buffers() {
+ if(video_out_buf)
+ free(video_out_buf);
+ video_out_buf = NULL;
+ if(encoded_out_img)
+ free(encoded_out_img);
+ encoded_out_img = NULL;
+ if(render_img)
+ free(render_img);
+ render_img = NULL;
+ render_img_size = 0;
+ if(video_data)
+ free(video_data);
+ video_data = NULL;
+}
+
+void MilesSessionInvoker::free_audio_buffers() {
+ if(audio_in_buf)
+ free(audio_in_buf);
+ audio_in_buf = NULL;
+ if(audio_data)
+ free(audio_data);
+ audio_data = NULL;
+ video_data = NULL;
+ if(encoded_out_audio)
+ free(encoded_out_audio);
+ encoded_out_audio = NULL;
+ if(audio_read_buf)
+ free(audio_read_buf);
+ audio_read_buf = NULL;
+}
+
+void MilesSessionInvoker::free_text_buffers() {
+ if(text_msg_buf)
+ free(text_msg_buf);
+ text_msg_buf = NULL;
+ text_msg_available = 0;
+}
+
// Yes, sort of ugly...
char confero_text_msg_buf[1000];
int confero_text_msg_available = 0;
@@ -255,6 +291,8 @@ void MilesSessionInvoker::processEventStart(const std::string& origin, const std
}
LOG(ERROR) << "session set up";
+ /* set up media buffers */
+ init_media_buffers();
/* Set up audio and video RTP sockets */
video_rtp_in_socket = miles_net_setup_udp_socket((char*)reflector.c_str(), video_port, video_port, 10, 16000);
@@ -354,6 +392,7 @@ void MilesSessionInvoker::processEventStop(const std::string& origin) {
LOG(ERROR) << "Error registering text message callback";
}
_isRunning = false;
+ free_text_buffers();
ev.name = "stop.reply";
returnEvent(ev);
LOG(ERROR) << "disconnected from reflector session";
@@ -558,6 +597,8 @@ void MilesSessionInvoker::processVideo() {
thumb_list = NULL;
miles_net_socket_close(video_rtp_in_socket);
miles_net_socket_close(video_rtcp_in_socket);
+
+ free_video_buffers();
}
void MilesSessionInvoker::processAudio() {
@@ -580,6 +621,8 @@ void MilesSessionInvoker::processAudio() {
miles_rtp_destroy_session(audio_session);
miles_net_socket_close(audio_rtp_in_socket);
miles_net_socket_close(audio_rtcp_in_socket);
+
+ free_video_buffers();
}
int MilesSessionInvoker::setup_audio() {
diff --git a/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.h b/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.h
index 2191b8a..552297c 100644
--- a/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.h
+++ b/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.h
@@ -140,6 +140,10 @@ protected:
void init_media_buffers();
void free_media_buffers();
+ void free_video_buffers();
+ void free_audio_buffers();
+ void free_text_buffers();
+
void render_video_image(char *img, int width, int height, int img_format);
void playback_audio(u_int32_t ssrc, char *buf, int sample_rate, int bps, int audio_format, int size);
int video_receiver(struct miles_rtp_in_stream *rtp_stream, char *data, int bytes_read);