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
8f7056b5
Commit
8f7056b5
authored
Oct 12, 2008
by
Derk-Jan Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
directory: Add XSPF node-extension support to our directory module.
parent
cfcb8686
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
9 deletions
+59
-9
modules/access/directory.c
modules/access/directory.c
+59
-9
No files found.
modules/access/directory.c
View file @
8f7056b5
...
...
@@ -125,6 +125,8 @@ struct access_sys_t
DIR
*
handle
;
char
*
ignored_exts
;
int
mode
;
int
i_item_count
;
char
*
psz_xspf_extension
;
};
static
block_t
*
Block
(
access_t
*
);
...
...
@@ -156,6 +158,8 @@ static int Open( vlc_object_t *p_this )
p_sys
->
current
=
NULL
;
p_sys
->
handle
=
handle
;
p_sys
->
ignored_exts
=
var_CreateGetString
(
p_access
,
"ignore-filetypes"
);
p_sys
->
i_item_count
=
0
;
p_sys
->
psz_xspf_extension
=
strdup
(
""
);
/* Handle mode */
char
*
psz
=
var_CreateGetString
(
p_access
,
"recursive"
);
...
...
@@ -196,6 +200,7 @@ static void Close( vlc_object_t * p_this )
}
if
(
p_sys
->
handle
!=
NULL
)
closedir
(
p_sys
->
handle
);
/* corner case,:Block() not called ever */
free
(
p_sys
->
psz_xspf_extension
);
free
(
p_sys
->
ignored_exts
);
free
(
p_sys
);
}
...
...
@@ -249,7 +254,7 @@ static block_t *Block (access_t *p_access)
{
/* Startup: send the XSPF header */
static
const
char
header
[]
=
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>
\n
"
"<playlist version=
\"
1
\"
xmlns=
\"
http://xspf.org/ns/0/
\"
>
\n
"
"<playlist version=
\"
1
\"
xmlns=
\"
http://xspf.org/ns/0/
\"
xmlns:vlc=
\"
http://www.videolan.org/vlc/playlist/ns/0/
\"
>
\n
"
" <trackList>
\n
"
;
block_t
*
block
=
block_Alloc
(
sizeof
(
header
)
-
1
);
if
(
!
block
)
...
...
@@ -290,22 +295,41 @@ static block_t *Block (access_t *p_access)
if
(
p_sys
->
current
==
NULL
)
{
/* End of XSPF playlist */
static
const
char
footer
[]
=
" </trackList>
\n
"
"</playlist>
\n
"
;
char
*
footer
;
int
len
=
asprintf
(
&
footer
,
" </trackList>
\n
"
\
" <extension application=
\"
http://www.videolan.org/vlc/playlist/0
\"
>
\n
"
\
"%s"
\
" </extension>
\n
"
\
"</playlist>
\n
"
,
p_sys
->
psz_xspf_extension
);
if
(
len
<
0
)
goto
fatal
;
block_t
*
block
=
block_Alloc
(
sizeof
(
footer
)
-
1
);
block_t
*
block
=
block_Alloc
(
len
);
if
(
!
block
)
goto
fatal
;
memcpy
(
block
->
p_buffer
,
footer
,
sizeof
(
footer
)
-
1
);
memcpy
(
block
->
p_buffer
,
footer
,
len
);
free
(
footer
);
p_access
->
info
.
b_eof
=
true
;
return
block
;
}
else
{
/* This was the end of a "subnode" */
/* Write the ID to the extension */
char
*
old_xspf_extension
=
p_sys
->
psz_xspf_extension
;
if
(
old_xspf_extension
==
NULL
)
goto
fatal
;
int
len2
=
asprintf
(
&
p_sys
->
psz_xspf_extension
,
"%s </vlc:node>
\n
"
,
old_xspf_extension
);
if
(
len2
==
-
1
)
goto
fatal
;
free
(
old_xspf_extension
);
}
return
NULL
;
}
/* Skip current and parent directories */
if
(
!
strcmp
(
entry
,
"."
)
||
!
strcmp
(
entry
,
".."
)
)
if
(
entry
[
0
]
==
'.'
)
return
NULL
;
/* Handle recursion */
if
(
p_sys
->
mode
!=
MODE_COLLAPSE
)
...
...
@@ -333,6 +357,17 @@ static block_t *Block (access_t *p_access)
return
NULL
;
}
p_sys
->
current
=
sub
;
/* Add node to xspf extension */
char
*
old_xspf_extension
=
p_sys
->
psz_xspf_extension
;
if
(
old_xspf_extension
==
NULL
)
goto
fatal
;
int
len2
=
asprintf
(
&
p_sys
->
psz_xspf_extension
,
"%s <vlc:node title=
\"
%s
\"
>
\n
"
,
old_xspf_extension
,
entry
);
if
(
len2
==
-
1
)
goto
fatal
;
free
(
old_xspf_extension
);
return
NULL
;
}
else
...
...
@@ -368,12 +403,27 @@ static block_t *Block (access_t *p_access)
if
(
encoded
==
NULL
)
goto
fatal
;
int
len
=
asprintf
(
&
entry
,
" <track><location>file://%s/%s</location></track>
\n
"
,
current
->
uri
,
encoded
);
" <track><location>file://%s/%s</location>
\n
"
\
" <extension application=
\"
http://www.videolan.org/vlc/playlist/0
\"
>
\n
"
\
" <vlc:id>%d</vlc:id>
\n
"
\
" </extension>
\n
"
\
" </track>
\n
"
,
current
->
uri
,
encoded
,
p_sys
->
i_item_count
++
);
free
(
encoded
);
if
(
len
==
-
1
)
goto
fatal
;
/* Write the ID to the extension */
char
*
old_xspf_extension
=
p_sys
->
psz_xspf_extension
;
if
(
old_xspf_extension
==
NULL
)
goto
fatal
;
int
len2
=
asprintf
(
&
p_sys
->
psz_xspf_extension
,
"%s <vlc:item tid=
\"
%i
\"
/>
\n
"
,
old_xspf_extension
,
p_sys
->
i_item_count
-
1
);
if
(
len2
==
-
1
)
goto
fatal
;
free
(
old_xspf_extension
);
/* TODO: new block allocator for malloc()ated data */
block_t
*
block
=
block_Alloc
(
len
);
if
(
!
block
)
...
...
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