Author Topic: BASSHLS beta (HTTP Live Streaming add-on)  (Read 13948 times)

Ian @ un4seen

  • Administrator
  • Posts: 19894
BASSHLS beta (HTTP Live Streaming add-on)
« on: 11 Nov '15 - 17:49 »
Here is a new add-on that adds support for HLS (HTTP Live Streaming) streams:

   www.un4seen.com/stuff/basshls.zip (updated: 6 Feb '17)

Win32/OSX/Linux/Android/iOS/WinStore versions are included. Dedicated BASS_HLS_StreamCreateURL and BASS_HLS_StreamCreateFile functions are provided, and it can also be used via the plugin system. Although local HLS playlist files are supported, the media segments in the playlist currently must be URLs.

HLS streams consist of a media playlist (and optionally a master playlist) and segments. The media segments usually have AAC data, but MP3 or AC3 are also possible. BASSHLS should support any audio format that's supported by BASS or a plugin. The data is usually in an MPEG-TS container, but it can also be plain audio data, possibly with ID3v2 tags. As well as possibly ID3v2 tags, the current segment's EXTINF tag (which may include a title) in the media playlist is available via the new BASS_TAG_HLS_EXTINF tag type. If present, the ID3v2 tags can/will change with each segment. A BASS_SYNC_HLS_SEGMENT sync type has been added to be informed of when a new segment starts downloading, which could be used to refresh the tags. A BASS_FILEPOS_HLS_SEGMENT BASS_StreamGetFilePosition option has also been added to get the current segment's sequence number.

When a master playlist is passed to BASSHLS, it will play the first entry from it. If you would like to play a different entry (eg. perhaps for a different bitrate), you can download the master playlist separately and then extract and pass the wanted entry's URL to BASSHLS.

A subset of the HLS spec is currently supported. The supported tags are: EXTINF, EXT-X-BYTERANGE, EXT-X-ENDLIST, EXT-X-KEY, EXT-X-MEDIA-SEQUENCE, EXT-X-TARGETDURATION. That seems to be sufficient, but please report if you find any HLS streams that aren't working properly. If you are looking for test streams, a bunch of streams can be found here:

   www.radiofeeds.co.uk/other.asp
   www.addictradio.net/en/labs/

It seems to be working nicely so far, but it's still early days for BASSHLS. Please report any problems/suggestions/etc that you may have.
« Last Edit: 6 Feb '17 - 17:39 by Ian @ un4seen »

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #1 on: 13 Nov '15 - 15:25 »
Android and iOS versions have been added to the package in the 1st post.

Oleg N

  • Posts: 74
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #2 on: 16 Nov '15 - 16:34 »
That's great news, thank You!

drama22

  • Posts: 17
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #3 on: 17 Nov '15 - 11:46 »
how it works ? can i stream from microphone from pc to android and from android To pc ?

Oleg N

  • Posts: 74
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #4 on: 17 Nov '15 - 12:53 »
drama22, for this You don't need BASSHLS, just BASSENC to create streaming server and BASS_StreamCreateURL() to receive/play it.

HLS is the protocol to play some new radio station streams available on internet.

radio42

  • Posts: 4521
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #5 on: 18 Nov '15 - 08:38 »
I guess 'drama22's question is, if the add-on would also allow him/her to create a HLS stream.
As far as I know this is not possible with BASSENC nor with the new BASSHLS.
Meaning the BASSHLS add-on purely adds playback support.

Oleg N

  • Posts: 74
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #6 on: 18 Nov '15 - 11:37 »
Yes, radio42, You answered this more clearly.

ramses

  • Posts: 103
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #7 on: 22 Nov '15 - 04:36 »
Hi Ian,

Is there a x64 version available ?

Thanks,

Philippe

Bert B.

  • Posts: 118
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #8 on: 23 Nov '15 - 07:59 »
Is there a x64 version available ?

Did you look inside the zip package?

ramses

  • Posts: 103
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #9 on: 23 Nov '15 - 08:25 »
Hi,

Not in the latest package. I see that the x64 version is now inside.

 :o

Philippe

ramses

  • Posts: 103
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #10 on: 24 Nov '15 - 11:30 »
Hi Ian,

It works very fine  :D

Did you have any sample to extract metadata (like in bass_radio standard package) ?

Regards,

Philippe

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #11 on: 24 Nov '15 - 13:58 »
I don't think most HLS streams include metadata. In some cases, a title will be included in the EXTINF tag, which you can get via the new BASS_TAG_HLS_EXTINF option. For example, you could try something like this:

Code: [Select]
BASS_ChannelSetSync(stream, BASS_SYNC_HLS_SEGMENT, 0, HLSSegmentSyncProc, 0); // set sync on new HLS segment

...

void CALLBACK HLSSegmentSyncProc(HSYNC handle, DWORD channel, DWORD data, void *user)
{
const char *extinf=BASS_ChannelGetTags(channel, BASS_TAG_HLS_EXTINF); // get new segment's EXTINF tag
const char *title=strchr(extinf, ','); // look for duration/title separator
if (title && title[1]) SetTitle(title+1); // use title
}

Some streams may also have ID3v2 tags, which you can get via the BASS_TAG_ID3V2 tag option.

leonardo

  • Posts: 5
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #12 on: 16 Dec '15 - 07:55 »
how to import addon android project? im usign android acc bass

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #13 on: 16 Dec '15 - 17:03 »
To add HLS support to your app, you should just need to add the BASSHLS libraries to your project's "libs" folder (alongside the BASS libraries) and add a BASS_PluginLoad call to your initialization code:

Code: [Select]
BASS.BASS_PluginLoad(getApplicationInfo().nativeLibraryDir+"/libbasshls.so", 0); // load BASSHLS

Do the same for the BASS_AAC add-on if you want to support AAC data (which is what most HLS streams contain).

leonardo

  • Posts: 5
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #14 on: 17 Dec '15 - 07:40 »
both type aac hls

leonardo

  • Posts: 5
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #15 on: 17 Dec '15 - 08:38 »
if(info.ctype ==BASS.BASS_CTYPE_STREAM_AAC){
                  fileformat=".aac";
               }else{
                  Logger.error("  Type"+info.ctype);
               }
               
   

this work. working but very slowly
« Last Edit: 27 Dec '15 - 14:42 by leonardo »

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #16 on: 17 Dec '15 - 13:31 »
Oh, do you want to detect an HLS stream? If so, you can do that by checking whether the BASS_FILEPOS_HLS_SEGMENT value is available, like this:

Code: [Select]
boolean isHLS=(BASS.BASS_StreamGetFilePosition(stream, BASSHLS.BASS_FILEPOS_HLS_SEGMENT)!=-1);

Brazil2

  • Posts: 3
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #17 on: 19 Jan '16 - 19:38 »
Bug: it doesn't update the metadata (NowPlaying) on track change.

For instance, with both of these streams:
AAC: http://hls1.addictradio.net/addictrock_aac_hls/playlist.m3u8
MP3: http://hls1.addictradio.net/addictrock_hls/playlist.m3u8

We got the correct artist and title when connecting but it's not updated on the next track, we have to stop and restart the stream to get the proper information.

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #18 on: 20 Jan '16 - 13:56 »
Testing those streams here, the BASS_TAG_HLS_EXTINF and BASS_TAG_ID3V2 tag types both seem to be getting updated OK. I do see an issue though, which could result in BASS_ChannelGetTags failing (returning NULL) sometimes, and even crashing sometimes in the case of BASS_TAG_ID3V2. Here's an update for you to try, which should fix that:

   www.un4seen.com/stuff/basshls-test.zip

If you still have the problem with that, please show how/when you are getting the tags.

Brazil2

  • Posts: 3
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #19 on: 20 Jan '16 - 15:56 »
www.un4seen.com/stuff/basshls-test.zip
If you still have the problem with that, please show how/when you are getting the tags.

It's the same with this version.

I have just dropped it into the plugins folder of AIMP3.
The playback works a treat but the tags are not updated on track change while it's working fine with all other 'normal' radios, doesn't matter which codec is used.

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #20 on: 20 Jan '16 - 17:08 »
OK. It isn't actually possible to simply drop BASSHLS.DLL into an existing app and have it automatically handle tag updates; some code additions will be needed: a BASS_SYNC_HLS_SEGMENT sync should be set, which can check the BASS_TAG_HLS_EXTINF/BASS_TAG_ID3V2 tags in its SYNCPROC callback function. From what you say, it sounds like AIMP3 doesn't currently do that.

Brazil2

  • Posts: 3
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #21 on: 21 Jan '16 - 10:11 »
some code additions will be needed: a BASS_SYNC_HLS_SEGMENT sync should be set, which can check the BASS_TAG_HLS_EXTINF/BASS_TAG_ID3V2 tags in its SYNCPROC callback function.

Got it, so I have to show your post to the AIMP dev.
Thanks for the answer :)

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #22 on: 22 Jan '16 - 14:26 »
The BASSHLS update I posted a couple of days ago is now available for all platforms in the 1st post.

