From 269ea3755e25b2bbb8097a512490f13a36205257 Mon Sep 17 00:00:00 2001 From: Valentin Chernov Date: Tue, 13 Nov 2018 22:41:54 -0500 Subject: [PATCH] New feature: simultaneous playing 3 pcap files (audio, video, and images) --- include/call.hpp | 4 +++- src/call.cpp | 26 ++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/include/call.hpp b/include/call.hpp index de8fcb4e..3005ef3b 100644 --- a/include/call.hpp +++ b/include/call.hpp @@ -163,7 +163,9 @@ class call : virtual public task, virtual public listener, public virtual socket #ifdef PCAPPLAY int hasMediaInformation; - pthread_t media_thread; + pthread_t media_thread_a; + pthread_t media_thread_i; + pthread_t media_thread_v; play_args_t play_args_a; play_args_t play_args_i; play_args_t play_args_v; diff --git a/src/call.cpp b/src/call.cpp index 1fadcead..b9cb837d 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -36,6 +36,7 @@ * Roland Meub * Andy Aicken * Martin H. VanLeeuwen + * Valentin Chernov */ #include @@ -507,7 +508,9 @@ void call::init(scenario * call_scenario, SIPpSocket *socket, struct sockaddr_st memset(&(play_args_i.from), 0, sizeof(struct sockaddr_storage)); memset(&(play_args_v.from), 0, sizeof(struct sockaddr_storage)); hasMediaInformation = 0; - media_thread = 0; + media_thread_a = 0; + media_thread_i = 0; + media_thread_v = 0; #endif peer_tag = NULL; @@ -633,9 +636,20 @@ call::~call() } # ifdef PCAPPLAY - if (media_thread != 0) { - pthread_cancel(media_thread); - pthread_join(media_thread, NULL); + if (media_thread_a != 0) { + pthread_cancel(media_thread_a); + pthread_join(media_thread_a, NULL); + media_thread_a = 0; + } + if (media_thread_i != 0) { + pthread_cancel(media_thread_i); + pthread_join(media_thread_i, NULL); + media_thread_i = 0; + } + if (media_thread_v != 0) { + pthread_cancel(media_thread_v); + pthread_join(media_thread_v, NULL); + media_thread_v = 0; } #endif @@ -3728,13 +3742,17 @@ call::T_ActionResult call::executeAction(const char* msg, message* curmsg) (currentAction->getActionType() == CAction::E_AT_PLAY_PCAP_VIDEO) || (currentAction->getActionType() == CAction::E_AT_PLAY_DTMF)) { play_args_t* play_args = 0; + pthread_t& media_thread = media_thread_a; + if ((currentAction->getActionType() == CAction::E_AT_PLAY_PCAP_AUDIO) || (currentAction->getActionType() == CAction::E_AT_PLAY_DTMF)) { play_args = &(this->play_args_a); } else if (currentAction->getActionType() == CAction::E_AT_PLAY_PCAP_IMAGE) { play_args = &(this->play_args_i); + media_thread = media_thread_i; } else if (currentAction->getActionType() == CAction::E_AT_PLAY_PCAP_VIDEO) { play_args = &(this->play_args_v); + media_thread = media_thread_v; } else { ERROR("Can't find pcap data to play"); }