فهرست منبع

UI: Add popup warnings for connection failure

Also, check for null stream path/key in the RTMP output module.
jp9000 11 سال پیش
والد
کامیت
03ca5919ce
7فایلهای تغییر یافته به همراه90 افزوده شده و 28 حذف شده
  1. 8 0
      build/data/obs-studio/locale/en.txt
  2. 1 1
      libobs/obs-defs.h
  3. 5 3
      libobs/obs-output.c
  4. 7 0
      libobs/util/base.h
  5. 56 22
      obs/window-basic-main.cpp
  6. 1 1
      obs/window-basic-main.hpp
  7. 12 1
      plugins/obs-outputs/rtmp-stream.c

+ 8 - 0
build/data/obs-studio/locale/en.txt

@@ -26,6 +26,14 @@ NameExists.Text="The name is already in use."
 
 NoNameEntered="Please enter a valid name"
 
+# output connect messages
+Output.ConnectFail.Title="Failed to connect"
+Output.ConnectFail.BadPath="Invalid Path or Connection URL.  Please check your settings to confirm that they are valid."
+Output.ConnectFail.ConnectFailed="Failed to connect to server"
+Output.ConnectFail.InvalidStream="Could not access the specified channel or stream key.  This could be because the key/channel is invalid, or because the server still thinks you are logged in."
+Output.ConnectFail.Error="An unexpected error occurred when trying to connect to the server.  More information in the log file."
+Output.ConnectFail.Disconnected="Disconnected from server."
+
 # audio device names
 Basic.DesktopDevice1="Desktop Audio"
 Basic.DesktopDevice2="Desktop Audio 2"

+ 1 - 1
libobs/obs-defs.h

@@ -30,5 +30,5 @@
 #define OBS_OUTPUT_BAD_PATH       -1
 #define OBS_OUTPUT_CONNECT_FAILED -2
 #define OBS_OUTPUT_INVALID_STREAM -3
-#define OBS_OUTPUT_FAIL           -4
+#define OBS_OUTPUT_ERROR          -4
 #define OBS_OUTPUT_DISCONNECTED   -5

+ 5 - 3
libobs/obs-output.c

@@ -37,8 +37,10 @@ const char *obs_output_getdisplayname(const char *id, const char *locale)
 }
 
 static const char *output_signals[] = {
-	"void start(ptr output, int errorcode)",
-	"void stop(ptr output)",
+	"void start(ptr output)",
+	"void stop(ptr output, int code)",
+	"void reconnect(ptr output)",
+	"void reconnect_success(ptr output)",
 	NULL
 };
 