drama22

  • Posts: 17
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #23 on: 25 Jan '16 - 12:09 »
drama22, for this You don't need BASSHLS, just BASSENC to create streaming server and BASS_StreamCreateURL() to receive/play it.

HLS is the protocol to play some new radio station streams available on internet.

is there any sample for that guide iam really new to bass thanks in advance

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #24 on: 25 Jan '16 - 16:42 »
A demonstration of what Oleg mentioned can be found in the SERVER example that's included in the BASSenc package. The main function of interest is BASS_Encode_ServerInit, so you should also look that up in the BASSenc documentation.

drama22

  • Posts: 17
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #25 on: 25 Jan '16 - 22:04 »
i am using delphi c example will not help me

Error

  • Guest
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #26 on: 31 Jan '16 - 12:29 »
And how we can create our own HLS stream? What encoder do i need (on linux, arm)? I  would like to try it out cause jPlayer is not reliable when playing a mp3 stream.

airstep

  • Posts: 2
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #27 on: 24 May '16 - 08:04 »
Hi!

How to use adaptive bitrate streaming provided by HLS?

How to check if it works with your library?

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #28 on: 24 May '16 - 13:19 »
BASSHLS doesn't currently include automated support for adaptive bitrate streaming (it always plays the first available stream/bitrate). You will need to download the master playlist yourself and extract the URL for the bitrate that you want, and pass that to BASSHLS.

