Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
ef4a8698
Commit
ef4a8698
authored
Apr 06, 2015
by
Jean-Baptiste Kempf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce text_segment structure and API
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
94ed9110
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
0 deletions
+90
-0
include/vlc_text_style.h
include/vlc_text_style.h
+45
-0
src/libvlccore.sym
src/libvlccore.sym
+3
-0
src/misc/text_style.c
src/misc/text_style.c
+42
-0
No files found.
include/vlc_text_style.h
View file @
ef4a8698
...
...
@@ -89,6 +89,26 @@ typedef struct
#define STYLE_DEFAULT_FONT_SIZE 22
typedef
struct
text_segment_t
text_segment_t
;
/**
* Text segment for subtitles
*
* This structure is used to store a formatted text, with mixed styles
* Every segment is comprised of one text and a unique style
*
* On style change, a new segment is created with the next part of text
* and the new style, and chained to the list
*
* Create with text_segment_New and clean the chain with
* text_segment_ChainDelete
*/
struct
text_segment_t
{
char
*
psz_text
;
/**< text string of the segment */
text_style_t
*
style
;
/**< style applied to this segment */
text_segment_t
*
p_next
;
/**< next segment */
};
/**
* Create a default text style
*/
...
...
@@ -109,6 +129,31 @@ VLC_API text_style_t * text_style_Duplicate( const text_style_t * );
*/
VLC_API
void
text_style_Delete
(
text_style_t
*
);
/**
* This function will create a new text segment.
*
* You should use text_segment_ChainDelete to destroy it, to clean all
* the linked segments.
*
* This duplicates the string passed as argument
*/
VLC_API
text_segment_t
*
text_segment_New
(
const
char
*
);
/**
* This function will destroy a list of text segments allocated
* by text_segment_New.
*
* You may pass it NULL.
*/
VLC_API
void
text_segment_ChainDelete
(
text_segment_t
*
);
/**
* This function will copy a text_segment and its chain into a new one
*
* You may give it NULL, but it will return NULL.
*/
VLC_API
text_segment_t
*
text_segment_Copy
(
text_segment_t
*
);
#ifdef __cplusplus
}
#endif
...
...
src/libvlccore.sym
View file @
ef4a8698
...
...
@@ -418,6 +418,9 @@ subpicture_region_ChainDelete
subpicture_region_Copy
subpicture_region_Delete
subpicture_region_New
text_segment_New
text_segment_ChainDelete
text_segment_Copy
vlc_tls_ClientCreate
vlc_tls_Delete
vlc_tls_ClientSessionCreate
...
...
src/misc/text_style.c
View file @
ef4a8698
...
...
@@ -94,3 +94,45 @@ void text_style_Delete( text_style_t *p_style )
free
(
p_style
);
}
text_segment_t
*
text_segment_New
(
const
char
*
psz_text
)
{
text_segment_t
*
segment
=
calloc
(
1
,
sizeof
(
*
segment
)
);
if
(
!
segment
)
return
NULL
;
segment
->
psz_text
=
strdup
(
psz_text
);
return
segment
;
}
void
text_segment_ChainDelete
(
text_segment_t
*
segment
)
{
while
(
segment
!=
NULL
)
{
text_segment_t
*
p_next
=
segment
->
p_next
;
free
(
segment
->
psz_text
);
//text_style_Delete( segment->style );
free
(
segment
);
segment
=
p_next
;
}
}
text_segment_t
*
text_segment_Copy
(
text_segment_t
*
p_src
)
{
text_segment_t
*
p_dst
=
NULL
,
*
p_dst0
=
NULL
;
while
(
p_src
&&
p_src
->
p_next
)
{
text_segment_t
*
p_next
=
text_segment_New
(
p_src
->
psz_text
);
p_src
=
p_src
->
p_next
;
if
(
p_dst
==
NULL
)
p_dst
=
p_dst0
=
p_next
;
else
p_dst
->
p_next
=
p_next
;
}
return
p_dst0
;
}
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