Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
lektor
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Kubat
lektor
Validations
ae028766
Vérifiée
Valider
ae028766
rédigé
Il y a 5 ans
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
First try to get duration from a kara (WIP)
parent
755e6842
Branches
Branches contenant la validation
Étiquettes
Étiquettes contenant la validation
1 requête de fusion
!100
Resolve "Kara length"
Modifications
4
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
4 fichiers modifiés
inc/lektor/mkv.h
+4
-0
4 ajouts, 0 suppression
inc/lektor/mkv.h
meson.build
+6
-0
6 ajouts, 0 suppression
meson.build
src/main/debug.c
+17
-0
17 ajouts, 0 suppression
src/main/debug.c
src/mkv/mkv.c
+101
-4
101 ajouts, 4 suppressions
src/mkv/mkv.c
avec
128 ajouts
et
4 suppressions
inc/lektor/mkv.h
+
4
−
0
Voir le fichier @
ae028766
...
...
@@ -47,6 +47,10 @@ struct kara {
Returns 0 on success and -1 on error. */
int
kara_metadata_read
(
struct
kara_metadata
*
dst
,
const
char
*
filename
);
/* Reads the duration of the .mkv file `filename`. Returns 0 on success
and -1 on error. */
int
kara_read_length
(
size_t
*
len
,
const
char
*
filename
);
/* Write metadata to a mkv file. Returns 0 on success and -1 on error */
int
kara_metadata_write
(
struct
kara_metadata
*
mdt
,
const
char
*
filename
,
const
char
*
mkvpropedit
);
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
meson.build
+
6
−
0
Voir le fichier @
ae028766
...
...
@@ -166,6 +166,12 @@ lkt = executable( 'lkt'
,
include_directories
:
includes
,
install
:
true
)
debug
=
executable
(
'lkt-debug'
,
files
(
'src/main/debug.c'
)
,
include_directories
:
includes
,
dependencies
:
[
bin_deps
]
)
# Man pages
man_sh
=
find_program
(
'scripts/man.sh'
)
man_header
=
run_command
(
'realpath'
,
'doc/header'
).
stdout
().
strip
()
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/main/debug.c
0 → 100644
+
17
−
0
Voir le fichier @
ae028766
#include
<lektor/mkv.h>
#include
<stdio.h>
int
main
(
int
argc
,
char
**
argv
)
{
size_t
len
=
0
;
if
(
argc
!=
2
)
return
1
;
if
(
kara_read_length
(
&
len
,
argv
[
1
])
<
0
)
return
2
;
printf
(
"Kara length: %ld
\n
"
,
len
);
return
0
;
}
Ce diff est replié.
Cliquez pour l'agrandir.
src/mkv/mkv.c
+
101
−
4
Voir le fichier @
ae028766
...
...
@@ -7,6 +7,7 @@
#include
<string.h>
#include
<strings.h>
#include
<unistd.h>
#include
<errno.h>
#include
<common/bufferfd.h>
#include
<lektor/mkv.h>
...
...
@@ -401,7 +402,7 @@ mkv_read_tag(struct bufferfd *bf, struct mkv_tag *res)
}
static
ssize_t
mkv_seek
_tags
(
struct
bufferfd
*
bf
,
size_t
header_len
)
mkv_seek
(
struct
bufferfd
*
bf
,
size_t
header_len
,
size_t
what
)
{
uint64_t
seekhead_len
;
...
...
@@ -430,7 +431,7 @@ mkv_seek_tags(struct bufferfd *bf, size_t header_len)
seekhead_len
-=
n
;
if
(
eid
==
EBML_MKV_SEEK
&&
s
.
id
==
EBML_MKV_TAGS
)
if
(
eid
==
EBML_MKV_SEEK
&&
s
.
id
==
what
)
return
bufferfd_seek
(
bf
,
s
.
pos
+
header_len
);
}
...
...
@@ -497,17 +498,113 @@ kara_read_tags(struct bufferfd *bf, struct kara_metadata *dst)
return
0
;
}
static
int
kara_read_segment
(
struct
bufferfd
*
bf
,
size_t
*
len
)
{
/* TODO: Read correct elements, Duration and TimestampScale,
the result will be `*len = Duration * TimestampScale`. */
uint64_t
data_len
;
if
(
mkv_read_element_length
(
bf
,
&
data_len
)
<
0
)
return
-
1
;
while
(
data_len
>
0
)
{
ssize_t
n
;
uint32_t
eid
;
uint64_t
elen
;
if
((
n
=
mkv_read_element_id
(
bf
,
&
eid
))
<
0
||
eid
!=
EBML_MKV_SEGMENT
)
return
-
1
;
data_len
-=
n
;
if
((
n
=
mkv_read_element_length
(
bf
,
&
elen
))
<
0
)
return
-
1
;
data_len
-=
n
;
/* Find what we need */
if
(
eid
==
EBML_MKV_SEG_DURATION
||
eid
==
EBML_MKV_SEG_TS_SCALE
)
{
switch
(
*
len
)
{
case
0
:
*
len
=
1
;
/* Fallthrough */
default:
printf
(
"Len: %ld
\n
"
,
n
);
*
len
*=
1
;
}
}
}
return
0
;
}
int
kara_read_length
(
size_t
*
len
,
const
char
*
filename
)
{
errno
=
0
;
int
status_code
=
-
1
;
struct
bufferfd
file
=
{
.
len
=
0
,
.
pos
=
0
,
.
fd
=
open
(
filename
,
O_RDONLY
),
};
if
(
file
.
fd
<
0
)
{
LOG_ERROR
(
"MKV"
,
"Faield to open file '%s': %s"
,
filename
,
strerror
(
errno
));
return
-
1
;
}
uint32_t
eid
;
uint64_t
elength
;
ssize_t
header_len
=
mkv_skip_header
(
&
file
);
if
(
header_len
<
0
)
goto
error
;
*
len
=
0
;
for
(;;)
{
if
(
mkv_read_element_id
(
&
file
,
&
eid
)
<
0
)
goto
error
;
if
(
eid
==
EBML_MKV_SEEKHEAD
)
{
if
(
mkv_seek
(
&
file
,
(
size_t
)
header_len
,
(
size_t
)
EBML_MKV_SEGMENT
)
<
0
)
goto
error
;
}
else
if
(
eid
==
EBML_MKV_SEGMENT
)
{
if
(
kara_read_segment
(
&
file
,
len
)
<
0
)
goto
error
;
break
;
}
else
{
if
(
mkv_read_element_length
(
&
file
,
&
elength
)
<
0
)
goto
error
;
if
(
bufferfd_skip
(
&
file
,
elength
)
<
0
)
goto
error
;
}
}
status_code
=
0
;
error:
close
(
file
.
fd
);
return
status_code
;
}
int
kara_metadata_read
(
struct
kara_metadata
*
dst
,
const
char
*
filename
)
{
int
status_code
=
-
1
;
struct
bufferfd
file
;
errno
=
0
;
file
.
len
=
0
;
file
.
pos
=
0
;
file
.
fd
=
open
(
filename
,
O_RDONLY
);
if
(
file
.
fd
<
0
)
{
perror
(
"Failed to open file"
);
LOG_ERROR
(
"MKV"
,
"Failed to open file '%s': %s"
,
filename
,
strerror
(
errno
));
return
-
1
;
}
...
...
@@ -525,7 +622,7 @@ kara_metadata_read(struct kara_metadata *dst, const char *filename)
goto
error
;
if
(
eid
==
EBML_MKV_SEEKHEAD
)
{
if
(
mkv_seek
_tags
(
&
file
,
(
size_t
)
header_len
)
<
0
)
if
(
mkv_seek
(
&
file
,
(
size_t
)
header_len
,
(
size_t
)
EBML_MKV_TAGS
)
<
0
)
goto
error
;
}
else
if
(
eid
==
EBML_MKV_TAGS
)
{
if
(
kara_read_tags
(
&
file
,
dst
)
<
0
)
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter