LibVLC command line options http-referrer for hls stream
I am consuming some HLS streams from our backend streaming server over https. Our backend streaming server requires every https request to set the referer header.
I am using :http-referrer option to set it.
Problem is LIbVLC is only setting the referer for the first request, for subsequent requests it does not set the header. Please note my stream is HLS adaptive means initial playlist.m3u8 contains some chunks.m3u8 links which then gives the .ts links. I've verified if mrl is provided as playlist.m3u8 i get a 403 forbidden on chunks.m3u8 if i provide chunks.m3u8 as mrl i get 403 error while loading the .ts.
Verbose log gives http request detail sent to server just for the initial one, but does not show for subsequent.
I am using this constructor in my Xamarin Forms ViewModel:
_libVlc = new LibVLC(new[]
{
"--http-referrer='http://example.com'",
"--verbose=2"
});
See logs:
11-19 04:42:37.717: I/mono-stdout(9035): OnMediaPlayerChanged
11-19 04:42:37.731: D/Mono(9035): DllImport searching in: 'libvlc' ('libvlc.so').
11-19 04:42:37.731: D/Mono(9035): Searching for 'libvlc_media_player_set_android_context'.
11-19 04:42:37.731: D/Mono(9035): Probing 'libvlc_media_player_set_android_context'.
11-19 04:42:37.731: D/Mono(9035): Found as 'libvlc_media_player_set_android_context'.
11-19 04:42:37.738: D/VLC(9035): [b06a3910/23a9] libvlc tls client: loaded 158 trusted CAs from system
11-19 04:42:37.738: D/VLC(9035): [b06a3910/23a9] libvlc tls client: using tls client module "gnutls"
11-19 04:42:37.741: D/VLC(9035): [b06a3910/23a9] libvlc tls client: resolving live.jagobd.com ...
11-19 04:42:38.166: D/VLC(9035): [b06a3910/23a9] libvlc tls client: TLS handshake: Resource temporarily unavailable, try again.
11-19 04:42:38.473: D/VLC(9035): [b06a3910/23a9] libvlc tls client: TLS handshake: Success.
11-19 04:42:38.474: D/VLC(9035): [b06a3910/23a9] libvlc tls client: - safe renegotiation (RFC5746) enabled
11-19 04:42:38.474: D/VLC(9035): [b06a3910/23a9] libvlc tls client: - false start (RFC7918) enabled
11-19 04:42:38.474: E/VLC(9035): [b06a3910/23a9] libvlc tls client: Certificate verification failure: The certificate is NOT trusted. The certificate issuer is unknown.
11-19 04:42:38.474: D/VLC(9035): [b06a3910/23a9] libvlc tls client: 1 certificate(s) in the list
11-19 04:42:38.475: D/VLC(9035): [b06a3910/23a9] libvlc tls client: certificate key match for live.jagobd.com
11-19 04:42:38.475: D/VLC(9035): [9827d410/23a9] http stream: outgoing request:
11-19 04:42:38.475: D/VLC(9035): GET /c2VydmVyX3RpbEU8Mi8xNy8yMDE0GIDU6RgzQ6NTAgdEoaeFzbF92YWxIZTO0U0ezN1IzMyfvcGVMZEJCTEFWeVN3PTOmdFsaWRtaW51aiPhnPTI/sample-stream.stream/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9MTEvMTkvMjAxOCA0OjQzOjIwIEFNJmhhc2hfdmFsdWU9MGRwSVBjTzI5RmVHYVMzcFNHNDYxQT09JnZhbGlkbWludXRlcz00MA== HTTP/1.1
11-19 04:42:38.475: D/VLC(9035): Host: example.com
11-19 04:42:38.475: D/VLC(9035): Accept: */*
11-19 04:42:38.475: D/VLC(9035): Accept-Language: en_US
11-19 04:42:38.475: D/VLC(9035): User-Agent: VLC/3.0.0 LibVLC/3.0.0
11-19 04:42:38.475: D/VLC(9035): Referer: 'http://example.com'
11-19 04:42:38.475: D/VLC(9035): Range: bytes=0-
11-19 04:42:38.475: D/VLC(9035):
11-19 04:42:39.095: D/VLC(9035): [9827d410/23a9] http stream: incoming response:
11-19 04:42:39.095: D/VLC(9035): HTTP/1.1 200 OK
11-19 04:42:39.095: D/VLC(9035): Server: Nimble/3.4.3-9
11-19 04:42:39.095: D/VLC(9035): Date: Mon, 19 Nov 2018 04:40:25 GMT
11-19 04:42:39.095: D/VLC(9035): Content-Type: application/vnd.apple.mpegurl
11-19 04:42:39.095: D/VLC(9035): Content-Length: 276
11-19 04:42:39.095: D/VLC(9035): Cache-Control: no-cache
11-19 04:42:39.095: D/VLC(9035): Access-Control-Allow-Origin: *
11-19 04:42:39.095: D/VLC(9035): Connection: Keep-Alive
11-19 04:42:39.095: D/VLC(9035):
11-19 04:42:39.095: D/VLC(9035): [9827d410/23a9] libvlc stream: using access module "access"
11-19 04:42:39.095: D/VLC(9035): [9827e130/23a9] libvlc stream: looking for stream_filter module matching "prefetch,cache_block": 26 candidates
11-19 04:42:39.095: D/VLC(9035): [9827e130/23a9] libvlc stream: using 276 bytes buffer, 276 bytes read
11-19 04:42:39.095: D/VLC(9035): [9827e130/23a9] libvlc stream: using stream_filter module "prefetch"
11-19 04:42:39.095: D/VLC(9035): [9827e3b0/23a9] libvlc stream: looking for stream_filter module matching "any": 26 candidates
11-19 04:42:39.103: D/VLC(9035): [9827e130/23ab] libvlc stream: end of stream
11-19 04:42:39.107: D/VLC(9035): [9827e3b0/23a9] libvlc stream: Trying Lua scripts in /data/user/0/com.zephyr.bdcast/files/.share/lua/playlist
11-19 04:42:39.107: D/VLC(9035): [9827e3b0/23a9] libvlc stream: Trying Lua scripts in /data/app/com.zephyr.bdcast-1/lib/x86/vlc/lua/playlist
11-19 04:42:39.107: D/VLC(9035): [9827e3b0/23a9] libvlc stream: Trying Lua scripts in /data/app/com.zephyr.bdcast-1/share/vlc/lua/playlist
11-19 04:42:39.107: D/VLC(9035): [9827e3b0/23a9] libvlc stream: no stream_filter modules matched
11-19 04:42:39.107: D/VLC(9035): [9247e930/23a9] libvlc stream_directory: looking for stream_directory module matching "any": 1 candidates
11-19 04:42:39.107: D/VLC(9035): [9247e930/23a9] libvlc stream_directory: no stream_directory modules matched
11-19 04:42:39.107: D/VLC(9035): [9827d2d0/23a9] libvlc input source: attachment of directory-extractor failed for https://example.com/c2VydmVyX3RpbEU8Mi8xNy8yMDE0GIDU6RgzQ6NTAgdEoaeFzbF92YWxIZTO0U0ezN1IzMyfvcGVMZEJCTEFWeVN3PTOmdFsaWRtaW51aiPhnPTI/sample-stream.stream/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9MTEvMTkvMjAxOCA0OjQzOjIwIEFNJmhhc2hfdmFsdWU9MGRwSVBjTzI5RmVHYVMzcFNHNDYxQT09JnZhbGlkbWludXRlcz00MA==
11-19 04:42:39.107: D/VLC(9035): [9827e3b0/23a9] libvlc stream: looking for stream_filter module matching "record": 26 candidates
11-19 04:42:39.107: D/VLC(9035): [9827e3b0/23a9] libvlc stream: using stream_filter module "record"
11-19 04:42:39.107: D/VLC(9035): [9827d2d0/23a9] libvlc input source: creating demux: access='https' demux='any' location='example.com/c2VydmVyX3RpbEU8Mi8xNy8yMDE0GIDU6RgzQ6NTAgdEoaeFzbF92YWxIZTO0U0ezN1IzMyfvcGVMZEJCTEFWeVN3PTOmdFsaWRtaW51aiPhnPTI/sample-stream.stream/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9MTEvMTkvMjAxOCA0OjQzOjIwIEFNJmhhc2hfdmFsdWU9MGRwSVBjTzI5RmVHYVMzcFNHNDYxQT09JnZhbGlkbWludXRlcz00MA==' file='(null)'
11-19 04:42:39.107: D/VLC(9035): [9827e450/23a9] libvlc demux: looking for demux module matching "any": 47 candidates
11-19 04:42:39.110: D/VLC(9035): [9827e450/23a9] libvlc demux: Period
11-19 04:42:39.110: D/VLC(9035): [9827e450/23a9] libvlc demux: BaseAdaptationSet default_id#0
11-19 04:42:39.110: D/VLC(9035): [9827e450/23a9] libvlc demux: Representation chunks.m3u8?nimblesessionid=50371179&wmsAuthSign=c2VydmVyX3RpbWU9MTEvMTkvMjAxOCA0OjQzOjIwIEFNJmhhc2hfdmFsdWU9MGRwSVBjTzI5RmVHYVMzcFNHNDYxQT09JnZhbGlkbWludXRlcz00MA==
11-19 04:42:39.110: D/VLC(9035): [9827e450/23a9] libvlc demux: (not loaded) Unknown
11-19 04:42:39.111: D/VLC(9035): [9827e450/23a9] libvlc demux: opening playlist file (example.com/c2VydmVyX3RpbEU8Mi8xNy8yMDE0GIDU6RgzQ6NTAgdEoaeFzbF92YWxIZTO0U0ezN1IzMyfvcGVMZEJCTEFWeVN3PTOmdFsaWRtaW51aiPhnPTI/sample-stream.stream/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9MTEvMTkvMjAxOCA0OjQzOjIwIEFNJmhhc2hfdmFsdWU9MGRwSVBjTzI5RmVHYVMzcFNHNDYxQT09JnZhbGlkbWludXRlcz00MA==)
11-19 04:42:39.111: D/VLC(9035): [9827e450/23a9] libvlc demux: using demux module "adaptive"
11-19 04:42:39.117: D/VLC(9035): [b4019cf0/23a9] libvlc demux meta: looking for meta reader module matching "any": 2 candidates
11-19 04:42:39.117: D/VLC(9035): [9827e450/23ad] libvlc demux: Retrieving https://example.com/c2VydmVyX3RpbEU8Mi8xNy8yMDE0GIDU6RgzQ6NTAgdEoaeFzbF92YWxIZTO0U0ezN1IzMyfvcGVMZEJCTEFWeVN3PTOmdFsaWRtaW51aiPhnPTI/sample-stream.stream/chunks.m3u8?nimblesessionid=50371179&wmsAuthSign=c2VydmVyX3RpbWU9MTEvMTkvMjAxOCA0OjQzOjIwIEFNJmhhc2hfdmFsdWU9MGRwSVBjTzI5RmVHYVMzcFNHNDYxQT09JnZhbGlkbWludXRlcz00MA== @0
11-19 04:42:39.118: D/VLC(9035): [9827e450/23ad] libvlc demux: net: connecting to live.jagobd.com port 444
11-19 04:42:39.117: D/VLC(9035): [b4019cf0/23a9] libvlc demux meta: Trying Lua scripts in /data/user/0/com.zephyr.bdcast/files/.share/lua/meta/reader
11-19 04:42:39.125: D/VLC(9035): [b4019cf0/23a9] libvlc demux meta: Trying Lua scripts in /data/app/com.zephyr.bdcast-1/lib/x86/vlc/lua/meta/reader
11-19 04:42:39.129: D/VLC(9035): [b4019cf0/23a9] libvlc demux meta: Trying Lua scripts in /data/app/com.zephyr.bdcast-1/share/vlc/lua/meta/reader
11-19 04:42:39.131: D/VLC(9035): [b4019cf0/23a9] libvlc demux meta: no meta reader modules matched
11-19 04:42:39.134: D/VLC(9035): [993f3230/23a9] libvlc input: `https://example.com/c2VydmVyX3RpbEU8Mi8xNy8yMDE0GIDU6RgzQ6NTAgdEoaeFzbF92YWxIZTO0U0ezN1IzMyfvcGVMZEJCTEFWeVN3PTOmdFsaWRtaW51aiPhnPTI/sample-stream.stream/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9MTEvMTkvMjAxOCA0OjQzOjIwIEFNJmhhc2hfdmFsdWU9MGRwSVBjTzI5RmVHYVMzcFNHNDYxQT09JnZhbGlkbWludXRlcz00MA==' successfully opened
11-19 04:42:39.418: D/VLC(9035): [9827e450/23ad] libvlc demux: connection succeeded (socket = 35)
11-19 04:42:39.418: D/VLC(9035): [aebd5a10/23ad] libvlc tls client: looking for tls client module matching "any": 1 candidates
11-19 04:42:39.419: D/VLC(9035): [aebd5a10/23ad] libvlc tls client: using GnuTLS version 3.5.16
11-19 04:42:39.441: D/VLC(9035): [aebd5a10/23ad] libvlc tls client: loaded 158 trusted CAs from system
11-19 04:42:39.441: D/VLC(9035): [aebd5a10/23ad] libvlc tls client: using tls client module "gnutls"
11-19 04:42:39.444: D/VLC(9035): [aebd5a10/23ad] libvlc tls client: TLS handshake: Resource temporarily unavailable, try again.
11-19 04:42:39.751: D/VLC(9035): [aebd5a10/23ad] libvlc tls client: TLS handshake: Success.
11-19 04:42:39.751: D/VLC(9035): [aebd5a10/23ad] libvlc tls client: - safe renegotiation (RFC5746) enabled
11-19 04:42:39.751: D/VLC(9035): [aebd5a10/23ad] libvlc tls client: - false start (RFC7918) enabled
11-19 04:42:39.752: E/VLC(9035): [aebd5a10/23ad] libvlc tls client: Certificate verification failure: The certificate is NOT trusted. The certificate issuer is unknown.
11-19 04:42:39.752: D/VLC(9035): [aebd5a10/23ad] libvlc tls client: 1 certificate(s) in the list
11-19 04:42:39.752: D/VLC(9035): [aebd5a10/23ad] libvlc tls client: certificate key match for live.jagobd.com
11-19 04:42:40.348: E/VLC(9035): [9827e450/23ad] libvlc demux: Failed reading https://example.com/c2VydmVyX3RpbEU8Mi8xNy8yMDE0GIDU6RgzQ6NTAgdEoaeFzbF92YWxIZTO0U0ezN1IzMyfvcGVMZEJCTEFWeVN3PTOmdFsaWRtaW51aiPhnPTI/sample-stream.stream/chunks.m3u8?nimblesessionid=50371179&wmsAuthSign=c2VydmVyX3RpbWU9MTEvMTkvMjAxOCA0OjQzOjIwIEFNJmhhc2hfdmFsdWU9MGRwSVBjTzI5RmVHYVMzcFNHNDYxQT09JnZhbGlkbWludXRlcz00MA==: HTTP/1.1 403 Forbidden
11-19 04:42:40.357: E/VLC(9035): [9827e450/23ad] libvlc demux: Failed to create demuxer 0x0 Unknown