airstep

  • Posts: 2
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #29 on: 24 May '16 - 14:09 »
BASSHLS doesn't currently include automated support for adaptive bitrate streaming (it always plays the first available stream/bitrate). You will need to download the master playlist yourself and extract the URL for the bitrate that you want, and pass that to BASSHLS.

ok, thank you!

leonardo

  • Posts: 5
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #30 on: 26 Jun '16 - 01:59 »
http://www.un4seen.com/stuff/basshls-test.zip 404 not found pls re upload.
my StreamCreateURL

c = BASS.BASS_StreamCreateURL(url, 0,
                  BASS.BASS_STREAM_BLOCK | BASS.BASS_STREAM_STATUS | BASS.BASS_STREAM_AUTOFREE, StatusProc, r); // open

how to create
BASS_HLS_StreamCreateURL
BASS_HLS_StreamCreateFile
thanks for help

               

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #31 on: 27 Jun '16 - 16:12 »
That "basshls-test" update has since become the official BASSHLS version and is available in the 1st post.

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #32 on: 25 Jul '16 - 17:50 »
An updated BASSHLS version is up now in the 1st post, adding support for the EXT-X-KEY tag and AES-128 encryption.

ak545

  • Posts: 6
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #33 on: 14 Sep '16 - 22:53 »
Hi Ian @ un4seen!

Thanks a lot for this work!

Earlier you wrote:
Quote
but please report if you find any HLS streams that aren't working properly
Yes, there is such a stream.

Content-Type:video/mp2t
https://radio7.ru/
https://hls-01-radio7.emgsound.ru/13/128/playlist.m3u8

This HLS stream is processed with errors.
When you reach the end of each segment - stops playing.


Best Regards,
Andrey Klimov

P.S. Sorry for my bad English.

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #34 on: 15 Sep '16 - 13:03 »
That stream seems to be working fine here. To test it, I added a BASS_PluginLoad("basshls.dll") call to the NETRADIO example. Here it is for you to try:

   www.un4seen.com/stuff/netradio-hls.exe

Can you reproduce the problem with that? If not, are you customising any BASS_CONFIG settings in your app?

ak545

  • Posts: 6
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #35 on: 15 Sep '16 - 15:45 »
That stream seems to be working fine here. To test it, I added a BASS_PluginLoad("basshls.dll") call to the NETRADIO example. Here it is for you to try:

   www.un4seen.com/stuff/netradio-hls.exe

Can you reproduce the problem with that? If not, are you customising any BASS_CONFIG settings in your app?

No, this example ( www.un4seen.com/stuff/netradio-hls.exe ) as the stream starts to play, but then after about 8 seconds stops (disconnected).

