Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
mediastreamer2
Commits
3e2218dc
Commit
3e2218dc
authored
Aug 18, 2015
by
François Grisez
Browse files
Fix crash when MKV recorder reopen a file
parent
d5bd172d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/videofilters/mkv.c
View file @
3e2218dc
...
...
@@ -795,14 +795,13 @@ static void matroska_uninit(Matroska *obj) {
ms_free
(
obj
->
p
);
}
static
int
ebml_reading_profile
(
const
ebml_master
*
head
)
{
size_t
length
=
EBML_ElementDataSize
((
ebml_element
*
)
head
,
FALSE
);
char
*
docType
=
ms_new0
(
char
,
length
);
static
int
ebml_reading_profile
(
ebml_master
*
head
)
{
char
docType
[
9
];
int
profile
;
int
docTypeReadVersion
;
EBML_StringGet
((
ebml_string
*
)
EBML_Master
Find
Child
(
head
,
&
EBML_ContextDocType
),
docType
,
length
);
docTypeReadVersion
=
EBML_IntegerValue
((
ebml_integer
*
)
EBML_Master
Find
Child
(
head
,
&
EBML_ContextDocTypeReadVersion
));
EBML_StringGet
((
ebml_string
*
)
EBML_Master
Get
Child
(
head
,
&
EBML_ContextDocType
),
docType
,
sizeof
(
docType
)
);
docTypeReadVersion
=
EBML_IntegerValue
((
ebml_integer
*
)
EBML_Master
Get
Child
(
head
,
&
EBML_ContextDocTypeReadVersion
));
if
(
strcmp
(
docType
,
"matroska"
)
==
0
)
{
...
...
@@ -827,8 +826,7 @@ static int ebml_reading_profile(const ebml_master *head) {
}
else
{
profile
=
-
1
;
}
ms_free
(
docType
);
return
profile
;
}
...
...
@@ -884,7 +882,7 @@ static ms_bool_t matroska_load_file(Matroska *obj) {
}
}
else
if
(
EBML_ElementIsType
(
elt
,
&
MATROSKA_ContextInfo
))
{
obj
->
info
=
(
ebml_master
*
)
elt
;
obj
->
timecodeScale
=
EBML_IntegerValue
((
ebml_integer
*
)
EBML_Master
Find
Child
(
obj
->
info
,
&
MATROSKA_ContextTimecodeScale
));
obj
->
timecodeScale
=
EBML_IntegerValue
((
ebml_integer
*
)
EBML_Master
Get
Child
(
obj
->
info
,
&
MATROSKA_ContextTimecodeScale
));
MATROSKA_LinkMetaSeekElement
(
obj
->
infoMeta
,
(
ebml_element
*
)
obj
->
info
);
}
else
if
(
EBML_ElementIsType
(
elt
,
&
MATROSKA_ContextTracks
))
{
obj
->
tracks
=
(
ebml_master
*
)
elt
;
...
...
@@ -1000,8 +998,8 @@ static void matroska_close_file(Matroska *obj) {
}
static
void
matroska_set_doctype_version
(
Matroska
*
obj
,
int
doctypeVersion
,
int
doctypeReadVersion
)
{
EBML_IntegerSetValue
((
ebml_integer
*
)
EBML_Master
Find
Child
(
obj
->
header
,
&
EBML_ContextDocTypeVersion
),
doctypeVersion
);
EBML_IntegerSetValue
((
ebml_integer
*
)
EBML_Master
Find
Child
(
obj
->
header
,
&
EBML_ContextDocTypeReadVersion
),
doctypeReadVersion
);
EBML_IntegerSetValue
((
ebml_integer
*
)
EBML_Master
Get
Child
(
obj
->
header
,
&
EBML_ContextDocTypeVersion
),
doctypeVersion
);
EBML_IntegerSetValue
((
ebml_integer
*
)
EBML_Master
Get
Child
(
obj
->
header
,
&
EBML_ContextDocTypeReadVersion
),
doctypeReadVersion
);
}
static
inline
void
matroska_write_ebml_header
(
Matroska
*
obj
)
{
...
...
@@ -1021,7 +1019,7 @@ static int matroska_set_segment_info(Matroska *obj, const char writingApp[], con
}
static
inline
timecode_t
matroska_get_duration
(
const
Matroska
*
obj
)
{
return
(
timecode_t
)
EBML_FloatValue
((
ebml_float
*
)
EBML_Master
Find
Child
(
obj
->
info
,
&
MATROSKA_ContextDuration
));
return
(
timecode_t
)
EBML_FloatValue
((
ebml_float
*
)
EBML_Master
Get
Child
(
obj
->
info
,
&
MATROSKA_ContextDuration
));
}
static
inline
timecode_t
matroska_get_timecode_scale
(
const
Matroska
*
obj
)
{
...
...
@@ -1166,7 +1164,7 @@ static int matroska_close_segment(Matroska *obj) {
static
ebml_master
*
matroska_find_track_entry
(
const
Matroska
*
obj
,
int
trackNum
)
{
ebml_element
*
trackEntry
=
NULL
;
for
(
trackEntry
=
EBML_MasterChildren
(
obj
->
tracks
);
trackEntry
!=
NULL
&&
EBML_IntegerValue
((
ebml_integer
*
)
EBML_Master
Find
Child
((
ebml_master
*
)
trackEntry
,
&
MATROSKA_ContextTrackNumber
))
!=
trackNum
;
trackEntry
!=
NULL
&&
EBML_IntegerValue
((
ebml_integer
*
)
EBML_Master
Get
Child
((
ebml_master
*
)
trackEntry
,
&
MATROSKA_ContextTrackNumber
))
!=
trackNum
;
trackEntry
=
EBML_MasterNext
(
trackEntry
));
return
(
ebml_master
*
)
trackEntry
;
}
...
...
@@ -1176,7 +1174,7 @@ static int matroska_get_codec_private(const Matroska *obj, int trackNum, const u
ebml_binary
*
codecPrivate
;
if
(
trackEntry
==
NULL
)
return
-
1
;
codecPrivate
=
(
ebml_binary
*
)
EBML_Master
Find
Child
(
trackEntry
,
&
MATROSKA_ContextCodecPrivate
);
codecPrivate
=
(
ebml_binary
*
)
EBML_Master
Get
Child
(
trackEntry
,
&
MATROSKA_ContextCodecPrivate
);
if
(
codecPrivate
==
NULL
)
return
-
2
;
...
...
@@ -1225,7 +1223,7 @@ static inline int matroska_clusters_count(const Matroska *obj) {
}
static
inline
timecode_t
matroska_current_cluster_timecode
(
const
Matroska
*
obj
)
{
return
EBML_IntegerValue
((
ebml_integer
*
)
EBML_Master
Find
Child
(
obj
->
cluster
,
&
MATROSKA_ContextTimecode
));
return
EBML_IntegerValue
((
ebml_integer
*
)
EBML_Master
Get
Child
(
obj
->
cluster
,
&
MATROSKA_ContextTimecode
));
}
static
ebml_master
*
matroska_find_track
(
const
Matroska
*
obj
,
int
trackNum
)
{
...
...
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