Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
e02e73ca
Commit
e02e73ca
authored
Dec 19, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
https: old-style live streaming (http-continuous) helper
parent
3f0a94de
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
256 additions
and
19 deletions
+256
-19
modules/access/http/Makefile.am
modules/access/http/Makefile.am
+1
-0
modules/access/http/access.c
modules/access/http/access.c
+98
-19
modules/access/http/live.c
modules/access/http/live.c
+125
-0
modules/access/http/live.h
modules/access/http/live.h
+32
-0
No files found.
modules/access/http/Makefile.am
View file @
e02e73ca
...
...
@@ -7,6 +7,7 @@ libvlc_http_la_SOURCES = \
access/http/message.c access/http/message.h
\
access/http/resource.c access/http/resource.h
\
access/http/file.c access/http/file.h
\
access/http/live.c access/http/live.h
\
access/http/hpack.c access/http/hpack.h access/http/hpackenc.c
\
access/http/h2frame.c access/http/h2frame.h
\
access/http/h2output.c access/http/h2output.h
\
...
...
modules/access/http/access.c
View file @
e02e73ca
...
...
@@ -32,14 +32,19 @@
#include "connmgr.h"
#include "file.h"
#include "live.h"
struct
access_sys_t
{
struct
vlc_http_mgr
*
manager
;
struct
vlc_http_file
*
file
;
union
{
struct
vlc_http_file
*
file
;
struct
vlc_http_live
*
live
;
};
};
static
block_t
*
Read
(
access_t
*
access
)
static
block_t
*
File
Read
(
access_t
*
access
)
{
access_sys_t
*
sys
=
access
->
p_sys
;
...
...
@@ -49,7 +54,7 @@ static block_t *Read(access_t *access)
return
b
;
}
static
int
Seek
(
access_t
*
access
,
uint64_t
pos
)
static
int
File
Seek
(
access_t
*
access
,
uint64_t
pos
)
{
access_sys_t
*
sys
=
access
->
p_sys
;
access
->
info
.
b_eof
=
false
;
...
...
@@ -59,7 +64,7 @@ static int Seek(access_t *access, uint64_t pos)
return
VLC_SUCCESS
;
}
static
int
Control
(
access_t
*
access
,
int
query
,
va_list
args
)
static
int
File
Control
(
access_t
*
access
,
int
query
,
va_list
args
)
{
access_sys_t
*
sys
=
access
->
p_sys
;
...
...
@@ -102,7 +107,51 @@ static int Control(access_t *access, int query, va_list args)
default:
return
VLC_EGENERIC
;
}
return
VLC_SUCCESS
;
}
static
block_t
*
LiveRead
(
access_t
*
access
)
{
access_sys_t
*
sys
=
access
->
p_sys
;
block_t
*
b
=
vlc_http_live_read
(
sys
->
live
);
if
(
b
==
NULL
)
/* TODO: loop instead of EOF, see vlc_http_live_read() */
access
->
info
.
b_eof
=
true
;
return
b
;
}
static
int
NoSeek
(
access_t
*
access
,
uint64_t
pos
)
{
(
void
)
access
;
(
void
)
pos
;
return
VLC_EGENERIC
;
}
static
int
LiveControl
(
access_t
*
access
,
int
query
,
va_list
args
)
{
access_sys_t
*
sys
=
access
->
p_sys
;
switch
(
query
)
{
case
ACCESS_CAN_SEEK
:
case
ACCESS_CAN_FASTSEEK
:
case
ACCESS_CAN_PAUSE
:
case
ACCESS_CAN_CONTROL_PACE
:
*
va_arg
(
args
,
bool
*
)
=
false
;
break
;
case
ACCESS_GET_PTS_DELAY
:
*
va_arg
(
args
,
int64_t
*
)
=
var_InheritInteger
(
access
,
"network-caching"
);
break
;
case
ACCESS_GET_CONTENT_TYPE
:
*
va_arg
(
args
,
char
**
)
=
vlc_http_live_get_type
(
sys
->
live
);
break
;
default:
return
VLC_EGENERIC
;
}
return
VLC_SUCCESS
;
}
...
...
@@ -111,9 +160,6 @@ static int Open(vlc_object_t *obj)
{
access_t
*
access
=
(
access_t
*
)
obj
;
if
(
var_InheritBool
(
obj
,
"http-continuous"
))
return
VLC_EGENERIC
;
/* FIXME not implemented yet */
char
*
proxy
=
vlc_getProxyUrl
(
access
->
psz_url
);
free
(
proxy
);
if
(
proxy
!=
NULL
)
...
...
@@ -139,15 +185,35 @@ static int Open(vlc_object_t *obj)
goto
error
;
char
*
ua
=
var_InheritString
(
obj
,
"http-user-agent"
);
char
*
ref
=
var_InheritString
(
obj
,
"http-referrer"
);
sys
->
file
=
vlc_http_file_create
(
sys
->
manager
,
access
->
psz_url
,
ua
,
ref
);
free
(
ref
);
char
*
referer
=
var_InheritString
(
obj
,
"http-referrer"
);
bool
live
=
var_InheritBool
(
obj
,
"http-continuous"
);
if
(
live
)
sys
->
live
=
vlc_http_live_create
(
sys
->
manager
,
access
->
psz_url
,
ua
,
referer
);
else
sys
->
file
=
vlc_http_file_create
(
sys
->
manager
,
access
->
psz_url
,
ua
,
referer
);
free
(
referer
);
free
(
ua
);
if
(
sys
->
file
==
NULL
)
goto
error
;
char
*
redir
=
vlc_http_file_get_redirect
(
sys
->
file
);
char
*
redir
;
if
(
live
)
{
if
(
sys
->
live
==
NULL
)
goto
error
;
redir
=
vlc_http_live_get_redirect
(
sys
->
live
);
}
else
{
if
(
sys
->
file
==
NULL
)
goto
error
;
redir
=
vlc_http_file_get_redirect
(
sys
->
file
);
}
if
(
redir
!=
NULL
)
{
access
->
psz_url
=
redir
;
...
...
@@ -157,7 +223,8 @@ static int Open(vlc_object_t *obj)
ret
=
VLC_EGENERIC
;
int
status
=
vlc_http_file_get_status
(
sys
->
file
);
int
status
=
live
?
vlc_http_live_get_status
(
sys
->
live
)
:
vlc_http_file_get_status
(
sys
->
file
);
if
(
status
<
0
)
{
msg_Err
(
access
,
"HTTP connection failure"
);
...
...
@@ -173,9 +240,18 @@ static int Open(vlc_object_t *obj)
access
->
info
.
b_eof
=
false
;
access
->
pf_read
=
NULL
;
access
->
pf_block
=
Read
;
access
->
pf_seek
=
Seek
;
access
->
pf_control
=
Control
;
if
(
live
)
{
access
->
pf_block
=
LiveRead
;
access
->
pf_seek
=
NoSeek
;
access
->
pf_control
=
LiveControl
;
}
else
{
access
->
pf_block
=
FileRead
;
access
->
pf_seek
=
FileSeek
;
access
->
pf_control
=
FileControl
;
}
access
->
p_sys
=
sys
;
return
VLC_SUCCESS
;
...
...
@@ -193,7 +269,10 @@ static void Close(vlc_object_t *obj)
access_t
*
access
=
(
access_t
*
)
obj
;
access_sys_t
*
sys
=
access
->
p_sys
;
vlc_http_file_destroy
(
sys
->
file
);
if
(
access
->
pf_block
==
LiveRead
)
vlc_http_live_destroy
(
sys
->
live
);
else
vlc_http_file_destroy
(
sys
->
file
);
vlc_http_mgr_destroy
(
sys
->
manager
);
free
(
sys
);
}
...
...
modules/access/http/live.c
0 → 100644
View file @
e02e73ca
/*****************************************************************************
* live.c: HTTP read-only live stream
*****************************************************************************
* Copyright (C) 2015 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <vlc_common.h>
#include "message.h"
#include "resource.h"
#include "live.h"
#pragma GCC visibility push(default)
struct
vlc_http_live
{
struct
vlc_http_resource
resource
;
struct
vlc_http_msg
*
resp
;
};
static
int
vlc_http_live_req
(
struct
vlc_http_msg
*
req
,
const
struct
vlc_http_resource
*
res
,
void
*
opaque
)
{
#if 0 // TODO
vlc_http_msg_add_header(req, "Accept-Encoding", "gzip, deflate");
#else
(
void
)
req
;
#endif
(
void
)
res
;
(
void
)
opaque
;
return
0
;
}
static
struct
vlc_http_msg
*
vlc_http_live_open
(
struct
vlc_http_live
*
live
)
{
return
vlc_http_res_open
(
&
live
->
resource
,
vlc_http_live_req
,
NULL
);
}
void
vlc_http_live_destroy
(
struct
vlc_http_live
*
live
)
{
if
(
live
->
resp
!=
NULL
)
vlc_http_msg_destroy
(
live
->
resp
);
vlc_http_res_deinit
(
&
live
->
resource
);
free
(
live
);
}
struct
vlc_http_live
*
vlc_http_live_create
(
struct
vlc_http_mgr
*
mgr
,
const
char
*
uri
,
const
char
*
ua
,
const
char
*
ref
)
{
struct
vlc_http_live
*
live
=
malloc
(
sizeof
(
*
live
));
if
(
unlikely
(
live
==
NULL
))
return
NULL
;
if
(
vlc_http_res_init
(
&
live
->
resource
,
mgr
,
uri
,
ua
,
ref
))
{
free
(
live
);
return
NULL
;
}
live
->
resp
=
NULL
;
return
live
;
}
int
vlc_http_live_get_status
(
struct
vlc_http_live
*
live
)
{
if
(
live
->
resp
==
NULL
)
{
live
->
resp
=
vlc_http_live_open
(
live
);
if
(
live
->
resp
==
NULL
)
return
-
1
;
}
return
vlc_http_msg_get_status
(
live
->
resp
);
}
char
*
vlc_http_live_get_redirect
(
struct
vlc_http_live
*
live
)
{
if
(
vlc_http_live_get_status
(
live
)
<
0
)
return
NULL
;
return
vlc_http_res_get_redirect
(
&
live
->
resource
,
live
->
resp
);
}
char
*
vlc_http_live_get_type
(
struct
vlc_http_live
*
live
)
{
if
(
vlc_http_live_get_status
(
live
)
<
0
)
return
NULL
;
return
vlc_http_res_get_type
(
live
->
resp
);
}
block_t
*
vlc_http_live_read
(
struct
vlc_http_live
*
live
)
{
if
(
vlc_http_live_get_status
(
live
)
<
0
)
return
NULL
;
struct
block_t
*
block
=
vlc_http_res_read
(
live
->
resp
);
if
(
block
!=
NULL
)
return
block
;
/* Automatically try to reconnect */
/* TODO: Retry-After parsing, loop and pacing timer */
vlc_http_msg_destroy
(
live
->
resp
);
live
->
resp
=
NULL
;
if
(
vlc_http_live_get_status
(
live
)
<
0
)
return
NULL
;
return
vlc_http_res_read
(
live
->
resp
);
}
modules/access/http/live.h
0 → 100644
View file @
e02e73ca
/*****************************************************************************
* live.h: HTTP read-only live stream declarations
*****************************************************************************
* Copyright (C) 2015 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
struct
vlc_http_live
;
struct
block_t
;
struct
vlc_http_live
*
vlc_http_live_create
(
struct
vlc_http_mgr
*
mgr
,
const
char
*
uri
,
const
char
*
ua
,
const
char
*
ref
);
void
vlc_http_live_destroy
(
struct
vlc_http_live
*
live
);
int
vlc_http_live_get_status
(
struct
vlc_http_live
*
live
);
char
*
vlc_http_live_get_redirect
(
struct
vlc_http_live
*
live
);
char
*
vlc_http_live_get_type
(
struct
vlc_http_live
*
live
);
block_t
*
vlc_http_live_read
(
struct
vlc_http_live
*
live
);
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