Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
268ff7ea
Commit
268ff7ea
authored
Sep 25, 2005
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Undo coding style fixes to make syncing with Xine code easier
parent
96537a3c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
892 additions
and
981 deletions
+892
-981
modules/access/rtsp/real.c
modules/access/rtsp/real.c
+302
-318
modules/access/rtsp/real_rmff.c
modules/access/rtsp/real_rmff.c
+315
-354
modules/access/rtsp/real_sdpplin.c
modules/access/rtsp/real_sdpplin.c
+275
-309
No files found.
modules/access/rtsp/real.c
View file @
268ff7ea
...
...
@@ -247,8 +247,7 @@ static void call_hash (char *key, char *challenge, int len) {
memcpy
(
key
+
b
+
24
,
challenge
+
c
,
len
-
c
);
}
static
void
calc_response
(
char
*
result
,
char
*
field
)
{
static
void
calc_response
(
char
*
result
,
char
*
field
)
{
char
buf1
[
128
];
char
buf2
[
128
];
int
i
;
...
...
@@ -273,9 +272,7 @@ static void calc_response (char *result, char *field)
memcpy
(
result
,
field
,
16
);
}
static
void
calc_response_string
(
char
*
result
,
char
*
challenge
)
{
static
void
calc_response_string
(
char
*
result
,
char
*
challenge
)
{
char
field
[
128
];
char
zres
[
20
];
int
i
;
...
...
@@ -304,8 +301,8 @@ static void calc_response_string (char *result, char *challenge)
}
}
void
real_calc_response_and_checksum
(
char
*
response
,
char
*
chksum
,
char
*
challenge
)
{
void
real_calc_response_and_checksum
(
char
*
response
,
char
*
chksum
,
char
*
challenge
)
{
int
ch_len
,
table_len
,
resp_len
;
int
i
;
char
*
ptr
;
...
...
@@ -366,8 +363,8 @@ void real_calc_response_and_checksum (char *response, char *chksum, char *challe
* takes a MLTI-Chunk and a rule number got from match_asm_rule,
* returns a pointer to selected data and number of bytes in that.
*/
static
int
select_mlti_data
(
const
char
*
mlti_chunk
,
int
mlti_size
,
int
selection
,
char
**
out
)
{
static
int
select_mlti_data
(
const
char
*
mlti_chunk
,
int
mlti_size
,
int
selection
,
char
**
out
)
{
int
numrules
,
codec
,
size
;
int
i
;
...
...
@@ -423,8 +420,8 @@ static int select_mlti_data(const char *mlti_chunk, int mlti_size, int selection
* looking at stream description.
*/
rmff_header_t
*
real_parse_sdp
(
char
*
data
,
char
**
stream_rules
,
uint32_t
bandwidth
)
{
rmff_header_t
*
real_parse_sdp
(
char
*
data
,
char
**
stream_rules
,
uint32_t
bandwidth
)
{
sdpplin_t
*
desc
=
NULL
;
rmff_header_t
*
header
=
NULL
;
char
*
buf
=
NULL
;
...
...
@@ -462,8 +459,9 @@ rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t bandwidt
memset
(
header
->
streams
,
0
,
sizeof
(
rmff_mdpr_t
*
)
*
(
desc
->
stream_count
+
1
));
lprintf
(
"number of streams: %u
\n
"
,
desc
->
stream_count
);
for
(
i
=
0
;
i
<
desc
->
stream_count
;
i
++
)
{
for
(
i
=
0
;
i
<
desc
->
stream_count
;
i
++
)
{
int
j
=
0
;
int
n
;
char
b
[
64
];
...
...
@@ -472,20 +470,17 @@ rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t bandwidt
lprintf
(
"calling asmrp_match with:
\n
%s
\n
%u
\n
"
,
desc
->
stream
[
i
]
->
asm_rule_book
,
bandwidth
);
n
=
asmrp_match
(
desc
->
stream
[
i
]
->
asm_rule_book
,
bandwidth
,
rulematches
);
for
(
j
=
0
;
j
<
n
;
j
++
)
{
for
(
j
=
0
;
j
<
n
;
j
++
)
{
lprintf
(
"asmrp rule match: %u for stream %u
\n
"
,
rulematches
[
j
],
desc
->
stream
[
i
]
->
stream_id
);
sprintf
(
b
,
"stream=%u;rule=%u,"
,
desc
->
stream
[
i
]
->
stream_id
,
rulematches
[
j
]);
strcat
(
*
stream_rules
,
b
);
}
if
(
!
desc
->
stream
[
i
]
->
mlti_data
)
{
if
(
!
desc
->
stream
[
i
]
->
mlti_data
)
{
len
=
0
;
if
(
buf
)
free
(
buf
);
buf
=
NULL
;
}
else
}
else
len
=
select_mlti_data
(
desc
->
stream
[
i
]
->
mlti_data
,
desc
->
stream
[
i
]
->
mlti_data_size
,
rulematches
[
0
],
&
buf
);
...
...
@@ -533,8 +528,7 @@ rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t bandwidt
rmff_fix_header
(
header
);
if
(
desc
)
{
if
(
desc
)
{
sdpplin_free
(
desc
);
free
(
desc
);
}
...
...
@@ -542,13 +536,11 @@ rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t bandwidt
return
header
;
error:
if
(
desc
)
{
if
(
desc
)
{
sdpplin_free
(
desc
);
free
(
desc
);
}
if
(
header
)
{
if
(
header
)
{
rmff_free_header
(
header
);
free
(
header
);
}
...
...
@@ -556,8 +548,8 @@ error:
return
NULL
;
}
int
real_get_rdt_chunk_header
(
rtsp_client_t
*
rtsp_session
,
rmff_pheader_t
*
ph
)
{
int
real_get_rdt_chunk_header
(
rtsp_client_t
*
rtsp_session
,
rmff_pheader_t
*
ph
)
{
int
n
=
1
;
uint8_t
header
[
8
];
int
size
;
...
...
@@ -566,20 +558,16 @@ int real_get_rdt_chunk_header(rtsp_client_t *rtsp_session, rmff_pheader_t *ph)
uint32_t
ts
;
n
=
rtsp_read_data
(
rtsp_session
,
header
,
8
);
if
(
n
<
8
)
return
0
;
if
(
header
[
0
]
!=
0x24
)
{
if
(
n
<
8
)
return
0
;
if
(
header
[
0
]
!=
0x24
)
{
lprintf
(
"rdt chunk not recognized: got 0x%02x
\n
"
,
header
[
0
]);
return
0
;
}
size
=
(
header
[
1
]
<<
16
)
+
(
header
[
2
]
<<
8
)
+
(
header
[
3
]);
flags1
=
header
[
4
];
if
((
flags1
!=
0x40
)
&&
(
flags1
!=
0x42
))
{
if
((
flags1
!=
0x40
)
&&
(
flags1
!=
0x42
))
{
lprintf
(
"got flags1: 0x%02x
\n
"
,
flags1
);
if
(
header
[
6
]
==
0x06
)
{
if
(
header
[
6
]
==
0x06
)
{
lprintf
(
"got end of stream packet
\n
"
);
return
0
;
}
...
...
@@ -587,19 +575,16 @@ int real_get_rdt_chunk_header(rtsp_client_t *rtsp_session, rmff_pheader_t *ph)
header
[
1
]
=
header
[
6
];
header
[
2
]
=
header
[
7
];
n
=
rtsp_read_data
(
rtsp_session
,
header
+
3
,
5
);
if
(
n
<
5
)
return
0
;
if
(
n
<
5
)
return
0
;
lprintf
(
"ignoring bytes:
\n
"
);
n
=
rtsp_read_data
(
rtsp_session
,
header
+
4
,
4
);
if
(
n
<
4
)
return
0
;
if
(
n
<
4
)
return
0
;
flags1
=
header
[
4
];
size
-=
9
;
}
unknown1
=
(
header
[
5
]
<<
16
)
+
(
header
[
6
]
<<
8
)
+
(
header
[
7
]);
n
=
rtsp_read_data
(
rtsp_session
,
header
,
6
);
if
(
n
<
6
)
return
0
;
if
(
n
<
6
)
return
0
;
ts
=
BE_32
(
header
);
#if 0
...
...
@@ -618,8 +603,8 @@ int real_get_rdt_chunk_header(rtsp_client_t *rtsp_session, rmff_pheader_t *ph)
}
int
real_get_rdt_chunk
(
rtsp_client_t
*
rtsp_session
,
rmff_pheader_t
*
ph
,
unsigned
char
**
buffer
)
{
unsigned
char
**
buffer
)
{
int
n
;
rmff_dump_pheader
(
ph
,
*
buffer
);
n
=
rtsp_read_data
(
rtsp_session
,
*
buffer
+
12
,
ph
->
length
-
12
);
...
...
@@ -628,8 +613,8 @@ int real_get_rdt_chunk(rtsp_client_t *rtsp_session, rmff_pheader_t *ph,
//! maximum size of the rtsp description, must be < INT_MAX
#define MAX_DESC_BUF (20 * 1024 * 1024)
rmff_header_t
*
real_setup_and_get_header
(
rtsp_client_t
*
rtsp_session
,
int
bandwidth
)
{
rmff_header_t
*
real_setup_and_get_header
(
rtsp_client_t
*
rtsp_session
,
int
bandwidth
)
{
char
*
description
=
NULL
;
char
*
session_id
=
NULL
;
rmff_header_t
*
h
;
...
...
@@ -658,8 +643,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_client_t *rtsp_session, int bandw
rtsp_schedule_field
(
rtsp_session
,
"Require: com.real.retain-entity-for-setup"
);
status
=
rtsp_request_describe
(
rtsp_session
,
NULL
);
if
(
status
<
200
||
status
>
299
)
{
if
(
status
<
200
||
status
>
299
)
{
char
*
alert
=
rtsp_search_answers
(
rtsp_session
,
"Alert"
);
if
(
alert
)
{
lprintf
(
"real: got message from server:
\n
%s
\n
"
,
alert
);
...
...
@@ -712,10 +696,10 @@ rmff_header_t *real_setup_and_get_header(rtsp_client_t *rtsp_session, int bandw
rmff_fix_header
(
h
);
#if 0
#if 0
fprintf("Title: %s\nCopyright: %s\nAuthor: %s\nStreams: %i\n",
h->cont->title, h->cont->copyright, h->cont->author, h->prop->num_streams);
#endif
#endif
/* setup our streams */
real_calc_response_and_checksum
(
challenge2
,
checksum
,
challenge1
);
...
...
modules/access/rtsp/real_rmff.c
View file @
268ff7ea
...
...
@@ -183,8 +183,8 @@ static void rmff_dump_cont(rmff_cont_t *cont, char *buffer) {
cont
->
object_id
=
BE_32
(
&
cont
->
object_id
);
}
static
void
rmff_dump_dataheader
(
rmff_data_t
*
data
,
char
*
buffer
)
{
static
void
rmff_dump_dataheader
(
rmff_data_t
*
data
,
char
*
buffer
)
{
if
(
!
data
)
return
;
data
->
object_id
=
BE_32
(
&
data
->
object_id
);
...
...
@@ -247,8 +247,8 @@ void rmff_dump_pheader(rmff_pheader_t *h, char *data) {
data
[
11
]
=
h
->
flags
;
}
rmff_fileheader_t
*
rmff_new_fileheader
(
uint32_t
num_headers
)
{
rmff_fileheader_t
*
rmff_new_fileheader
(
uint32_t
num_headers
)
{
rmff_fileheader_t
*
fileheader
=
malloc
(
sizeof
(
rmff_fileheader_t
));
if
(
!
fileheader
)
return
NULL
;
...
...
@@ -273,8 +273,8 @@ rmff_prop_t *rmff_new_prop (
uint32_t
index_offset
,
uint32_t
data_offset
,
uint16_t
num_streams
,
uint16_t
flags
)
{
uint16_t
flags
)
{
rmff_prop_t
*
prop
=
malloc
(
sizeof
(
rmff_prop_t
));
if
(
!
prop
)
return
NULL
;
...
...
@@ -309,8 +309,8 @@ rmff_mdpr_t *rmff_new_mdpr(
const
char
*
stream_name
,
const
char
*
mime_type
,
uint32_t
type_specific_len
,
const
char
*
type_specific_data
)
{
const
char
*
type_specific_data
)
{
rmff_mdpr_t
*
mdpr
=
malloc
(
sizeof
(
rmff_mdpr_t
));
if
(
!
mdpr
)
return
NULL
;
...
...
@@ -326,22 +326,19 @@ rmff_mdpr_t *rmff_new_mdpr(
mdpr
->
preroll
=
preroll
;
mdpr
->
duration
=
duration
;
mdpr
->
stream_name_size
=
0
;
if
(
stream_name
)
{
if
(
stream_name
)
{
mdpr
->
stream_name
=
strdup
(
stream_name
);
mdpr
->
stream_name_size
=
strlen
(
stream_name
);
}
mdpr
->
mime_type_size
=
0
;
if
(
mime_type
)
{
if
(
mime_type
)
{
mdpr
->
mime_type
=
strdup
(
mime_type
);
mdpr
->
mime_type_size
=
strlen
(
mime_type
);
}
mdpr
->
type_specific_len
=
type_specific_len
;
mdpr
->
type_specific_data
=
malloc
(
sizeof
(
char
)
*
type_specific_len
);
if
(
!
mdpr
->
type_specific_data
)
{
if
(
!
mdpr
->
type_specific_data
)
{
if
(
mdpr
->
stream_name
)
free
(
mdpr
->
stream_name
);
free
(
mdpr
);
return
NULL
;
...
...
@@ -352,8 +349,8 @@ rmff_mdpr_t *rmff_new_mdpr(
return
mdpr
;
}
rmff_cont_t
*
rmff_new_cont
(
const
char
*
title
,
const
char
*
author
,
const
char
*
copyright
,
const
char
*
comment
)
{
rmff_cont_t
*
rmff_new_cont
(
const
char
*
title
,
const
char
*
author
,
const
char
*
copyright
,
const
char
*
comment
)
{
rmff_cont_t
*
cont
=
malloc
(
sizeof
(
rmff_cont_t
));
if
(
!
cont
)
return
NULL
;
...
...
@@ -369,8 +366,7 @@ rmff_cont_t *rmff_new_cont(const char *title, const char *author, const char *co
cont
->
copyright_len
=
0
;
cont
->
comment_len
=
0
;
if
(
title
)
{
if
(
title
)
{
cont
->
title_len
=
strlen
(
title
);
cont
->
title
=
strdup
(
title
);
}
...
...
@@ -379,13 +375,11 @@ rmff_cont_t *rmff_new_cont(const char *title, const char *author, const char *co
cont
->
author_len
=
strlen
(
author
);
cont
->
author
=
strdup
(
author
);
}
if
(
copyright
)
{
if
(
copyright
)
{
cont
->
copyright_len
=
strlen
(
copyright
);
cont
->
copyright
=
strdup
(
copyright
);
}
if
(
comment
)
{
if
(
comment
)
{
cont
->
comment_len
=
strlen
(
comment
);
cont
->
comment
=
strdup
(
comment
);
}
...
...
@@ -393,8 +387,7 @@ rmff_cont_t *rmff_new_cont(const char *title, const char *author, const char *co
return
cont
;
}
rmff_data_t
*
rmff_new_dataheader
(
uint32_t
num_packets
,
uint32_t
next_data_header
)
{
rmff_data_t
*
rmff_new_dataheader
(
uint32_t
num_packets
,
uint32_t
next_data_header
)
{
rmff_data_t
*
data
=
malloc
(
sizeof
(
rmff_data_t
));
if
(
!
data
)
return
NULL
;
...
...
@@ -408,31 +401,26 @@ rmff_data_t *rmff_new_dataheader(uint32_t num_packets, uint32_t next_data_header
return
data
;
}
void
rmff_print_header
(
rmff_header_t
*
h
)
{
void
rmff_print_header
(
rmff_header_t
*
h
)
{
rmff_mdpr_t
**
stream
;
if
(
!
h
)
{
if
(
!
h
)
{
printf
(
"rmff_print_header: NULL given
\n
"
);
return
;
}
if
(
h
->
fileheader
)
{
if
(
h
->
fileheader
)
{
printf
(
"
\n
FILE:
\n
"
);
printf
(
"file version : %d
\n
"
,
h
->
fileheader
->
file_version
);
printf
(
"number of headers : %d
\n
"
,
h
->
fileheader
->
num_headers
);
}
if
(
h
->
cont
)
{
if
(
h
->
cont
)
{
printf
(
"
\n
CONTENT:
\n
"
);
printf
(
"title : %s
\n
"
,
h
->
cont
->
title
);
printf
(
"author : %s
\n
"
,
h
->
cont
->
author
);
printf
(
"copyright : %s
\n
"
,
h
->
cont
->
copyright
);
printf
(
"comment : %s
\n
"
,
h
->
cont
->
comment
);
}
if
(
h
->
prop
)
{
if
(
h
->
prop
)
{
printf
(
"
\n
STREAM PROPERTIES:
\n
"
);
printf
(
"bit rate (max/avg) : %i/%i
\n
"
,
h
->
prop
->
max_bit_rate
,
h
->
prop
->
avg_bit_rate
);
printf
(
"packet size (max/avg) : %i/%i bytes
\n
"
,
h
->
prop
->
max_packet_size
,
h
->
prop
->
avg_packet_size
);
...
...
@@ -449,10 +437,8 @@ void rmff_print_header(rmff_header_t *h)
printf
(
"
\n
"
);
}
stream
=
h
->
streams
;
if
(
stream
)
{
while
(
*
stream
)
{
if
(
stream
)
{
while
(
*
stream
)
{
printf
(
"
\n
STREAM %i:
\n
"
,
(
*
stream
)
->
stream_number
);
printf
(
"stream name [mime type] : %s [%s]
\n
"
,
(
*
stream
)
->
stream_name
,
(
*
stream
)
->
mime_type
);
printf
(
"bit rate (max/avg) : %i/%i
\n
"
,
(
*
stream
)
->
max_bit_rate
,
(
*
stream
)
->
avg_bit_rate
);
...
...
@@ -464,8 +450,7 @@ void rmff_print_header(rmff_header_t *h)
stream
++
;
}
}
if
(
h
->
data
)
{
if
(
h
->
data
)
{
printf
(
"
\n
DATA:
\n
"
);
printf
(
"size : %i
\n
"
,
h
->
data
->
size
);
printf
(
"packets : %i
\n
"
,
h
->
data
->
num_packets
);
...
...
@@ -473,63 +458,50 @@ void rmff_print_header(rmff_header_t *h)
}
}
void
rmff_fix_header
(
rmff_header_t
*
h
)
{
void
rmff_fix_header
(
rmff_header_t
*
h
)
{
unsigned
int
num_headers
=
0
;
unsigned
int
header_size
=
0
;
rmff_mdpr_t
**
streams
;
int
num_streams
=
0
;
if
(
!
h
)
{
if
(
!
h
)
{
lprintf
(
"rmff_fix_header: fatal: no header given.
\n
"
);
return
;
}
if
(
!
h
->
streams
)
{
if
(
!
h
->
streams
)
{
lprintf
(
"rmff_fix_header: warning: no MDPR chunks
\n
"
);
}
else
{
}
else
{
streams
=
h
->
streams
;
while
(
*
streams
)
{
while
(
*
streams
)
{
num_streams
++
;
num_headers
++
;
header_size
+=
(
*
streams
)
->
size
;
streams
++
;
}
}
if
(
h
->
prop
)
{
if
(
h
->
prop
->
size
!=
50
)
{
if
(
h
->
prop
)
{
if
(
h
->
prop
->
size
!=
50
)
{
lprintf
(
"rmff_fix_header: correcting prop.size from %i to %i
\n
"
,
h
->
prop
->
size
,
50
);
h
->
prop
->
size
=
50
;
}
if
(
h
->
prop
->
num_streams
!=
num_streams
)
{
if
(
h
->
prop
->
num_streams
!=
num_streams
)
{
lprintf
(
"rmff_fix_header: correcting prop.num_streams from %i to %i
\n
"
,
h
->
prop
->
num_streams
,
num_streams
);
h
->
prop
->
num_streams
=
num_streams
;
}
num_headers
++
;
header_size
+=
50
;
}
else
lprintf
(
"rmff_fix_header: warning: no PROP chunk.
\n
"
);
}
else
lprintf
(
"rmff_fix_header: warning: no PROP chunk.
\n
"
);
if
(
h
->
cont
)
{
if
(
h
->
cont
)
{
num_headers
++
;
header_size
+=
h
->
cont
->
size
;
}
else
lprintf
(
"rmff_fix_header: warning: no CONT chunk.
\n
"
);
}
else
lprintf
(
"rmff_fix_header: warning: no CONT chunk.
\n
"
);
if
(
!
h
->
data
)
{
if
(
!
h
->
data
)
{
lprintf
(
"rmff_fix_header: no DATA chunk, creating one
\n
"
);
h
->
data
=
malloc
(
sizeof
(
rmff_data_t
));
if
(
h
->
data
)
{
if
(
h
->
data
)
{
memset
(
h
->
data
,
0
,
sizeof
(
rmff_data_t
));
h
->
data
->
object_id
=
DATA_TAG
;
h
->
data
->
object_version
=
0
;
...
...
@@ -540,12 +512,10 @@ void rmff_fix_header(rmff_header_t *h)
}
num_headers
++
;
if
(
!
h
->
fileheader
)
{
if
(
!
h
->
fileheader
)
{
lprintf
(
"rmff_fix_header: no fileheader, creating one"
);
h
->
fileheader
=
malloc
(
sizeof
(
rmff_fileheader_t
));
if
(
h
->
fileheader
)
{
if
(
h
->
fileheader
)
{
memset
(
h
->
fileheader
,
0
,
sizeof
(
rmff_fileheader_t
));
h
->
fileheader
->
object_id
=
RMF_TAG
;
h
->
fileheader
->
size
=
34
;
...
...
@@ -557,26 +527,21 @@ void rmff_fix_header(rmff_header_t *h)
header_size
+=
h
->
fileheader
->
size
;
num_headers
++
;
if
(
h
->
fileheader
->
num_headers
!=
num_headers
)
{
if
(
h
->
fileheader
->
num_headers
!=
num_headers
)
{
lprintf
(
"rmff_fix_header: setting num_headers from %i to %i
\n
"
,
h
->
fileheader
->
num_headers
,
num_headers
);
h
->
fileheader
->
num_headers
=
num_headers
;
}
if
(
h
->
prop
)
{
if
(
h
->
prop
->
data_offset
!=
header_size
)
{
if
(
h
->
prop
)
{
if
(
h
->
prop
->
data_offset
!=
header_size
)
{
lprintf
(
"rmff_fix_header: setting prop.data_offset from %i to %i
\n
"
,
h
->
prop
->
data_offset
,
header_size
);
h
->
prop
->
data_offset
=
header_size
;
}
if
(
h
->
prop
->
num_packets
==
0
)
{
if
(
h
->
prop
->
num_packets
==
0
)
{
int
p
=
(
int
)(
h
->
prop
->
avg_bit_rate
/
8
.
0
*
(
h
->
prop
->
duration
/
1000
.
0
)
/
h
->
prop
->
avg_packet_size
);
lprintf
(
"rmff_fix_header: assuming prop.num_packets=%i
\n
"
,
p
);
h
->
prop
->
num_packets
=
p
;
}
if
(
h
->
data
->
num_packets
==
0
)
{
if
(
h
->
data
->
num_packets
==
0
)
{
lprintf
(
"rmff_fix_header: assuming data.num_packets=%i
\n
"
,
h
->
prop
->
num_packets
);
h
->
data
->
num_packets
=
h
->
prop
->
num_packets
;
}
...
...
@@ -585,8 +550,7 @@ void rmff_fix_header(rmff_header_t *h)
}
}
int
rmff_get_header_size
(
rmff_header_t
*
h
)
{
int
rmff_get_header_size
(
rmff_header_t
*
h
)
{
if
(
!
h
)
return
0
;
if
(
!
h
->
prop
)
return
-
1
;
return
h
->
prop
->
data_offset
+
18
;
...
...
@@ -599,20 +563,17 @@ void rmff_free_header(rmff_header_t *h)
if
(
h
->
fileheader
)
free
(
h
->
fileheader
);
if
(
h
->
prop
)
free
(
h
->
prop
);
if
(
h
->
data
)
free
(
h
->
data
);
if
(
h
->
cont
)
{
if
(
h
->
cont
)
{
free
(
h
->
cont
->
title
);
free
(
h
->
cont
->
author
);
free
(
h
->
cont
->
copyright
);
free
(
h
->
cont
->
comment
);
free
(
h
->
cont
);
}
if
(
h
->
streams
)
{
if
(
h
->
streams
)
{
rmff_mdpr_t
**
s
=
h
->
streams
;
while
(
*
s
)
{
while
(
*
s
)
{
free
((
*
s
)
->
stream_name
);
free
((
*
s
)
->
mime_type
);
free
((
*
s
)
->
type_specific_data
);
...
...
modules/access/rtsp/real_sdpplin.c
View file @
268ff7ea
...
...
@@ -29,8 +29,8 @@
* Decodes base64 strings (based upon b64 package)
*/
static
char
*
b64_decode
(
const
char
*
in
,
char
*
out
,
int
*
size
)
{
static
char
*
b64_decode
(
const
char
*
in
,
char
*
out
,
int
*
size
)
{
char
dtable
[
256
];
/* Encode / decode table */
int
i
,
k
;
unsigned
int
j
;
...
...
@@ -53,16 +53,13 @@ static char *b64_decode(const char *in, char *out, int *size)
k
=
0
;
/*CONSTANTCONDITION*/
for
(
j
=
0
;
j
<
strlen
(
in
);
j
+=
4
)
{
for
(
j
=
0
;
j
<
strlen
(
in
);
j
+=
4
)
{
char
a
[
4
],
b
[
4
];
for
(
i
=
0
;
i
<
4
;
i
++
)
{
for
(
i
=
0
;
i
<
4
;
i
++
)
{
int
c
=
in
[
i
+
j
];
if
(
dtable
[
c
]
&
0x80
)
{
if
(
dtable
[
c
]
&
0x80
)
{
printf
(
"Illegal character '%c' in input.
\n
"
,
c
);
exit
(
1
);
}
...
...
@@ -74,8 +71,7 @@ static char *b64_decode(const char *in, char *out, int *size)
out
[
k
++
]
=
(
b
[
1
]
<<
4
)
|
(
b
[
2
]
>>
2
);
out
[
k
++
]
=
(
b
[
2
]
<<
6
)
|
b
[
3
];
i
=
a
[
2
]
==
'='
?
1
:
(
a
[
3
]
==
'='
?
2
:
3
);
if
(
i
<
3
)
{
if
(
i
<
3
)
{
out
[
k
]
=
0
;
*
size
=
k
;
return
out
;
...
...
@@ -86,23 +82,21 @@ static char *b64_decode(const char *in, char *out, int *size)
return
out
;
}
static
char
*
nl
(
char
*
data
)
{
static
char
*
nl
(
char
*
data
)
{
char
*
nlptr
=
(
data
)
?
strchr
(
data
,
'\n'
)
:
NULL
;
return
(
nlptr
)
?
nlptr
+
1
:
NULL
;
}
static
int
filter
(
const
char
*
in
,
const
char
*
filter
,
char
**
out
)
{
static
int
filter
(
const
char
*
in
,
const
char
*
filter
,
char
**
out
)
{
int
flen
=
strlen
(
filter
);
int
len
;
if
(
!
in
)
return
0
;
if
(
!
in
)
return
0
;
len
=
(
strchr
(
in
,
'\n'
))
?
strchr
(
in
,
'\n'
)
-
in
:
strlen
(
in
);
if
(
!
strncmp
(
in
,
filter
,
flen
))
{
if
(
!
strncmp
(
in
,
filter
,
flen
))
{
if
(
in
[
flen
]
==
'"'
)
flen
++
;
if
(
in
[
len
-
1
]
==
13
)
len
--
;
if
(
in
[
len
-
1
]
==
'"'
)
len
--
;
...
...
@@ -113,8 +107,8 @@ static int filter(const char *in, const char *filter, char **out)
return
0
;
}
static
sdpplin_stream_t
*
sdpplin_parse_stream
(
char
**
data
)
{
static
sdpplin_stream_t
*
sdpplin_parse_stream
(
char
**
data
)
{
sdpplin_stream_t
*
desc
=
malloc
(
sizeof
(
sdpplin_stream_t
));
char
*
buf
=
malloc
(
32000
);
char
*
decoded
=
malloc
(
32000
);
...
...
@@ -126,77 +120,64 @@ static sdpplin_stream_t *sdpplin_parse_stream(char **data)
if
(
!
buf
)
goto
error
;
if
(
!
decoded
)
goto
error
;
if
(
filter
(
*
data
,
"m="
,
&
buf
))
{
if
(
filter
(
*
data
,
"m="
,
&
buf
))
{
desc
->
id
=
strdup
(
buf
);
}
else
{
}
else
{
lprintf
(
"sdpplin: no m= found.
\n
"
);
goto
error
;
}
*
data
=
nl
(
*
data
);
while
(
*
data
&&
**
data
&&
*
data
[
0
]
!=
'm'
)
{
while
(
*
data
&&
**
data
&&
*
data
[
0
]
!=
'm'
)
{
handled
=
0
;
if
(
filter
(
*
data
,
"a=control:streamid="
,
&
buf
))
{
if
(
filter
(
*
data
,
"a=control:streamid="
,
&
buf
))
{
desc
->
stream_id
=
atoi
(
buf
);
handled
=
1
;
*
data
=
nl
(
*
data
);
}
if
(
filter
(
*
data
,
"a=MaxBitRate:integer;"
,
&
buf
))
{
if
(
filter
(
*
data
,
"a=MaxBitRate:integer;"
,
&
buf
))
{
desc
->
max_bit_rate
=
atoi
(
buf
);
if
(
!
desc
->
avg_bit_rate
)
desc
->
avg_bit_rate
=
desc
->
max_bit_rate
;
handled
=
1
;
*
data
=
nl
(
*
data
);
}
if
(
filter
(
*
data
,
"a=MaxPacketSize:integer;"
,
&
buf
))
{
if
(
filter
(
*
data
,
"a=MaxPacketSize:integer;"
,
&
buf
))
{
desc
->
max_packet_size
=
atoi
(
buf
);
if
(
!
desc
->
avg_packet_size
)
desc
->
avg_packet_size
=
desc
->
max_packet_size
;
handled
=
1
;
*
data
=
nl
(
*
data
);
}
if
(
filter
(
*
data
,
"a=StartTime:integer;"
,
&
buf
))
{
if
(
filter
(
*
data
,
"a=StartTime:integer;"
,
&
buf
))
{
desc
->
start_time
=
atoi
(
buf
);
handled
=
1
;
*
data
=
nl
(
*
data
);
}
if
(
filter
(
*
data
,
"a=Preroll:integer;"
,
&
buf
))
{
if
(
filter
(
*
data
,
"a=Preroll:integer;"
,
&
buf
))
{
desc
->
preroll
=
atoi
(
buf
);
handled
=
1
;
*
data
=
nl
(
*
data
);
}
if
(
filter
(
*
data
,
"a=length:npt="
,
&
buf
))
{
if
(
filter
(
*
data
,
"a=length:npt="
,
&
buf
))
{
desc
->
duration
=
(
uint32_t
)(
atof
(
buf
)
*
1000
);
handled
=
1
;
*
data
=
nl
(
*
data
);
}
if
(
filter
(
*
data
,
"a=StreamName:string;"
,
&
buf
))
{
if
(
filter
(
*
data
,
"a=StreamName:string;"
,
&
buf
))
{
desc
->
stream_name
=
strdup
(
buf
);
desc
->
stream_name_size
=
strlen
(
desc
->
stream_name
);
handled
=
1
;
*
data
=
nl
(
*
data
);
}
if
(
filter
(
*
data
,
"a=mimetype:string;"
,
&
buf
))
{
if
(
filter
(
*
data
,
"a=mimetype:string;"
,
&
buf
))
{
desc
->
mime_type
=
strdup
(
buf
);
desc
->
mime_type_size
=
strlen
(
desc
->
mime_type
);
handled
=
1
;
*
data
=
nl
(
*
data
);
}
if
(
filter
(
*
data
,
"a=OpaqueData:buffer;"
,
&
buf
))
{
if
(
filter
(
*
data
,
"a=OpaqueData:buffer;"
,
&
buf
))
{
decoded
=
b64_decode
(
buf
,
decoded
,
&
(
desc
->
mlti_data_size
));
desc
->
mlti_data
=
malloc
(
sizeof
(
char
)
*
desc
->
mlti_data_size
);
memcpy
(
desc
->
mlti_data
,
decoded
,
desc
->
mlti_data_size
);
...
...
@@ -204,15 +185,13 @@ static sdpplin_stream_t *sdpplin_parse_stream(char **data)
*
data
=
nl
(
*
data
);
lprintf
(
"mlti_data_size: %i
\n
"
,
desc
->
mlti_data_size
);
}
if
(
filter
(
*
data
,
"a=ASMRuleBook:string;"
,
&
buf
))
{
if
(
filter
(
*
data
,
"a=ASMRuleBook:string;"
,
&
buf
))
{
desc
->
asm_rule_book
=
strdup
(
buf
);
handled
=
1
;
*
data
=
nl
(
*
data
);
}
if
(
!
handled
)
{
if
(
!
handled
)
{
#ifdef LOG
int
len
=
strchr
(
*
data
,
'\n'
)
-
(
*
data
);
memcpy
(
buf
,
*
data
,
len
+
1
);
...
...
@@ -233,8 +212,8 @@ error:
return
NULL
;
}
sdpplin_t
*
sdpplin_parse
(
char
*
data
)
{
sdpplin_t
*
sdpplin_parse
(
char
*
data
)
{
sdpplin_t
*
desc
=
malloc
(
sizeof
(
sdpplin_t
));
sdpplin_stream_t
*
stream
;
char
*
buf
=
malloc
(
3200
);
...
...
@@ -243,74 +222,63 @@ sdpplin_t *sdpplin_parse(char *data)
int
len
;
if
(
!
desc
)
return
NULL
;
if
(
!
buf
)
{
if
(
!
buf
)
{
free
(
desc
);
return
NULL
;
}
if
(
!
decoded
)
{
if
(
!
decoded
)
{
free
(
buf
);
free
(
desc
);
return
NULL
;
}
memset
(
desc
,
0
,
sizeof
(
sdpplin_t
));
while
(
data
&&
*
data
)
{
while
(
data
&&
*
data
)
{
handled
=
0
;
if
(
filter
(
data
,
"m="
,
&
buf
))
{
if
(
filter
(
data
,
"m="
,
&
buf
))
{
stream
=
sdpplin_parse_stream
(
&
data
);
lprintf
(
"got data for stream id %u
\n
"
,
stream
->
stream_id
);
desc
->
stream
[
stream
->
stream_id
]
=
stream
;
continue
;
}
if
(
filter
(
data
,
"a=Title:buffer;"
,
&
buf
))
{
if
(
filter
(
data
,
"a=Title:buffer;"
,
&
buf
))
{
decoded
=
b64_decode
(
buf
,
decoded
,
&
len
);
desc
->
title
=
strdup
(
decoded
);
handled
=
1
;
data
=
nl
(
data
);
}
if
(
filter
(
data
,
"a=Author:buffer;"
,
&
buf
))
{
if
(
filter
(
data
,
"a=Author:buffer;"
,
&
buf
))
{
decoded
=
b64_decode
(
buf
,
decoded
,
&
len
);
desc
->
author
=
strdup
(
decoded
);
handled
=
1
;
data
=
nl
(
data
);
}
if
(
filter
(
data
,
"a=Copyright:buffer;"
,
&
buf
))
{
if
(
filter
(
data
,
"a=Copyright:buffer;"
,
&
buf
))
{
decoded
=
b64_decode
(
buf
,
decoded
,
&
len
);
desc
->
copyright
=
strdup
(
decoded
);
handled
=
1
;
data
=
nl
(
data
);
}
if
(
filter
(
data
,
"a=Abstract:buffer;"
,
&
buf
))
{
if
(
filter
(
data
,
"a=Abstract:buffer;"
,
&
buf
))
{
decoded
=
b64_decode
(
buf
,
decoded
,
&
len
);
desc
->
abstract
=
strdup
(
decoded
);
handled
=
1
;
data
=
nl
(
data
);
}
if
(
filter
(
data
,
"a=StreamCount:integer;"
,
&
buf
))
{
if
(
filter
(
data
,
"a=StreamCount:integer;"
,
&
buf
))
{
desc
->
stream_count
=
atoi
(
buf
);
desc
->
stream
=
malloc
(
sizeof
(
sdpplin_stream_t
*
)
*
desc
->
stream_count
);
handled
=
1
;
data
=
nl
(
data
);
}
if
(
filter
(
data
,
"a=Flags:integer;"
,
&
buf
))
{
if
(
filter
(
data
,
"a=Flags:integer;"
,
&
buf
))
{
desc
->
flags
=
atoi
(
buf
);
handled
=
1
;
data
=
nl
(
data
);
}
if
(
!
handled
)
{
if
(
!
handled
)
{
#ifdef LOG
int
len
=
strchr
(
data
,
'\n'
)
-
data
;
memcpy
(
buf
,
data
,
len
+
1
);
...
...
@@ -326,16 +294,14 @@ sdpplin_t *sdpplin_parse(char *data)
return
desc
;
}
void
sdpplin_free
(
sdpplin_t
*
description
)
{
void
sdpplin_free
(
sdpplin_t
*
description
)
{
int
i
;
if
(
!
description
)
return
;
for
(
i
=
0
;
i
<
description
->
stream_count
;
i
++
)
{
if
(
description
->
stream
[
i
]
)
{
for
(
i
=
0
;
i
<
description
->
stream_count
;
i
++
)
{
if
(
description
->
stream
[
i
]
)
{
if
(
description
->
stream
[
i
]
->
id
)
free
(
description
->
stream
[
i
]
->
id
);
if
(
description
->
stream
[
i
]
->
bandwidth
)
free
(
description
->
stream
[
i
]
->
bandwidth
);
if
(
description
->
stream
[
i
]
->
range
)
free
(
description
->
stream
[
i
]
->
range
);
...
...
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