Skip to content

Commit

Permalink
RTPStream/PCAP: Support variables for filename
Browse files Browse the repository at this point in the history
Allow using [fieldX] and all types of variables on playback.
  • Loading branch information
orgads committed Oct 25, 2021
1 parent 205e10f commit cc4d64a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
12 changes: 12 additions & 0 deletions src/call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6073,6 +6073,12 @@ 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;
if ((currentAction->getActionType() == CAction::E_AT_PLAY_PCAP_AUDIO) ||
(currentAction->getActionType() == CAction::E_AT_PLAY_PCAP_IMAGE) ||
(currentAction->getActionType() == CAction::E_AT_PLAY_PCAP_VIDEO)) {
const char *fileName = createSendingMessage(currentAction->getMessage(), -2 /* do not add crlf*/);
currentAction->setPcapArgs(fileName);
}
if ((currentAction->getActionType() == CAction::E_AT_PLAY_PCAP_AUDIO) ||
(currentAction->getActionType() == CAction::E_AT_PLAY_DTMF)) {
play_args = &(this->play_args_a);
Expand Down Expand Up @@ -6131,6 +6137,8 @@ call::T_ActionResult call::executeAction(const char* msg, message* curmsg)
} else if (currentAction->getActionType() == CAction::E_AT_RTP_STREAM_RESUME) {
rtpstream_resume(&rtpstream_callinfo);
} else if (currentAction->getActionType() == CAction::E_AT_RTP_STREAM_PLAY) {
const char *fileName = createSendingMessage(currentAction->getMessage(), -2 /* do not add crlf*/);
currentAction->setRTPStreamActInfo(fileName);
rtpstream_play(&rtpstream_callinfo, currentAction->getRTPStreamActInfo());
// Obtain ID of parent thread used for the related RTP task
call_scenario->addRtpTaskThreadID(rtpstream_callinfo.threadID);
Expand All @@ -6139,6 +6147,8 @@ call::T_ActionResult call::executeAction(const char* msg, message* curmsg)
} else if (currentAction->getActionType() == CAction::E_AT_RTP_STREAM_RESUMEAPATTERN) {
rtpstream_resumeapattern(&rtpstream_callinfo);
} else if (currentAction->getActionType() == CAction::E_AT_RTP_STREAM_PLAYAPATTERN) {
const char *fileName = createSendingMessage(currentAction->getMessage(), -2 /* do not add crlf*/);
currentAction->setRTPStreamActInfo(fileName);
#ifdef USE_TLS
//
// TX/RX-UAC-AUDIO SRTP context (a)(b) -- SRTP PAYLOAD SIZE + DERIVE SESSION ENCRYPTION/SALTING/AUTHENTICATION KEYS + SELECT ENCRYPTION KEY + RESET CIPHER STATE
Expand Down Expand Up @@ -6186,6 +6196,8 @@ call::T_ActionResult call::executeAction(const char* msg, message* curmsg)
} else if (currentAction->getActionType() == CAction::E_AT_RTP_STREAM_RESUMEVPATTERN) {
rtpstream_resumevpattern(&rtpstream_callinfo);
} else if (currentAction->getActionType() == CAction::E_AT_RTP_STREAM_PLAYVPATTERN) {
const char *fileName = createSendingMessage(currentAction->getMessage(), -2 /* do not add crlf*/);
currentAction->setRTPStreamActInfo(fileName);
#ifdef USE_TLS
//
// TX/RX-UAC-VIDEO SRTP context (a)(b) -- SRTP PAYLOAD SIZE + DERIVE SESSION ENCRYPTION/SALTING/AUTHENTICATION KEYS + SELECT ENCRYPTION KEY + RESET CIPHER STATE
Expand Down
28 changes: 6 additions & 22 deletions src/scenario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,22 +239,6 @@ double get_double(const char *ptr, const char *what)
static char* xp_get_keyword_value(const char *name)
{
const char* ptr = xp_get_value(name);
size_t len;

if (ptr && ptr[0] == '[' && (len = strlen(ptr)) && ptr[len - 1] == ']') {
int i = 0;
len -= 2; /* without the brackets */
while (generic[i]) {
const char* keyword = *generic[i];
if (strncmp(ptr + 1, keyword, len) == 0 && strlen(keyword) == len) {
const char* value = *(generic[i] + 1);
return strdup(value);
}
++i;
}
ERROR("%s \"%s\" looks like a keyword value, but keyword not supplied!", name, ptr);
}

return ptr ? strdup(ptr) : NULL;
}

Expand Down Expand Up @@ -1651,17 +1635,17 @@ void scenario::parseAction(CActions *actions)
tmpAction->setIntCmd(type);
#ifdef PCAPPLAY
} else if ((ptr = xp_get_keyword_value("play_pcap_audio"))) {
tmpAction->setPcapArgs(ptr);
tmpAction->setMessage(ptr);
tmpAction->setActionType(CAction::E_AT_PLAY_PCAP_AUDIO);
hasMedia = 1;
free(ptr);
} else if ((ptr = xp_get_keyword_value("play_pcap_image"))) {
tmpAction->setPcapArgs(ptr);
tmpAction->setMessage(ptr);
tmpAction->setActionType(CAction::E_AT_PLAY_PCAP_IMAGE);
hasMedia = 1;
free(ptr);
} else if ((ptr = xp_get_keyword_value("play_pcap_video"))) {
tmpAction->setPcapArgs(ptr);
tmpAction->setMessage(ptr);
tmpAction->setActionType(CAction::E_AT_PLAY_PCAP_VIDEO);
hasMedia = 1;
free(ptr);
Expand Down Expand Up @@ -1691,7 +1675,7 @@ void scenario::parseAction(CActions *actions)
}
else if (!strncmp(ptr, "apattern", 8))
{
tmpAction->setRTPStreamActInfo(ptr);
tmpAction->setMessage(ptr);
tmpAction->setActionType(CAction::E_AT_RTP_STREAM_PLAYAPATTERN);
}
else if (!strcmp(ptr, "pausevpattern"))
Expand All @@ -1704,7 +1688,7 @@ void scenario::parseAction(CActions *actions)
}
else if (!strncmp(ptr, "vpattern", 8))
{
tmpAction->setRTPStreamActInfo(ptr);
tmpAction->setMessage(ptr);
tmpAction->setActionType(CAction::E_AT_RTP_STREAM_PLAYVPATTERN);
}
else if (!strcmp(ptr, "pause"))
Expand All @@ -1717,7 +1701,7 @@ void scenario::parseAction(CActions *actions)
}
else
{
tmpAction->setRTPStreamActInfo(ptr);
tmpAction->setMessage(ptr);
tmpAction->setActionType(CAction::E_AT_RTP_STREAM_PLAY);
}
free(ptr);
Expand Down

0 comments on commit cc4d64a

Please sign in to comment.