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().
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 )
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; \
int i_seekpoint; /* idem, start from 0 */
} info;
demux_sys_t *p_sys;
+
+ /* Weak link to parent input */
+ input_thread_t *p_input;
};
*/
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; \
/* Text reader state */
stream_text_t *p_text;
+
+ /* Weak link to parent input */
+ input_thread_t *p_input;
};
/**
* 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.
*/
/*****************************************************************************
* 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" );
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 );
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;
+}
+
#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
* 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 )
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 );
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:
*****************************************************************************/
#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 * );
}
/* 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
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 ) )
{
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 );
return s;
}
+
void stream_CommonDelete( stream_t *s )
{
if( s->p_text )
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 )
{
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 )
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;
}
/* 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 );
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;
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;
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 )
{
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;
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;
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;
if( s == NULL )
return NULL;
+ s->p_input = p_source->p_input;
+
/* */
s->psz_path = strdup( p_source->psz_path );
if( !s->psz_path )
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
decoder_UnlinkPicture
decode_URI
decode_URI_duplicate
+demux_GetParentInput
demux_PacketizerDestroy
demux_PacketizerNew
demux_vaControlHelper
stream_Block
stream_Control
stream_Delete
-__stream_DemuxNew
+stream_DemuxNew
stream_DemuxSend
__stream_MemoryNew
stream_Peek