瀏覽代碼

UI: Add option to automatically record while streaming

Allows the ability for users to make it so recording automatically
starts when they start streaming.  Also adds the option to allow the
recording to continue when stream is stopped.

Closes jp9000/obs-studio#554
cg2121 9 年之前
父節點
當前提交
2dfb211956
共有 5 個文件被更改,包括 175 次插入98 次删除
  1. 2 0
      obs/data/locale/en-US.ini
  2. 127 94
      obs/forms/OBSBasicSettings.ui
  3. 4 0
      obs/obs-app.cpp
  4. 23 3
      obs/window-basic-main.cpp
  5. 19 1
      obs/window-basic-settings.cpp

+ 2 - 0
obs/data/locale/en-US.ini

@@ -365,6 +365,8 @@ Basic.Settings.General.ScreenSnapping="Snap Sources to edge of screen"
 Basic.Settings.General.CenterSnapping="Snap Sources to horizontal and vertical center"
 Basic.Settings.General.SourceSnapping="Snap Sources to other sources"
 Basic.Settings.General.SnapDistance="Snap Sensitivity"
+Basic.Settings.General.RecordWhenStreaming="Automatically record when streaming"
+Basic.Settings.General.KeepRecordingWhenStreamStops="Keep recording when stream stops"
 
 # basic mode 'stream' settings
 Basic.Settings.Stream="Stream"

+ 127 - 94
obs/forms/OBSBasicSettings.ui

@@ -185,14 +185,21 @@
            </property>
           </widget>
          </item>
-         <item row="6" column="0" colspan="2">
+         <item row="6" column="1">
+          <widget class="QCheckBox" name="recordWhenStreaming">
+           <property name="text">
+            <string>Basic.Settings.General.RecordWhenStreaming</string>
+           </property>
+          </widget>
+         </item>
+         <item row="8" column="0" colspan="2">
           <widget class="Line" name="line_4">
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
           </widget>
          </item>
-         <item row="7" column="0" colspan="2">
+         <item row="9" column="0" colspan="2">
           <widget class="QGroupBox" name="groupBox_10">
            <property name="enabled">
             <bool>true</bool>
@@ -292,6 +299,16 @@
            </property>
           </widget>
          </item>
+         <item row="7" column="1">
+          <widget class="QCheckBox" name="keepRecordStreamStops">
+           <property name="enabled">
+            <bool>false</bool>
+           </property>
+           <property name="text">
+            <string>Basic.Settings.General.KeepRecordingWhenStreamStops</string>
+           </property>
+          </widget>
+         </item>
         </layout>
        </widget>
        <widget class="QWidget" name="streamPage">
@@ -2504,8 +2521,8 @@
              <rect>
               <x>0</x>
               <y>0</y>
-              <width>80</width>
-              <height>16</height>
+              <width>98</width>
+              <height>28</height>
              </rect>
             </property>
            </widget>
