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
099840ef
Commit
099840ef
authored
Jul 23, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stream: fold stream_text_t into stream private data
parent
740ed443
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
64 deletions
+59
-64
include/vlc_stream.h
include/vlc_stream.h
+0
-6
src/input/stream.c
src/input/stream.c
+59
-49
src/input/stream.h
src/input/stream.h
+0
-9
No files found.
include/vlc_stream.h
View file @
099840ef
...
@@ -39,9 +39,6 @@ extern "C" {
...
@@ -39,9 +39,6 @@ extern "C" {
* Byte streams and byte stream filter modules interface
* Byte streams and byte stream filter modules interface
*/
*/
/* Opaque definition for text reader context */
typedef
struct
stream_text_t
stream_text_t
;
/**
/**
* stream_t definition
* stream_t definition
*/
*/
...
@@ -73,9 +70,6 @@ struct stream_t
...
@@ -73,9 +70,6 @@ struct stream_t
/* Private data for module */
/* Private data for module */
stream_sys_t
*
p_sys
;
stream_sys_t
*
p_sys
;
/* Text reader state */
stream_text_t
*
p_text
;
/* Weak link to parent input */
/* Weak link to parent input */
input_thread_t
*
p_input
;
input_thread_t
*
p_input
;
};
};
...
...
src/input/stream.c
View file @
099840ef
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
* stream.c
* stream.c
*****************************************************************************
*****************************************************************************
* Copyright (C) 1999-2004 VLC authors and VideoLAN
* Copyright (C) 1999-2004 VLC authors and VideoLAN
* Copyright 2008-2015 Rémi Denis-Courmont
* $Id$
* $Id$
*
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
...
@@ -32,43 +33,55 @@
...
@@ -32,43 +33,55 @@
#include <vlc_common.h>
#include <vlc_common.h>
#include <vlc_memory.h>
#include <vlc_memory.h>
#include <vlc_access.h>
#include <vlc_access.h>
#include <vlc_charset.h>
#include <libvlc.h>
#include <libvlc.h>
#include "stream.h"
#include "stream.h"
/****************************************************************************
typedef
struct
stream_priv_t
* stream_CommonNew: create an empty stream structure
****************************************************************************/
stream_t
*
stream_CommonNew
(
vlc_object_t
*
p_obj
)
{
{
stream_t
*
s
=
(
stream_t
*
)
vlc_custom_create
(
p_obj
,
sizeof
(
*
s
),
"stream"
)
;
stream_t
stream
;
if
(
!
s
)
/* UTF-16 and UTF-32 file reading */
return
NULL
;
struct
{
vlc_iconv_t
conv
;
unsigned
char
char_width
;
bool
little_endian
;
}
text
;
}
stream_priv_t
;
s
->
p_text
=
malloc
(
sizeof
(
*
s
->
p_text
)
);
/**
if
(
!
s
->
p_text
)
* Allocates a VLC stream object
{
*/
vlc_object_release
(
s
);
stream_t
*
stream_CommonNew
(
vlc_object_t
*
parent
)
{
stream_priv_t
*
priv
=
vlc_custom_create
(
parent
,
sizeof
(
*
priv
),
"stream"
);
if
(
unlikely
(
priv
==
NULL
))
return
NULL
;
return
NULL
;
}
stream_t
*
s
=
&
priv
->
stream
;
s
->
psz_access
=
NULL
;
s
->
psz_path
=
NULL
;
/* UTF16 and UTF32 text file conversion */
/* UTF16 and UTF32 text file conversion */
s
->
p_text
->
conv
=
(
vlc_iconv_t
)(
-
1
);
priv
->
text
.
conv
=
(
vlc_iconv_t
)(
-
1
);
s
->
p_text
->
i_
char_width
=
1
;
priv
->
text
.
char_width
=
1
;
s
->
p_text
->
b_
little_endian
=
false
;
priv
->
text
.
little_endian
=
false
;
return
s
;
return
s
;
}
}
/**
* Destroys a VLC stream object
*/
void
stream_CommonDelete
(
stream_t
*
s
)
void
stream_CommonDelete
(
stream_t
*
s
)
{
{
if
(
s
->
p_text
)
stream_priv_t
*
priv
=
(
stream_priv_t
*
)
s
;
{
if
(
s
->
p_text
->
conv
!=
(
vlc_iconv_t
)(
-
1
)
)
if
(
priv
->
text
.
conv
!=
(
vlc_iconv_t
)(
-
1
))
vlc_iconv_close
(
s
->
p_text
->
conv
);
vlc_iconv_close
(
priv
->
text
.
conv
);
free
(
s
->
p_text
);
}
free
(
s
->
psz_access
);
free
(
s
->
psz_access
);
free
(
s
->
psz_path
);
free
(
s
->
psz_path
);
vlc_object_release
(
s
);
vlc_object_release
(
s
);
...
@@ -93,9 +106,6 @@ stream_t *stream_UrlNew( vlc_object_t *p_parent, const char *psz_url )
...
@@ -93,9 +106,6 @@ stream_t *stream_UrlNew( vlc_object_t *p_parent, const char *psz_url )
return
stream_AccessNew
(
p_access
);
return
stream_AccessNew
(
p_access
);
}
}
/****************************************************************************
* stream_ReadLine:
****************************************************************************/
/**
/**
* Read from the stream untill first newline.
* Read from the stream untill first newline.
* \param s Stream handle to read from
* \param s Stream handle to read from
...
@@ -105,6 +115,7 @@ stream_t *stream_UrlNew( vlc_object_t *p_parent, const char *psz_url )
...
@@ -105,6 +115,7 @@ stream_t *stream_UrlNew( vlc_object_t *p_parent, const char *psz_url )
#define STREAM_LINE_MAX (2048*100)
#define STREAM_LINE_MAX (2048*100)
char
*
stream_ReadLine
(
stream_t
*
s
)
char
*
stream_ReadLine
(
stream_t
*
s
)
{
{
stream_priv_t
*
priv
=
(
stream_priv_t
*
)
s
;
char
*
p_line
=
NULL
;
char
*
p_line
=
NULL
;
int
i_line
=
0
,
i_read
=
0
;
int
i_line
=
0
,
i_read
=
0
;
...
@@ -132,7 +143,7 @@ char *stream_ReadLine( stream_t *s )
...
@@ -132,7 +143,7 @@ char *stream_ReadLine( stream_t *s )
if
(
!
memcmp
(
p_data
,
"
\xFF\xFE
"
,
2
)
)
if
(
!
memcmp
(
p_data
,
"
\xFF\xFE
"
,
2
)
)
{
{
psz_encoding
=
"UTF-16LE"
;
psz_encoding
=
"UTF-16LE"
;
s
->
p_text
->
b_
little_endian
=
true
;
priv
->
text
.
little_endian
=
true
;
}
}
else
if
(
!
memcmp
(
p_data
,
"
\xFE\xFF
"
,
2
)
)
else
if
(
!
memcmp
(
p_data
,
"
\xFE\xFF
"
,
2
)
)
{
{
...
@@ -143,17 +154,17 @@ char *stream_ReadLine( stream_t *s )
...
@@ -143,17 +154,17 @@ char *stream_ReadLine( stream_t *s )
if
(
psz_encoding
!=
NULL
)
if
(
psz_encoding
!=
NULL
)
{
{
msg_Dbg
(
s
,
"UTF-16 BOM detected"
);
msg_Dbg
(
s
,
"UTF-16 BOM detected"
);
s
->
p_text
->
i_
char_width
=
2
;
priv
->
text
.
char_width
=
2
;
s
->
p_text
->
conv
=
vlc_iconv_open
(
"UTF-8"
,
psz_encoding
);
priv
->
text
.
conv
=
vlc_iconv_open
(
"UTF-8"
,
psz_encoding
);
if
(
s
->
p_text
->
conv
==
(
vlc_iconv_t
)
-
1
)
if
(
priv
->
text
.
conv
==
(
vlc_iconv_t
)
-
1
)
msg_Err
(
s
,
"iconv_open failed"
);
msg_Err
(
s
,
"iconv_open failed"
);
}
}
}
}
if
(
i_data
%
s
->
p_text
->
i_
char_width
)
if
(
i_data
%
priv
->
text
.
char_width
)
{
{
/* keep i_char_width boundary */
/* keep i_char_width boundary */
i_data
=
i_data
-
(
i_data
%
s
->
p_text
->
i_
char_width
);
i_data
=
i_data
-
(
i_data
%
priv
->
text
.
char_width
);
msg_Warn
(
s
,
"the read is not i_char_width compatible"
);
msg_Warn
(
s
,
"the read is not i_char_width compatible"
);
}
}
...
@@ -161,7 +172,7 @@ char *stream_ReadLine( stream_t *s )
...
@@ -161,7 +172,7 @@ char *stream_ReadLine( stream_t *s )
break
;
break
;
/* Check if there is an EOL */
/* Check if there is an EOL */
if
(
s
->
p_text
->
i_
char_width
==
1
)
if
(
priv
->
text
.
char_width
==
1
)
{
{
/* UTF-8: 0A <LF> */
/* UTF-8: 0A <LF> */
psz_eol
=
memchr
(
p_data
,
'\n'
,
i_data
);
psz_eol
=
memchr
(
p_data
,
'\n'
,
i_data
);
...
@@ -171,10 +182,10 @@ char *stream_ReadLine( stream_t *s )
...
@@ -171,10 +182,10 @@ char *stream_ReadLine( stream_t *s )
}
}
else
else
{
{
const
uint8_t
*
p_last
=
p_data
+
i_data
-
s
->
p_text
->
i_
char_width
;
const
uint8_t
*
p_last
=
p_data
+
i_data
-
priv
->
text
.
char_width
;
uint16_t
eol
=
s
->
p_text
->
b_
little_endian
?
0x0A00
:
0x00A0
;
uint16_t
eol
=
priv
->
text
.
little_endian
?
0x0A00
:
0x00A0
;
assert
(
s
->
p_text
->
i_
char_width
==
2
);
assert
(
priv
->
text
.
char_width
==
2
);
psz_eol
=
NULL
;
psz_eol
=
NULL
;
/* UTF-16: 000A <LF> */
/* UTF-16: 000A <LF> */
for
(
const
uint8_t
*
p
=
p_data
;
p
<=
p_last
;
p
+=
2
)
for
(
const
uint8_t
*
p
=
p_data
;
p
<=
p_last
;
p
+=
2
)
...
@@ -188,7 +199,7 @@ char *stream_ReadLine( stream_t *s )
...
@@ -188,7 +199,7 @@ char *stream_ReadLine( stream_t *s )
if
(
psz_eol
==
NULL
)
if
(
psz_eol
==
NULL
)
{
/* UTF-16: 000D <CR> */
{
/* UTF-16: 000D <CR> */
eol
=
s
->
p_text
->
b_
little_endian
?
0x0D00
:
0x00D0
;
eol
=
priv
->
text
.
little_endian
?
0x0D00
:
0x00D0
;
for
(
const
uint8_t
*
p
=
p_data
;
p
<=
p_last
;
p
+=
2
)
for
(
const
uint8_t
*
p
=
p_data
;
p
<=
p_last
;
p
+=
2
)
{
{
if
(
U16_AT
(
p
)
==
eol
)
if
(
U16_AT
(
p
)
==
eol
)
...
@@ -204,12 +215,12 @@ char *stream_ReadLine( stream_t *s )
...
@@ -204,12 +215,12 @@ char *stream_ReadLine( stream_t *s )
{
{
i_data
=
(
psz_eol
-
(
char
*
)
p_data
)
+
1
;
i_data
=
(
psz_eol
-
(
char
*
)
p_data
)
+
1
;
p_line
=
realloc_or_free
(
p_line
,
p_line
=
realloc_or_free
(
p_line
,
i_line
+
i_data
+
s
->
p_text
->
i_
char_width
);
/* add \0 */
i_line
+
i_data
+
priv
->
text
.
char_width
);
/* add \0 */
if
(
!
p_line
)
if
(
!
p_line
)
goto
error
;
goto
error
;
i_data
=
stream_Read
(
s
,
&
p_line
[
i_line
],
i_data
);
i_data
=
stream_Read
(
s
,
&
p_line
[
i_line
],
i_data
);
if
(
i_data
<=
0
)
break
;
/* Hmmm */
if
(
i_data
<=
0
)
break
;
/* Hmmm */
i_line
+=
i_data
-
s
->
p_text
->
i_
char_width
;
/* skip \n */
;
i_line
+=
i_data
-
priv
->
text
.
char_width
;
/* skip \n */
;
i_read
+=
i_data
;
i_read
+=
i_data
;
/* We have our line */
/* We have our line */
...
@@ -218,7 +229,7 @@ char *stream_ReadLine( stream_t *s )
...
@@ -218,7 +229,7 @@ char *stream_ReadLine( stream_t *s )
/* Read data (+1 for easy \0 append) */
/* Read data (+1 for easy \0 append) */
p_line
=
realloc_or_free
(
p_line
,
p_line
=
realloc_or_free
(
p_line
,
i_line
+
STREAM_PROBE_LINE
+
s
->
p_text
->
i_
char_width
);
i_line
+
STREAM_PROBE_LINE
+
priv
->
text
.
char_width
);
if
(
!
p_line
)
if
(
!
p_line
)
goto
error
;
goto
error
;
i_data
=
stream_Read
(
s
,
&
p_line
[
i_line
],
STREAM_PROBE_LINE
);
i_data
=
stream_Read
(
s
,
&
p_line
[
i_line
],
STREAM_PROBE_LINE
);
...
@@ -232,13 +243,10 @@ char *stream_ReadLine( stream_t *s )
...
@@ -232,13 +243,10 @@ char *stream_ReadLine( stream_t *s )
if
(
i_read
>
0
)
if
(
i_read
>
0
)
{
{
int
j
;
memset
(
p_line
+
i_line
,
0
,
priv
->
text
.
char_width
);
for
(
j
=
0
;
j
<
s
->
p_text
->
i_char_width
;
j
++
)
i_line
+=
priv
->
text
.
char_width
;
/* the added \0 */
{
p_line
[
i_line
+
j
]
=
'\0'
;
if
(
priv
->
text
.
char_width
>
1
)
}
i_line
+=
s
->
p_text
->
i_char_width
;
/* the added \0 */
if
(
s
->
p_text
->
i_char_width
>
1
)
{
{
int
i_new_line
=
0
;
int
i_new_line
=
0
;
size_t
i_in
=
0
,
i_out
=
0
;
size_t
i_in
=
0
,
i_out
=
0
;
...
@@ -257,7 +265,7 @@ char *stream_ReadLine( stream_t *s )
...
@@ -257,7 +265,7 @@ char *stream_ReadLine( stream_t *s )
p_in
=
p_line
;
p_in
=
p_line
;
p_out
=
psz_new_line
;
p_out
=
psz_new_line
;
if
(
vlc_iconv
(
s
->
p_text
->
conv
,
&
p_in
,
&
i_in
,
&
p_out
,
&
i_out
)
==
(
size_t
)
-
1
)
if
(
vlc_iconv
(
priv
->
text
.
conv
,
&
p_in
,
&
i_in
,
&
p_out
,
&
i_out
)
==
(
size_t
)
-
1
)
{
{
msg_Err
(
s
,
"iconv failed"
);
msg_Err
(
s
,
"iconv failed"
);
msg_Dbg
(
s
,
"original: %d, in %d, out %d"
,
i_line
,
(
int
)
i_in
,
(
int
)
i_out
);
msg_Dbg
(
s
,
"original: %d, in %d, out %d"
,
i_line
,
(
int
)
i_in
,
(
int
)
i_out
);
...
@@ -282,9 +290,11 @@ error:
...
@@ -282,9 +290,11 @@ error:
free
(
p_line
);
free
(
p_line
);
/* */
/* */
if
(
s
->
p_text
->
conv
!=
(
vlc_iconv_t
)(
-
1
)
)
if
(
priv
->
text
.
conv
!=
(
vlc_iconv_t
)(
-
1
)
)
vlc_iconv_close
(
s
->
p_text
->
conv
);
{
s
->
p_text
->
conv
=
(
vlc_iconv_t
)(
-
1
);
vlc_iconv_close
(
priv
->
text
.
conv
);
priv
->
text
.
conv
=
(
vlc_iconv_t
)(
-
1
);
}
return
NULL
;
return
NULL
;
}
}
...
...
src/input/stream.h
View file @
099840ef
...
@@ -27,15 +27,6 @@
...
@@ -27,15 +27,6 @@
#include <vlc_common.h>
#include <vlc_common.h>
#include <vlc_stream.h>
#include <vlc_stream.h>
#include <vlc_charset.h>
struct
stream_text_t
{
/* UTF-16 and UTF-32 file reading */
vlc_iconv_t
conv
;
int
i_char_width
;
bool
b_little_endian
;
};
/* */
/* */
stream_t
*
stream_CommonNew
(
vlc_object_t
*
);
stream_t
*
stream_CommonNew
(
vlc_object_t
*
);
...
...
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