Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
mediastreamer2
Commits
4ca3bf8a
Commit
4ca3bf8a
authored
Sep 16, 2014
by
Simon Morlat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve pcap_player so it does what its documentation says !
parent
2fcc5c67
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
109 additions
and
63 deletions
+109
-63
tools/Makefile.am
tools/Makefile.am
+2
-2
tools/common.c
tools/common.c
+75
-0
tools/common.h
tools/common.h
+24
-0
tools/mediastream.c
tools/mediastream.c
+2
-59
tools/pcap_playback.c
tools/pcap_playback.c
+6
-2
No files found.
tools/Makefile.am
View file @
4ca3bf8a
...
...
@@ -52,8 +52,8 @@ bin_PROGRAMS+=pcap_playback
endif
endif
mediastream_SOURCES
=
mediastream.c
pcap_playback_SOURCES
=
pcap_playback.c
mediastream_SOURCES
=
mediastream.c
common.c common.h
pcap_playback_SOURCES
=
pcap_playback.c
common.c common.h
mediastream_LDADD
=
$(TEST_DEPLIBS)
pcap_playback_LDADD
=
$(TEST_DEPLIBS)
...
...
tools/common.c
0 → 100644
View file @
4ca3bf8a
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2014 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "common.h"
static
PayloadType
*
create_custom_payload_type
(
const
char
*
type
,
const
char
*
subtype
,
const
char
*
rate
,
const
char
*
channels
,
int
number
){
PayloadType
*
pt
=
payload_type_new
();
if
(
strcasecmp
(
type
,
"audio"
)
==
0
){
pt
->
type
=
PAYLOAD_AUDIO_PACKETIZED
;
}
else
if
(
strcasecmp
(
type
,
"video"
)
==
0
){
pt
->
type
=
PAYLOAD_VIDEO
;
}
else
{
fprintf
(
stderr
,
"Unsupported payload type should be audio or video, not %s
\n
"
,
type
);
exit
(
-
1
);
}
pt
->
mime_type
=
ms_strdup
(
subtype
);
pt
->
clock_rate
=
atoi
(
rate
);
pt
->
channels
=
atoi
(
channels
);
return
pt
;
}
PayloadType
*
ms_tools_parse_custom_payload
(
const
char
*
name
){
char
type
[
64
]
=
{
0
};
char
subtype
[
64
]
=
{
0
};
char
clockrate
[
64
]
=
{
0
};
char
nchannels
[
64
];
char
*
separator
;
if
(
strlen
(
name
)
>=
sizeof
(
clockrate
)
-
1
){
fprintf
(
stderr
,
"Cannot parse %s: too long.
\n
"
,
name
);
exit
(
-
1
);
}
separator
=
strchr
(
name
,
'/'
);
if
(
separator
){
char
*
separator2
;
strncpy
(
type
,
name
,
separator
-
name
);
separator2
=
strchr
(
separator
+
1
,
'/'
);
if
(
separator2
){
char
*
separator3
;
strncpy
(
subtype
,
separator
+
1
,
separator2
-
separator
-
1
);
separator3
=
strchr
(
separator2
+
1
,
'/'
);
if
(
separator3
){
strncpy
(
clockrate
,
separator2
+
1
,
separator3
-
separator2
-
1
);
strcpy
(
nchannels
,
separator3
+
1
);
}
else
{
nchannels
[
0
]
=
'1'
;
nchannels
[
1
]
=
'\0'
;
strcpy
(
clockrate
,
separator2
+
1
);
}
fprintf
(
stdout
,
"Found custom payload type=%s, mime=%s, clockrate=%s nchannels=%s
\n
"
,
type
,
subtype
,
clockrate
,
nchannels
);
return
create_custom_payload_type
(
type
,
subtype
,
clockrate
,
nchannels
,
114
);
}
}
fprintf
(
stderr
,
"Error parsing payload name %s.
\n
"
,
name
);
exit
(
-
1
);
}
\ No newline at end of file
tools/common.h
0 → 100644
View file @
4ca3bf8a
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2014 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "mediastreamer2/mediastream.h"
PayloadType
*
ms_tools_parse_custom_payload
(
const
char
*
name
);
\ No newline at end of file
tools/mediastream.c
View file @
4ca3bf8a
...
...
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <math.h>
#include "
mediastreamer2/mediastream
.h"
#include "
common
.h"
#include "mediastreamer2/msequalizer.h"
#include "mediastreamer2/msvolume.h"
#ifdef VIDEO_ENABLED
...
...
@@ -174,8 +174,6 @@ static bool_t parse_ice_addr(char* addr, char* type, int type_len, char* ip, int
static
void
display_items
(
void
*
user_data
,
uint32_t
csrc
,
rtcp_sdes_type_t
t
,
const
char
*
content
,
uint8_t
content_len
);
static
void
parse_rtcp
(
mblk_t
*
m
);
static
void
parse_events
(
RtpSession
*
session
,
OrtpEvQueue
*
q
);
static
PayloadType
*
create_custom_payload_type
(
const
char
*
type
,
const
char
*
subtype
,
const
char
*
rate
,
const
char
*
channels
,
int
number
);
static
PayloadType
*
parse_custom_payload
(
const
char
*
name
);
static
bool_t
parse_window_ids
(
const
char
*
ids
,
int
*
video_id
,
int
*
preview_id
);
const
char
*
usage
=
"mediastream --local <port> --remote <ip:port>
\n
"
...
...
@@ -397,7 +395,7 @@ bool_t parse_args(int argc, char** argv, MediastreamDatas* out) {
out
->
payload
=
atoi
(
argv
[
i
]);
}
else
{
out
->
payload
=
114
;
out
->
custom_pt
=
parse_custom_payload
(
argv
[
i
]);
out
->
custom_pt
=
ms_tools_
parse_custom_payload
(
argv
[
i
]);
}
}
else
if
(
strcmp
(
argv
[
i
],
"--fmtp"
)
==
0
){
i
++
;
...
...
@@ -1193,61 +1191,6 @@ static void parse_events(RtpSession *session, OrtpEvQueue *q){
}
}
static
PayloadType
*
create_custom_payload_type
(
const
char
*
type
,
const
char
*
subtype
,
const
char
*
rate
,
const
char
*
channels
,
int
number
){
PayloadType
*
pt
=
payload_type_new
();
if
(
strcasecmp
(
type
,
"audio"
)
==
0
){
pt
->
type
=
PAYLOAD_AUDIO_PACKETIZED
;
}
else
if
(
strcasecmp
(
type
,
"video"
)
==
0
){
pt
->
type
=
PAYLOAD_VIDEO
;
}
else
{
fprintf
(
stderr
,
"Unsupported payload type should be audio or video, not %s
\n
"
,
type
);
exit
(
-
1
);
}
pt
->
mime_type
=
ms_strdup
(
subtype
);
pt
->
clock_rate
=
atoi
(
rate
);
pt
->
channels
=
atoi
(
channels
);
return
pt
;
}
static
PayloadType
*
parse_custom_payload
(
const
char
*
name
){
char
type
[
64
]
=
{
0
};
char
subtype
[
64
]
=
{
0
};
char
clockrate
[
64
]
=
{
0
};
char
nchannels
[
64
];
char
*
separator
;
if
(
strlen
(
name
)
>=
sizeof
(
clockrate
)
-
1
){
fprintf
(
stderr
,
"Cannot parse %s: too long.
\n
"
,
name
);
exit
(
-
1
);
}
separator
=
strchr
(
name
,
'/'
);
if
(
separator
){
char
*
separator2
;
strncpy
(
type
,
name
,
separator
-
name
);
separator2
=
strchr
(
separator
+
1
,
'/'
);
if
(
separator2
){
char
*
separator3
;
strncpy
(
subtype
,
separator
+
1
,
separator2
-
separator
-
1
);
separator3
=
strchr
(
separator2
+
1
,
'/'
);
if
(
separator3
){
strncpy
(
clockrate
,
separator2
+
1
,
separator3
-
separator2
-
1
);
strcpy
(
nchannels
,
separator3
+
1
);
}
else
{
nchannels
[
0
]
=
'1'
;
nchannels
[
1
]
=
'\0'
;
strcpy
(
clockrate
,
separator2
+
1
);
}
fprintf
(
stdout
,
"Found custom payload type=%s, mime=%s, clockrate=%s nchannels=%s
\n
"
,
type
,
subtype
,
clockrate
,
nchannels
);
return
create_custom_payload_type
(
type
,
subtype
,
clockrate
,
nchannels
,
114
);
}
}
fprintf
(
stderr
,
"Error parsing payload name %s.
\n
"
,
name
);
exit
(
-
1
);
}
static
bool_t
parse_window_ids
(
const
char
*
ids
,
int
*
video_id
,
int
*
preview_id
)
{
char
*
copy
=
strdup
(
ids
);
...
...
tools/pcap_playback.c
View file @
4ca3bf8a
...
...
@@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <math.h>
#include "
mediastreamer2/mediastream
.h"
#include "
common
.h"
#include "mediastreamer2/msequalizer.h"
#include "mediastreamer2/msfileplayer.h"
#include "mediastreamer2/msvolume.h"
...
...
@@ -137,6 +137,9 @@ static bool_t parse_args(int argc, char **argv, MediastreamDatas *out)
i
++
;
if
(
isdigit
(
argv
[
i
][
0
]))
{
out
->
payload
=
atoi
(
argv
[
i
]);
}
else
{
out
->
payload
=
114
;
out
->
pt
=
ms_tools_parse_custom_payload
(
argv
[
i
]);
}
}
else
if
(
strcmp
(
argv
[
i
],
"--playback-card"
)
==
0
)
{
i
++
;
...
...
@@ -196,7 +199,8 @@ static void setup_media_streams(MediastreamDatas *args)
ms_filter_reset_statistics
();
signal
(
SIGINT
,
stop_handler
);
args
->
pt
=
rtp_profile_get_payload
(
args
->
profile
,
args
->
payload
);
if
(
args
->
pt
==
NULL
)
args
->
pt
=
rtp_profile_get_payload
(
args
->
profile
,
args
->
payload
);
if
(
args
->
pt
==
NULL
)
{
printf
(
"Error: no payload defined with number %i."
,
args
->
payload
);
exit
(
-
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment