Skip to content

Commit

Permalink
feat(controller): Add IPMAN-S Support.
Browse files Browse the repository at this point in the history
No need to select dont'check anymore. And hide useless options for
IPMAN-S device.

Signed-off-by: Yibai Zhang <[email protected]>
  • Loading branch information
summershrimp committed Feb 27, 2022
1 parent 1d92824 commit b827006
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/controller/cameracontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

#define HTTP_SHORT_TIMEOUT 3 * 1000
#define HTTP_NORMAL_TIMEOUT 5 * 1000
#define HTTP_COMMAND_TIMEOUT 10 * 1000
#define HTTP_COMMAND_TIMEOUT 3 * 1000
#define HTTP_LONG_TIMEOUT 8 * 1000
#define HTTP_GET_MODE_LONG_TIMEOUT 20 * 1000

Expand Down
24 changes: 16 additions & 8 deletions src/obs-ssp-source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,9 @@ bool source_ip_modified(void* data, obs_properties_t *props,
}
s->cameraStatus->setIp(source_ip);
s->cameraStatus->refreshAll([=](bool ok){
if(!ok) return;
s->ip_checked = true;
if(ok) {
s->ip_checked = true;
}
obs_source_update_properties(s->source);
});
return false;
Expand All @@ -467,9 +468,9 @@ static bool custom_ip_modify_callback(void* data, obs_properties_t *props,
}
s->cameraStatus->setIp(ip);
s->cameraStatus->refreshAll([=](bool ok){
if(!ok) return;
ssp_blog(LOG_INFO, "refresh ok");
s->ip_checked = true;
if(ok) {
s->ip_checked = true;
}
obs_source_update_properties(s->source);
});

Expand Down Expand Up @@ -614,17 +615,24 @@ obs_properties_t* ssp_source_getproperties(void* data)

obs_property_set_modified_callback2(resolutions, resolution_modify_callback, data);

obs_properties_add_list(props, PROP_FRAME_RATE,
obs_property_t* framerate = obs_properties_add_list(props, PROP_FRAME_RATE,
obs_module_text("SSPPlugin.SourceProps.FrameRate"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);

obs_properties_add_int(props, PROP_BITRATE,
obs_module_text("SSPPlugin.SourceProps.Bitrate"),
10, 300, 5);
5, 300, 5);

obs_properties_add_bool(props, PROP_LED_TALLY,
obs_property_t* tally = obs_properties_add_bool(props, PROP_LED_TALLY,
obs_module_text("SSPPlugin.SourceProps.LedAsTally"));

if(s->cameraStatus->model.contains(IPMANS_MODEL_CODE, Qt::CaseInsensitive)) {
obs_property_set_visible(resolutions, false);
obs_property_set_visible(encoders, false);
obs_property_set_visible(framerate, false);
obs_property_set_visible(tally, false);
}

return props;
}

Expand Down
14 changes: 13 additions & 1 deletion src/ssp-controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ void CameraStatus::doSetStream(int stream_index, QString resolution, bool low_no
need_downresolution = true;
}
}
auto bitrate2 = QString::number(bitrate);

if(model.contains(IPMANS_MODEL_CODE, Qt::CaseInsensitive)) {
auto index = QString("stream") + QString::number(stream_index + 1);
controller->setStreamBitrate(index, bitrate2, [=](HttpResponse *rsp){
if(rsp->statusCode != 200 || rsp->code != 0){
return cb(false, QString("Could not set bitrate to %1").arg(bitrate2));
}
return cb(true, "Success");
});
return;
}

QString real_resolution;
QString width, height;
auto arr = resolution.split("*");
Expand All @@ -169,7 +182,6 @@ void CameraStatus::doSetStream(int stream_index, QString resolution, bool low_no
}

auto index = QString("Stream") + QString::number(stream_index);
auto bitrate2 = QString::number(bitrate);
blog(LOG_INFO, "Setting movie resolution");
controller->setCameraConfig(CONFIG_KEY_MOVIE_RESOLUTION, real_resolution, [=](HttpResponse *rsp){
if(rsp->statusCode != 200 || rsp->code != 0){
Expand Down
1 change: 1 addition & 0 deletions src/ssp-controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ along with this program; If not, see <https://www.gnu.org/licenses/>
#include "controller/cameracontroller.h"

#define E2C_MODEL_CODE "elephant"
#define IPMANS_MODEL_CODE "wlm"

typedef std::function<void(bool ok)> StatusUpdateCallback;
typedef std::function<void(bool ok, QString)> StatusReasonUpdateCallback;
Expand Down

0 comments on commit b827006

Please sign in to comment.