2018-06-28 08:44:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-07-09 07:09:06 +00:00
|
|
|
#include <QSemaphore>
|
|
|
|
|
2018-06-28 08:44:43 +00:00
|
|
|
#include <Limelight.h>
|
|
|
|
#include <opus_multistream.h>
|
|
|
|
#include "backend/computermanager.h"
|
2018-07-08 04:52:20 +00:00
|
|
|
#include "settings/streamingpreferences.h"
|
2018-06-28 08:44:43 +00:00
|
|
|
#include "input.hpp"
|
2018-07-18 03:00:16 +00:00
|
|
|
#include "video/decoder.h"
|
2018-07-08 04:52:20 +00:00
|
|
|
|
2018-07-07 23:30:26 +00:00
|
|
|
class Session : public QObject
|
2018-06-28 08:44:43 +00:00
|
|
|
{
|
2018-07-07 23:30:26 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2018-07-08 04:52:20 +00:00
|
|
|
friend class SdlInputHandler;
|
2018-07-09 07:09:06 +00:00
|
|
|
friend class DeferredSessionCleanupTask;
|
2018-07-08 04:52:20 +00:00
|
|
|
|
2018-06-28 08:44:43 +00:00
|
|
|
public:
|
|
|
|
explicit Session(NvComputer* computer, NvApp& app);
|
|
|
|
|
2018-07-07 23:30:26 +00:00
|
|
|
Q_INVOKABLE void exec();
|
|
|
|
|
2018-07-26 07:41:46 +00:00
|
|
|
static
|
|
|
|
bool isHardwareDecodeAvailable(StreamingPreferences::VideoDecoderSelection vds,
|
|
|
|
int videoFormat, int width, int height, int frameRate);
|
|
|
|
|
2018-08-25 20:36:54 +00:00
|
|
|
static
|
|
|
|
int getDecoderCapabilities(StreamingPreferences::VideoDecoderSelection vds,
|
|
|
|
int videoFormat, int width, int height, int frameRate);
|
|
|
|
|
2018-07-07 23:30:26 +00:00
|
|
|
signals:
|
|
|
|
void stageStarting(QString stage);
|
2018-06-28 08:44:43 +00:00
|
|
|
|
2018-07-07 23:30:26 +00:00
|
|
|
void stageFailed(QString stage, long errorCode);
|
2018-06-28 08:44:43 +00:00
|
|
|
|
2018-07-07 23:30:26 +00:00
|
|
|
void connectionStarted();
|
|
|
|
|
|
|
|
void displayLaunchError(QString text);
|
|
|
|
|
|
|
|
void displayLaunchWarning(QString text);
|
2018-06-28 08:44:43 +00:00
|
|
|
|
|
|
|
private:
|
2018-07-07 23:30:26 +00:00
|
|
|
bool validateLaunch();
|
|
|
|
|
2018-08-04 23:05:37 +00:00
|
|
|
void emitLaunchWarning(QString text);
|
|
|
|
|
2018-07-08 04:52:20 +00:00
|
|
|
int getDecoderCapabilities();
|
|
|
|
|
|
|
|
int sdlDetermineAudioConfiguration();
|
|
|
|
|
2018-08-31 04:09:31 +00:00
|
|
|
bool testAudio(int audioConfiguration);
|
|
|
|
|
2018-07-20 23:01:22 +00:00
|
|
|
void getWindowDimensions(bool fullScreen,
|
|
|
|
int& x, int& y,
|
|
|
|
int& width, int& height);
|
|
|
|
|
|
|
|
void toggleFullscreen();
|
|
|
|
|
2018-07-18 03:00:16 +00:00
|
|
|
static
|
|
|
|
bool chooseDecoder(StreamingPreferences::VideoDecoderSelection vds,
|
|
|
|
SDL_Window* window, int videoFormat, int width, int height,
|
2018-08-21 01:19:42 +00:00
|
|
|
int frameRate, bool enableVsync, IVideoDecoder*& chosenDecoder);
|
2018-07-08 04:52:20 +00:00
|
|
|
|
2018-06-28 08:44:43 +00:00
|
|
|
static
|
|
|
|
void clStageStarting(int stage);
|
|
|
|
|
|
|
|
static
|
|
|
|
void clStageFailed(int stage, long errorCode);
|
|
|
|
|
|
|
|
static
|
|
|
|
void clConnectionTerminated(long errorCode);
|
|
|
|
|
|
|
|
static
|
|
|
|
void clLogMessage(const char* format, ...);
|
|
|
|
|
|
|
|
static
|
2018-07-08 04:52:20 +00:00
|
|
|
int drSetup(int videoFormat, int width, int height, int frameRate, void*, int);
|
|
|
|
|
|
|
|
static
|
|
|
|
void drCleanup();
|
|
|
|
|
|
|
|
static
|
|
|
|
int drSubmitDecodeUnit(PDECODE_UNIT du);
|
2018-06-28 08:44:43 +00:00
|
|
|
|
|
|
|
static
|
|
|
|
int sdlAudioInit(int audioConfiguration,
|
|
|
|
POPUS_MULTISTREAM_CONFIGURATION opusConfig,
|
|
|
|
void* arContext, int arFlags);
|
|
|
|
|
|
|
|
static
|
|
|
|
void sdlAudioStart();
|
|
|
|
|
|
|
|
static
|
|
|
|
void sdlAudioStop();
|
|
|
|
|
|
|
|
static
|
|
|
|
void sdlAudioCleanup();
|
|
|
|
|
|
|
|
static
|
|
|
|
void sdlAudioDecodeAndPlaySample(char* sampleData, int sampleLength);
|
|
|
|
|
2018-07-08 04:52:20 +00:00
|
|
|
StreamingPreferences m_Preferences;
|
2018-06-28 08:44:43 +00:00
|
|
|
STREAM_CONFIGURATION m_StreamConfig;
|
2018-07-08 04:52:20 +00:00
|
|
|
DECODER_RENDERER_CALLBACKS m_VideoCallbacks;
|
2018-06-28 08:44:43 +00:00
|
|
|
NvComputer* m_Computer;
|
|
|
|
NvApp m_App;
|
2018-07-08 04:52:20 +00:00
|
|
|
SDL_Window* m_Window;
|
2018-07-18 03:00:16 +00:00
|
|
|
IVideoDecoder* m_VideoDecoder;
|
|
|
|
SDL_SpinLock m_DecoderLock;
|
2018-07-20 22:31:57 +00:00
|
|
|
bool m_NeedsIdr;
|
2018-08-31 04:09:31 +00:00
|
|
|
bool m_AudioDisabled;
|
2018-07-20 22:31:57 +00:00
|
|
|
|
|
|
|
int m_ActiveVideoFormat;
|
|
|
|
int m_ActiveVideoWidth;
|
|
|
|
int m_ActiveVideoHeight;
|
|
|
|
int m_ActiveVideoFrameRate;
|
2018-06-28 08:44:43 +00:00
|
|
|
|
|
|
|
static SDL_AudioDeviceID s_AudioDevice;
|
|
|
|
static OpusMSDecoder* s_OpusDecoder;
|
|
|
|
static short s_OpusDecodeBuffer[];
|
|
|
|
static int s_ChannelCount;
|
2018-07-16 03:17:08 +00:00
|
|
|
static int s_PendingDrops;
|
2018-07-16 04:43:43 +00:00
|
|
|
static int s_PendingHardDrops;
|
2018-07-16 03:17:08 +00:00
|
|
|
static unsigned int s_SampleIndex;
|
2018-07-16 04:43:43 +00:00
|
|
|
static Uint32 s_BaselinePendingData;
|
2018-06-28 08:44:43 +00:00
|
|
|
|
|
|
|
static AUDIO_RENDERER_CALLBACKS k_AudioCallbacks;
|
|
|
|
static CONNECTION_LISTENER_CALLBACKS k_ConnCallbacks;
|
|
|
|
static Session* s_ActiveSession;
|
2018-07-09 07:09:06 +00:00
|
|
|
static QSemaphore s_ActiveSessionSemaphore;
|
2018-06-28 08:44:43 +00:00
|
|
|
};
|