Code: [Select]
procedure ClosedStream(handle: HSYNC; channel, data: DWORD; user: Pointer); {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
...

procedure ClosedStream(handle: HSYNC; channel, data: DWORD; user: Pointer); {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
begin
   //Oops! WTF???
   // at the end of each piece of management comes here
   // It's only when play from: https://hls-01-radio7.emgsound.ru/13/128/playlist.m3u8
  {
    https://hls-01-radio7.emgsound.ru/commercial/13/1556_aDowU2hvWmJBTFNQSTV0ODZuZUFlRTQy_1/1/30138/out0.ts // after end -> BASS_SYNC_END ???
    https://hls-01-radio7.emgsound.ru/commercial/13/1556_aDowU2hvWmJBTFNQSTV0ODZuZUFlRTQy_1/1/30138/out1.ts // after end -> BASS_SYNC_END ???
    https://hls-01-radio7.emgsound.ru/commercial/13/1556_aDowU2hvWmJBTFNQSTV0ODZuZUFlRTQy_1/1/30138/out2.ts // after end -> BASS_SYNC_END ???
    ...
   }
   FormClockMain.MemoDebug.Lines.Add('THE FINISH!');
end;

...
var   
    G_STREAM_URL: String;
    chan: HSTREAM;

...
    BASS_Init( bla bla bla....);
...
    BASS_PluginLoad("basshls.dll"); // Of course! Ash stump!
...
    G_STREAM_URL := 'https://hls-01-radio7.emgsound.ru/13/128/playlist.m3u8';
    BASS_SetConfig(BASS_CONFIG_NET_BUFFER, 5000);
    BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST, 1);
    chan := BASS_StreamCreateURL(
                                 PAnsiChar(G_STREAM_URL),
                                 0,
                                 BASS_STREAM_BLOCK or BASS_STREAM_STATUS or BASS_SAMPLE_FX or BASS_STREAM_AUTOFREE,
                                 @StatusProc,
                                 nil
                                );
   if (chan <> 0) then
   begin
         BASS_ChannelSetSync(chan, BASS_SYNC_META, 0, @MetaSync, nil);
         BASS_ChannelSetSync(chan, BASS_SYNC_OGG_CHANGE, 0, @MetaSync, nil);
         BASS_ChannelSetSync(chan, BASS_SYNC_HLS_SEGMENT, 0, @MetaSync, nil);
         BASS_ChannelSetSync(chan, BASS_SYNC_END or BASS_SYNC_STALL, 0, @ClosedStream, nil);
         // play it!
         if BASS_ChannelPlay(chan, FALSE) then
         begin
            // ...
         end;
   end;
    //I write this on Lazarus 1.6 and Free Pascal 3.0 for Windows/Linux/MacOS

My code works fine for HLS, from these sources:
www.radiofeeds.co.uk/other.asp
www.addictradio.net/en/labs/
Look: https://youtu.be/7q3KLaOQqHk

but don't work for this:
https://hls-01-radio7.emgsound.ru/13/128/playlist.m3u8
With your example (netradio-hls.exe) there is the same.
+
https://youtu.be/5TpsKc3AP9o

I have attached screenshots (Developer Tools of the Google Chrome) from the site ( https://radio7.ru/ ) to understand how it happens.
I hope for understanding, so very bad speak English.



« Last Edit: 15 Sep '16 - 16:06 by ak545 »

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #36 on: 15 Sep '16 - 16:12 »
That's strange, the stream is still playing fine here. I will send you a debug BASSHLS version to get some more info on what is happening there.

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #37 on: 16 Sep '16 - 13:52 »
For anyone else that has had this problem with some HLS streams, a BASSHLS update is now up in the 1st post.


Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #39 on: 5 Oct '16 - 16:52 »
That's strange. Both streams seem to be working fine here, with the netradio-hls.exe example posted above. Can you reproduce the problem with that there, and if so, what is the error code?

Pedro Leonardo

  • Posts: 80
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #40 on: 5 Oct '16 - 17:06 »
Hi,
with the NetRadio-hls.exe example is working. You can send NetRadio-hls sources? Am I doing something wrong..

Regards
Leonardo

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #41 on: 5 Oct '16 - 17:30 »
It is the NETRADIO.C example included in the BASS package, with a BASS_PluginLoad call added in WinMain to load BASSHLS:

Code: [Select]
// check the correct BASS was loaded
if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
MessageBox(0,"An incorrect version of BASS.DLL was loaded",0,MB_ICONERROR);
return 0;
}

BASS_PluginLoad("basshls.dll",0);

Pedro Leonardo

  • Posts: 80
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #42 on: 5 Oct '16 - 18:53 »
Hi,
I develop in Delphi

my TForm1.FormCreate


  // check the correct BASS was loaded
  win := handle;
  if (HIWORD(BASS_GetVersion) <> BASSVERSION) then
  begin
    MessageBox(0, 'An incorrect version of BASS.DLL was loaded', nil, MB_ICONERROR);
    Halt;
  end;
  if (not BASS_Init(-1, 44100, 0, Handle, nil)) then
  begin
    Error('Can''t initialize device');
    Halt;
  end;
  BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST, 1); // enable playlist processing
  BASS_SetConfig(BASS_CONFIG_NET_PREBUF, 0); // minimize automatic pre-buffering, so we can do it (and display it) instead
  BASS_PluginLoad(PChar('basshls.dll'), BASS_UNICODE);