@@ -519,7 +521,7 @@ static inline void signal_start(struct obs_output *output)
 static inline void signal_stop(struct obs_output *output, int code)
 {
 	struct calldata params = {0};
-	calldata_setint(&params, "errorcode", code);
+	calldata_setint(&params, "code", code);
 	calldata_setptr(&params, "output", output);
 	signal_handler_signal(output->context.signals, "stop", &params);
 	calldata_free(&params);

+ 7 - 0
libobs/util/base.h

@@ -28,6 +28,13 @@
 extern "C" {
 #endif
 
+#define STRINGIFY(x) #x
+#define STRINGIFY_(x) STRINGIFY(x)
+#define S__LINE__ STRINGIFY_(__LINE__)
+
+#define INT_CUR_LINE __LINE__
+#define FILE_LINE __FILE__ " (" S__LINE__ "): "
+
 enum {
 	/**
 	 * Use if there's a problem that can potentially affect the program,

+ 56 - 22
obs/window-basic-main.cpp

@@ -144,14 +144,14 @@ static void LoadAudioDevice(const char *name, int channel, obs_data_t parent)
 
 void OBSBasic::CreateDefaultScene()
 {
-	obs_scene_t  scene  = obs_scene_create(Str("Studio.Basic.Scene"));
+	obs_scene_t  scene  = obs_scene_create(Str("Basic.Scene"));
 	obs_source_t source = obs_scene_getsource(scene);
 
 	obs_add_source(source);
 
 #ifdef __APPLE__
 	source = obs_source_create(OBS_SOURCE_TYPE_INPUT, "display_capture",
-			Str("Studio.Basic.DisplayCapture"), NULL);
+			Str("Basic.DisplayCapture"), NULL);
 
 	if (source) {
 		obs_scene_add(scene, source);
@@ -226,7 +226,7 @@ static void OBSStartStreaming(void *data, calldata_t params)
 
 static void OBSStopStreaming(void *data, calldata_t params)
 {
-	int code = (int)calldata_int(params, "errorcode");
+	int code = (int)calldata_int(params, "code");
 	QMetaObject::invokeMethod(static_cast<OBSBasic*>(data),
 			"StreamingStop", Q_ARG(int, code));
 }
@@ -387,9 +387,9 @@ bool OBSBasic::InitBasicConfig()
 {
 	BPtr<char> configPath(os_get_config_path("obs-studio/basic/basic.ini"));
 
-	int errorcode = basicConfig.Open(configPath, CONFIG_OPEN_ALWAYS);
-	if (errorcode != CONFIG_SUCCESS) {
-		OBSErrorBox(NULL, "Failed to open basic.ini: %d", errorcode);
+	int code = basicConfig.Open(configPath, CONFIG_OPEN_ALWAYS);
+	if (code != CONFIG_SUCCESS) {
+		OBSErrorBox(NULL, "Failed to open basic.ini: %d", code);
 		return false;
 	}
 
@@ -809,7 +809,7 @@ bool OBSBasic::ResetAudio()
 }
 
 void OBSBasic::ResetAudioDevice(const char *sourceId, const char *deviceName,
-		int channel)
+		const char *deviceDesc, int channel)
 {
 	const char *deviceId = config_get_string(basicConfig, "Audio",
 			deviceName);
@@ -835,7 +835,7 @@ void OBSBasic::ResetAudioDevice(const char *sourceId, const char *deviceName,
 		obs_data_t settings = obs_data_create();
 		obs_data_setstring(settings, "device_id", deviceId);
 		source = obs_source_create(OBS_SOURCE_TYPE_INPUT,
-				sourceId, Str(deviceName), settings);
+				sourceId, deviceDesc, settings);
 		obs_data_release(settings);
 
 		obs_set_output_source(channel, source);
@@ -845,11 +845,16 @@ void OBSBasic::ResetAudioDevice(const char *sourceId, const char *deviceName,
 
 void OBSBasic::ResetAudioDevices()
 {
-	ResetAudioDevice(App()->OutputAudioSource(), "DesktopDevice1", 1);
-	ResetAudioDevice(App()->OutputAudioSource(), "DesktopDevice2", 2);
-	ResetAudioDevice(App()->InputAudioSource(),  "AuxDevice1", 3);
-	ResetAudioDevice(App()->InputAudioSource(),  "AuxDevice2", 4);
-	ResetAudioDevice(App()->InputAudioSource(),  "AuxDevice3", 5);
+	ResetAudioDevice(App()->OutputAudioSource(), "DesktopDevice1",
+			Str("Basic.DesktopDevice1"), 1);
+	ResetAudioDevice(App()->OutputAudioSource(), "DesktopDevice2",
+			Str("Basic.DesktopDevice2"), 2);
+	ResetAudioDevice(App()->InputAudioSource(),  "AuxDevice1",
+			Str("Basic.AuxDevice1"), 3);
+	ResetAudioDevice(App()->InputAudioSource(),  "AuxDevice2",
+			Str("Basic.AuxDevice2"), 4);
+	ResetAudioDevice(App()->InputAudioSource(),  "AuxDevice3",
+			Str("Basic.AuxDevice3"), 5);
 }
 
 void OBSBasic::ResizePreview(uint32_t cx, uint32_t cy)
@@ -962,16 +967,16 @@ void OBSBasic::on_actionAddScene_triggered()
 	QString placeHolderText = format.arg(ui->scenes->count() + 1);
 
 	bool accepted = NameDialog::AskForName(this,
-			QTStr("MainWindow.AddSceneDlg.Title"),
-			QTStr("MainWindow.AddSceneDlg.Text"),
+			QTStr("Basic.Main.AddSceneDlg.Title"),
+			QTStr("Basic.Main.AddSceneDlg.Text"),
 			name,
 			placeHolderText);
 
 	if (accepted) {
 		if (name.empty()) {
 			QMessageBox::information(this,
-					QTStr("MainWindow.NoNameEntered"),
-					QTStr("MainWindow.NoNameEntered"));
+					QTStr("NoNameEntered"),
+					QTStr("NoNameEntered"));
 			on_actionAddScene_triggered();
 			return;
 		}
@@ -979,8 +984,8 @@ void OBSBasic::on_actionAddScene_triggered()
 		obs_source_t source = obs_get_source_by_name(name.c_str());
 		if (source) {
 			QMessageBox::information(this,
-					QTStr("MainWindow.NameExists.Title"),
-					QTStr("MainWindow.NameExists.Text"));
+					QTStr("NameExists.Title"),
+					QTStr("NameExists.Text"));
 
 			obs_source_release(source);
 			on_actionAddScene_triggered();
@@ -1118,10 +1123,39 @@ void OBSBasic::StreamingStart()
 	ui->streamButton->setText("Stop Streaming");
 }
 
-void OBSBasic::StreamingStop(int errorcode)
+void OBSBasic::StreamingStop(int code)
 {
-	UNUSED_PARAMETER(errorcode);
-	ui->streamButton->setText("Start Streaming");
+	const char *errorMessage;
+
+	switch (code) {
+	case OBS_OUTPUT_BAD_PATH:
+		errorMessage = Str("Output.ConnectFail.BadPath");
+		break;
+
+	case OBS_OUTPUT_CONNECT_FAILED:
+		errorMessage = Str("Output.ConnectFail.ConnectFailed");
+		break;
+
+	case OBS_OUTPUT_INVALID_STREAM:
+		errorMessage = Str("Output.ConnectFail.InvalidStream");
+		break;
+
+	case OBS_OUTPUT_ERROR:
+		errorMessage = Str("Output.ConnectFail.Error");
+		break;
+
+	case OBS_OUTPUT_DISCONNECTED:
+		/* doesn't happen if output is set to reconnect.  note that
+		 * reconnects are handled in the output, not in the UI */
+		errorMessage = Str("Output.ConnectFail.Disconnected");
+	}
+
+	ui->streamButton->setText(QTStr("Basic.Main.StartStreaming"));
+
+	if (code != OBS_OUTPUT_SUCCESS)
+		QMessageBox::information(this,
+				QTStr("Output.ConnectFail.Title"),
+				QT_UTF8(errorMessage));
 }
 
 void OBSBasic::on_streamButton_clicked()

+ 1 - 1
obs/window-basic-main.hpp

@@ -135,7 +135,7 @@ public:
 	bool ResetAudio();
 
 	void ResetAudioDevice(const char *sourceId, const char *deviceName,
-			int channel);
+			const char *deviceDesc, int channel);
 	void ResetAudioDevices();
 
 	void NewProject();

