Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
085985d5
Commit
085985d5
authored
Mar 11, 2004
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* mux: sout_buffer_t -> block_t.
parent
8547ffaa
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
237 additions
and
278 deletions
+237
-278
modules/mux/asf.c
modules/mux/asf.c
+28
-28
modules/mux/avi.c
modules/mux/avi.c
+33
-43
modules/mux/dummy.c
modules/mux/dummy.c
+5
-14
modules/mux/mp4.c
modules/mux/mp4.c
+17
-20
modules/mux/mpeg/pes.c
modules/mux/mpeg/pes.c
+8
-20
modules/mux/mpeg/pes.h
modules/mux/mpeg/pes.h
+2
-2
modules/mux/mpeg/ps.c
modules/mux/mpeg/ps.c
+21
-22
modules/mux/mpeg/ts.c
modules/mux/mpeg/ts.c
+59
-61
modules/mux/ogg.c
modules/mux/ogg.c
+64
-68
No files found.
modules/mux/asf.c
View file @
085985d5
...
...
@@ -2,7 +2,7 @@
* asf.c
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id
: asf.c,v 1.10 2004/01/25 13:37:12 kuehne Exp
$
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
...
...
@@ -92,7 +92,7 @@ struct sout_mux_sys_t
vlc_bool_t
b_write_header
;
sout_buffer
_t
*
pk
;
block
_t
*
pk
;
int
i_pk_used
;
int
i_pk_frame
;
mtime_t
i_pk_dts
;
...
...
@@ -110,10 +110,10 @@ struct sout_mux_sys_t
static
int
MuxGetStream
(
sout_mux_t
*
,
int
*
pi_stream
,
mtime_t
*
pi_dts
);
static
sout_buffer
_t
*
asf_header_create
(
sout_mux_t
*
,
vlc_bool_t
b_broadcast
);
static
sout_buffer
_t
*
asf_packet_create
(
sout_mux_t
*
,
asf_track_t
*
,
sout_buffer
_t
*
);
static
sout_buffer
_t
*
asf_stream_end_create
(
sout_mux_t
*
);
static
block
_t
*
asf_header_create
(
sout_mux_t
*
,
vlc_bool_t
b_broadcast
);
static
block
_t
*
asf_packet_create
(
sout_mux_t
*
,
asf_track_t
*
,
block
_t
*
);
static
block
_t
*
asf_stream_end_create
(
sout_mux_t
*
);
typedef
struct
{
...
...
@@ -215,7 +215,7 @@ static void Close( vlc_object_t * p_this )
{
sout_mux_t
*
p_mux
=
(
sout_mux_t
*
)
p_this
;
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
sout_buffer
_t
*
out
;
block
_t
*
out
;
int
i
;
msg_Dbg
(
p_mux
,
"Asf muxer closed"
);
...
...
@@ -499,9 +499,9 @@ static int Mux ( sout_mux_t *p_mux )
if
(
p_sys
->
b_write_header
)
{
sout_buffer
_t
*
out
=
asf_header_create
(
p_mux
,
VLC_TRUE
);
block
_t
*
out
=
asf_header_create
(
p_mux
,
VLC_TRUE
);
out
->
i_flags
|=
SOUT_BUFFER_FLAGS
_HEADER
;
out
->
i_flags
|=
BLOCK_FLAG
_HEADER
;
sout_AccessOutWrite
(
p_mux
->
p_access
,
out
);
p_sys
->
b_write_header
=
VLC_FALSE
;
...
...
@@ -513,8 +513,8 @@ static int Mux ( sout_mux_t *p_mux )
asf_track_t
*
tk
;
int
i_stream
;
mtime_t
i_dts
;
sout_buffer
_t
*
data
;
sout_buffer
_t
*
pk
;
block
_t
*
data
;
block
_t
*
pk
;
if
(
MuxGetStream
(
p_mux
,
&
i_stream
,
&
i_dts
)
)
{
...
...
@@ -534,7 +534,7 @@ static int Mux ( sout_mux_t *p_mux )
p_input
=
p_mux
->
pp_inputs
[
i_stream
];
tk
=
(
asf_track_t
*
)
p_input
->
p_sys
;
data
=
sout
_FifoGet
(
p_input
->
p_fifo
);
data
=
block
_FifoGet
(
p_input
->
p_fifo
);
if
(
(
pk
=
asf_packet_create
(
p_mux
,
tk
,
data
)
)
)
{
...
...
@@ -557,7 +557,7 @@ static int MuxGetStream( sout_mux_t *p_mux,
for
(
i
=
0
,
i_dts
=
0
,
i_stream
=
-
1
;
i
<
p_mux
->
i_nb_inputs
;
i
++
)
{
sout_input_t
*
p_input
=
p_mux
->
pp_inputs
[
i
];
sout_buffer
_t
*
p_data
;
block
_t
*
p_data
;
if
(
p_input
->
p_fifo
->
i_depth
<=
0
)
{
...
...
@@ -571,7 +571,7 @@ static int MuxGetStream( sout_mux_t *p_mux,
continue
;
}
p_data
=
sout
_FifoShow
(
p_input
->
p_fifo
);
p_data
=
block
_FifoShow
(
p_input
->
p_fifo
);
if
(
i_stream
==
-
1
||
p_data
->
i_dts
<
i_dts
)
{
...
...
@@ -790,7 +790,7 @@ static void asf_chunk_add( bo_t *bo,
bo_addle_u16
(
bo
,
i_len
+
8
);
}
static
sout_buffer
_t
*
asf_header_create
(
sout_mux_t
*
p_mux
,
static
block
_t
*
asf_header_create
(
sout_mux_t
*
p_mux
,
vlc_bool_t
b_broadcast
)
{
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
...
...
@@ -800,7 +800,7 @@ static sout_buffer_t *asf_header_create( sout_mux_t *p_mux,
int
i_size
;
int
i_ci_size
;
int
i_cd_size
=
0
;
sout_buffer
_t
*
out
;
block
_t
*
out
;
bo_t
bo
;
int
i
;
...
...
@@ -843,13 +843,13 @@ static sout_buffer_t *asf_header_create( sout_mux_t *p_mux,
if
(
p_sys
->
b_asf_http
)
{
out
=
sout_BufferNew
(
p_mux
->
p_sout
,
i_size
+
50
+
12
);
out
=
block_New
(
p_mux
,
i_size
+
50
+
12
);
bo_init
(
&
bo
,
out
->
p_buffer
,
i_size
+
50
+
12
);
asf_chunk_add
(
&
bo
,
0x4824
,
i_size
+
50
,
0xc00
,
p_sys
->
i_seq
++
);
}
else
{
out
=
sout_BufferNew
(
p_mux
->
p_sout
,
i_size
+
50
);
out
=
block_New
(
p_mux
,
i_size
+
50
);
bo_init
(
&
bo
,
out
->
p_buffer
,
i_size
+
50
);
}
/* header object */
...
...
@@ -965,15 +965,15 @@ static sout_buffer_t *asf_header_create( sout_mux_t *p_mux,
/****************************************************************************
*
****************************************************************************/
static
sout_buffer
_t
*
asf_packet_create
(
sout_mux_t
*
p_mux
,
asf_track_t
*
tk
,
sout_buffer
_t
*
data
)
static
block
_t
*
asf_packet_create
(
sout_mux_t
*
p_mux
,
asf_track_t
*
tk
,
block
_t
*
data
)
{
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
int
i_data
=
data
->
i_
size
;
int
i_data
=
data
->
i_
buffer
;
int
i_pos
=
0
;
uint8_t
*
p_data
=
data
->
p_buffer
;
sout_buffer
_t
*
first
=
NULL
,
**
last
=
&
first
;
block
_t
*
first
=
NULL
,
**
last
=
&
first
;
int
i_preheader
=
p_sys
->
b_asf_http
?
12
:
0
;
while
(
i_pos
<
i_data
)
...
...
@@ -983,7 +983,7 @@ static sout_buffer_t *asf_packet_create( sout_mux_t *p_mux,
if
(
p_sys
->
pk
==
NULL
)
{
p_sys
->
pk
=
sout_BufferNew
(
p_mux
->
p_sout
,
p_sys
->
pk
=
block_New
(
p_mux
,
p_sys
->
i_packet_size
+
i_preheader
);
/* reserve 14 bytes for the packet header */
p_sys
->
i_pk_used
=
14
+
i_preheader
;
...
...
@@ -1043,21 +1043,21 @@ static sout_buffer_t *asf_packet_create( sout_mux_t *p_mux,
}
tk
->
i_sequence
++
;
sout_BufferDelete
(
p_mux
->
p_sout
,
data
);
block_Release
(
data
);
return
first
;
}
static
sout_buffer
_t
*
asf_stream_end_create
(
sout_mux_t
*
p_mux
)
static
block
_t
*
asf_stream_end_create
(
sout_mux_t
*
p_mux
)
{
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
sout_buffer
_t
*
out
=
NULL
;
block
_t
*
out
=
NULL
;
bo_t
bo
;
if
(
p_sys
->
b_asf_http
)
{
out
=
sout_BufferNew
(
p_mux
->
p_sout
,
12
);
out
=
block_New
(
p_mux
,
12
);
bo_init
(
&
bo
,
out
->
p_buffer
,
12
);
asf_chunk_add
(
&
bo
,
0x4524
,
0
,
0x00
,
p_sys
->
i_seq
++
);
}
...
...
modules/mux/avi.c
View file @
085985d5
...
...
@@ -2,7 +2,7 @@
* avi.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id
: avi.c,v 1.18 2004/02/06 23:43:32 gbazin Exp
$
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
...
...
@@ -119,8 +119,8 @@ struct sout_mux_sys_t
#define AVIIF_KEYFRAME 0x00000010L
/* this frame is a key frame.*/
static
sout_buffer
_t
*
avi_HeaderCreateRIFF
(
sout_mux_t
*
);
static
sout_buffer
_t
*
avi_HeaderCreateidx1
(
sout_mux_t
*
);
static
block
_t
*
avi_HeaderCreateRIFF
(
sout_mux_t
*
);
static
block
_t
*
avi_HeaderCreateidx1
(
sout_mux_t
*
);
static
void
SetFCC
(
uint8_t
*
p
,
char
*
fcc
)
{
...
...
@@ -154,7 +154,6 @@ static int Open( vlc_object_t *p_this )
p_mux
->
pf_delstream
=
DelStream
;
p_mux
->
pf_mux
=
Mux
;
p_mux
->
p_sys
=
p_sys
;
p_mux
->
i_preheader
=
8
;
/* (fourcc,length) header */
return
VLC_SUCCESS
;
}
...
...
@@ -167,14 +166,14 @@ static void Close( vlc_object_t * p_this )
sout_mux_t
*
p_mux
=
(
sout_mux_t
*
)
p_this
;
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
sout_buffer
_t
*
p_hdr
,
*
p_idx1
;
block
_t
*
p_hdr
,
*
p_idx1
;
int
i_stream
;
msg_Dbg
(
p_mux
,
"AVI muxer closed"
);
/* first create idx1 chunk (write at the end of the stream */
p_idx1
=
avi_HeaderCreateidx1
(
p_mux
);
p_sys
->
i_idx1_size
=
p_idx1
->
i_
size
;
p_sys
->
i_idx1_size
=
p_idx1
->
i_
buffer
;
sout_AccessOutWrite
(
p_mux
->
p_access
,
p_idx1
);
/* calculate some value for headers creations */
...
...
@@ -388,7 +387,7 @@ static int Mux ( sout_mux_t *p_mux )
if
(
p_sys
->
b_write_header
)
{
sout_buffer
_t
*
p_hdr
;
block
_t
*
p_hdr
;
msg_Dbg
(
p_mux
,
"writing header"
);
...
...
@@ -401,7 +400,7 @@ static int Mux ( sout_mux_t *p_mux )
for
(
i
=
0
;
i
<
p_mux
->
i_nb_inputs
;
i
++
)
{
int
i_count
;
sout
_fifo_t
*
p_fifo
;
block
_fifo_t
*
p_fifo
;
i_stream
=
*
((
int
*
)
p_mux
->
pp_inputs
[
i
]
->
p_sys
);
p_stream
=
&
p_sys
->
stream
[
i_stream
];
...
...
@@ -411,27 +410,32 @@ static int Mux ( sout_mux_t *p_mux )
while
(
i_count
>
0
)
{
avi_idx1_entry_t
*
p_idx
;
sout_buffer
_t
*
p_data
;
block
_t
*
p_data
;
p_data
=
sout_FifoGet
(
p_fifo
);
p_data
=
block_FifoGet
(
p_fifo
);
if
(
p_fifo
->
i_depth
>
0
)
{
block_t
*
p_next
=
block_FifoShow
(
p_fifo
);
p_data
->
i_length
=
p_next
->
i_dts
-
p_data
->
i_dts
;
}
p_stream
->
i_frames
++
;
if
(
p_data
->
i_length
<
0
)
{
msg_Warn
(
p_mux
,
"argg length < 0 l"
);
sout_BufferDelete
(
p_mux
->
p_sout
,
p_data
);
block_Release
(
p_data
);
i_count
--
;
continue
;
}
p_stream
->
i_duration
+=
p_data
->
i_length
;
p_stream
->
i_totalsize
+=
p_data
->
i_
size
;
p_stream
->
i_totalsize
+=
p_data
->
i_
buffer
;
/* add idx1 entry for this frame */
p_idx
=
&
p_sys
->
idx1
.
entry
[
p_sys
->
idx1
.
i_entry_count
];
memcpy
(
p_idx
->
fcc
,
p_stream
->
fcc
,
4
);
p_idx
->
i_flags
=
AVIIF_KEYFRAME
;
p_idx
->
i_pos
=
p_sys
->
i_movi_size
+
4
;
p_idx
->
i_length
=
p_data
->
i_
size
;
p_idx
->
i_length
=
p_data
->
i_
buffer
;
p_sys
->
idx1
.
i_entry_count
++
;
if
(
p_sys
->
idx1
.
i_entry_count
>=
p_sys
->
idx1
.
i_entry_max
)
{
...
...
@@ -440,34 +444,20 @@ static int Mux ( sout_mux_t *p_mux )
p_sys
->
idx1
.
i_entry_max
*
sizeof
(
avi_idx1_entry_t
)
);
}
if
(
sout_BufferReallocFromPreHeader
(
p_mux
->
p_sout
,
p_data
,
8
)
)
{
/* there isn't enough data in preheader */
sout_buffer_t
*
p_hdr
;
p_hdr
=
sout_BufferNew
(
p_mux
->
p_sout
,
8
);
SetFCC
(
p_hdr
->
p_buffer
,
p_stream
->
fcc
);
SetDWLE
(
p_hdr
->
p_buffer
+
4
,
p_data
->
i_size
);
sout_AccessOutWrite
(
p_mux
->
p_access
,
p_hdr
);
p_sys
->
i_movi_size
+=
p_hdr
->
i_size
;
}
else
p_data
=
block_Realloc
(
p_data
,
8
,
0
);
if
(
p_data
)
{
SetFCC
(
p_data
->
p_buffer
,
p_stream
->
fcc
);
SetDWLE
(
p_data
->
p_buffer
+
4
,
p_data
->
i_size
-
8
);
}
SetDWLE
(
p_data
->
p_buffer
+
4
,
p_data
->
i_buffer
-
8
);
if
(
p_data
->
i_size
&
0x01
)
if
(
p_data
->
i_buffer
&
0x01
)
{
sout_BufferRealloc
(
p_mux
->
p_sout
,
p_data
,
p_data
->
i_size
+
1
);
p_data
->
i_size
+=
1
;
p_data
=
block_Realloc
(
p_data
,
0
,
p_data
->
i_buffer
+
1
);
}
p_sys
->
i_movi_size
+=
p_data
->
i_size
;
p_sys
->
i_movi_size
+=
p_data
->
i_buffer
;
sout_AccessOutWrite
(
p_mux
->
p_access
,
p_data
);
}
i_count
--
;
}
...
...
@@ -774,16 +764,16 @@ static int avi_HeaderAdd_strl( sout_mux_t *p_mux,
AVI_BOX_EXIT
(
0
);
}
static
sout_buffer
_t
*
avi_HeaderCreateRIFF
(
sout_mux_t
*
p_mux
)
static
block
_t
*
avi_HeaderCreateRIFF
(
sout_mux_t
*
p_mux
)
{
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
sout_buffer
_t
*
p_hdr
;
block
_t
*
p_hdr
;
int
i_stream
;
int
i_maxbytespersec
;
int
i_junk
;
buffer_out_t
bo
;
p_hdr
=
sout_BufferNew
(
p_mux
->
p_sout
,
HDR_SIZE
);
p_hdr
=
block_New
(
p_mux
,
HDR_SIZE
);
memset
(
p_hdr
->
p_buffer
,
0
,
HDR_SIZE
);
bo_Init
(
&
bo
,
HDR_SIZE
,
p_hdr
->
p_buffer
);
...
...
@@ -814,17 +804,17 @@ static sout_buffer_t *avi_HeaderCreateRIFF( sout_mux_t *p_mux )
return
(
p_hdr
);
}
static
sout_buffer
_t
*
avi_HeaderCreateidx1
(
sout_mux_t
*
p_mux
)
static
block
_t
*
avi_HeaderCreateidx1
(
sout_mux_t
*
p_mux
)
{
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
sout_buffer
_t
*
p_idx1
;
block
_t
*
p_idx1
;
uint32_t
i_idx1_size
;
unsigned
int
i
;
buffer_out_t
bo
;
i_idx1_size
=
16
*
p_sys
->
idx1
.
i_entry_count
;
p_idx1
=
sout_BufferNew
(
p_mux
->
p_sout
,
i_idx1_size
+
8
);
p_idx1
=
block_New
(
p_mux
,
i_idx1_size
+
8
);
memset
(
p_idx1
->
p_buffer
,
0
,
i_idx1_size
);
bo_Init
(
&
bo
,
i_idx1_size
,
p_idx1
->
p_buffer
);
...
...
modules/mux/dummy.c
View file @
085985d5
...
...
@@ -2,7 +2,7 @@
* dummy.c: dummy muxer module for vlc
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id
: dummy.c,v 1.10 2003/12/14 22:49:28 gbazin Exp
$
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
...
...
@@ -28,10 +28,8 @@
#include <stdlib.h>
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/sout.h>
#include "codecs.h"
/*****************************************************************************
* Module descriptor
...
...
@@ -130,22 +128,18 @@ static int Mux( sout_mux_t *p_mux )
for
(
i
=
0
;
i
<
p_mux
->
i_nb_inputs
;
i
++
)
{
block_fifo_t
*
p_fifo
;
int
i_count
;
sout_fifo_t
*
p_fifo
;
if
(
p_sys
->
b_header
&&
p_mux
->
pp_inputs
[
i
]
->
p_fmt
->
i_extra
)
{
/* Write header data */
sout_buffer_t
*
p_data
;
p_data
=
sout_BufferNew
(
p_mux
->
p_sout
,
p_mux
->
pp_inputs
[
i
]
->
p_fmt
->
i_extra
);
block_t
*
p_data
;
p_data
=
block_New
(
p_mux
,
p_mux
->
pp_inputs
[
i
]
->
p_fmt
->
i_extra
);
memcpy
(
p_data
->
p_buffer
,
p_mux
->
pp_inputs
[
i
]
->
p_fmt
->
p_extra
,
p_mux
->
pp_inputs
[
i
]
->
p_fmt
->
i_extra
);
p_data
->
i_size
=
p_mux
->
pp_inputs
[
i
]
->
p_fmt
->
i_extra
;
p_data
->
i_dts
=
p_data
->
i_pts
=
p_data
->
i_length
=
0
;
msg_Dbg
(
p_mux
,
"writing header data"
);
sout_AccessOutWrite
(
p_mux
->
p_access
,
p_data
);
}
...
...
@@ -154,15 +148,12 @@ static int Mux( sout_mux_t *p_mux )
i_count
=
p_fifo
->
i_depth
;
while
(
i_count
>
0
)
{
sout_buffer_t
*
p_data
;
p_data
=
sout_FifoGet
(
p_fifo
);
block_t
*
p_data
=
block_FifoGet
(
p_fifo
);
sout_AccessOutWrite
(
p_mux
->
p_access
,
p_data
);
i_count
--
;
}
}
p_sys
->
b_header
=
VLC_FALSE
;
...
...
modules/mux/mp4.c
View file @
085985d5
...
...
@@ -151,7 +151,7 @@ static void box_gather ( bo_t *box, bo_t *box2 );
static
void
box_send
(
sout_mux_t
*
p_mux
,
bo_t
*
box
);
static
sout_buffer
_t
*
bo_to_sout
(
sout_instance_t
*
p_sout
,
bo_t
*
box
);
static
block
_t
*
bo_to_sout
(
sout_instance_t
*
p_sout
,
bo_t
*
box
);
static
bo_t
*
GetMoovBox
(
sout_mux_t
*
p_mux
);
...
...
@@ -217,7 +217,7 @@ static void Close( vlc_object_t * p_this )
{
sout_mux_t
*
p_mux
=
(
sout_mux_t
*
)
p_this
;
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
sout_buffer
_t
*
p_hdr
;
block
_t
*
p_hdr
;
bo_t
bo
,
*
moov
;
vlc_value_t
val
;
...
...
@@ -260,14 +260,14 @@ static void Close( vlc_object_t * p_this )
{
/* Move data to the end of the file so we can fit the moov header
* at the start */
sout_buffer
_t
*
p_buf
;
block
_t
*
p_buf
;
int64_t
i_chunk
,
i_size
=
p_sys
->
i_pos
-
p_sys
->
i_mdat_pos
;
int
i_moov_size
=
moov
->
i_buffer
;
while
(
i_size
>
0
)
{
i_chunk
=
__MIN
(
32768
,
i_size
);
p_buf
=
sout_BufferNew
(
p_mux
->
p_sout
,
i_chunk
);
p_buf
=
block_New
(
p_mux
,
i_chunk
);
sout_AccessOutSeek
(
p_mux
->
p_access
,
p_sys
->
i_mdat_pos
+
i_size
-
i_chunk
);
if
(
sout_AccessOutRead
(
p_mux
->
p_access
,
p_buf
)
<
i_chunk
)
...
...
@@ -420,15 +420,15 @@ static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
for
(
i
=
0
,
i_dts
=
0
,
i_stream
=
-
1
;
i
<
p_mux
->
i_nb_inputs
;
i
++
)
{
sout
_fifo_t
*
p_fifo
=
p_mux
->
pp_inputs
[
i
]
->
p_fifo
;
sout_buffer
_t
*
p_buf
;
block
_fifo_t
*
p_fifo
=
p_mux
->
pp_inputs
[
i
]
->
p_fifo
;
block
_t
*
p_buf
;
if
(
p_fifo
->
i_depth
<=
1
)
{
return
-
1
;
// wait that all fifo have at least 2 packets
}
p_buf
=
sout
_FifoShow
(
p_fifo
);
p_buf
=
block
_FifoShow
(
p_fifo
);
if
(
i_stream
<
0
||
p_buf
->
i_dts
<
i_dts
)
{
i_dts
=
p_buf
->
i_dts
;
...
...
@@ -458,7 +458,7 @@ static int Mux( sout_mux_t *p_mux )
sout_input_t
*
p_input
;
int
i_stream
;
mp4_stream_t
*
p_stream
;
sout_buffer
_t
*
p_data
;
block
_t
*
p_data
;
mtime_t
i_dts
;
if
(
MuxGetStream
(
p_mux
,
&
i_stream
,
&
i_dts
)
<
0
)
...
...
@@ -469,10 +469,10 @@ static int Mux( sout_mux_t *p_mux )
p_input
=
p_mux
->
pp_inputs
[
i_stream
];
p_stream
=
(
mp4_stream_t
*
)
p_input
->
p_sys
;
p_data
=
sout
_FifoGet
(
p_input
->
p_fifo
);
p_data
=
block
_FifoGet
(
p_input
->
p_fifo
);
if
(
p_input
->
p_fifo
->
i_depth
>
0
)
{
sout_buffer_t
*
p_next
=
sout
_FifoShow
(
p_input
->
p_fifo
);
block_t
*
p_next
=
block
_FifoShow
(
p_input
->
p_fifo
);
int64_t
i_diff
=
p_next
->
i_dts
-
p_data
->
i_dts
;
if
(
i_diff
<
I64C
(
1000000
)
)
/* protection */
...
...
@@ -509,7 +509,7 @@ static int Mux( sout_mux_t *p_mux )
/* add index entry */
p_stream
->
entry
[
p_stream
->
i_entry_count
].
i_pos
=
p_sys
->
i_pos
;
p_stream
->
entry
[
p_stream
->
i_entry_count
].
i_size
=
p_data
->
i_
size
;
p_stream
->
entry
[
p_stream
->
i_entry_count
].
i_size
=
p_data
->
i_
buffer
;
p_stream
->
entry
[
p_stream
->
i_entry_count
].
i_pts_dts
=
__MAX
(
p_data
->
i_pts
-
p_data
->
i_dts
,
0
);
p_stream
->
entry
[
p_stream
->
i_entry_count
].
i_length
=
p_data
->
i_length
;
...
...
@@ -526,7 +526,7 @@ static int Mux( sout_mux_t *p_mux )
/* update */
p_stream
->
i_duration
+=
p_data
->
i_length
;
p_sys
->
i_pos
+=
p_data
->
i_
size
;
p_sys
->
i_pos
+=
p_data
->
i_
buffer
;
/* write data */
sout_AccessOutWrite
(
p_mux
->
p_access
,
p_data
);
...
...
@@ -1116,8 +1116,7 @@ static bo_t *GetStblBox( sout_mux_t *p_mux, mp4_stream_t *p_stream )
stss
=
NULL
;
for
(
i
=
0
,
i_index
=
0
;
i
<
p_stream
->
i_entry_count
;
i
++
)
{
if
(
p_stream
->
entry
[
i
].
i_flags
&
(
BLOCK_FLAG_TYPE_I
<<
SOUT_BUFFER_FLAGS_BLOCK_SHIFT
)
)
if
(
p_stream
->
entry
[
i
].
i_flags
&
BLOCK_FLAG_TYPE_I
)
{
if
(
stss
==
NULL
)
{
...
...
@@ -1704,24 +1703,22 @@ static void box_gather ( bo_t *box, bo_t *box2 )
box_free
(
box2
);
}
static
sout_buffer
_t
*
bo_to_sout
(
sout_instance_t
*
p_sout
,
bo_t
*
box
)
static
block
_t
*
bo_to_sout
(
sout_instance_t
*
p_sout
,
bo_t
*
box
)
{
sout_buffer
_t
*
p_buf
;
block
_t
*
p_buf
;
p_buf
=
sout_Buffer
New
(
p_sout
,
box
->
i_buffer
);
p_buf
=
block_
New
(
p_sout
,
box
->
i_buffer
);
if
(
box
->
i_buffer
>
0
)
{
memcpy
(
p_buf
->
p_buffer
,
box
->
p_buffer
,
box
->
i_buffer
);
}
p_buf
->
i_size
=
box
->
i_buffer
;
return
p_buf
;
}
static
void
box_send
(
sout_mux_t
*
p_mux
,
bo_t
*
box
)
{
sout_buffer
_t
*
p_buf
;
block
_t
*
p_buf
;
p_buf
=
bo_to_sout
(
p_mux
->
p_sout
,
box
);
box_free
(
box
);
...
...
modules/mux/mpeg/pes.c
View file @
085985d5
...
...
@@ -2,7 +2,7 @@
* pes.c: PES packetizer used by the MPEG multiplexers
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id
: pes.c,v 1.15 2004/03/03 11:34:41 massiot Exp
$
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
...
...
@@ -229,12 +229,12 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
}
int
E_
(
EStoPES
)(
sout_instance_t
*
p_sout
,
sout_buffer
_t
**
pp_pes
,
sout_buffer
_t
*
p_es
,
block
_t
**
pp_pes
,
block
_t
*
p_es
,
int
i_stream_id
,
int
b_mpeg2
)
{
sout_buffer
_t
*
p_es_sav
,
*
p_pes
;
block
_t
*
p_es_sav
,
*
p_pes
;
mtime_t
i_pts
,
i_dts
,
i_length
;
uint8_t
*
p_data
;
...
...
@@ -258,7 +258,7 @@ int E_( EStoPES )( sout_instance_t *p_sout,
i_pts
=
p_es
->
i_pts
<=
0
?
0
:
p_es
->
i_pts
*
9
/
100
;
// 90000 units clock
i_dts
=
p_es
->
i_dts
<=
0
?
0
:
p_es
->
i_dts
*
9
/
100
;
// 90000 units clock
i_size
=
p_es
->
i_
size
;
i_size
=
p_es
->
i_
buffer
;
p_data
=
p_es
->
p_buffer
;
*
pp_pes
=
p_pes
=
NULL
;
...
...
@@ -274,12 +274,7 @@ int E_( EStoPES )( sout_instance_t *p_sout,
if
(
p_es
)
{
if
(
sout_BufferReallocFromPreHeader
(
p_sout
,
p_es
,
i_pes_header
)
)
{
msg_Err
(
p_sout
,
"cannot realloc preheader (should never happen)"
);
return
(
-
1
);
}
p_es
=
block_Realloc
(
p_es
,
i_pes_header
,
0
);
/* reuse p_es for first frame */
*
pp_pes
=
p_pes
=
p_es
;
/* don't touch i_dts, i_pts, i_length as are already set :) */
...
...
@@ -287,8 +282,7 @@ int E_( EStoPES )( sout_instance_t *p_sout,
}
else
{
p_pes
->
p_next
=
sout_BufferNew
(
p_sout
,
i_pes_header
+
i_pes_payload
);
p_pes
->
p_next
=
block_New
(
p_sout
,
i_pes_header
+
i_pes_payload
);
p_pes
=
p_pes
->
p_next
;
p_pes
->
i_dts
=
0
;
...
...
@@ -307,16 +301,10 @@ int E_( EStoPES )( sout_instance_t *p_sout,
i_size
-=
i_pes_payload
;
p_data
+=
i_pes_payload
;
p_pes
->
i_
size
=
i_pes_header
+
i_pes_payload
;
p_pes
->
i_
buffer
=
i_pes_header
+
i_pes_payload
;
}
while
(
i_size
>
0
);
/* save some space */
if
(
p_es_sav
->
i_size
+
10
*
1024
<
p_es_sav
->
i_buffer_size
)
{
sout_BufferRealloc
(
p_sout
,
p_es_sav
,
p_es_sav
->
i_size
);
}
/* Now redate all pes */
i_dts
=
(
*
pp_pes
)
->
i_dts
;
i_length
=
(
*
pp_pes
)
->
i_length
/
i_pes_count
;
...
...
modules/mux/mpeg/pes.h
View file @
085985d5
...
...
@@ -2,7 +2,7 @@
* pes.h
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id
: pes.h,v 1.3 2003/01/08 10:34:58 fenrir Exp
$
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
...
...
@@ -35,5 +35,5 @@
int
E_
(
EStoPES
)(
sout_instance_t
*
p_sout
,
sout_buffer_t
**
pp_pes
,
sout_buffer_t
*
p_es
,
block_t
**
pp_pes
,
block_t
*
p_es
,
int
i_stream_id
,
int
b_mpeg2
);
modules/mux/mpeg/ps.c
View file @
085985d5
...
...
@@ -3,7 +3,7 @@
* multiplexer module for vlc
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id
: ps.c,v 1.16 2003/11/21 15:32:08 fenrir Exp
$
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
...
...
@@ -72,8 +72,8 @@ static int Mux ( sout_mux_t * );
*****************************************************************************/
static
int
MuxGetStream
(
sout_mux_t
*
,
int
*
,
mtime_t
*
);
static
void
MuxWritePackHeader
(
sout_mux_t
*
,
sout_buffer
_t
**
,
mtime_t
);
static
void
MuxWriteSystemHeader
(
sout_mux_t
*
,
sout_buffer
_t
**
);
static
void
MuxWritePackHeader
(
sout_mux_t
*
,
block
_t
**
,
mtime_t
);
static
void
MuxWriteSystemHeader
(
sout_mux_t
*
,
block
_t
**
);
static
void
StreamIdInit
(
vlc_bool_t
*
id
,
int
i_range
);
static
int
StreamIdGet
(
vlc_bool_t
*
id
,
int
i_id_min
,
int
i_id_max
);
...
...
@@ -120,7 +120,6 @@ static int Open( vlc_object_t *p_this )
p_mux
->
pf_addstream
=
AddStream
;
p_mux
->
pf_delstream
=
DelStream
;
p_mux
->
pf_mux
=
Mux
;
p_mux
->
i_preheader
=
30
;
// really enough for a pes header
p_mux
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
sout_mux_sys_t
)
);
/* Init free stream id */
...
...
@@ -149,11 +148,11 @@ static void Close( vlc_object_t * p_this )
sout_mux_t
*
p_mux
=
(
sout_mux_t
*
)
p_this
;
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
sout_buffer
_t
*
p_end
;
block
_t
*
p_end
;
msg_Info
(
p_mux
,
"Close"
);
p_end
=
sout_BufferNew
(
p_mux
->
p_sout
,
4
);
p_end
=
block_New
(
p_mux
,
4
);
p_end
->
p_buffer
[
0
]
=
0x00
;
p_end
->
p_buffer
[
1
]
=
0x00
;
p_end
->
p_buffer
[
2
]
=
0x01
;
...
...
@@ -297,7 +296,7 @@ static int Mux( sout_mux_t *p_mux )
sout_input_t
*
p_input
;
ps_stream_t
*
p_stream
;
sout_buffer
_t
*
p_ps
,
*
p_data
;
block
_t
*
p_ps
,
*
p_data
;
mtime_t
i_dts
;
int
i_stream
;
...
...
@@ -320,25 +319,25 @@ static int Mux( sout_mux_t *p_mux )
/* Write regulary SystemHeader */
if
(
p_sys
->
i_pes_count
%
300
==
0
)
{
sout_buffer
_t
*
p_pk
;
block
_t
*
p_pk
;
MuxWriteSystemHeader
(
p_mux
,
&
p_ps
);
/* For MPEG1 streaming, set HEADER flag */
for
(
p_pk
=
p_ps
;
p_pk
!=
NULL
;
p_pk
=
p_pk
->
p_next
)
{
p_pk
->
i_flags
|=
SOUT_BUFFER_FLAGS
_HEADER
;
p_pk
->
i_flags
|=
BLOCK_FLAG
_HEADER
;
}
}
/* Get and mux a packet */
p_data
=
sout
_FifoGet
(
p_input
->
p_fifo
);
p_data
=
block
_FifoGet
(
p_input
->
p_fifo
);
E_
(
EStoPES
)(
p_mux
->
p_sout
,
&
p_data
,
p_data
,
p_stream
->
i_stream_id
,
p_mux
->
p_sys
->
b_mpeg2
);
sout_BufferChain
(
&
p_ps
,
p_data
);
block_ChainAppend
(
&
p_ps
,
p_data
);
sout_AccessOutWrite
(
p_mux
->
p_access
,
p_ps
);
/* Increase counter */
...
...
@@ -381,16 +380,16 @@ static void StreamIdRelease( vlc_bool_t *id, int i_id_min, int i_id )
id
[
i_id
-
i_id_min
]
=
VLC_TRUE
;
}
static
void
MuxWritePackHeader
(
sout_mux_t
*
p_mux
,
sout_buffer
_t
**
p_buf
,
static
void
MuxWritePackHeader
(
sout_mux_t
*
p_mux
,
block
_t
**
p_buf
,
mtime_t
i_dts
)
{
sout_buffer
_t
*
p_hdr
;
block
_t
*
p_hdr
;
bits_buffer_t
bits
;
mtime_t
i_src
;
i_src
=
i_dts
*
9
/
100
;
p_hdr
=
sout_BufferNew
(
p_mux
->
p_sout
,
18
);
p_hdr
=
block_New
(
p_mux
,
18
);
bits_initwrite
(
&
bits
,
14
,
p_hdr
->
p_buffer
);
bits_write
(
&
bits
,
32
,
0x01ba
);
...
...
@@ -426,15 +425,15 @@ static void MuxWritePackHeader( sout_mux_t *p_mux, sout_buffer_t **p_buf,
bits_write
(
&
bits
,
3
,
0
);
// stuffing bytes
}
p_hdr
->
i_
size
=
p_mux
->
p_sys
->
b_mpeg2
?
14
:
12
;
p_hdr
->
i_
buffer
=
p_mux
->
p_sys
->
b_mpeg2
?
14
:
12
;
sout_BufferChain
(
p_buf
,
p_hdr
);
block_ChainAppend
(
p_buf
,
p_hdr
);
}
static
void
MuxWriteSystemHeader
(
sout_mux_t
*
p_mux
,
sout_buffer
_t
**
p_buf
)
static
void
MuxWriteSystemHeader
(
sout_mux_t
*
p_mux
,
block
_t
**
p_buf
)
{
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
sout_buffer
_t
*
p_hdr
;
block
_t
*
p_hdr
;
bits_buffer_t
bits
;
vlc_bool_t
b_private
;
int
i_nb_private
,
i_nb_stream
;
...
...
@@ -456,7 +455,7 @@ static void MuxWriteSystemHeader( sout_mux_t *p_mux, sout_buffer_t **p_buf )
/* Private stream are declared only one time */
i_nb_stream
=
p_mux
->
i_nb_inputs
-
(
i_nb_private
>
0
?
i_nb_private
-
1
:
0
);
p_hdr
=
sout_BufferNew
(
p_mux
->
p_sout
,
12
+
i_nb_stream
*
3
);
p_hdr
=
block_New
(
p_mux
,
12
+
i_nb_stream
*
3
);
bits_initwrite
(
&
bits
,
12
+
i_nb_stream
*
3
,
p_hdr
->
p_buffer
);
bits_write
(
&
bits
,
32
,
0x01bb
);
...
...
@@ -520,7 +519,7 @@ static void MuxWriteSystemHeader( sout_mux_t *p_mux, sout_buffer_t **p_buf )
}
}
sout_BufferChain
(
p_buf
,
p_hdr
);
block_ChainAppend
(
p_buf
,
p_hdr
);
}
/*
...
...
@@ -537,7 +536,7 @@ static int MuxGetStream( sout_mux_t *p_mux,
for
(
i
=
0
,
i_dts
=
0
,
i_stream
=
-
1
;
i
<
p_mux
->
i_nb_inputs
;
i
++
)
{
sout_input_t
*
p_input
=
p_mux
->
pp_inputs
[
i
];
sout_buffer
_t
*
p_data
;
block
_t
*
p_data
;
if
(
p_input
->
p_fifo
->
i_depth
<=
0
)
{
...
...
@@ -551,7 +550,7 @@ static int MuxGetStream( sout_mux_t *p_mux,
continue
;
}
p_data
=
sout
_FifoShow
(
p_input
->
p_fifo
);
p_data
=
block
_FifoShow
(
p_input
->
p_fifo
);
if
(
i_stream
==
-
1
||
p_data
->
i_dts
<
i_dts
)
{
...
...
modules/mux/mpeg/ts.c
View file @
085985d5
...
...
@@ -2,7 +2,7 @@
* ts.c: MPEG-II TS Muxer
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id
: ts.c,v 1.46 2004/03/03 11:34:41 massiot Exp
$
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
...
...
@@ -95,13 +95,13 @@ vlc_module_end();
/*****************************************************************************
* Local data structures
*****************************************************************************/
#define SOUT_BUFFER_FLAGS_PRIVATE_PCR ( 1 <<
SOUT_BUFFER_FLAGS
_PRIVATE_SHIFT )
#define SOUT_BUFFER_FLAGS_PRIVATE_CSA ( 2 <<
SOUT_BUFFER_FLAGS
_PRIVATE_SHIFT )
#define SOUT_BUFFER_FLAGS_PRIVATE_PCR ( 1 <<
BLOCK_FLAG
_PRIVATE_SHIFT )
#define SOUT_BUFFER_FLAGS_PRIVATE_CSA ( 2 <<
BLOCK_FLAG
_PRIVATE_SHIFT )
typedef
struct
{
int
i_depth
;
sout_buffer
_t
*
p_first
;
sout_buffer
_t
**
pp_last
;
block
_t
*
p_first
;
block
_t
**
pp_last
;
}
sout_buffer_chain_t
;
static
inline
void
BufferChainInit
(
sout_buffer_chain_t
*
c
)
...
...
@@ -110,7 +110,7 @@ static inline void BufferChainInit ( sout_buffer_chain_t *c )
c
->
p_first
=
NULL
;
c
->
pp_last
=
&
c
->
p_first
;
}
static
inline
void
BufferChainAppend
(
sout_buffer_chain_t
*
c
,
sout_buffer
_t
*
b
)
static
inline
void
BufferChainAppend
(
sout_buffer_chain_t
*
c
,
block
_t
*
b
)
{
*
c
->
pp_last
=
b
;
c
->
i_depth
++
;
...
...
@@ -122,9 +122,9 @@ static inline void BufferChainAppend( sout_buffer_chain_t *c, sout_buffer_t *b )
}
c
->
pp_last
=
&
b
->
p_next
;
}
static
inline
sout_buffer
_t
*
BufferChainGet
(
sout_buffer_chain_t
*
c
)
static
inline
block
_t
*
BufferChainGet
(
sout_buffer_chain_t
*
c
)
{
sout_buffer
_t
*
b
=
c
->
p_first
;
block
_t
*
b
=
c
->
p_first
;
if
(
b
)
{
...
...
@@ -140,19 +140,19 @@ static inline sout_buffer_t *BufferChainGet( sout_buffer_chain_t *c )
}
return
b
;
}
static
inline
sout_buffer
_t
*
BufferChainPeek
(
sout_buffer_chain_t
*
c
)
static
inline
block
_t
*
BufferChainPeek
(
sout_buffer_chain_t
*
c
)
{
sout_buffer
_t
*
b
=
c
->
p_first
;
block
_t
*
b
=
c
->
p_first
;
return
b
;
}
static
inline
void
BufferChainClean
(
sout_instance_t
*
p_sout
,
sout_buffer_chain_t
*
c
)
{
sout_buffer
_t
*
b
;
block
_t
*
b
;
while
(
(
b
=
BufferChainGet
(
c
)
)
)
{
sout_BufferDelete
(
p_sout
,
b
);
block_Release
(
b
);
}
BufferChainInit
(
c
);
}
...
...
@@ -260,10 +260,10 @@ static void TSDate ( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
static
void
GetPAT
(
sout_mux_t
*
p_mux
,
sout_buffer_chain_t
*
c
);
static
void
GetPMT
(
sout_mux_t
*
p_mux
,
sout_buffer_chain_t
*
c
);
static
sout_buffer
_t
*
TSNew
(
sout_mux_t
*
p_mux
,
ts_stream_t
*
p_stream
,
vlc_bool_t
b_pcr
);
static
void
TSSetPCR
(
sout_buffer
_t
*
p_ts
,
mtime_t
i_dts
);
static
block
_t
*
TSNew
(
sout_mux_t
*
p_mux
,
ts_stream_t
*
p_stream
,
vlc_bool_t
b_pcr
);
static
void
TSSetPCR
(
block
_t
*
p_ts
,
mtime_t
i_dts
);
static
void
PEStoTS
(
sout_instance_t
*
,
sout_buffer_chain_t
*
,
sout_buffer
_t
*
,
ts_stream_t
*
);
static
void
PEStoTS
(
sout_instance_t
*
,
sout_buffer_chain_t
*
,
block
_t
*
,
ts_stream_t
*
);
/*****************************************************************************
* Open:
...
...
@@ -283,7 +283,6 @@ static int Open( vlc_object_t *p_this )
p_mux
->
pf_delstream
=
DelStream
;
p_mux
->
pf_mux
=
Mux
;
p_mux
->
p_sys
=
p_sys
;
p_mux
->
i_preheader
=
30
;
// really enough for a pes header
srand
(
(
uint32_t
)
mdate
()
);
...
...
@@ -773,7 +772,7 @@ static int Mux( sout_mux_t *p_mux )
for
(
;;
)
{
vlc_bool_t
b_ok
=
VLC_TRUE
;
sout_buffer
_t
*
p_data
;
block
_t
*
p_data
;
/* Accumulate enough data in the pcr stream (>i_shaping_delay) */
/* Accumulate enough data in all other stream ( >= length of pcr) */
...
...
@@ -804,10 +803,10 @@ static int Mux( sout_mux_t *p_mux )
}
b_ok
=
VLC_FALSE
;
p_data
=
sout
_FifoGet
(
p_input
->
p_fifo
);
p_data
=
block
_FifoGet
(
p_input
->
p_fifo
);
if
(
p_input
->
p_fifo
->
i_depth
>
0
)
{
sout_buffer_t
*
p_next
=
sout
_FifoShow
(
p_input
->
p_fifo
);
block_t
*
p_next
=
block
_FifoShow
(
p_input
->
p_fifo
);
p_data
->
i_length
=
p_next
->
i_dts
-
p_data
->
i_dts
;
}
...
...
@@ -820,7 +819,7 @@ static int Mux( sout_mux_t *p_mux )
p_data
->
i_dts
,
p_stream
->
i_pes_dts
,
p_pcr_stream
->
i_pes_dts
);
sout_BufferDelete
(
p_mux
->
p_sout
,
p_data
);
block_Release
(
p_data
);
BufferChainClean
(
p_mux
->
p_sout
,
&
p_stream
->
chain_pes
);
p_stream
->
i_pes_dts
=
0
;
...
...
@@ -853,8 +852,7 @@ static int Mux( sout_mux_t *p_mux )
BufferChainAppend
(
&
p_stream
->
chain_pes
,
p_data
);
if
(
p_sys
->
b_use_key_frames
&&
p_stream
==
p_pcr_stream
&&
(
p_data
->
i_flags
&
(
BLOCK_FLAG_TYPE_I
<<
SOUT_BUFFER_FLAGS_BLOCK_SHIFT
))
&&
(
p_data
->
i_flags
&
BLOCK_FLAG_TYPE_I
)
&&
(
p_stream
->
i_pes_length
>
300000
)
)
{
i_shaping_delay
=
p_stream
->
i_pes_length
;
...
...
@@ -881,12 +879,12 @@ static int Mux( sout_mux_t *p_mux )
for
(
i
=
0
;
i
<
p_mux
->
i_nb_inputs
;
i
++
)
{
ts_stream_t
*
p_stream
=
(
ts_stream_t
*
)
p_mux
->
pp_inputs
[
i
]
->
p_sys
;
sout_buffer
_t
*
p_pes
;
block
_t
*
p_pes
;
/* False for pcr stream but it will be enough to do PCR algo */
for
(
p_pes
=
p_stream
->
chain_pes
.
p_first
;
p_pes
!=
NULL
;
p_pes
=
p_pes
->
p_next
)
{
int
i_size
=
p_pes
->
i_
size
;
int
i_size
=
p_pes
->
i_
buffer
;
if
(
p_pes
->
i_dts
+
p_pes
->
i_length
>
p_pcr_stream
->
i_pes_dts
+
p_pcr_stream
->
i_pes_length
)
{
mtime_t
i_frag
=
p_pcr_stream
->
i_pes_dts
+
p_pcr_stream
->
i_pes_length
-
p_pes
->
i_dts
;
...
...
@@ -895,7 +893,7 @@ static int Mux( sout_mux_t *p_mux )
/* Next stream */
break
;
}
i_size
=
p_pes
->
i_
size
*
i_frag
/
p_pes
->
i_length
;
i_size
=
p_pes
->
i_
buffer
*
i_frag
/
p_pes
->
i_length
;
}
i_packet_count
+=
(
i_size
+
183
)
/
184
;
}
...
...
@@ -918,7 +916,7 @@ static int Mux( sout_mux_t *p_mux )
int
i_stream
;
mtime_t
i_dts
;
ts_stream_t
*
p_stream
;
sout_buffer
_t
*
p_ts
;
block
_t
*
p_ts
;
vlc_bool_t
b_pcr
;
/* Select stream (lowest dts) */
...
...
@@ -987,7 +985,7 @@ static void TSSchedule( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
for
(
i
=
0
;
i
<
i_packet_count
;
i
++
)
{
sout_buffer
_t
*
p_ts
=
BufferChainGet
(
p_chain_ts
);
block
_t
*
p_ts
=
BufferChainGet
(
p_chain_ts
);
mtime_t
i_new_dts
=
i_pcr_dts
+
i_pcr_length
*
i
/
i_packet_count
;
BufferChainAppend
(
&
new_chain
,
p_ts
);
...
...
@@ -1069,7 +1067,7 @@ static void TSDate( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
/* msg_Dbg( p_mux, "real pck=%d", i_packet_count ); */
for
(
i
=
0
;
i
<
i_packet_count
;
i
++
)
{
sout_buffer
_t
*
p_ts
=
BufferChainGet
(
p_chain_ts
);
block
_t
*
p_ts
=
BufferChainGet
(
p_chain_ts
);
mtime_t
i_new_dts
=
i_pcr_dts
+
i_pcr_length
*
i
/
i_packet_count
;
p_ts
->
i_dts
=
i_new_dts
;
...
...
@@ -1092,10 +1090,10 @@ static void TSDate( sout_mux_t *p_mux, sout_buffer_chain_t *p_chain_ts,
}
}
static
sout_buffer
_t
*
TSNew
(
sout_mux_t
*
p_mux
,
ts_stream_t
*
p_stream
,
vlc_bool_t
b_pcr
)
static
block
_t
*
TSNew
(
sout_mux_t
*
p_mux
,
ts_stream_t
*
p_stream
,
vlc_bool_t
b_pcr
)
{
sout_buffer
_t
*
p_pes
=
p_stream
->
chain_pes
.
p_first
;
sout_buffer
_t
*
p_ts
;
block
_t
*
p_pes
=
p_stream
->
chain_pes
.
p_first
;
block
_t
*
p_ts
;
vlc_bool_t
b_new_pes
=
VLC_FALSE
;
vlc_bool_t
b_adaptation_field
=
VLC_FALSE
;
...
...
@@ -1107,14 +1105,14 @@ static sout_buffer_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, vlc_bool_
{
b_new_pes
=
VLC_TRUE
;
}
i_payload
=
__MIN
(
(
int
)
p_pes
->
i_
size
-
p_stream
->
i_pes_used
,
i_payload_max
);
i_payload
=
__MIN
(
(
int
)
p_pes
->
i_
buffer
-
p_stream
->
i_pes_used
,
i_payload_max
);
if
(
b_pcr
||
i_payload
<
i_payload_max
)
{
b_adaptation_field
=
VLC_TRUE
;
}
p_ts
=
sout_BufferNew
(
p_mux
->
p_sout
,
188
);
p_ts
=
block_New
(
p_mux
,
188
);
p_ts
->
i_dts
=
p_pes
->
i_dts
;
p_ts
->
p_buffer
[
0
]
=
0x47
;
...
...
@@ -1168,13 +1166,13 @@ static sout_buffer_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, vlc_bool_
memcpy
(
&
p_ts
->
p_buffer
[
188
-
i_payload
],
&
p_pes
->
p_buffer
[
p_stream
->
i_pes_used
],
i_payload
);
p_stream
->
i_pes_used
+=
i_payload
;
p_stream
->
i_pes_dts
=
p_pes
->
i_dts
+
p_pes
->
i_length
*
p_stream
->
i_pes_used
/
p_pes
->
i_
size
;
p_stream
->
i_pes_length
-=
p_pes
->
i_length
*
i_payload
/
p_pes
->
i_
size
;
p_stream
->
i_pes_dts
=
p_pes
->
i_dts
+
p_pes
->
i_length
*
p_stream
->
i_pes_used
/
p_pes
->
i_
buffer
;
p_stream
->
i_pes_length
-=
p_pes
->
i_length
*
i_payload
/
p_pes
->
i_
buffer
;
if
(
p_stream
->
i_pes_used
>=
(
int
)
p_pes
->
i_
size
)
if
(
p_stream
->
i_pes_used
>=
(
int
)
p_pes
->
i_
buffer
)
{
p_pes
=
BufferChainGet
(
&
p_stream
->
chain_pes
);
sout_BufferDelete
(
p_mux
->
p_sout
,
p_pes
);
block_Release
(
p_pes
);
p_pes
=
p_stream
->
chain_pes
.
p_first
;
if
(
p_pes
)
...
...
@@ -1200,7 +1198,7 @@ static sout_buffer_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, vlc_bool_
}
static
void
TSSetPCR
(
sout_buffer
_t
*
p_ts
,
mtime_t
i_dts
)
static
void
TSSetPCR
(
block
_t
*
p_ts
,
mtime_t
i_dts
)
{
mtime_t
i_pcr
=
9
*
i_dts
/
100
;
...
...
@@ -1232,7 +1230,7 @@ static void TSSetConstraints( sout_mux_t *p_mux, sout_buffer_chain_t *c, mtime_t
if( i_packets < i_packets_min && i_packets_min > 0 )
{
sout_buffer
_t *p_pk;
block
_t *p_pk;
int i_div = ( i_packets_min - i_packets ) / i_packets;
int i_mod = ( i_packets_min - i_packets ) % i_packets;
int i_rest = 0;
...
...
@@ -1254,7 +1252,7 @@ static void TSSetConstraints( sout_mux_t *p_mux, sout_buffer_chain_t *c, mtime_t
for( i = 0; i < i_null; i++ )
{
sout_buffer
_t *p_null;
block
_t *p_null;
p_null = sout_BufferNew( p_mux->p_sout, 188 );
p_null->p_buffer[0] = 0x47;
...
...
@@ -1273,7 +1271,7 @@ static void TSSetConstraints( sout_mux_t *p_mux, sout_buffer_chain_t *c, mtime_t
}
else if( i_packets > i_packets_max && i_packets_max > 0 )
{
sout_buffer
_t *p_pk;
block
_t *p_pk;
int i;
/* Arg, we need to drop packets, I don't do something clever (like
...
...
@@ -1298,7 +1296,7 @@ static void TSSetConstraints( sout_mux_t *p_mux, sout_buffer_chain_t *c, mtime_t
#endif
static
void
PEStoTS
(
sout_instance_t
*
p_sout
,
sout_buffer_chain_t
*
c
,
sout_buffer
_t
*
p_pes
,
sout_buffer_chain_t
*
c
,
block
_t
*
p_pes
,
ts_stream_t
*
p_stream
)
{
uint8_t
*
p_data
;
...
...
@@ -1306,7 +1304,7 @@ static void PEStoTS( sout_instance_t *p_sout,
int
b_new_pes
;
/* get PES total size */
i_size
=
p_pes
->
i_
size
;
i_size
=
p_pes
->
i_
buffer
;
p_data
=
p_pes
->
p_buffer
;
b_new_pes
=
VLC_TRUE
;
...
...
@@ -1315,9 +1313,9 @@ static void PEStoTS( sout_instance_t *p_sout,
{
int
b_adaptation_field
;
int
i_copy
;
sout_buffer
_t
*
p_ts
;
block
_t
*
p_ts
;
p_ts
=
sout_Buffer
New
(
p_sout
,
188
);
p_ts
=
block_
New
(
p_sout
,
188
);
/* write header
* 8b 0x47 sync byte
* 1b transport_error_indicator
...
...
@@ -1366,17 +1364,17 @@ static void PEStoTS( sout_instance_t *p_sout,
if
(
i_size
<=
0
)
{
sout_buffer
_t
*
p_next
=
p_pes
->
p_next
;
block
_t
*
p_next
=
p_pes
->
p_next
;
p_pes
->
p_next
=
NULL
;
sout_BufferDelete
(
p_sout
,
p_pes
);
block_Release
(
p_pes
);
if
(
p_next
==
NULL
)
{
break
;
}
b_new_pes
=
VLC_TRUE
;
p_pes
=
p_next
;
i_size
=
p_pes
->
i_
size
;
i_size
=
p_pes
->
i_
buffer
;
p_data
=
p_pes
->
p_buffer
;
}
}
...
...
@@ -1472,10 +1470,10 @@ static void GetPAT( sout_mux_t *p_mux,
sout_buffer_chain_t
*
c
)
{
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
sout_buffer
_t
*
p_pat
;
block
_t
*
p_pat
;
bits_buffer_t
bits
;
p_pat
=
sout_BufferNew
(
p_mux
->
p_sout
,
1024
);
p_pat
=
block_New
(
p_mux
,
1024
);
p_pat
->
i_pts
=
0
;
p_pat
->
i_dts
=
0
;
...
...
@@ -1502,7 +1500,7 @@ static void GetPAT( sout_mux_t *p_mux,
bits_write
(
&
bits
,
32
,
CalculateCRC
(
bits
.
p_data
+
1
,
bits
.
i_data
-
1
)
);
p_pat
->
i_
size
=
bits
.
i_data
;
p_pat
->
i_
buffer
=
bits
.
i_data
;
PEStoTS
(
p_mux
->
p_sout
,
c
,
p_pat
,
&
p_sys
->
pat
);
}
...
...
@@ -1511,11 +1509,11 @@ static void GetPMT( sout_mux_t *p_mux,
sout_buffer_chain_t
*
c
)
{
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
sout_buffer
_t
*
p_pmt
;
block
_t
*
p_pmt
;
bits_buffer_t
bits
;
int
i_stream
;
p_pmt
=
sout_BufferNew
(
p_mux
->
p_sout
,
1024
);
p_pmt
=
block_New
(
p_mux
,
1024
);
p_pmt
->
i_pts
=
0
;
p_pmt
->
i_dts
=
0
;
...
...
@@ -1558,16 +1556,16 @@ static void GetPMT( sout_mux_t *p_mux,
bits_write
(
&
bits
,
32
,
CalculateCRC
(
bits
.
p_data
+
1
,
bits
.
i_data
-
1
)
);
p_pmt
->
i_
size
=
bits
.
i_data
;
p_pmt
->
i_
buffer
=
bits
.
i_data
;
PEStoTS
(
p_mux
->
p_sout
,
c
,
p_pmt
,
&
p_sys
->
pmt
);
}
#elif defined MODULE_NAME_IS_mux_ts_dvbpsi
static
sout_buffer
_t
*
WritePSISection
(
sout_instance_t
*
p_sout
,
static
block
_t
*
WritePSISection
(
sout_instance_t
*
p_sout
,
dvbpsi_psi_section_t
*
p_section
)
{
sout_buffer
_t
*
p_psi
,
*
p_first
=
NULL
;
block
_t
*
p_psi
,
*
p_first
=
NULL
;
while
(
p_section
)
...
...
@@ -1577,18 +1575,18 @@ static sout_buffer_t *WritePSISection( sout_instance_t *p_sout,
i_size
=
(
uint32_t
)(
p_section
->
p_payload_end
-
p_section
->
p_data
)
+
(
p_section
->
b_syntax_indicator
?
4
:
0
);
p_psi
=
sout_Buffer
New
(
p_sout
,
i_size
+
1
);
p_psi
=
block_
New
(
p_sout
,
i_size
+
1
);
p_psi
->
i_pts
=
0
;
p_psi
->
i_dts
=
0
;
p_psi
->
i_length
=
0
;
p_psi
->
i_
size
=
i_size
+
1
;
p_psi
->
i_
buffer
=
i_size
+
1
;
p_psi
->
p_buffer
[
0
]
=
0
;
// pointer
memcpy
(
p_psi
->
p_buffer
+
1
,
p_section
->
p_data
,
i_size
);
sout_BufferChain
(
&
p_first
,
p_psi
);
block_ChainAppend
(
&
p_first
,
p_psi
);
p_section
=
p_section
->
p_next
;
}
...
...
@@ -1600,7 +1598,7 @@ static void GetPAT( sout_mux_t *p_mux,
sout_buffer_chain_t
*
c
)
{
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
sout_buffer
_t
*
p_pat
;
block
_t
*
p_pat
;
dvbpsi_pat_t
pat
;
dvbpsi_psi_section_t
*
p_section
;
...
...
@@ -1639,7 +1637,7 @@ static void GetPMT( sout_mux_t *p_mux,
sout_buffer_chain_t
*
c
)
{
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
sout_buffer
_t
*
p_pmt
;
block
_t
*
p_pmt
;
dvbpsi_pmt_t
pmt
;
dvbpsi_pmt_es_t
*
p_es
;
...
...
modules/mux/ogg.c
View file @
085985d5
...
...
@@ -2,7 +2,7 @@
* ogg.c: ogg muxer module for vlc
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id
: ogg.c,v 1.28 2004/02/06 23:43:32 gbazin Exp
$
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
...
...
@@ -41,22 +41,11 @@
#include <ogg/ogg.h>
/*****************************************************************************
*
Exported prototypes
*
Module descriptor
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
static
int
Capability
(
sout_mux_t
*
,
int
,
void
*
,
void
*
);
static
int
AddStream
(
sout_mux_t
*
,
sout_input_t
*
);
static
int
DelStream
(
sout_mux_t
*
,
sout_input_t
*
);
static
int
Mux
(
sout_mux_t
*
);
static
sout_buffer_t
*
OggCreateHeader
(
sout_mux_t
*
,
mtime_t
);
static
sout_buffer_t
*
OggCreateFooter
(
sout_mux_t
*
,
mtime_t
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_description
(
_
(
"Ogg/ogm muxer"
)
);
set_capability
(
"sout mux"
,
10
);
...
...
@@ -65,6 +54,18 @@ vlc_module_begin();
set_callbacks
(
Open
,
Close
);
vlc_module_end
();
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static
int
Capability
(
sout_mux_t
*
,
int
,
void
*
,
void
*
);
static
int
AddStream
(
sout_mux_t
*
,
sout_input_t
*
);
static
int
DelStream
(
sout_mux_t
*
,
sout_input_t
*
);
static
int
Mux
(
sout_mux_t
*
);
static
block_t
*
OggCreateHeader
(
sout_mux_t
*
,
mtime_t
);
static
block_t
*
OggCreateFooter
(
sout_mux_t
*
,
mtime_t
);
/*****************************************************************************
* Misc declarations
*****************************************************************************/
...
...
@@ -137,7 +138,7 @@ static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
for
(
i
=
0
,
i_dts
=
0
,
i_stream
=
-
1
;
i
<
p_mux
->
i_nb_inputs
;
i
++
)
{
sout
_fifo_t
*
p_fifo
;
block
_fifo_t
*
p_fifo
;
p_fifo
=
p_mux
->
pp_inputs
[
i
]
->
p_fifo
;
...
...
@@ -150,9 +151,9 @@ static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
(
p_mux
->
pp_inputs
[
i
]
->
p_fmt
->
i_cat
==
SPU_ES
&&
p_fifo
->
i_depth
>
0
)
)
{
sout_buffer
_t
*
p_buf
;
block
_t
*
p_buf
;
p_buf
=
sout
_FifoShow
(
p_fifo
);
p_buf
=
block
_FifoShow
(
p_fifo
);
if
(
i_stream
<
0
||
p_buf
->
i_dts
<
i_dts
)
{
i_dts
=
p_buf
->
i_dts
;
...
...
@@ -195,7 +196,7 @@ typedef struct
oggds_header_t
oggds_header
;
sout_buffer
_t
*
pp_sout_headers
[
3
];
block
_t
*
pp_sout_headers
[
3
];
int
i_sout_headers
;
}
ogg_stream_t
;
...
...
@@ -215,8 +216,8 @@ struct sout_mux_sys_t
ogg_stream_t
**
pp_del_streams
;
};
static
void
OggSetDate
(
sout_buffer
_t
*
,
mtime_t
,
mtime_t
);
static
sout_buffer
_t
*
OggStreamFlush
(
sout_mux_t
*
,
ogg_stream_state
*
,
static
void
OggSetDate
(
block
_t
*
,
mtime_t
,
mtime_t
);
static
block
_t
*
OggStreamFlush
(
sout_mux_t
*
,
ogg_stream_state
*
,
mtime_t
);
/*****************************************************************************
...
...
@@ -240,7 +241,6 @@ static int Open( vlc_object_t *p_this )
p_mux
->
pf_addstream
=
AddStream
;
p_mux
->
pf_delstream
=
DelStream
;
p_mux
->
pf_mux
=
Mux
;
p_mux
->
i_preheader
=
1
;
/* First serial number is random.
* (Done like this because on win32 you need to seed the random number
...
...
@@ -263,13 +263,13 @@ static void Close( vlc_object_t * p_this )
if
(
p_sys
->
i_del_streams
)
{
sout_buffer
_t
*
p_og
=
NULL
;
block
_t
*
p_og
=
NULL
;
mtime_t
i_dts
=
-
1
;
int
i
;
/* Close the current ogg stream */
msg_Dbg
(
p_mux
,
"writing footer"
);
sout_BufferChain
(
&
p_og
,
OggCreateFooter
(
p_mux
,
0
)
);
block_ChainAppend
(
&
p_og
,
OggCreateFooter
(
p_mux
,
0
)
);
/* Remove deleted logical streams */
for
(
i
=
0
;
i
<
p_sys
->
i_del_streams
;
i
++
)
...
...
@@ -455,7 +455,7 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
{
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
ogg_stream_t
*
p_stream
=
(
ogg_stream_t
*
)
p_input
->
p_sys
;
sout_buffer
_t
*
p_og
;
block
_t
*
p_og
;
msg_Dbg
(
p_mux
,
"removing input"
);
...
...
@@ -473,7 +473,7 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
for
(
i
=
0
;
i
<
p_stream
->
i_sout_headers
;
i
++
)
{
sout_BufferDelete
(
p_mux
->
p_sout
,
p_stream
->
pp_sout_headers
[
i
]
);
block_Release
(
p_stream
->
pp_sout_headers
[
i
]
);
p_stream
->
i_sout_headers
=
0
;
}
...
...
@@ -502,10 +502,10 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
/*****************************************************************************
* Ogg bitstream manipulation routines
*****************************************************************************/
static
sout_buffer
_t
*
OggStreamFlush
(
sout_mux_t
*
p_mux
,
static
block
_t
*
OggStreamFlush
(
sout_mux_t
*
p_mux
,
ogg_stream_state
*
p_os
,
mtime_t
i_pts
)
{
sout_buffer
_t
*
p_og
,
*
p_og_first
=
NULL
;
block
_t
*
p_og
,
*
p_og_first
=
NULL
;
ogg_page
og
;
for
(
;;
)
...
...
@@ -519,27 +519,26 @@ static sout_buffer_t *OggStreamFlush( sout_mux_t *p_mux,
}
i_size
=
og
.
header_len
+
og
.
body_len
;
p_og
=
sout_BufferNew
(
p_mux
->
p_sout
,
i_size
);
p_og
=
block_New
(
p_mux
,
i_size
);
memcpy
(
p_og
->
p_buffer
,
og
.
header
,
og
.
header_len
);
memcpy
(
p_og
->
p_buffer
+
og
.
header_len
,
og
.
body
,
og
.
body_len
);
p_og
->
i_size
=
i_size
;
p_og
->
i_dts
=
0
;
p_og
->
i_pts
=
i_pts
;
p_og
->
i_length
=
0
;
i_pts
=
0
;
// write it only once
sout_BufferChain
(
&
p_og_first
,
p_og
);
block_ChainAppend
(
&
p_og_first
,
p_og
);
}
return
(
p_og_first
);
}
static
sout_buffer
_t
*
OggStreamPageOut
(
sout_mux_t
*
p_mux
,
static
block
_t
*
OggStreamPageOut
(
sout_mux_t
*
p_mux
,
ogg_stream_state
*
p_os
,
mtime_t
i_pts
)
{
sout_buffer
_t
*
p_og
,
*
p_og_first
=
NULL
;
block
_t
*
p_og
,
*
p_og_first
=
NULL
;
ogg_page
og
;
for
(
;;
)
...
...
@@ -553,27 +552,26 @@ static sout_buffer_t *OggStreamPageOut( sout_mux_t *p_mux,
}
i_size
=
og
.
header_len
+
og
.
body_len
;
p_og
=
sout_BufferNew
(
p_mux
->
p_sout
,
i_size
);
p_og
=
block_New
(
p_mux
,
i_size
);
memcpy
(
p_og
->
p_buffer
,
og
.
header
,
og
.
header_len
);
memcpy
(
p_og
->
p_buffer
+
og
.
header_len
,
og
.
body
,
og
.
body_len
);
p_og
->
i_size
=
i_size
;
p_og
->
i_dts
=
0
;
p_og
->
i_pts
=
i_pts
;
p_og
->
i_length
=
0
;
i_pts
=
0
;
// write them only once
sout_BufferChain
(
&
p_og_first
,
p_og
);
block_ChainAppend
(
&
p_og_first
,
p_og
);
}
return
(
p_og_first
);
}
static
sout_buffer
_t
*
OggCreateHeader
(
sout_mux_t
*
p_mux
,
mtime_t
i_dts
)
static
block
_t
*
OggCreateHeader
(
sout_mux_t
*
p_mux
,
mtime_t
i_dts
)
{
sout_buffer
_t
*
p_hdr
=
NULL
;
sout_buffer
_t
*
p_og
;
block
_t
*
p_hdr
=
NULL
;
block
_t
*
p_og
;
ogg_packet
op
;
int
i
;
...
...
@@ -600,9 +598,9 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
/* first packet in order: vorbis/speex/theora info */
if
(
!
p_stream
->
i_sout_headers
)
{
p_og
=
sout
_FifoGet
(
p_mux
->
pp_inputs
[
i
]
->
p_fifo
);
p_og
=
block
_FifoGet
(
p_mux
->
pp_inputs
[
i
]
->
p_fifo
);
op
.
packet
=
p_og
->
p_buffer
;
op
.
bytes
=
p_og
->
i_
size
;
op
.
bytes
=
p_og
->
i_
buffer
;
op
.
b_o_s
=
1
;
op
.
e_o_s
=
0
;
op
.
granulepos
=
0
;
...
...
@@ -612,8 +610,7 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
OggStreamFlush
(
p_mux
,
&
p_stream
->
os
,
0
);
p_stream
->
i_sout_headers
++
;
}
p_og
=
sout_BufferDuplicate
(
p_mux
->
p_sout
,
p_stream
->
pp_sout_headers
[
0
]
);
p_og
=
block_Duplicate
(
p_stream
->
pp_sout_headers
[
0
]
);
/* Get keyframe_granule_shift for theora granulepos calculation */
if
(
p_stream
->
i_fourcc
==
VLC_FOURCC
(
't'
,
'h'
,
'e'
,
'o'
)
)
...
...
@@ -655,7 +652,7 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
p_og
=
OggStreamFlush
(
p_mux
,
&
p_stream
->
os
,
0
);
}
sout_BufferChain
(
&
p_hdr
,
p_og
);
block_ChainAppend
(
&
p_hdr
,
p_og
);
}
/* Take care of the non b_o_s headers */
...
...
@@ -675,9 +672,9 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
if
(
p_stream
->
i_sout_headers
<
j
+
2
)
{
/* next packets in order: comments and codebooks */
p_og
=
sout
_FifoGet
(
p_mux
->
pp_inputs
[
i
]
->
p_fifo
);
p_og
=
block
_FifoGet
(
p_mux
->
pp_inputs
[
i
]
->
p_fifo
);
op
.
packet
=
p_og
->
p_buffer
;
op
.
bytes
=
p_og
->
i_
size
;
op
.
bytes
=
p_og
->
i_
buffer
;
op
.
b_o_s
=
0
;
op
.
e_o_s
=
0
;
op
.
granulepos
=
0
;
...
...
@@ -688,9 +685,8 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
p_stream
->
i_sout_headers
++
;
}
p_og
=
sout_BufferDuplicate
(
p_mux
->
p_sout
,
p_stream
->
pp_sout_headers
[
j
+
1
]
);
sout_BufferChain
(
&
p_hdr
,
p_og
);
p_og
=
block_Duplicate
(
p_stream
->
pp_sout_headers
[
j
+
1
]
);
block_ChainAppend
(
&
p_hdr
,
p_og
);
}
}
else
if
(
p_stream
->
i_fourcc
!=
VLC_FOURCC
(
'f'
,
'l'
,
'a'
,
'c'
)
)
...
...
@@ -709,7 +705,7 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
op
.
packetno
=
p_stream
->
i_packet_no
++
;
ogg_stream_packetin
(
&
p_stream
->
os
,
&
op
);
p_og
=
OggStreamFlush
(
p_mux
,
&
p_stream
->
os
,
0
);
sout_BufferChain
(
&
p_hdr
,
p_og
);
block_ChainAppend
(
&
p_hdr
,
p_og
);
}
/* Special case for mp4v and flac */
...
...
@@ -734,23 +730,23 @@ static sout_buffer_t *OggCreateHeader( sout_mux_t *p_mux, mtime_t i_dts )
op
.
packetno
=
p_stream
->
i_packet_no
++
;
ogg_stream_packetin
(
&
p_stream
->
os
,
&
op
);
p_og
=
OggStreamFlush
(
p_mux
,
&
p_stream
->
os
,
0
);
sout_BufferChain
(
&
p_hdr
,
p_og
);
block_ChainAppend
(
&
p_hdr
,
p_og
);
}
}
/* set HEADER flag */
for
(
p_og
=
p_hdr
;
p_og
!=
NULL
;
p_og
=
p_og
->
p_next
)
{
p_og
->
i_flags
|=
SOUT_BUFFER_FLAGS
_HEADER
;
p_og
->
i_flags
|=
BLOCK_FLAG
_HEADER
;
}
return
(
p_hdr
);
}
static
sout_buffer
_t
*
OggCreateFooter
(
sout_mux_t
*
p_mux
,
mtime_t
i_dts
)
static
block
_t
*
OggCreateFooter
(
sout_mux_t
*
p_mux
,
mtime_t
i_dts
)
{
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
sout_buffer
_t
*
p_hdr
=
NULL
;
sout_buffer
_t
*
p_og
;
block
_t
*
p_hdr
=
NULL
;
block
_t
*
p_og
;
ogg_packet
op
;
int
i
;
...
...
@@ -786,7 +782,7 @@ static sout_buffer_t *OggCreateFooter( sout_mux_t *p_mux, mtime_t i_dts )
ogg_stream_packetin
(
&
p_stream
->
os
,
&
op
);
p_og
=
OggStreamFlush
(
p_mux
,
&
p_stream
->
os
,
0
);
sout_BufferChain
(
&
p_hdr
,
p_og
);
block_ChainAppend
(
&
p_hdr
,
p_og
);
ogg_stream_clear
(
&
p_stream
->
os
);
}
...
...
@@ -801,17 +797,17 @@ static sout_buffer_t *OggCreateFooter( sout_mux_t *p_mux, mtime_t i_dts )
ogg_stream_packetin
(
&
p_sys
->
pp_del_streams
[
i
]
->
os
,
&
op
);
p_og
=
OggStreamFlush
(
p_mux
,
&
p_sys
->
pp_del_streams
[
i
]
->
os
,
0
);
sout_BufferChain
(
&
p_hdr
,
p_og
);
block_ChainAppend
(
&
p_hdr
,
p_og
);
ogg_stream_clear
(
&
p_sys
->
pp_del_streams
[
i
]
->
os
);
}
return
(
p_hdr
);
}
static
void
OggSetDate
(
sout_buffer
_t
*
p_og
,
mtime_t
i_dts
,
mtime_t
i_length
)
static
void
OggSetDate
(
block
_t
*
p_og
,
mtime_t
i_dts
,
mtime_t
i_length
)
{
int
i_count
;
sout_buffer
_t
*
p_tmp
;
block
_t
*
p_tmp
;
mtime_t
i_delta
;
for
(
p_tmp
=
p_og
,
i_count
=
0
;
p_tmp
!=
NULL
;
p_tmp
=
p_tmp
->
p_next
)
...
...
@@ -835,7 +831,7 @@ static void OggSetDate( sout_buffer_t *p_og, mtime_t i_dts, mtime_t i_length )
static
int
Mux
(
sout_mux_t
*
p_mux
)
{
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
sout_buffer
_t
*
p_og
=
NULL
;
block
_t
*
p_og
=
NULL
;
int
i_stream
;
mtime_t
i_dts
;
...
...
@@ -854,7 +850,7 @@ static int Mux( sout_mux_t *p_mux )
int
i
;
msg_Dbg
(
p_mux
,
"writing footer"
);
sout_BufferChain
(
&
p_og
,
OggCreateFooter
(
p_mux
,
0
)
);
block_ChainAppend
(
&
p_og
,
OggCreateFooter
(
p_mux
,
0
)
);
/* Remove deleted logical streams */
for
(
i
=
0
;
i
<
p_sys
->
i_del_streams
;
i
++
)
...
...
@@ -870,7 +866,7 @@ static int Mux( sout_mux_t *p_mux )
p_sys
->
i_streams
=
p_mux
->
i_nb_inputs
;
p_sys
->
i_del_streams
=
0
;
p_sys
->
i_add_streams
=
0
;
sout_BufferChain
(
&
p_og
,
OggCreateHeader
(
p_mux
,
i_dts
)
);
block_ChainAppend
(
&
p_og
,
OggCreateHeader
(
p_mux
,
i_dts
)
);
/* Write header and/or footer */
OggSetDate
(
p_og
,
i_dts
,
0
);
...
...
@@ -882,7 +878,7 @@ static int Mux( sout_mux_t *p_mux )
{
sout_input_t
*
p_input
;
ogg_stream_t
*
p_stream
;
sout_buffer
_t
*
p_data
;
block
_t
*
p_data
;
ogg_packet
op
;
if
(
MuxGetStream
(
p_mux
,
&
i_stream
,
&
i_dts
)
<
0
)
...
...
@@ -892,19 +888,19 @@ static int Mux( sout_mux_t *p_mux )
p_input
=
p_mux
->
pp_inputs
[
i_stream
];
p_stream
=
(
ogg_stream_t
*
)
p_input
->
p_sys
;
p_data
=
sout
_FifoGet
(
p_input
->
p_fifo
);
p_data
=
block
_FifoGet
(
p_input
->
p_fifo
);
if
(
p_stream
->
i_fourcc
!=
VLC_FOURCC
(
'v'
,
'o'
,
'r'
,
'b'
)
&&
p_stream
->
i_fourcc
!=
VLC_FOURCC
(
'f'
,
'l'
,
'a'
,
'c'
)
&&
p_stream
->
i_fourcc
!=
VLC_FOURCC
(
's'
,
'p'
,
'x'
,
' '
)
&&
p_stream
->
i_fourcc
!=
VLC_FOURCC
(
't'
,
'h'
,
'e'
,
'o'
)
)
{
sout_BufferReallocFromPreHeader
(
p_mux
->
p_sout
,
p_data
,
1
);
p_data
=
block_Realloc
(
p_data
,
1
,
0
);
p_data
->
p_buffer
[
0
]
=
PACKET_IS_SYNCPOINT
;
// FIXME
}
op
.
packet
=
p_data
->
p_buffer
;
op
.
bytes
=
p_data
->
i_
size
;
op
.
bytes
=
p_data
->
i_
buffer
;
op
.
b_o_s
=
0
;
op
.
e_o_s
=
0
;
op
.
packetno
=
p_stream
->
i_packet_no
++
;
...
...
@@ -952,12 +948,12 @@ static int Mux( sout_mux_t *p_mux )
{
/* Subtitles or Speex packets are quite small so they
* need to be flushed to be sent on time */
sout_BufferChain
(
&
p_og
,
OggStreamFlush
(
p_mux
,
&
p_stream
->
os
,
block_ChainAppend
(
&
p_og
,
OggStreamFlush
(
p_mux
,
&
p_stream
->
os
,
p_data
->
i_dts
)
);
}
else
{
sout_BufferChain
(
&
p_og
,
OggStreamPageOut
(
p_mux
,
&
p_stream
->
os
,
block_ChainAppend
(
&
p_og
,
OggStreamPageOut
(
p_mux
,
&
p_stream
->
os
,
p_data
->
i_dts
)
);
}
...
...
@@ -980,8 +976,8 @@ static int Mux( sout_mux_t *p_mux )
p_stream
->
i_length
+=
p_data
->
i_length
;
}
sout_BufferDelete
(
p_mux
->
p_sout
,
p_data
);
block_Release
(
p_data
);
}
return
(
VLC_SUCCESS
)
;
return
VLC_SUCCESS
;
}
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