returns error 41 and does not work


Regards
Leonardo

ak545

  • Posts: 6
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #43 on: 6 Oct '16 - 07:25 »
Leonardo

BASS_ERROR_FILEFORM    =41   ;unsupported file format
Error code 41 (is BASS_ERROR_FILEFORM), which means the file format wasn't recognised.

Code: [Select]
File: http://wz5.dnip.com.br/alternativa1fmhd/alternativa1fmhd.stream/playlist.m3u8
Code: 41 (00000029)
Message: Unsupported file format
-------------------------
HTTP/1.1 200 OK
Accept-Ranges: bytes
Server: WowzaStreamingEngine/4.4.1
Cache-Control: no-cache
Date: Thu, 06 Oct 2016 06:32:59 GMT
Content-Type: application/vnd.apple.mpegurl
Content-Length: 102


This problem was in the old version of the basshls.dll
In latest version of the basshls.dll everything works fine.
Look: https://youtu.be/_zHVM_HdR_s

Try add bass_aac.dll
Code: [Select]
BASS_PluginLoad(PChar('bass_aac.dll'), BASS_UNICODE);because Content-Type: application/vnd.apple.mpegurl


P.S.
And just
Before - Plugin Load
Code: [Select]
BASS_PluginLoad(PChar('basshls.dll'), BASS_UNICODE);
After - Bass Init
Code: [Select]
BASS_Init(-1, 44100, 0, Handle, nil);
« Last Edit: 6 Oct '16 - 08:18 by ak545 »

Pedro Leonardo

  • Posts: 80
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #44 on: 6 Oct '16 - 13:25 »
Hi
Thank you. Now it is working well

Regards

melvinlee.yk

  • Posts: 6
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #45 on: 12 Oct '16 - 10:21 »
Hi Ian,

I'm testing out the HLS lib on Android but keep getting Code Error 41 which is unsupported file error. Tried the following few URL but doesn't seems to work, but had verified the source it's working.
http://hls1.addictradio.net/addictalternative_aac_hls/playlist.m3u8
http://db3.indexcom.com/bucket/ram/00/05/05.m3u8

Updated latest libbass.so as well as the libbasshls.so

Here's a brief of my implementation:
Code: [Select]
private void play(Context context, String streamUrl) throws Exception {
        BASS.BASS_Init(-1, 44100, 0);
        BASS.BASS_PluginLoad(context.getApplicationInfo().nativeLibraryDir+"/libbasshls.so", 0); // load BASSHLS

        int audioOutStream = BASSHLS.BASS_HLS_StreamCreateURL(streamUrl, BASS.BASS_STREAM_AUTOFREE, streamDownloadCallback, 0);
        if(audioOutStream == 0){
            throw new Exception("Unable to create stream. BASS Error Code : " + BASS.BASS_ErrorGetCode());
        }

        BASS.BASS_SetConfig(BASS.BASS_CONFIG_NET_PLAYLIST, 1);
        BASS.BASS_ChannelSetSync(audioOutStream, BASS.BASS_SYNC_META, 0, metaSyncCallback, 0);
        BASS.BASS_ChannelSetSync(audioOutStream, BASS.BASS_SYNC_OGG_CHANGE, 0, metaSyncCallback, 0); // Icecast/OGG
        // set sync for end of stream
        BASS.BASS_ChannelSetSync(audioOutStream, BASS.BASS_SYNC_END, 0, endSyncCallback, 0);
        BASS.BASS_ChannelPlay(audioOutStream, false);
}

