Hi,
Here is a small patch to add the play_pcap_image action.
If deemed useful, please consider it for inclusion so i
don't have to keep this patch around. :-)
Cheers,
Vincent
Index: scenario.cpp
===================================================================
--- scenario.cpp (revision 600)
+++ scenario.cpp (working copy)
@@ -1596,11 +1596,17 @@
tmpAction->setPcapArgs(ptr);
tmpAction->setActionType(CAction::E_AT_PLAY_PCAP_VIDEO);
hasMedia = 1;
+ } else if ((ptr = xp_get_value((char *) "play_pcap_image"))) {
+ tmpAction->setPcapArgs(ptr);
+ tmpAction->setActionType(CAction::E_AT_PLAY_PCAP_IMAGE);
+ hasMedia = 1;
#else
} else if ((ptr = xp_get_value((char *) "play_pcap_audio"))) {
ERROR("play_pcap_audio requires pcap support! Please recompile SIPp");
} else if ((ptr = xp_get_value((char *) "play_pcap_video"))) {
ERROR("play_pcap_video requires pcap support! Please recompile SIPp");
+ } else if ((ptr = xp_get_value((char *) "play_pcap_image"))) {
+ ERROR("play_pcap_image requires pcap support! Please recompile SIPp");
#endif
} else {
ERROR("illegal <exec> in the scenario\n");
Index: actions.cpp
===================================================================
--- actions.cpp (revision 600)
+++ actions.cpp (working copy)
@@ -146,7 +146,7 @@
} else if (M_action == E_AT_VAR_TO_DOUBLE) {
printf("Type[%d] - toDouble varId[%s]", M_action, display_scenario->allocVars->getName(M_varId));
#ifdef PCAPPLAY
- } else if ((M_action == E_AT_PLAY_PCAP_AUDIO) || (M_action == E_AT_PLAY_PCAP_VIDEO)) {
+ } else if ((M_action == E_AT_PLAY_PCAP_AUDIO) || (M_action == E_AT_PLAY_PCAP_VIDEO) || (M_action == E_AT_PLAY_PCAP_IMAGE) ) {
printf("Type[%d] - file[%s]", M_action, M_pcapArgs->file);
#endif
} else {
Index: actions.hpp
===================================================================
--- actions.hpp (revision 600)
+++ actions.hpp (working copy)
@@ -70,6 +70,7 @@
#ifdef PCAPPLAY
E_AT_PLAY_PCAP_AUDIO,
E_AT_PLAY_PCAP_VIDEO,
+ E_AT_PLAY_PCAP_IMAGE,
#endif
E_AT_NB_ACTION
};
Index: call.cpp
===================================================================
--- call.cpp (revision 600)
+++ call.cpp (working copy)
@@ -182,6 +182,8 @@
*/
#define PAT_AUDIO 1
#define PAT_VIDEO 2
+#define PAT_IMAGE 3
+
uint16_t get_remote_port_media(char *msg, int pattype)
{
char *pattern;
@@ -192,8 +194,10 @@
pattern = "m=audio ";
} else if (pattype == PAT_VIDEO) {
pattern = "m=video ";
+ } else if (pattype == PAT_IMAGE) {
+ pattern = "m=image ";
} else {
- ERROR("Internal error: Undefined media pattern %d\n", 3);
+ ERROR("Internal error: Undefined media pattern %d\n", 4);
}
begin = strstr(msg, pattern);
@@ -214,7 +218,7 @@
* IPv{4,6} compliant
*/
void call::get_remote_media_addr(char *msg) {
- uint16_t video_port, audio_port;
+ uint16_t video_port, audio_port, image_port;
if (media_ip_is_ipv6) {
struct in6_addr ip_media;
if (get_remote_ipv6_media(msg, &ip_media)) {
@@ -236,6 +240,15 @@
(_RCAST(struct sockaddr_in6 *, &(play_args_v.to)))->sin6_port = video_port;
(_RCAST(struct sockaddr_in6 *, &(play_args_v.to)))->sin6_addr = ip_media;
}
+ image_port = get_remote_port_media(msg, PAT_IMAGE);
+ if (image_port) {
+ /* We have image in the SDP: set the to_image addr */
+ (_RCAST(struct sockaddr_in6 *, &(play_args_i.to)))->sin6_flowinfo = 0;
+ (_RCAST(struct sockaddr_in6 *, &(play_args_i.to)))->sin6_scope_id = 0;
+ (_RCAST(struct sockaddr_in6 *, &(play_args_i.to)))->sin6_family = AF_INET6;
+ (_RCAST(struct sockaddr_in6 *, &(play_args_i.to)))->sin6_port = image_port;
+ (_RCAST(struct sockaddr_in6 *, &(play_args_i.to)))->sin6_addr = ip_media;
+ }
hasMediaInformation = 1;
}
}
@@ -257,6 +270,13 @@
(_RCAST(struct sockaddr_in *, &(play_args_v.to)))->sin_port = video_port;
(_RCAST(struct sockaddr_in *, &(play_args_v.to)))->sin_addr.s_addr = ip_media;
}
+ image_port = get_remote_port_media(msg, PAT_IMAGE);
+ if (image_port) {
+ /* We have image in the SDP: set the to_image addr */
+ (_RCAST(struct sockaddr_in *, &(play_args_i.to)))->sin_family = AF_INET;
+ (_RCAST(struct sockaddr_in *, &(play_args_i.to)))->sin_port = image_port;
+ (_RCAST(struct sockaddr_in *, &(play_args_i.to)))->sin_addr.s_addr = ip_media;
+ }
hasMediaInformation = 1;
}
}
@@ -506,8 +526,10 @@
#ifdef PCAPPLAY
memset(&(play_args_a.to), 0, sizeof(struct sockaddr_storage));
memset(&(play_args_v.to), 0, sizeof(struct sockaddr_storage));
+ memset(&(play_args_i.to), 0, sizeof(struct sockaddr_storage));
memset(&(play_args_a.from), 0, sizeof(struct sockaddr_storage));
memset(&(play_args_v.from), 0, sizeof(struct sockaddr_storage));
+ memset(&(play_args_i.from), 0, sizeof(struct sockaddr_storage));
hasMediaInformation = 0;
media_thread = 0;
#endif
@@ -2192,6 +2214,12 @@
} else {
(_RCAST(struct sockaddr_in *, &(play_args_v.from)))->sin_port = port;
}
+ } else if (strstr(begin, "image")) {
+ if (media_ip_is_ipv6) {
+ (_RCAST(struct sockaddr_in6 *, &(play_args_i.from)))->sin6_port = port;
+ } else {
+ (_RCAST(struct sockaddr_in *, &(play_args_i.from)))->sin_port = port;
+ }
} else {
ERROR("media_port keyword with no audio or video on the current line (%s)", begin);
}
@@ -3798,12 +3826,15 @@
}
#ifdef PCAPPLAY
} else if ((currentAction->getActionType() == CAction::E_AT_PLAY_PCAP_AUDIO) ||
- (currentAction->getActionType() == CAction::E_AT_PLAY_PCAP_VIDEO)) {
+ (currentAction->getActionType() == CAction::E_AT_PLAY_PCAP_VIDEO) ||
+ (currentAction->getActionType() == CAction::E_AT_PLAY_PCAP_IMAGE)) {
play_args_t *play_args;
if (currentAction->getActionType() == CAction::E_AT_PLAY_PCAP_AUDIO) {
play_args = &(this->play_args_a);
} else if (currentAction->getActionType() == CAction::E_AT_PLAY_PCAP_VIDEO) {
play_args = &(this->play_args_v);
+ } else if (currentAction->getActionType() == CAction::E_AT_PLAY_PCAP_IMAGE) {
+ play_args = &(this->play_args_i);
}
play_args->pcap = currentAction->getPcapPkts();
/* port number is set in [auto_]media_port interpolation */
Index: call.hpp
===================================================================
--- call.hpp (revision 600)
+++ call.hpp (working copy)
@@ -168,6 +168,7 @@
pthread_t media_thread;
play_args_t play_args_a;
play_args_t play_args_v;
+ play_args_t play_args_i;
#endif
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Sipp-users mailing list
Sipp-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sipp-users