Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature: Simultaneous playback of 3 pcap files #371

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/call.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 22 additions & 4 deletions src/call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* Roland Meub
* Andy Aicken
* Martin H. VanLeeuwen
* Valentin Chernov
*/

#include <algorithm>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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");
}
Expand Down