Appreciate in advance for any advise.

Thanks.


Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #46 on: 12 Oct '16 - 17:16 »
Those streams both use AAC encoding. BASS can use the OS's AAC decoder on OSX, iOS and Windows (Vista and above), but on other platforms the BASS_AAC add-on will need to be loaded via BASS_PluginLoad to play them.

Melvin

  • Guest
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #47 on: 13 Oct '16 - 09:23 »
Those streams both use AAC encoding. BASS can use the OS's AAC decoder on OSX, iOS and Windows (Vista and above), but on other platforms the BASS_AAC add-on will need to be loaded via BASS_PluginLoad to play them.

Thanks Ian, it's working now as per advised. Appreciate it   :)

melvinlee.yk

  • Posts: 6
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #48 on: 14 Oct '16 - 10:03 »
I don't think most HLS streams include metadata. In some cases, a title will be included in the EXTINF tag, which you can get via the new BASS_TAG_HLS_EXTINF option. For example, you could try something like this:

Code: [Select]
BASS_ChannelSetSync(stream, BASS_SYNC_HLS_SEGMENT, 0, HLSSegmentSyncProc, 0); // set sync on new HLS segment

...

void CALLBACK HLSSegmentSyncProc(HSYNC handle, DWORD channel, DWORD data, void *user)
{
const char *extinf=BASS_ChannelGetTags(channel, BASS_TAG_HLS_EXTINF); // get new segment's EXTINF tag
const char *title=strchr(extinf, ','); // look for duration/title separator
if (title && title[1]) SetTitle(title+1); // use title
}

Some streams may also have ID3v2 tags, which you can get via the BASS_TAG_ID3V2 tag option.

Hi Ian,

I've been trying to get the EXTINF from the following stream on Android:
http://hls1.addictradio.net/addictrock_aac_hls/playlist.m3u8

using the following implementation as referencing to yours,
Code: [Select]
        int audioOutStream = BASSHLS.BASS_HLS_StreamCreateURL(streamUrl, 0, streamDownloadCallback, 0);
        BASS.BASS_ChannelSetSync(audioOutStream, BASSHLS.BASS_SYNC_HLS_SEGMENT, 0, metaSyncCallback, 0);
        BASS.BASS_ChannelSetSync(audioOutStream, BASS.BASS_SYNC_END, 0, endSyncCallback, 0);
        BASS.BASS_ChannelPlay(audioOutStream, false);

Code: [Select]
    private class MetaSyncCallback implements BASS.SYNCPROC {
        @Override
        public void SYNCPROC(int handle, int channel, int data, Object user) {
            Object extinf = BASS.BASS_ChannelGetTags(audioOutStream, BASSHLS.BASS_TAG_HLS_EXTINF);
            Log.i("XXX", "EXTINF : " + extinf)
        }
    }

Just wondering am i missing out anything since the returns of BASS_ChannelGetTags() kept returning null values on it? but I guess the stream above does contains something.

Also, I'm getting something from ID3v2 Tag which has something like this, does it mean I need to further process this ByteBuffer in order to get the metadata?
Code: [Select]
java.nio.DirectByteBuffer[position=0,limit=109,capacity=109]

Thanks.

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #49 on: 14 Oct '16 - 17:06 »
Not all HLS streams include titles in the EXTINF tags, but that one does. I'm not sure if it will solve the problem you're having, but you should probably cast the BASS_ChannelGetTags return value to a String, like this:

Code: [Select]
String extinf = (String)BASS.BASS_ChannelGetTags(audioOutStream, BASSHLS.BASS_TAG_HLS_EXTINF);

That stream does also include ID3v2 tags (title and artist). You can use the Tags add-on to process them.

Code: [Select]
String title = TAGS.TAGS_Read(audioOutStream, "%ARTI - %TITL");

melvinlee.yk

  • Posts: 6
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #50 on: 17 Oct '16 - 04:01 »
Not all HLS streams include titles in the EXTINF tags, but that one does. I'm not sure if it will solve the problem you're having, but you should probably cast the BASS_ChannelGetTags return value to a String, like this:

Code: [Select]
String extinf = (String)BASS.BASS_ChannelGetTags(audioOutStream, BASSHLS.BASS_TAG_HLS_EXTINF);

