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
2b3f7c57
Commit
2b3f7c57
authored
Dec 08, 2008
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prepare for stream filter.
parent
132855eb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
103 additions
and
68 deletions
+103
-68
include/vlc_stream.h
include/vlc_stream.h
+31
-9
src/input/demux.c
src/input/demux.c
+7
-7
src/input/stream.c
src/input/stream.c
+62
-35
src/input/stream.h
src/input/stream.h
+2
-14
src/input/stream_memory.c
src/input/stream_memory.c
+1
-3
No files found.
include/vlc_stream.h
View file @
2b3f7c57
...
...
@@ -42,6 +42,37 @@ extern "C" {
* @{
*/
/* Opaque definition for text reader context */
typedef
struct
stream_text_t
stream_text_t
;
/**
* stream_t definition
*/
struct
stream_t
{
VLC_COMMON_MEMBERS
/* Module properties */
module_t
*
p_module
;
/* For stream filter they will hold an array of stream sources */
int
i_source
;
stream_t
**
pp_source
;
/* */
int
(
*
pf_read
)
(
stream_t
*
,
void
*
p_read
,
unsigned
int
i_read
);
int
(
*
pf_peek
)
(
stream_t
*
,
const
uint8_t
**
pp_peek
,
unsigned
int
i_peek
);
int
(
*
pf_control
)(
stream_t
*
,
int
i_query
,
va_list
);
void
(
*
pf_destroy
)(
stream_t
*
);
/* Private data for module */
stream_sys_t
*
p_sys
;
/* Text reader state */
stream_text_t
*
p_text
;
};
/**
* Possible commands to send to stream_Control() and stream_vaControl()
*/
...
...
@@ -144,13 +175,4 @@ VLC_EXPORT( stream_t *,__stream_UrlNew, (vlc_object_t *p_this, const char *psz_u
}
# endif
# if defined (__PLUGIN__) || defined (__BUILTIN__)
/* FIXME UGLY HACK to keep VLC_OBJECT working */
/* Maybe we should make VLC_OBJECT a simple cast noawadays... */
struct
stream_t
{
VLC_COMMON_MEMBERS
};
# endif
#endif
src/input/demux.c
View file @
2b3f7c57
...
...
@@ -332,13 +332,10 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, const char *psz_demux,
s
->
pf_peek
=
DStreamPeek
;
s
->
pf_control
=
DStreamControl
;
s
->
i_char_width
=
1
;
s
->
b_little_endian
=
false
;
s
->
p_sys
=
malloc
(
sizeof
(
d_stream_sys_t
)
);
if
(
s
->
p_sys
==
NULL
)
{
vlc_object_releas
e
(
s
);
stream_CommonDelet
e
(
s
);
return
NULL
;
}
p_sys
=
(
d_stream_sys_t
*
)
s
->
p_sys
;
...
...
@@ -352,7 +349,7 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, const char *psz_demux,
/* decoder fifo */
if
(
(
p_sys
->
p_fifo
=
block_FifoNew
()
)
==
NULL
)
{
vlc_object_releas
e
(
s
);
stream_CommonDelet
e
(
s
);
free
(
p_sys
->
psz_name
);
free
(
p_sys
);
return
NULL
;
...
...
@@ -361,7 +358,7 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, const char *psz_demux,
if
(
vlc_thread_create
(
s
,
"stream out"
,
DStreamThread
,
VLC_THREAD_PRIORITY_INPUT
,
false
)
)
{
vlc_object_releas
e
(
s
);
stream_CommonDelet
e
(
s
);
free
(
p_sys
->
psz_name
);
free
(
p_sys
);
return
NULL
;
...
...
@@ -376,6 +373,9 @@ void stream_DemuxSend( stream_t *s, block_t *p_block )
if
(
p_block
)
block_FifoPut
(
p_sys
->
p_fifo
,
p_block
);
}
/* FIXME why is it needed ?
* We may be able to use pf_destroy
*/
void
stream_DemuxDelete
(
stream_t
*
s
)
{
d_stream_sys_t
*
p_sys
=
(
d_stream_sys_t
*
)
s
->
p_sys
;
...
...
@@ -395,7 +395,7 @@ void stream_DemuxDelete( stream_t *s )
free
(
p_sys
->
psz_name
);
free
(
p_sys
);
vlc_object_releas
e
(
s
);
stream_CommonDelet
e
(
s
);
}
...
...
src/input/stream.c
View file @
2b3f7c57
...
...
@@ -223,8 +223,35 @@ static void ARecordWrite( stream_t *s, const uint8_t *p_buffer, size_t i_buffer
****************************************************************************/
stream_t
*
stream_CommonNew
(
vlc_object_t
*
p_obj
)
{
return
(
stream_t
*
)
vlc_custom_create
(
p_obj
,
sizeof
(
stream_t
),
VLC_OBJECT_GENERIC
,
"stream"
);
stream_t
*
s
=
(
stream_t
*
)
vlc_custom_create
(
p_obj
,
sizeof
(
*
s
),
VLC_OBJECT_GENERIC
,
"stream"
);
if
(
!
s
)
return
NULL
;
s
->
p_text
=
malloc
(
sizeof
(
*
s
->
p_text
)
);
if
(
!
s
->
p_text
)
{
vlc_object_release
(
s
);
return
NULL
;
}
/* UTF16 and UTF32 text file conversion */
s
->
p_text
->
conv
=
(
vlc_iconv_t
)(
-
1
);
s
->
p_text
->
i_char_width
=
1
;
s
->
p_text
->
b_little_endian
=
false
;
return
s
;
}
void
stream_CommonDelete
(
stream_t
*
s
)
{
if
(
s
->
p_text
)
{
if
(
s
->
p_text
->
conv
!=
(
vlc_iconv_t
)(
-
1
)
)
vlc_iconv_close
(
s
->
p_text
->
conv
);
free
(
s
->
p_text
);
}
vlc_object_release
(
s
);
}
/****************************************************************************
...
...
@@ -275,7 +302,7 @@ stream_t *stream_AccessNew( access_t *p_access, bool b_quick )
s
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
stream_sys_t
)
);
if
(
!
p_sys
)
{
vlc_object_releas
e
(
s
);
stream_CommonDelet
e
(
s
);
return
NULL
;
}
...
...
@@ -287,11 +314,6 @@ stream_t *stream_AccessNew( access_t *p_access, bool b_quick )
s
->
pf_control
=
AStreamControl
;
s
->
pf_destroy
=
AStreamDestroy
;
/* UTF16 and UTF32 text file conversion */
s
->
i_char_width
=
1
;
s
->
b_little_endian
=
false
;
s
->
conv
=
(
vlc_iconv_t
)(
-
1
);
/* Common field */
p_sys
->
p_access
=
p_access
;
if
(
p_access
->
pf_block
)
...
...
@@ -463,7 +485,7 @@ error:
free
(
psz_list
);
free
(
s
->
p_sys
);
vlc_object_detach
(
s
);
vlc_object_releas
e
(
s
);
stream_CommonDelet
e
(
s
);
return
NULL
;
}
...
...
@@ -498,7 +520,7 @@ static void AStreamDestroy( stream_t *s )
free
(
p_sys
->
list
);
free
(
p_sys
);
vlc_object_releas
e
(
s
);
stream_CommonDelet
e
(
s
);
}
static
void
UStreamDestroy
(
stream_t
*
s
)
...
...
@@ -1623,14 +1645,14 @@ char *stream_ReadLine( stream_t *s )
else
if
(
!
memcmp
(
p_data
,
"
\xFF\xFE
"
,
2
)
)
{
psz_encoding
=
"UTF-16LE"
;
s
->
b_little_endian
=
true
;
s
->
i_char_width
=
2
;
s
->
p_text
->
b_little_endian
=
true
;
s
->
p_text
->
i_char_width
=
2
;
i_bom_size
=
2
;
}
else
if
(
!
memcmp
(
p_data
,
"
\xFE\xFF
"
,
2
)
)
{
psz_encoding
=
"UTF-16BE"
;
s
->
i_char_width
=
2
;
s
->
p_text
->
i_char_width
=
2
;
i_bom_size
=
2
;
}
...
...
@@ -1645,17 +1667,19 @@ char *stream_ReadLine( stream_t *s )
/* Open the converter if we need it */
if
(
psz_encoding
!=
NULL
)
{
input_thread_t
*
p_input
;
msg_Dbg
(
s
,
"%s BOM detected"
,
psz_encoding
);
p_input
=
(
input_thread_t
*
)
vlc_object_find
(
s
,
VLC_OBJECT_INPUT
,
FIND_PARENT
);
if
(
s
->
i_char_width
>
1
)
if
(
s
->
p_text
->
i_char_width
>
1
)
{
s
->
conv
=
vlc_iconv_open
(
"UTF-8"
,
psz_encoding
);
if
(
s
->
conv
==
(
vlc_iconv_t
)
-
1
)
s
->
p_text
->
conv
=
vlc_iconv_open
(
"UTF-8"
,
psz_encoding
);
if
(
s
->
p_text
->
conv
==
(
vlc_iconv_t
)
-
1
)
{
msg_Err
(
s
,
"iconv_open failed"
);
}
}
/* FIXME that's UGLY */
input_thread_t
*
p_input
;
p_input
=
(
input_thread_t
*
)
vlc_object_find
(
s
,
VLC_OBJECT_INPUT
,
FIND_PARENT
);
if
(
p_input
!=
NULL
)
{
var_Create
(
p_input
,
"subsdec-encoding"
,
VLC_VAR_STRING
|
VLC_VAR_DOINHERIT
);
...
...
@@ -1665,10 +1689,10 @@ char *stream_ReadLine( stream_t *s )
}
}
if
(
i_data
%
s
->
i_char_width
)
if
(
i_data
%
s
->
p_text
->
i_char_width
)
{
/* keep i_char_width boundary */
i_data
=
i_data
-
(
i_data
%
s
->
i_char_width
);
i_data
=
i_data
-
(
i_data
%
s
->
p_text
->
i_char_width
);
msg_Warn
(
s
,
"the read is not i_char_width compatible"
);
}
...
...
@@ -1676,7 +1700,7 @@ char *stream_ReadLine( stream_t *s )
break
;
/* Check if there is an EOL */
if
(
s
->
i_char_width
==
1
)
if
(
s
->
p_text
->
i_char_width
==
1
)
{
/* UTF-8: 0A <LF> */
psz_eol
=
memchr
(
p_data
,
'\n'
,
i_data
);
...
...
@@ -1684,11 +1708,11 @@ char *stream_ReadLine( stream_t *s )
else
{
const
uint8_t
*
p
=
p_data
;
const
uint8_t
*
p_last
=
p
+
i_data
-
s
->
i_char_width
;
const
uint8_t
*
p_last
=
p
+
i_data
-
s
->
p_text
->
i_char_width
;
if
(
s
->
i_char_width
==
2
)
if
(
s
->
p_text
->
i_char_width
==
2
)
{
if
(
s
->
b_little_endian
==
true
)
if
(
s
->
p_text
->
b_little_endian
==
true
)
{
/* UTF-16LE: 0A 00 <LF> */
while
(
p
<=
p_last
&&
(
p
[
0
]
!=
0x0A
||
p
[
1
]
!=
0x00
)
)
...
...
@@ -1708,19 +1732,19 @@ char *stream_ReadLine( stream_t *s )
}
else
{
psz_eol
=
(
char
*
)
p
+
(
s
->
i_char_width
-
1
);
psz_eol
=
(
char
*
)
p
+
(
s
->
p_text
->
i_char_width
-
1
);
}
}
if
(
psz_eol
)
if
(
psz_eol
)
{
i_data
=
(
psz_eol
-
(
char
*
)
p_data
)
+
1
;
p_line
=
realloc
(
p_line
,
i_line
+
i_data
+
s
->
i_char_width
);
/* add \0 */
p_line
=
realloc
(
p_line
,
i_line
+
i_data
+
s
->
p_text
->
i_char_width
);
/* add \0 */
if
(
!
p_line
)
goto
error
;
i_data
=
stream_Read
(
s
,
&
p_line
[
i_line
],
i_data
);
if
(
i_data
<=
0
)
break
;
/* Hmmm */
i_line
+=
i_data
-
s
->
i_char_width
;
/* skip \n */
;
i_line
+=
i_data
-
s
->
p_text
->
i_char_width
;
/* skip \n */
;
i_read
+=
i_data
;
/* We have our line */
...
...
@@ -1728,7 +1752,7 @@ char *stream_ReadLine( stream_t *s )
}
/* Read data (+1 for easy \0 append) */
p_line
=
realloc
(
p_line
,
i_line
+
STREAM_PROBE_LINE
+
s
->
i_char_width
);
p_line
=
realloc
(
p_line
,
i_line
+
STREAM_PROBE_LINE
+
s
->
p_text
->
i_char_width
);
if
(
!
p_line
)
goto
error
;
i_data
=
stream_Read
(
s
,
&
p_line
[
i_line
],
STREAM_PROBE_LINE
);
...
...
@@ -1740,12 +1764,12 @@ char *stream_ReadLine( stream_t *s )
if
(
i_read
>
0
)
{
int
j
;
for
(
j
=
0
;
j
<
s
->
i_char_width
;
j
++
)
for
(
j
=
0
;
j
<
s
->
p_text
->
i_char_width
;
j
++
)
{
p_line
[
i_line
+
j
]
=
'\0'
;
}
i_line
+=
s
->
i_char_width
;
/* the added \0 */
if
(
s
->
i_char_width
>
1
)
i_line
+=
s
->
p_text
->
i_char_width
;
/* the added \0 */
if
(
s
->
p_text
->
i_char_width
>
1
)
{
size_t
i_in
=
0
,
i_out
=
0
;
const
char
*
p_in
=
NULL
;
...
...
@@ -1760,7 +1784,7 @@ char *stream_ReadLine( stream_t *s )
p_in
=
p_line
;
p_out
=
psz_new_line
;
if
(
vlc_iconv
(
s
->
conv
,
&
p_in
,
&
i_in
,
&
p_out
,
&
i_out
)
==
(
size_t
)
-
1
)
if
(
vlc_iconv
(
s
->
p_text
->
conv
,
&
p_in
,
&
i_in
,
&
p_out
,
&
i_out
)
==
(
size_t
)
-
1
)
{
msg_Err
(
s
,
"iconv failed"
);
msg_Dbg
(
s
,
"original: %d, in %d, out %d"
,
i_line
,
(
int
)
i_in
,
(
int
)
i_out
);
...
...
@@ -1781,10 +1805,13 @@ char *stream_ReadLine( stream_t *s )
}
error:
/* We failed to read any data, probably EOF */
free
(
p_line
);
if
(
s
->
conv
!=
(
vlc_iconv_t
)(
-
1
)
)
vlc_iconv_close
(
s
->
conv
);
/* */
if
(
s
->
p_text
->
conv
!=
(
vlc_iconv_t
)(
-
1
)
)
vlc_iconv_close
(
s
->
p_text
->
conv
);
s
->
p_text
->
conv
=
(
vlc_iconv_t
)(
-
1
);
return
NULL
;
}
...
...
src/input/stream.h
View file @
2b3f7c57
...
...
@@ -32,21 +32,8 @@
#include <vlc_common.h>
#include <vlc_stream.h>
/**
* stream_t definition
*/
struct
stream_t
struct
stream_text_t
{
VLC_COMMON_MEMBERS
/*block_t *(*pf_block) ( stream_t *, int i_size );*/
int
(
*
pf_read
)
(
stream_t
*
,
void
*
p_read
,
unsigned
int
i_read
);
int
(
*
pf_peek
)
(
stream_t
*
,
const
uint8_t
**
pp_peek
,
unsigned
int
i_peek
);
int
(
*
pf_control
)(
stream_t
*
,
int
i_query
,
va_list
);
void
(
*
pf_destroy
)(
stream_t
*
);
stream_sys_t
*
p_sys
;
/* UTF-16 and UTF-32 file reading */
vlc_iconv_t
conv
;
int
i_char_width
;
...
...
@@ -55,6 +42,7 @@ struct stream_t
/* */
stream_t
*
stream_CommonNew
(
vlc_object_t
*
);
void
stream_CommonDelete
(
stream_t
*
);
/* */
stream_t
*
stream_AccessNew
(
access_t
*
p_access
,
bool
);
...
...
src/input/stream_memory.c
View file @
2b3f7c57
...
...
@@ -69,8 +69,6 @@ stream_t *__stream_MemoryNew( vlc_object_t *p_this, uint8_t *p_buffer,
s
->
pf_control
=
Control
;
s
->
pf_destroy
=
Delete
;
s
->
i_char_width
=
1
;
s
->
b_little_endian
=
false
;
vlc_object_attach
(
s
,
p_this
);
return
s
;
...
...
@@ -81,7 +79,7 @@ static void Delete( stream_t *s )
if
(
!
s
->
p_sys
->
i_preserve_memory
)
free
(
s
->
p_sys
->
p_buffer
);
free
(
s
->
p_sys
);
vlc_object_detach
(
s
);
vlc_object_releas
e
(
s
);
stream_CommonDelet
e
(
s
);
}
/****************************************************************************
...
...
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