Commit 0d1f966a authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

Implement access_GetParentInput and demux_GetParentInput and use.

This try to avoid vlc_object_find() as much as possible.
This is conservative, because where there is no associated parent input, we'll try to find in certain cases the parent input. This will probably be
 removed later on. Because yes, there is not necessarily a parent input for access and demux, especially if created from stream_UrlNew().
parent 60677faf
......@@ -115,6 +115,9 @@ struct access_t
int i_seekpoint;/* idem, start from 0 */
} info;
access_sys_t *p_sys;
/* Weak link to parent input */
input_thread_t *p_input;
};
static inline int access_vaControl( access_t *p_access, int i_query, va_list args )
......@@ -144,6 +147,12 @@ static inline void access_InitFields( access_t *p_a )
p_a->info.i_seekpoint = 0;
}
/**
* This function will return the parent input of this access.
* It is retained. It can return NULL.
*/
VLC_EXPORT( input_thread_t *, access_GetParentInput, ( access_t *p_access ) );
#define ACCESS_SET_CALLBACKS( read, block, control, seek ) \
p_access->pf_read = read; \
p_access->pf_block = block; \
......
......@@ -71,6 +71,9 @@ struct demux_t
int i_seekpoint; /* idem, start from 0 */
} info;
demux_sys_t *p_sys;
/* Weak link to parent input */
input_thread_t *p_input;
};
......@@ -190,6 +193,12 @@ VLC_EXPORT( decoder_t *,demux_PacketizerNew, ( demux_t *p_demux, es_format_t *p_
*/
VLC_EXPORT( void, demux_PacketizerDestroy, ( decoder_t *p_packetizer ) );
/**
* This function will return the parent input of this demux.
* It is retained. Can return NULL.
*/
VLC_EXPORT( input_thread_t *, demux_GetParentInput, ( demux_t *p_demux ) );
/* */
#define DEMUX_INIT_COMMON() do { \
p_demux->pf_control = Control; \
......
......@@ -75,6 +75,9 @@ struct stream_t
/* Text reader state */
stream_text_t *p_text;
/* Weak link to parent input */
input_thread_t *p_input;
};
/**
......@@ -157,8 +160,8 @@ static inline char *stream_ContentType( stream_t *s )
* Create a special stream and a demuxer, this allows chaining demuxers
* You must delete it using stream_Delete.
*/
#define stream_DemuxNew( a, b, c ) __stream_DemuxNew( VLC_OBJECT(a), b, c)
VLC_EXPORT( stream_t *,__stream_DemuxNew, ( vlc_object_t *p_obj, const char *psz_demux, es_out_t *out ) );
VLC_EXPORT( stream_t *, stream_DemuxNew, ( demux_t *p_demux, const char *psz_demux, es_out_t *out ) );
/**
* Send data to a stream_t handle created by stream_DemuxNew.
*/
......
......@@ -31,8 +31,9 @@
/*****************************************************************************
* access_New:
*****************************************************************************/
access_t *__access_New( vlc_object_t *p_obj, const char *psz_access,
const char *psz_demux, const char *psz_path )
access_t *__access_New( vlc_object_t *p_obj, input_thread_t *p_parent_input,
const char *psz_access, const char *psz_demux,
const char *psz_path )
{
access_t *p_access = vlc_custom_create( p_obj, sizeof (*p_access),
VLC_OBJECT_GENERIC, "access" );
......@@ -44,6 +45,8 @@ access_t *__access_New( vlc_object_t *p_obj, const char *psz_access,
msg_Dbg( p_obj, "creating access '%s' path='%s'",
psz_access, psz_path );
p_access->p_input = p_parent_input;
p_access->psz_path = strdup( psz_path );
p_access->psz_access = strdup( psz_access );
p_access->psz_demux = strdup( psz_demux );
......@@ -89,3 +92,12 @@ void access_Delete( access_t *p_access )
vlc_object_release( p_access );
}
/*****************************************************************************
* access_GetParentInput:
*****************************************************************************/
input_thread_t * access_GetParentInput( access_t *p_access )
{
return p_access->p_input ? vlc_object_hold((vlc_object_t *)p_access->p_input) : NULL;
}
......@@ -32,9 +32,10 @@
#include <vlc_common.h>
#include <vlc_access.h>
#define access_New( a, b, c, d ) __access_New(VLC_OBJECT(a), b, c, d )
access_t * __access_New( vlc_object_t *p_obj, const char *psz_access,
const char *psz_demux, const char *psz_path );
#define access_New( a, b, c, d, e ) __access_New(VLC_OBJECT(a), b, c, d, e )
access_t * __access_New( vlc_object_t *p_obj, input_thread_t *p_input,
const char *psz_access, const char *psz_demux,
const char *psz_path );
void access_Delete( access_t * );
#endif
......
......@@ -37,7 +37,7 @@ static bool SkipAPETag( demux_t *p_demux );
* demux_New:
* if s is NULL then load a access_demux
*****************************************************************************/
demux_t *__demux_New( vlc_object_t *p_obj,
demux_t *__demux_New( vlc_object_t *p_obj, input_thread_t *p_parent_input,
const char *psz_access, const char *psz_demux,
const char *psz_path,
stream_t *s, es_out_t *out, bool b_quick )
......@@ -49,6 +49,8 @@ demux_t *__demux_New( vlc_object_t *p_obj,
if( p_demux == NULL ) return NULL;
p_demux->p_input = p_parent_input;
/* Parse URL */
p_demux->psz_access = strdup( psz_access );
p_demux->psz_demux = strdup( psz_demux );
......@@ -203,6 +205,15 @@ void demux_Delete( demux_t *p_demux )
vlc_object_release( p_demux );
}
/*****************************************************************************
* demux_GetParentInput:
*****************************************************************************/
input_thread_t * demux_GetParentInput( demux_t *p_demux )
{
return p_demux->p_input ? vlc_object_hold((vlc_object_t*)p_demux->p_input) : NULL;
}
/*****************************************************************************
* demux_vaControlHelper:
*****************************************************************************/
......
......@@ -35,8 +35,8 @@
#include "stream.h"
/* stream_t *s could be null and then it mean a access+demux in one */
#define demux_New( a, b, c, d, e, f,g ) __demux_New(VLC_OBJECT(a),b,c,d,e,f,g)
demux_t *__demux_New( vlc_object_t *p_obj, const char *psz_access, const char *psz_demux, const char *psz_path, stream_t *s, es_out_t *out, bool );
#define demux_New( a, b, c, d, e, f, g, h ) __demux_New(VLC_OBJECT(a),b,c,d,e,f,g,h)
demux_t *__demux_New( vlc_object_t *p_obj, input_thread_t *p_parent_input, const char *psz_access, const char *psz_demux, const char *psz_path, stream_t *s, es_out_t *out, bool );
void demux_Delete( demux_t * );
......
......@@ -2416,7 +2416,7 @@ static int InputSourceInit( input_thread_t *p_input,
}
/* Try access_demux first */
in->p_demux = demux_New( p_input, psz_access, psz_demux, psz_path,
in->p_demux = demux_New( p_input, p_input, psz_access, psz_demux, psz_path,
NULL, p_input->p->p_es_out, false );
}
else
......@@ -2481,7 +2481,7 @@ static int InputSourceInit( input_thread_t *p_input,
else
{
/* Now try a real access */
in->p_access = access_New( p_input, psz_access, psz_demux, psz_path );
in->p_access = access_New( p_input, p_input, psz_access, psz_demux, psz_path );
if( in->p_access == NULL )
{
if( vlc_object_alive( p_input ) )
......@@ -2609,7 +2609,7 @@ static int InputSourceInit( input_thread_t *p_input,
{
psz_real_path = psz_path;
}
in->p_demux = demux_New( p_input, psz_access, psz_demux,
in->p_demux = demux_New( p_input, p_input, psz_access, psz_demux,
psz_real_path,
in->p_stream, p_input->p->p_es_out,
p_input->b_preparsing );
......
......@@ -229,6 +229,7 @@ stream_t *stream_CommonNew( vlc_object_t *p_obj )
return s;
}
void stream_CommonDelete( stream_t *s )
{
if( s->p_text )
......@@ -258,8 +259,15 @@ stream_t *__stream_UrlNew( vlc_object_t *p_parent, const char *psz_url )
strcpy( psz_dup, psz_url );
input_SplitMRL( &psz_access, &psz_demux, &psz_path, psz_dup );
/* Get a weak link to the parent input */
/* FIXME: This should probably be removed in favor of a NULL input. */
input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_parent, VLC_OBJECT_INPUT, FIND_PARENT );
/* Now try a real access */
p_access = access_New( p_parent, psz_access, psz_demux, psz_path );
p_access = access_New( p_parent, p_input, psz_access, psz_demux, psz_path );
if(p_input)
vlc_object_release((vlc_object_t*)p_input);
if( p_access == NULL )
{
......@@ -285,6 +293,7 @@ stream_t *stream_AccessNew( access_t *p_access, char **ppsz_list )
if( !s )
return NULL;
s->p_input = p_access->p_input;
s->psz_path = strdup( p_access->psz_path );
s->p_sys = p_sys = malloc( sizeof( *p_sys ) );
if( !s->psz_path || !s->p_sys )
......@@ -348,7 +357,7 @@ stream_t *stream_AccessNew( access_t *p_access, char **ppsz_list )
if( !psz_name )
break;
access_t *p_tmp = access_New( p_access,
access_t *p_tmp = access_New( p_access, p_access->p_input,
p_access->psz_access, "", psz_name );
if( !p_tmp )
continue;
......@@ -1533,8 +1542,7 @@ char *stream_ReadLine( stream_t *s )
}
/* FIXME that's UGLY */
input_thread_t *p_input;
p_input = (input_thread_t *)vlc_object_find( s, VLC_OBJECT_INPUT, FIND_PARENT );
input_thread_t *p_input = s->p_input;
if( p_input != NULL)
{
var_Create( p_input, "subsdec-encoding", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
......@@ -1716,7 +1724,7 @@ static int AReadStream( stream_t *s, void *p_read, unsigned int i_read )
msg_Dbg( s, "opening input `%s'", psz_name );
p_list_access = access_New( s, p_access->psz_access, "", psz_name );
p_list_access = access_New( s, s->p_input, p_access->psz_access, "", psz_name );
if( !p_list_access ) return 0;
......@@ -1788,7 +1796,7 @@ static block_t *AReadBlock( stream_t *s, bool *pb_eof )
msg_Dbg( s, "opening input `%s'", psz_name );
p_list_access = access_New( s, p_access->psz_access, "", psz_name );
p_list_access = access_New( s, s->p_input, p_access->psz_access, "", psz_name );
if( !p_list_access ) return 0;
......@@ -1843,7 +1851,7 @@ static int ASeek( stream_t *s, int64_t i_pos )
if( i != p_sys->i_list_index && i != 0 )
{
p_list_access =
access_New( s, p_access->psz_access, "", psz_name );
access_New( s, s->p_input, p_access->psz_access, "", psz_name );
}
else if( i != p_sys->i_list_index )
{
......
......@@ -54,9 +54,9 @@ static void DStreamDelete ( stream_t * );
static void* DStreamThread ( vlc_object_t * );
stream_t *__stream_DemuxNew( vlc_object_t *p_obj, const char *psz_demux,
es_out_t *out )
stream_t *stream_DemuxNew( demux_t *p_demux, const char *psz_demux, es_out_t *out )
{
vlc_object_t *p_obj = VLC_OBJECT(p_demux);
/* We create a stream reader, and launch a thread */
stream_t *s;
stream_sys_t *p_sys;
......@@ -64,6 +64,7 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, const char *psz_demux,
s = stream_CommonNew( p_obj );
if( s == NULL )
return NULL;
s->p_input = p_demux->p_input;
s->psz_path = strdup(""); /* N/A */
s->pf_read = DStreamRead;
s->pf_peek = DStreamPeek;
......@@ -278,7 +279,7 @@ static void* DStreamThread( vlc_object_t* p_this )
int canc = vlc_savecancel();
/* Create the demuxer */
if( !(p_demux = demux_New( s, "", p_sys->psz_name, "", s, p_sys->out,
if( !(p_demux = demux_New( s, s->p_input, "", p_sys->psz_name, "", s, p_sys->out,
false )) )
{
return NULL;
......
......@@ -42,6 +42,8 @@ stream_t *stream_FilterNew( stream_t *p_source,
if( s == NULL )
return NULL;
s->p_input = p_source->p_input;
/* */
s->psz_path = strdup( p_source->psz_path );
if( !s->psz_path )
......
......@@ -78,6 +78,12 @@ stream_t *__stream_MemoryNew( vlc_object_t *p_this, uint8_t *p_buffer,
vlc_object_attach( s, p_this );
/* Get a weak link to the parent input */
/* FIXME: The usage of vlc_object_find has to be removed. */
s->p_input = (input_thread_t *)vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_PARENT );
if(s->p_input)
vlc_object_release((vlc_object_t*)s->p_input);
return s;
}
......
access_GetParentInput
ACL_AddNet
ACL_Check
__ACL_Create
......@@ -97,6 +98,7 @@ decoder_SynchroTrash
decoder_UnlinkPicture
decode_URI
decode_URI_duplicate
demux_GetParentInput
demux_PacketizerDestroy
demux_PacketizerNew
demux_vaControlHelper
......@@ -379,7 +381,7 @@ __stats_TimerStop
stream_Block
stream_Control
stream_Delete
__stream_DemuxNew
stream_DemuxNew
stream_DemuxSend
__stream_MemoryNew
stream_Peek
......
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