That stream does also include ID3v2 tags (title and artist). You can use the Tags add-on to process them.

Code: [Select]
String title = TAGS.TAGS_Read(audioOutStream, "%ARTI - %TITL");

Hi Ian,

Thanks for the advise. However, the casting of
Code: [Select]
String extinf = (String)BASS.BASS_ChannelGetTags(audioOutStream, BASSHLS.BASS_TAG_HLS_EXTINF); doesn't seem to work as in the returns are still null.

But using
Code: [Select]
String title = TAGS.TAGS_Read(audioOutStream, "%ARTI - %TITL"); does allows me to see the Artist and Track within the Id3v2 tag.

Thanks.


« Last Edit: 17 Oct '16 - 04:18 by melvinlee.yk »

radio42

  • Posts: 4521
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #51 on: 17 Oct '16 - 08:12 »
Try this:
Code: [Select]
Utils.IntPtrAsStringUtf8(BASS_ChannelGetTags(handle, BASSTag.BASS_TAG_HLS_EXTINF));

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #52 on: 17 Oct '16 - 17:23 »
Thanks for the advise. However, the casting of
Code: [Select]
String extinf = (String)BASS.BASS_ChannelGetTags(audioOutStream, BASSHLS.BASS_TAG_HLS_EXTINF); doesn't seem to work as in the returns are still null.

Oh yes, I think I know what the problem is. The error code (from BASS_ErrorGetCode) is 501, isn't it? The JNI stuff for the BASS_TAG_HLS_EXTINF tag (to convert to Java string) hasn't been implemented yet. I will put up an update to correct that tomorrow.

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #53 on: 18 Oct '16 - 15:17 »
An update is now up in the 1st post, adding the missing JNI stuff for the BASS_TAG_HLS_EXTINF tag. This update also adds support for URLs that begin with "//" in the playlists, so all platforms have been updated.

An updated NETRADIO example has also been put in the Android BASS package, with support for HLS streams and displaying of the BASS_TAG_HLS_EXTINF tag.

melvinlee.yk

  • Posts: 6
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #54 on: 19 Oct '16 - 03:50 »
Thanks for the advise. However, the casting of
Code: [Select]
String extinf = (String)BASS.BASS_ChannelGetTags(audioOutStream, BASSHLS.BASS_TAG_HLS_EXTINF); doesn't seem to work as in the returns are still null.

Oh yes, I think I know what the problem is. The error code (from BASS_ErrorGetCode) is 501, isn't it? The JNI stuff for the BASS_TAG_HLS_EXTINF tag (to convert to Java string) hasn't been implemented yet. I will put up an update to correct that tomorrow.

Thanks a lot Ian.

Code: [Select]
BASS.BASS_ChannelGetTags(audioOutStream, BASSHLS.BASS_TAG_HLS_EXTINF); is now returning values with formats like below. Appreciate that.  ;)

Code: [Select]
10,title="Fever",artist="The Black Keys"

Rob Oldaker

  • Guest
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #55 on: 13 Dec '16 - 15:19 »
Hi,

I have been using the hls plug to see if I can stream the BBC IPlayer. Live radio streams work a treat:
example below:-
http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/ak/bbc_6music.m3u8

However the pre-recorded programmes they have don't work. This is an example url that fails:-
http://cp401492-vh.akamaihd.net/i/prod_af_mp4_heaacv1_48/iplayerstream/p04htkml_b085j6fh_1481406091165.mp4/index_0_a.m3u8
The error coming back is BASS_ERROR_FILEOPEN

Any ideas what might be wrong. The second stream plays ok in "https://www.hlsplayer.net/"

Thanks,

Rob.

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #56 on: 13 Dec '16 - 16:15 »
However the pre-recorded programmes they have don't work. This is an example url that fails:-
http://cp401492-vh.akamaihd.net/i/prod_af_mp4_heaacv1_48/iplayerstream/p04htkml_b085j6fh_1481406091165.mp4/index_0_a.m3u8
The error coming back is BASS_ERROR_FILEOPEN

What do you see if you download that M3U8 file and open it in a text editor? Trying that here, I see "An error occurred while processing your request", which would explain why it isn't working. Do you have another URL that does contain a valid M3U8 file and isn't playable with BASSHLS?

Rob Oldaker

  • Guest
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #57 on: 14 Dec '16 - 13:59 »
Hi,