+ 12 - 1
plugins/obs-outputs/rtmp-stream.c

@@ -352,7 +352,8 @@ static int init_send(struct rtmp_stream *stream)
 	ret = pthread_create(&stream->send_thread, NULL, send_thread, stream);
 	if (ret != 0) {
 		RTMP_Close(&stream->rtmp);
-		return OBS_OUTPUT_FAIL;
+		blog(LOG_ERROR, __FILE__": Failed to create send thread");
+		return OBS_OUTPUT_ERROR;
 	}
 
 	stream->active = true;
@@ -365,6 +366,16 @@ static int init_send(struct rtmp_stream *stream)
 static int try_connect(struct rtmp_stream *stream)
 {
 #ifndef FILE_TEST
+	if (dstr_isempty(&stream->path)) {
+		blog(LOG_WARNING, FILE_LINE "URL is empty");
+		return OBS_OUTPUT_BAD_PATH;
+	}
+
+	if (dstr_isempty(&stream->key)) {
+		blog(LOG_WARNING, FILE_LINE "Stream key is empty");
+		return OBS_OUTPUT_BAD_PATH;
+	}
+
 	blog(LOG_INFO, "Connecting to RTMP URL %s...", stream->path.array);
 
 	if (!RTMP_SetupURL2(&stream->rtmp, stream->path.array,