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>
|
2018-07-08 04:52:20 +00:00
|
|
|
#include "settings/streamingpreferences.h"
|
2020-05-01 03:09:36 +00:00
|
|
|
#include "input/input.h"
|
2018-07-18 03:00:16 +00:00
|
|
|
#include "video/decoder.h"
|
2018-09-13 13:23:06 +00:00
|
|
|
#include "audio/renderers/renderer.h"
|
2019-01-20 07:05:56 +00:00
|
|
|
#include "video/overlaymanager.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;
|
2020-08-11 05:21:54 +00:00
|
|
|
friend class AsyncConnectionStartThread;
|
2018-07-08 04:52:20 +00:00
|
|
|
|
2018-06-28 08:44:43 +00:00
|
|
|
public:
|
2018-09-29 21:06:55 +00:00
|
|
|
explicit Session(NvComputer* computer, NvApp& app, StreamingPreferences *preferences = nullptr);
|
2018-06-28 08:44:43 +00:00
|
|
|
|
2018-12-06 03:49:06 +00:00
|
|
|
virtual ~Session();
|
|
|
|
|
2018-09-05 22:15:53 +00:00
|
|
|
Q_INVOKABLE void exec(int displayOriginX, int displayOriginY);
|
2018-07-07 23:30:26 +00:00
|
|
|
|
2018-07-26 07:41:46 +00:00
|
|
|
static
|
2020-02-09 19:35:05 +00:00
|
|
|
void getDecoderInfo(SDL_Window* window,
|
2020-02-23 08:43:43 +00:00
|
|
|
bool& isHardwareAccelerated, bool& isFullScreenOnly, QSize& maxResolution);
|
2018-07-26 07:41:46 +00:00
|
|
|
|
2019-01-20 07:05:56 +00:00
|
|
|
static Session* get()
|
|
|
|
{
|
|
|
|
return s_ActiveSession;
|
|
|
|
}
|
|
|
|
|
2019-02-13 02:43:38 +00:00
|
|
|
Overlay::OverlayManager& getOverlayManager()
|
2019-01-20 07:05:56 +00:00
|
|
|
{
|
|
|
|
return m_OverlayManager;
|
|
|
|
}
|
|
|
|
|
2021-01-09 23:51:25 +00:00
|
|
|
void flushWindowEvents();
|
|
|
|
|
2018-07-07 23:30:26 +00:00
|
|
|
signals:
|
|
|
|
void stageStarting(QString stage);
|
2018-06-28 08:44:43 +00:00
|
|
|
|
2020-12-23 19:56:15 +00:00
|
|
|
void stageFailed(QString stage, int errorCode, QString failingPorts);
|
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
|
|
|
|
2018-12-06 03:49:06 +00:00
|
|
|
void quitStarting();
|
|
|
|
|
2020-08-09 00:59:26 +00:00
|
|
|
void sessionFinished(int portTestResult);
|
2018-12-06 03:49:06 +00:00
|
|
|
|
2018-06-28 08:44:43 +00:00
|
|
|
private:
|
2019-03-24 00:46:42 +00:00
|
|
|
bool initialize();
|
2018-09-09 17:17:32 +00:00
|
|
|
|
2020-08-11 05:21:54 +00:00
|
|
|
bool startConnectionAsync();
|
|
|
|
|
2019-03-24 00:46:42 +00:00
|
|
|
bool validateLaunch(SDL_Window* testWindow);
|
2018-07-07 23:30:26 +00:00
|
|
|
|
2018-08-04 23:05:37 +00:00
|
|
|
void emitLaunchWarning(QString text);
|
|
|
|
|
2019-12-14 23:20:44 +00:00
|
|
|
bool populateDecoderProperties(SDL_Window* window);
|
2018-07-08 04:52:20 +00:00
|
|
|
|
2019-07-26 16:50:45 +00:00
|
|
|
IAudioRenderer* createAudioRenderer(const POPUS_MULTISTREAM_CONFIGURATION opusConfig);
|
2018-07-08 04:52:20 +00:00
|
|
|
|
2018-08-31 04:09:31 +00:00
|
|
|
bool testAudio(int audioConfiguration);
|
|
|
|
|
2019-07-26 16:50:45 +00:00
|
|
|
int getAudioRendererCapabilities(int audioConfiguration);
|
2019-06-23 19:49:37 +00:00
|
|
|
|
2018-09-05 22:45:36 +00:00
|
|
|
void getWindowDimensions(int& x, int& y,
|
2018-07-20 23:01:22 +00:00
|
|
|
int& width, int& height);
|
|
|
|
|
|
|
|
void toggleFullscreen();
|
|
|
|
|
2019-05-19 20:10:42 +00:00
|
|
|
void notifyMouseEmulationMode(bool enabled);
|
|
|
|
|
2018-09-04 02:54:41 +00:00
|
|
|
void updateOptimalWindowDisplayMode();
|
|
|
|
|
2020-02-09 19:35:05 +00:00
|
|
|
static
|
|
|
|
bool isHardwareDecodeAvailable(SDL_Window* window,
|
|
|
|
StreamingPreferences::VideoDecoderSelection vds,
|
|
|
|
int videoFormat, int width, int height, int frameRate);
|
|
|
|
|
2018-07-18 03:00:16 +00:00
|
|
|
static
|
|
|
|
bool chooseDecoder(StreamingPreferences::VideoDecoderSelection vds,
|
|
|
|
SDL_Window* window, int videoFormat, int width, int height,
|
2018-12-25 20:57:00 +00:00
|
|
|
int frameRate, bool enableVsync, bool enableFramePacing,
|
2019-02-13 02:42:53 +00:00
|
|
|
bool testOnly,
|
2018-12-25 20:57:00 +00:00
|
|
|
IVideoDecoder*& chosenDecoder);
|
2018-07-08 04:52:20 +00:00
|
|
|
|
2018-06-28 08:44:43 +00:00
|
|
|
static
|
|
|
|
void clStageStarting(int stage);
|
|
|
|
|
|
|
|
static
|
2020-02-25 07:03:34 +00:00
|
|
|
void clStageFailed(int stage, int errorCode);
|
2018-06-28 08:44:43 +00:00
|
|
|
|
|
|
|
static
|
2020-02-25 07:03:34 +00:00
|
|
|
void clConnectionTerminated(int errorCode);
|
2018-06-28 08:44:43 +00:00
|
|
|
|
|
|
|
static
|
|
|
|
void clLogMessage(const char* format, ...);
|
|
|
|
|
2019-02-12 05:39:55 +00:00
|
|
|
static
|
|
|
|
void clRumble(unsigned short controllerNumber, unsigned short lowFreqMotor, unsigned short highFreqMotor);
|
|
|
|
|
2019-03-17 22:08:21 +00:00
|
|
|
static
|
|
|
|
void clConnectionStatusUpdate(int connectionStatus);
|
|
|
|
|
2018-06-28 08:44:43 +00:00
|
|
|
static
|
2018-09-13 13:23:06 +00:00
|
|
|
int arInit(int audioConfiguration,
|
|
|
|
const POPUS_MULTISTREAM_CONFIGURATION opusConfig,
|
|
|
|
void* arContext, int arFlags);
|
2018-07-08 04:52:20 +00:00
|
|
|
|
|
|
|
static
|
2018-09-13 13:23:06 +00:00
|
|
|
void arCleanup();
|
2018-06-28 08:44:43 +00:00
|
|
|
|
|
|
|
static
|
2018-09-13 13:23:06 +00:00
|
|
|
void arDecodeAndPlaySample(char* sampleData, int sampleLength);
|
2018-06-28 08:44:43 +00:00
|
|
|
|
|
|
|
static
|
2018-09-13 13:23:06 +00:00
|
|
|
int drSetup(int videoFormat, int width, int height, int frameRate, void*, int);
|
2018-06-28 08:44:43 +00:00
|
|
|
|
|
|
|
static
|
2018-09-13 13:23:06 +00:00
|
|
|
void drCleanup();
|
2018-06-28 08:44:43 +00:00
|
|
|
|
|
|
|
static
|
2018-09-13 13:23:06 +00:00
|
|
|
int drSubmitDecodeUnit(PDECODE_UNIT du);
|
2018-06-28 08:44:43 +00:00
|
|
|
|
2018-09-29 21:06:55 +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;
|
2019-06-23 19:49:37 +00:00
|
|
|
AUDIO_RENDERER_CALLBACKS m_AudioCallbacks;
|
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;
|
2020-12-25 21:32:11 +00:00
|
|
|
bool m_AudioMuted;
|
2018-09-04 02:17:34 +00:00
|
|
|
Uint32 m_FullScreenFlag;
|
2018-09-05 22:15:53 +00:00
|
|
|
int m_DisplayOriginX;
|
|
|
|
int m_DisplayOriginY;
|
2018-09-08 23:01:35 +00:00
|
|
|
bool m_PendingWindowedTransition;
|
2018-12-06 06:17:26 +00:00
|
|
|
bool m_UnexpectedTermination;
|
2019-02-12 05:39:55 +00:00
|
|
|
SdlInputHandler* m_InputHandler;
|
2019-02-13 03:30:02 +00:00
|
|
|
SDL_SpinLock m_InputHandlerLock;
|
2019-05-19 20:10:42 +00:00
|
|
|
int m_MouseEmulationRefCount;
|
2021-01-15 01:28:21 +00:00
|
|
|
int m_FlushingWindowEventsRef;
|
2018-07-20 22:31:57 +00:00
|
|
|
|
2020-08-11 05:21:54 +00:00
|
|
|
bool m_AsyncConnectionSuccess;
|
|
|
|
int m_PortTestResults;
|
2020-08-09 00:59:26 +00:00
|
|
|
|
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
|
|
|
|
2018-09-13 13:23:06 +00:00
|
|
|
OpusMSDecoder* m_OpusDecoder;
|
|
|
|
IAudioRenderer* m_AudioRenderer;
|
|
|
|
OPUS_MULTISTREAM_CONFIGURATION m_AudioConfig;
|
2018-10-02 08:21:42 +00:00
|
|
|
int m_AudioSampleCount;
|
2019-02-15 06:32:54 +00:00
|
|
|
Uint32 m_DropAudioEndTime;
|
2018-06-28 08:44:43 +00:00
|
|
|
|
2019-02-13 02:43:38 +00:00
|
|
|
Overlay::OverlayManager m_OverlayManager;
|
2019-01-20 07:05:56 +00:00
|
|
|
|
2018-06-28 08:44:43 +00:00
|
|
|
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
|
|
|
};
|