Commit 81cfe15f authored by Stéphane Borel's avatar Stéphane Borel

-Merged DVD netlist with input netlist to remove duplicated code.

Basically, this adds the ability for the netlist to handle transport
packets that carry more than one data_packet.
parent 2ebfdccd
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* but exported to plug-ins * but exported to plug-ins
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: input_ext-plugins.h,v 1.2 2001/07/18 14:21:00 massiot Exp $ * $Id: input_ext-plugins.h,v 1.3 2001/11/11 01:32:03 stef Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -156,13 +156,18 @@ typedef struct netlist_s ...@@ -156,13 +156,18 @@ typedef struct netlist_s
struct iovec * p_free_iovec; struct iovec * p_free_iovec;
/* FIFO size */ /* FIFO size */
unsigned int i_nb_iovec;
unsigned int i_nb_pes; unsigned int i_nb_pes;
unsigned int i_nb_data; unsigned int i_nb_data;
/* Index */ /* Index */
unsigned int i_iovec_start, i_iovec_end;
unsigned int i_data_start, i_data_end; unsigned int i_data_start, i_data_end;
unsigned int i_pes_start, i_pes_end; unsigned int i_pes_start, i_pes_end;
/* Reference counters for iovec */
unsigned int * pi_refcount;
/* Number of blocs read once by readv */ /* Number of blocs read once by readv */
unsigned int i_read_once; unsigned int i_read_once;
} netlist_t; } netlist_t;
...@@ -171,17 +176,23 @@ typedef struct netlist_s ...@@ -171,17 +176,23 @@ typedef struct netlist_s
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
int input_NetlistInit( struct input_thread_s *, int input_NetlistInit( struct input_thread_s *,
int i_nb_data, int i_nb_pes, int i_nb_iovec,
int i_nb_data,
int i_nb_pes,
size_t i_buffer_size, size_t i_buffer_size,
int i_read_once ); int i_read_once );
struct iovec * input_NetlistGetiovec( void * p_method_data ); struct iovec * input_NetlistGetiovec( void * p_method_data );
void input_NetlistMviovec( void * , size_t, struct data_packet_s **); void input_NetlistMviovec( void * , int,
struct data_packet_s **);
struct data_packet_s * input_NetlistNewPtr( void * );
struct data_packet_s * input_NetlistNewPacket( void *, size_t ); struct data_packet_s * input_NetlistNewPacket( void *, size_t );
struct pes_packet_s * input_NetlistNewPES( void * ); struct pes_packet_s * input_NetlistNewPES( void * );
void input_NetlistDeletePacket( void *, struct data_packet_s * ); void input_NetlistDeletePacket( void *,
void input_NetlistDeletePES( void *, struct pes_packet_s * ); struct data_packet_s * );
void input_NetlistEnd( struct input_thread_s * ); void input_NetlistDeletePES( void *,
struct pes_packet_s * );
void input_NetlistEnd( struct input_thread_s * );
/* /*
......
...@@ -121,11 +121,12 @@ typedef struct module_symbols_s ...@@ -121,11 +121,12 @@ typedef struct module_symbols_s
mtime_t ); mtime_t );
int ( * input_NetlistInit ) ( struct input_thread_s *, int ( * input_NetlistInit ) ( struct input_thread_s *,
int, int, size_t, int ); int, int, int, size_t, int );
struct iovec * ( * input_NetlistGetiovec ) ( void * p_method_data ); struct iovec * ( * input_NetlistGetiovec ) ( void * p_method_data );
void ( * input_NetlistMviovec ) ( void * , size_t, void ( * input_NetlistMviovec ) ( void * , int,
struct data_packet_s **); struct data_packet_s **);
struct data_packet_s * ( * input_NetlistNewPacket ) ( void *, size_t ); struct data_packet_s * ( * input_NetlistNewPacket ) ( void *, size_t );
struct data_packet_s * ( * input_NetlistNewPtr ) ( void * );
struct pes_packet_s * ( * input_NetlistNewPES ) ( void * ); struct pes_packet_s * ( * input_NetlistNewPES ) ( void * );
void ( * input_NetlistDeletePacket ) ( void *, struct data_packet_s * ); void ( * input_NetlistDeletePacket ) ( void *, struct data_packet_s * );
void ( * input_NetlistDeletePES ) ( void *, struct pes_packet_s * ); void ( * input_NetlistDeletePES ) ( void *, struct pes_packet_s * );
...@@ -192,6 +193,7 @@ typedef struct module_symbols_s ...@@ -192,6 +193,7 @@ typedef struct module_symbols_s
(p_symbols)->input_NetlistGetiovec = input_NetlistGetiovec; \ (p_symbols)->input_NetlistGetiovec = input_NetlistGetiovec; \
(p_symbols)->input_NetlistMviovec = input_NetlistMviovec; \ (p_symbols)->input_NetlistMviovec = input_NetlistMviovec; \
(p_symbols)->input_NetlistNewPacket = input_NetlistNewPacket; \ (p_symbols)->input_NetlistNewPacket = input_NetlistNewPacket; \
(p_symbols)->input_NetlistNewPtr = input_NetlistNewPtr; \
(p_symbols)->input_NetlistNewPES = input_NetlistNewPES; \ (p_symbols)->input_NetlistNewPES = input_NetlistNewPES; \
(p_symbols)->input_NetlistDeletePacket = input_NetlistDeletePacket; \ (p_symbols)->input_NetlistDeletePacket = input_NetlistDeletePacket; \
(p_symbols)->input_NetlistDeletePES = input_NetlistDeletePES; \ (p_symbols)->input_NetlistDeletePES = input_NetlistDeletePES; \
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# Objects # Objects
# #
PLUGIN_DVD = dvd.o input_dvd.o dvd_netlist.o dvd_ifo.o dvd_udf.o dvd_summary.o $(OBJ_DVD) PLUGIN_DVD = dvd.o input_dvd.o dvd_ifo.o dvd_udf.o dvd_summary.o $(OBJ_DVD)
BUILTIN_DVD = $(PLUGIN_DVD:%.o=BUILTIN_%.o) BUILTIN_DVD = $(PLUGIN_DVD:%.o=BUILTIN_%.o)
ALL_OBJ = $(PLUGIN_DVD) $(BUILTIN_DVD) ALL_OBJ = $(PLUGIN_DVD) $(BUILTIN_DVD)
......
This diff is collapsed.
/*****************************************************************************
* dvd_netlist.h: Specific netlist structures for DVD packets
*****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: dvd_netlist.h,v 1.2 2001/03/03 07:07:01 stef Exp $
*
* Authors: Henri Fallon <henri@videolan.org>
* Stphane Borel <stef@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* netlist_t: structure to manage a netlist
*****************************************************************************/
typedef struct dvd_netlist_s
{
vlc_mutex_t lock;
size_t i_buffer_size;
/* Buffers */
byte_t * p_buffers; /* Big malloc'ed area */
data_packet_t * p_data; /* malloc'ed area */
pes_packet_t * p_pes; /* malloc'ed area */
/* FIFOs of free packets */
data_packet_t ** pp_free_data;
pes_packet_t ** pp_free_pes;
struct iovec * p_free_iovec;
/* FIFO size */
unsigned int i_nb_iovec;
unsigned int i_nb_pes;
unsigned int i_nb_data;
/* Index */
unsigned int i_iovec_start, i_iovec_end;
unsigned int i_data_start, i_data_end;
unsigned int i_pes_start, i_pes_end;
/* Reference counters for iovec */
unsigned int * pi_refcount;
/* Nb of packets read once */
unsigned int i_read_once;
} dvd_netlist_t;
/*****************************************************************************
* Prototypes
*****************************************************************************/
struct dvd_netlist_s * DVDNetlistInit( int , int, int, size_t, int );
struct iovec * DVDGetiovec( void * p_method_data );
void DVDMviovec( void * , int, struct data_packet_s **);
struct data_packet_s * DVDNewPtr( void * );
struct data_packet_s * DVDNewPacket( void *, size_t );
struct pes_packet_s * DVDNewPES( void * );
void DVDDeletePacket( void *, struct data_packet_s * );
void DVDDeletePES( void *, struct pes_packet_s * );
void DVDNetlistEnd( struct dvd_netlist_s * );
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* -dvd_udf to find files * -dvd_udf to find files
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.92 2001/11/07 17:37:16 stef Exp $ * $Id: input_dvd.c,v 1.93 2001/11/11 01:32:03 stef Exp $
* *
* Author: Stphane Borel <stef@via.ecp.fr> * Author: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -86,7 +86,6 @@ ...@@ -86,7 +86,6 @@
#include "input_ext-plugins.h" #include "input_ext-plugins.h"
#include "input_dvd.h" #include "input_dvd.h"
#include "dvd_netlist.h"
#include "dvd_ifo.h" #include "dvd_ifo.h"
#include "dvd_summary.h" #include "dvd_summary.h"
...@@ -138,10 +137,10 @@ void _M( input_getfunctions )( function_list_t * p_function_list ) ...@@ -138,10 +137,10 @@ void _M( input_getfunctions )( function_list_t * p_function_list )
input.pf_read = DVDRead; input.pf_read = DVDRead;
input.pf_set_area = DVDSetArea; input.pf_set_area = DVDSetArea;
input.pf_demux = input_DemuxPS; input.pf_demux = input_DemuxPS;
input.pf_new_packet = DVDNewPacket; input.pf_new_packet = input_NetlistNewPacket;
input.pf_new_pes = DVDNewPES; input.pf_new_pes = input_NetlistNewPES;
input.pf_delete_packet = DVDDeletePacket; input.pf_delete_packet = input_NetlistDeletePacket;
input.pf_delete_pes = DVDDeletePES; input.pf_delete_pes = input_NetlistDeletePES;
input.pf_rewind = DVDRewind; input.pf_rewind = DVDRewind;
input.pf_seek = DVDSeek; input.pf_seek = DVDSeek;
#undef input #undef input
...@@ -214,9 +213,8 @@ static void DVDInit( input_thread_t * p_input ) ...@@ -214,9 +213,8 @@ static void DVDInit( input_thread_t * p_input )
p_input->i_read_once = DVD_DATA_READ_ONCE; p_input->i_read_once = DVD_DATA_READ_ONCE;
/* Reading structures initialisation */ /* Reading structures initialisation */
p_input->p_method_data = input_NetlistInit( p_input, DVD_NETLIST_SIZE, 2 * DVD_NETLIST_SIZE,
DVDNetlistInit( DVD_NETLIST_SIZE, 2 * DVD_NETLIST_SIZE, DVD_NETLIST_SIZE, DVD_LB_SIZE, p_dvd->i_block_once );
DVD_NETLIST_SIZE, DVD_LB_SIZE, p_dvd->i_block_once );
intf_WarnMsg( 2, "dvd info: netlist initialized" ); intf_WarnMsg( 2, "dvd info: netlist initialized" );
/* Ifo allocation & initialisation */ /* Ifo allocation & initialisation */
...@@ -370,16 +368,14 @@ static void DVDClose( struct input_thread_s *p_input ) ...@@ -370,16 +368,14 @@ static void DVDClose( struct input_thread_s *p_input )
static void DVDEnd( input_thread_t * p_input ) static void DVDEnd( input_thread_t * p_input )
{ {
thread_dvd_data_t * p_dvd; thread_dvd_data_t * p_dvd;
dvd_netlist_t * p_netlist;
p_dvd = (thread_dvd_data_t*)p_input->p_plugin_data; p_dvd = (thread_dvd_data_t*)p_input->p_plugin_data;
p_netlist = (dvd_netlist_t *)p_input->p_method_data;
IfoDestroy( p_dvd->p_ifo ); IfoDestroy( p_dvd->p_ifo );
free( p_dvd ); free( p_dvd );
DVDNetlistEnd( p_netlist ); input_NetlistEnd( p_input );
} }
/***************************************************************************** /*****************************************************************************
...@@ -809,7 +805,7 @@ static int DVDRead( input_thread_t * p_input, ...@@ -809,7 +805,7 @@ static int DVDRead( input_thread_t * p_input,
data_packet_t ** pp_packets ) data_packet_t ** pp_packets )
{ {
thread_dvd_data_t * p_dvd; thread_dvd_data_t * p_dvd;
dvd_netlist_t * p_netlist; netlist_t * p_netlist;
struct iovec * p_vec; struct iovec * p_vec;
struct data_packet_s * pp_data[DVD_DATA_READ_ONCE]; struct data_packet_s * pp_data[DVD_DATA_READ_ONCE];
u8 * pi_cur; u8 * pi_cur;
...@@ -825,7 +821,7 @@ static int DVDRead( input_thread_t * p_input, ...@@ -825,7 +821,7 @@ static int DVDRead( input_thread_t * p_input,
boolean_t b_eoc; boolean_t b_eoc;
p_dvd = (thread_dvd_data_t *)p_input->p_plugin_data; p_dvd = (thread_dvd_data_t *)p_input->p_plugin_data;
p_netlist = (dvd_netlist_t *)p_input->p_method_data; p_netlist = (netlist_t *)p_input->p_method_data;
b_eoc = 0; b_eoc = 0;
i_sector = p_dvd->i_title_start + p_dvd->i_sector; i_sector = p_dvd->i_title_start + p_dvd->i_sector;
...@@ -892,7 +888,7 @@ intf_WarnMsg( 2, "Sector: 0x%x Read: %d Chapter: %d", p_dvd->i_sector, i_block_o ...@@ -892,7 +888,7 @@ intf_WarnMsg( 2, "Sector: 0x%x Read: %d Chapter: %d", p_dvd->i_sector, i_block_o
p_netlist->i_read_once = i_block_once; p_netlist->i_read_once = i_block_once;
/* Get an iovec pointer */ /* Get an iovec pointer */
if( ( p_vec = DVDGetiovec( p_netlist ) ) == NULL ) if( ( p_vec = input_NetlistGetiovec( p_netlist ) ) == NULL )
{ {
intf_ErrMsg( "dvd error: can't get iovec" ); intf_ErrMsg( "dvd error: can't get iovec" );
return -1; return -1;
...@@ -904,7 +900,7 @@ intf_WarnMsg( 2, "Sector: 0x%x Read: %d Chapter: %d", p_dvd->i_sector, i_block_o ...@@ -904,7 +900,7 @@ intf_WarnMsg( 2, "Sector: 0x%x Read: %d Chapter: %d", p_dvd->i_sector, i_block_o
/* Update netlist indexes: we don't do it in DVDGetiovec since we /* Update netlist indexes: we don't do it in DVDGetiovec since we
* need know the real number of blocks read */ * need know the real number of blocks read */
DVDMviovec( p_netlist, i_read_blocks, pp_data ); input_NetlistMviovec( p_netlist, i_read_blocks, pp_data );
/* Update global position */ /* Update global position */
p_dvd->i_sector += i_read_blocks; p_dvd->i_sector += i_read_blocks;
...@@ -925,31 +921,25 @@ intf_WarnMsg( 2, "Sector: 0x%x Read: %d Chapter: %d", p_dvd->i_sector, i_block_o ...@@ -925,31 +921,25 @@ intf_WarnMsg( 2, "Sector: 0x%x Read: %d Chapter: %d", p_dvd->i_sector, i_block_o
{ {
/* That's the case for all packets, except pack header. */ /* That's the case for all packets, except pack header. */
i_packet_size = U16_AT( pi_cur + 4 ); i_packet_size = U16_AT( pi_cur + 4 );
pp_packets[i_packet] = DVDNewPtr( p_netlist ); pp_packets[i_packet] = input_NetlistNewPtr( p_netlist );
(*pp_data[i_iovec]->pi_refcount)++;
pp_packets[i_packet]->pi_refcount =
pp_data[i_iovec]->pi_refcount;
pp_packets[i_packet]->p_buffer = pp_data[i_iovec]->p_buffer;
} }
else else
{ {
/* MPEG-2 Pack header. */ /* MPEG-2 Pack header. */
i_packet_size = 8; i_packet_size = 8;
pp_packets[i_packet] = pp_data[i_iovec]; pp_packets[i_packet] = pp_data[i_iovec];
} }
(*pp_data[i_iovec]->pi_refcount)++;
pp_packets[i_packet]->pi_refcount = pp_data[i_iovec]->pi_refcount;
pp_packets[i_packet]->p_buffer = pp_data[i_iovec]->p_buffer;
pp_packets[i_packet]->p_payload_start = pp_packets[i_packet]->p_payload_start =
pp_packets[i_packet]->p_buffer + i_pos; pp_packets[i_packet]->p_buffer + i_pos;
pp_packets[i_packet]->p_payload_end = pp_packets[i_packet]->p_payload_end =
pp_packets[i_packet]->p_payload_start + i_packet_size + 6; pp_packets[i_packet]->p_payload_start + i_packet_size + 6;
pp_packets[i_packet]->p_next = NULL;
pp_packets[i_packet]->b_discard_payload = 0;
i_packet++; i_packet++;
i_pos += i_packet_size + 6; i_pos += i_packet_size + 6;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_es.c: Elementary Stream demux and packet management * input_es.c: Elementary Stream demux and packet management
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: input_es.c,v 1.11 2001/10/02 17:04:42 massiot Exp $ * $Id: input_es.c,v 1.12 2001/11/11 01:32:03 stef Exp $
* *
* Author: Christophe Massiot <massiot@via.ecp.fr> * Author: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -145,7 +145,7 @@ static void ESInit( input_thread_t * p_input ) ...@@ -145,7 +145,7 @@ static void ESInit( input_thread_t * p_input )
p_input->p_method_data = NULL; p_input->p_method_data = NULL;
/* Initialize netlist */ /* Initialize netlist */
if( input_NetlistInit( p_input, NB_DATA, NB_PES, ES_PACKET_SIZE, if( input_NetlistInit( p_input, NB_DATA, NB_DATA, NB_PES, ES_PACKET_SIZE,
INPUT_READ_ONCE ) ) INPUT_READ_ONCE ) )
{ {
intf_ErrMsg( "ES input : Could not initialize netlist" ); intf_ErrMsg( "ES input : Could not initialize netlist" );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_ts.c: TS demux and netlist management * input_ts.c: TS demux and netlist management
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input_ts.c,v 1.35 2001/10/22 02:33:54 xav Exp $ * $Id: input_ts.c,v 1.36 2001/11/11 01:32:03 stef Exp $
* *
* Authors: Henri Fallon <henri@videolan.org> * Authors: Henri Fallon <henri@videolan.org>
* *
...@@ -185,7 +185,7 @@ static void TSInit( input_thread_t * p_input ) ...@@ -185,7 +185,7 @@ static void TSInit( input_thread_t * p_input )
/* Initialize netlist */ /* Initialize netlist */
if( input_NetlistInit( p_input, NB_DATA, NB_PES, TS_PACKET_SIZE, if( input_NetlistInit( p_input, NB_DATA, NB_DATA, NB_PES, TS_PACKET_SIZE,
INPUT_READ_ONCE ) ) INPUT_READ_ONCE ) )
{ {
intf_ErrMsg( "TS input : Could not initialize netlist" ); intf_ErrMsg( "TS input : Could not initialize netlist" );
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment