atrooney-online-2/test/test_bass.cpp
TrickyLeifa c9f52b7223 Ported to CMake, ...
* Ported the project to CMake
  * Android and Mac support dropped for the time
being.
  * Tests, BASS and Discord-RPC are now options
* Restructured and reformated the project.
  * Merged `include` and `src`
  * Renamed `resource` to `data`
  * Renamed various files
  * External libraries headers are no longer included in `src`
  * Replaced header guards with #pragma once
  * Multiple refactors (keywords, headers)
  * Added Qt6 compatibility
* Removed various unused functions and headers
* Reworked AOPacket
  * When content is passed to AOPacket, it should be ensured that the content is already decoded.
  * Encoding/decoding are now static methods.
* Fixed various memory leaks
* Removed animation code for AOImage
  * AOImage is always using static images
* Simplified ChatLogPiece
2024-05-15 00:04:16 +02:00

47 lines
1.1 KiB
C++

#include <cstring>
#include <iostream>
#include <QString>
#include <catch2/catch.hpp>
#include "bass.h"
#include "bassmidi.h"
#include "bassopus.h"
TEST_CASE("BASS URL streaming", "[bass][noci]")
{
// Sample
QString url = "https://raw.githubusercontent.com/skyedeving/aocharedit/master/Attorney%20Online%20Character%20Editor/Resources/about.mp3";
// initialize
BASS_Init(-1, 44100, 0, 0, nullptr);
// create stream from url
HSTREAM stream;
unsigned int flags = BASS_STREAM_AUTOFREE | BASS_STREAM_STATUS;
if (url.endsWith(".opus"))
{
stream = BASS_OPUS_StreamCreateURL(url.toStdString().c_str(), 0, flags, nullptr, 0);
}
else
{
stream = BASS_StreamCreateURL(url.toStdString().c_str(), 0, flags, nullptr, 0);
}
// Log http status
const char *tags = BASS_ChannelGetTags(stream, BASS_TAG_HTTP);
if (tags)
{
while (*tags)
{
UNSCOPED_INFO(tags);
tags += strlen(tags) + 1;
}
}
// Test
REQUIRE(stream != 0);
REQUIRE(BASS_ChannelPlay(stream, TRUE) == TRUE);
// while (BASS_ChannelIsActive(stream) != BASS_ACTIVE_STOPPED); // block test to listen
}