@@ -3299,8 +3316,8 @@
    <slot>setCurrentIndex(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>159</x>
-     <y>34</y>
+     <x>310</x>
+     <y>29</y>
     </hint>
     <hint type="destinationlabel">
      <x>241</x>
@@ -3315,8 +3332,8 @@
    <slot>setCurrentIndex(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>586</x>
-     <y>38</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
     <hint type="destinationlabel">
      <x>250</x>
@@ -3331,12 +3348,12 @@
    <slot>setVisible(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>875</x>
-     <y>360</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
     <hint type="destinationlabel">
-     <x>875</x>
-     <y>427</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
    </hints>
   </connection>
@@ -3347,12 +3364,12 @@
    <slot>setVisible(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>875</x>
-     <y>360</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
     <hint type="destinationlabel">
-     <x>466</x>
-     <y>427</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
    </hints>
   </connection>
@@ -3363,12 +3380,12 @@
    <slot>setVisible(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>875</x>
-     <y>360</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
     <hint type="destinationlabel">
-     <x>875</x>
-     <y>503</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
    </hints>
   </connection>
@@ -3379,12 +3396,12 @@
    <slot>setVisible(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>875</x>
-     <y>360</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
     <hint type="destinationlabel">
-     <x>466</x>
-     <y>503</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
    </hints>
   </connection>
@@ -3395,12 +3412,12 @@
    <slot>setCurrentIndex(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>705</x>
-     <y>144</y>
+     <x>259</x>
+     <y>48</y>
     </hint>
     <hint type="destinationlabel">
-     <x>396</x>
-     <y>245</y>
+     <x>241</x>
+     <y>30</y>
     </hint>
    </hints>
   </connection>
@@ -3411,12 +3428,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>514</x>
-     <y>344</y>
+     <x>259</x>
+     <y>60</y>
     </hint>
     <hint type="destinationlabel">
-     <x>748</x>
-     <y>344</y>
+     <x>228</x>
+     <y>50</y>
     </hint>
    </hints>
   </connection>
@@ -3427,12 +3444,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>864</x>
-     <y>141</y>
+     <x>259</x>
+     <y>39</y>
     </hint>
     <hint type="destinationlabel">
-     <x>427</x>
-     <y>178</y>
+     <x>228</x>
+     <y>29</y>
     </hint>
    </hints>
   </connection>
@@ -3443,12 +3460,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>864</x>
-     <y>141</y>
+     <x>259</x>
+     <y>60</y>
     </hint>
     <hint type="destinationlabel">
-     <x>864</x>
-     <y>178</y>
+     <x>228</x>
+     <y>50</y>
     </hint>
    </hints>
   </connection>
@@ -3459,12 +3476,12 @@
    <slot>setCurrentIndex(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>864</x>
-     <y>141</y>
+     <x>259</x>
+     <y>60</y>
     </hint>
     <hint type="destinationlabel">
-     <x>427</x>
-     <y>215</y>
+     <x>259</x>
+     <y>60</y>
     </hint>
    </hints>
   </connection>
@@ -3475,12 +3492,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>864</x>
-     <y>141</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
     <hint type="destinationlabel">
-     <x>864</x>
-     <y>215</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
    </hints>
   </connection>
@@ -3491,12 +3508,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>427</x>
-     <y>355</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
     <hint type="destinationlabel">
-     <x>862</x>
-     <y>355</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
    </hints>
   </connection>
@@ -3507,12 +3524,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>424</x>
-     <y>331</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
     <hint type="destinationlabel">
-     <x>658</x>
-     <y>331</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
    </hints>
   </connection>
@@ -3523,12 +3540,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>875</x>
-     <y>254</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
     <hint type="destinationlabel">
-     <x>466</x>
-     <y>291</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
    </hints>
   </connection>
@@ -3539,12 +3556,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>516</x>
-     <y>411</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
     <hint type="destinationlabel">
      <x>250</x>
-     <y>92</y>
+     <y>39</y>
     </hint>
    </hints>
   </connection>
@@ -3555,12 +3572,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>533</x>
-     <y>273</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
     <hint type="destinationlabel">
-     <x>449</x>
-     <y>301</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
    </hints>
   </connection>
@@ -3571,12 +3588,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>690</x>
-     <y>454</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
     <hint type="destinationlabel">
-     <x>690</x>
-     <y>506</y>
+     <x>250</x>
+     <y>39</y>
     </hint>
    </hints>
   </connection>
@@ -3587,12 +3604,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>376</x>
-     <y>196</y>
+     <x>720</x>
+     <y>280</y>
     </hint>
     <hint type="destinationlabel">
-     <x>305</x>
-     <y>224</y>
+     <x>346</x>
+     <y>306</y>
     </hint>
    </hints>
   </connection>
@@ -3603,12 +3620,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>417</x>
-     <y>204</y>
+     <x>761</x>
+     <y>280</y>
     </hint>
     <hint type="destinationlabel">
-     <x>434</x>
-     <y>234</y>
+     <x>778</x>
+     <y>306</y>
     </hint>
    </hints>
   </connection>
@@ -3619,12 +3636,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>476</x>
-     <y>202</y>
+     <x>820</x>
+     <y>280</y>
     </hint>
     <hint type="destinationlabel">
-     <x>466</x>
-     <y>253</y>
+     <x>810</x>
+     <y>329</y>
     </hint>
    </hints>
   </connection>
@@ -3635,12 +3652,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>518</x>
-     <y>204</y>
+     <x>862</x>
+     <y>280</y>
     </hint>
     <hint type="destinationlabel">
-     <x>515</x>
-     <y>277</y>
+     <x>859</x>
+     <y>352</y>
     </hint>
    </hints>
   </connection>
@@ -3651,12 +3668,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>557</x>
-     <y>207</y>
+     <x>866</x>
+     <y>280</y>
     </hint>
     <hint type="destinationlabel">
      <x>866</x>
-     <y>306</y>
+     <y>375</y>
     </hint>
    </hints>
   </connection>
@@ -3667,12 +3684,28 @@
    <slot>setVisible(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>484</x>
-     <y>147</y>
+     <x>250</x>
+     <y>39</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>250</x>
+     <y>39</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>recordWhenStreaming</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>keepRecordStreamStops</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>404</x>
+     <y>193</y>
     </hint>
     <hint type="destinationlabel">
-     <x>483</x>
-     <y>170</y>
+     <x>404</x>
+     <y>219</y>
     </hint>
    </hints>
   </connection>

+ 4 - 0
obs/obs-app.cpp

@@ -354,6 +354,10 @@ bool OBSApp::InitGlobalConfigDefaults()
 			"CenterSnapping", false);
 	config_set_default_double(globalConfig, "BasicWindow",
 			"SnapDistance", 10.0);
+	config_set_default_bool(globalConfig, "BasicWindow",
+			"RecordWhenStreaming", false);
+	config_set_default_bool(globalConfig, "BasicWindow",
+			"KeepRecordingWhenStreamStops", false);
 
 #ifdef __APPLE__
 	config_set_default_bool(globalConfig, "Video", "DisableOSXVSync", true);

+ 23 - 3
obs/window-basic-main.cpp

@@ -3339,6 +3339,11 @@ void OBSBasic::StartStreaming()
 		ui->streamButton->setText(QTStr("Basic.Main.StartStreaming"));
 		ui->streamButton->setEnabled(true);
 	}
+
+	bool recordWhenStreaming = config_get_bool(GetGlobalConfig(),
+			"BasicWindow", "RecordWhenStreaming");
+	if (recordWhenStreaming)
+		StartRecording();
 }
 
 void OBSBasic::StopStreaming()
@@ -3352,6 +3357,13 @@ void OBSBasic::StopStreaming()
 		ui->profileMenu->setEnabled(true);
 		App()->DecrementSleepInhibition();
 	}
+
+	bool recordWhenStreaming = config_get_bool(GetGlobalConfig(),
+			"BasicWindow", "RecordWhenStreaming");
+	bool keepRecordingWhenStreamStops = config_get_bool(GetGlobalConfig(),
+			"BasicWindow", "KeepRecordingWhenStreamStops");
+	if (recordWhenStreaming && !keepRecordingWhenStreamStops)
+		StopRecording();
 }
 
 void OBSBasic::ForceStopStreaming()
@@ -3365,6 +3377,13 @@ void OBSBasic::ForceStopStreaming()
 		ui->profileMenu->setEnabled(true);
 		App()->DecrementSleepInhibition();
 	}
+
+	bool recordWhenStreaming = config_get_bool(GetGlobalConfig(),
+			"BasicWindow", "RecordWhenStreaming");
+	bool keepRecordingWhenStreamStops = config_get_bool(GetGlobalConfig(),
+			"BasicWindow", "KeepRecordingWhenStreamStops");
+	if (recordWhenStreaming && !keepRecordingWhenStreamStops)
+		StopRecording();
 }
 
 void OBSBasic::StreamDelayStarting(int sec)
@@ -3481,10 +3500,11 @@ void OBSBasic::StreamingStop(int code)
 
 void OBSBasic::StartRecording()
 {
-	SaveProject();
+	if (outputHandler->RecordingActive())
+		return;
 
-	if (!outputHandler->RecordingActive())
-		outputHandler->StartRecording();
+	SaveProject();
+	outputHandler->StartRecording();
 }
 
 void OBSBasic::RecordStopping()

+ 19 - 1
obs/window-basic-settings.cpp

@@ -272,6 +272,8 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
 	HookWidget(ui->warnBeforeStreamStart,CHECK_CHANGED,  GENERAL_CHANGED);
 	HookWidget(ui->warnBeforeStreamStop, CHECK_CHANGED,  GENERAL_CHANGED);
 	HookWidget(ui->hideProjectorCursor,  CHECK_CHANGED,  GENERAL_CHANGED);
+	HookWidget(ui->recordWhenStreaming,  CHECK_CHANGED,  GENERAL_CHANGED);
+	HookWidget(ui->keepRecordStreamStops,CHECK_CHANGED,  GENERAL_CHANGED);
 	HookWidget(ui->snappingEnabled,      CHECK_CHANGED,  GENERAL_CHANGED);
 	HookWidget(ui->screenSnapping,       CHECK_CHANGED,  GENERAL_CHANGED);
 	HookWidget(ui->centerSnapping,       CHECK_CHANGED,  GENERAL_CHANGED);
@@ -795,6 +797,14 @@ void OBSBasicSettings::LoadGeneralSettings()
 	LoadLanguageList();
 	LoadThemeList();
 
+	bool recordWhenStreaming = config_get_bool(GetGlobalConfig(),
+			"BasicWindow", "RecordWhenStreaming");
+	ui->recordWhenStreaming->setChecked(recordWhenStreaming);
+
+	bool keepRecordStreamStops = config_get_bool(GetGlobalConfig(),
+			"BasicWindow", "KeepRecordingWhenStreamStops");
+	ui->keepRecordStreamStops->setChecked(keepRecordStreamStops);
+
 	bool snappingEnabled = config_get_bool(GetGlobalConfig(),
 			"BasicWindow", "SnappingEnabled");
 	ui->snappingEnabled->setChecked(snappingEnabled);
@@ -815,7 +825,6 @@ void OBSBasicSettings::LoadGeneralSettings()
 			"BasicWindow", "SnapDistance");
 	ui->snapDistance->setValue(snapDistance);
 
-
 	bool warnBeforeStreamStart = config_get_bool(GetGlobalConfig(),
 			"BasicWindow", "WarnBeforeStartingStream");
 	ui->warnBeforeStreamStart->setChecked(warnBeforeStreamStart);
@@ -2166,6 +2175,15 @@ void OBSBasicSettings::SaveGeneralSettings()
 	config_set_bool(GetGlobalConfig(), "BasicWindow",
 			"HideProjectorCursor",
 			ui->hideProjectorCursor->isChecked());
+
+	if (WidgetChanged(ui->recordWhenStreaming))
+		config_set_bool(GetGlobalConfig(), "BasicWindow",
+				"RecordWhenStreaming",
+				ui->recordWhenStreaming->isChecked());
+	if (WidgetChanged(ui->keepRecordStreamStops))
+		config_set_bool(GetGlobalConfig(), "BasicWindow",
+				"KeepRecordingWhenStreamStops",
+				ui->keepRecordStreamStops->isChecked());
 }
 
 void OBSBasicSettings::SaveStream1Settings()