[vlc-devel] [PATCH 02/48] hls: Remove url_t from segments
Jean-Paul Saman
jpsaman at videolan.org
Tue Jan 10 11:18:03 CET 2012
Why is this change needed?
The patch does not explain what the problem is and what it tires to
solve. So NACK for now.
Kind regards,
Jean-Paul Saman
On Mon, Jan 9, 2012 at 4:16 PM, Hugo Beauzée-Luyssen <beauze.h at gmail.com> wrote:
> From: Luc Saillard <luc.saillard at sfr.com>
>
> ---
> modules/stream_filter/httplive.c | 40 +++++++++++++++++++++++++------------
> 1 files changed, 27 insertions(+), 13 deletions(-)
>
> diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
> index a698c05..20e2821 100644
> --- a/modules/stream_filter/httplive.c
> +++ b/modules/stream_filter/httplive.c
> @@ -66,7 +66,7 @@ typedef struct segment_s
> uint64_t size; /* segment size in bytes */
> uint64_t bandwidth; /* bandwidth usage of segments (bits per second)*/
>
> - vlc_url_t url;
> + char *uri;
> vlc_mutex_t lock;
> block_t *data; /* data */
> } segment_t;
> @@ -337,7 +337,7 @@ static segment_t *segment_New(hls_stream_t* hls, const int duration, const char
> segment->size = 0; /* bytes */
> segment->sequence = 0;
> segment->bandwidth = 0;
> - vlc_UrlParse(&segment->url, uri, 0);
> + segment->uri = uri?strdup(uri):NULL;
> segment->data = NULL;
> vlc_array_append(hls->segments, segment);
> vlc_mutex_init(&segment->lock);
> @@ -348,7 +348,8 @@ static void segment_Free(segment_t *segment)
> {
> vlc_mutex_destroy(&segment->lock);
>
> - vlc_UrlClean(&segment->url);
> + if (segment->uri)
> + free(segment->uri);
> if (segment->data)
> block_Release(segment->data);
> free(segment);
> @@ -600,6 +601,7 @@ static int parse_AddSegment(stream_t *s, hls_stream_t *hls, const int duration,
>
> vlc_mutex_lock(&hls->lock);
> segment_t *segment = segment_New(hls, duration, psz_uri ? psz_uri : uri);
> + msg_Dbg(s, "AddSegment() segment=%p uri=%s ", segment, psz_uri ? psz_uri : uri);
> if (segment)
> segment->sequence = hls->sequence + vlc_array_count(hls->segments) - 1;
> vlc_mutex_unlock(&hls->lock);
> @@ -1068,7 +1070,7 @@ static int hls_UpdatePlaylist(stream_t *s, hls_stream_t *hls_new, hls_stream_t *
> /* they should be the same */
> if ((p->sequence != segment->sequence) ||
> (p->duration != segment->duration) ||
> - (strcmp(p->url.psz_path, segment->url.psz_path) != 0))
> + (strcmp(p->uri, segment->uri) != 0))
> {
> msg_Warn(s, "existing segment found with different content - resetting");
> msg_Warn(s, "- sequence: new=%d, old=%d", p->sequence, segment->sequence);
> @@ -1086,8 +1088,18 @@ static int hls_UpdatePlaylist(stream_t *s, hls_stream_t *hls_new, hls_stream_t *
> }
> segment->sequence = p->sequence;
> segment->duration = p->duration;
> - vlc_UrlClean(&segment->url);
> - vlc_UrlParse(&segment->url, psz_url, 0);
> + free(segment->uri);
> + segment->uri = strdup(p->uri);
> + /* We must free the content, because if the key was not downloaded, content can't be decrypted */
> + if (segment->data)
> + {
> + block_Release(segment->data);
> + segment->data = NULL;
> + }
> + if (segment->psz_key_path)
> + free(segment->psz_key_path);
> + segment->psz_key_path = p->psz_key_path?strdup(p->psz_key_path):NULL;
> + vlc_mutex_unlock(&segment->lock);
> segment_Free(p);
> free(psz_url);
> }
> @@ -1316,6 +1328,14 @@ static void* hls_Thread(void *p_this)
> segment_t *segment = segment_GetSegment(hls, p_sys->download.segment);
> vlc_mutex_unlock(&hls->lock);
>
> + if (segment == NULL)
> + {
> + msg_Dbg(s, "segment %d from stream %d is null !!!", p_sys->download.segment, p_sys->download.stream);
> + continue;
> + }
> +
> + msg_Dbg(s, "Downloading segment %d from stream %d (aka %s)", p_sys->download.segment, p_sys->download.stream, segment->uri);
> +
> if ((segment != NULL) &&
> (Download(s, hls, segment, &p_sys->download.stream) != VLC_SUCCESS))
> {
> @@ -1463,13 +1483,7 @@ static int hls_Download(stream_t *s, segment_t *segment)
> {
> assert(segment);
>
> - /* Construct URL */
> - char *psz_url = ConstructUrl(&segment->url);
> - if (psz_url == NULL)
> - return VLC_ENOMEM;
> -
> - stream_t *p_ts = stream_UrlNew(s, psz_url);
> - free(psz_url);
> + stream_t *p_ts = stream_UrlNew(s, segment->uri);
> if (p_ts == NULL)
> return VLC_EGENERIC;
>
> --
> 1.7.8.3
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list