I think the error maybe due to the streams becoming unavailable after a period of time. This is another stream that has the same errors:-
http://cp401492-vh.akamaihd.net/i/prod_af_mp4_heaacv1_48/iplayerstream/p04g738d_b082vyqf_1479742915685.mp4/index_0_a.m3u8?hdnea=st=1481723378~exp=1481744978~acl=/*p04g738d_b082vyqf_1479742915685.mp4*~hmac=813f0d8b0d6a36c11ae5cbee606dc9e450ff9df68861387f71b2daf0ec8de182

These are the first few lines of the downloaded .m3u8 file (there are a few hundred of the streams listed in the file):-
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-ALLOW-CACHE:YES
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:10.000,
http://cp401492-vh.akamaihd.net/i/prod_af_mp4_heaacv1_48/iplayerstream/p04g738d_b082vyqf_1479742915685.mp4/segment1_0_a.ts
#EXTINF:10.000,
http://cp401492-vh.akamaihd.net/i/prod_af_mp4_heaacv1_48/iplayerstream/p04g738d_b082vyqf_1479742915685.mp4/segment2_0_a.ts
#EXTINF:10.000,
http://cp401492-vh.akamaihd.net/i/prod_af_mp4_heaacv1_48/iplayerstream/p04g738d_b082vyqf_1479742915685.mp4/segment3_0_a.ts
#EXTINF:10.000,
http://cp401492-vh.akamaihd.net/i/prod_af_mp4_heaacv1_48/iplayerstream/p04g738d_b082vyqf_1479742915685.mp4/segment4_0_a.ts

Thanks,

Rob.

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #58 on: 14 Dec '16 - 17:23 »
Ah, I see the problem. The server is setting a cookie when sending the playlist and it requires that cookie to be included when requesting the playlist entries. Here's an update for you to try:

   www.un4seen.com/stuff/basshls.dll

Rob Oldaker

  • Guest
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #59 on: 19 Dec '16 - 19:46 »
Hi,

Thanks for the update, that worked!  :). The BBC IPlayer has multiple stream urls for each program they offer and the new plugin works fine with all the ones I have tried.

However, I am having an issue with setting the position of the stream. I use the method BASS_ChannelSetPosition, using the one with a "double" second parameter of the stream position in seconds. Its coming back with "BASS_ERROR_POSITION". Is this supported? I am using the channel in "decode" mode so am setting the flag to "BASSFlag.BASS_STREAM_DECODE|BASSFlag.BASS_SAMPLE_FLOAT".

Thanks,

Rob.

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #60 on: 20 Dec '16 - 15:37 »
Seeking in HLS streams isn't currently supported, but I guess that ability could be added for playlists that contain the entire stream (ie. include "EXT-X-PLAYLIST-TYPE"). I'll put that on the "look into it" list :)

In the meantime, one way you could implement seeking is to download the playlist and remove the media segments that you want to skip before passing it to BASSHLS (using mem=TRUE with BASS_HLS_StreamCreateFile). Note that the media segment URLs must be absolute (not relative) then so that BASSHLS knows where to find them. If you want to start at a mid-segment position, you can use the BASS_POS_DECODETO flag with BASS_ChannelSetPosition to achieve that.

Rob Oldaker

  • Guest
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #61 on: 20 Dec '16 - 20:24 »
OK, thanks for the response - I will give it a go.

rob.

Rob Oldaker

  • Guest
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #62 on: 22 Dec '16 - 09:28 »
Your suggestion worked great :). I didn't try setting the position within each segment but just set the position to the segment boundaries by manipulating the .m3u8 file downloaded.

Its very fast to start playing and seeking within the stream.

I don't think the fix you did for the cookies works with this method, however. The cookies get set when you download the .m3u8 and there is no way of telling the "StreamCreateFile" method what cookies are required for the stream segments. This is no big deal as there are three "types" of streams available and only one has the requirement for cookies.

Rob.

pzs7602

  • Posts: 50
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #63 on: 5 Feb '17 - 12:58 »
Is there a Windows Store version of BASSHLS available?

Ian @ un4seen

  • Administrator
  • Posts: 19894
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #64 on: 6 Feb '17 - 17:40 »
A Windows Store version has now been added to the package in the 1st post.

pzs7602

  • Posts: 50
Re: BASSHLS beta (HTTP Live Streaming add-on)
« Reply #65 on: 7 Feb '17 - 13:21 »
@Ian Thanks!