|
22 | 22 | #include "capture_source_internal.h" |
23 | 23 | #include "ffi.pb.h" |
24 | 24 | #include "ffi_client.h" |
| 25 | +#include "lk_log.h" |
25 | 26 | #include "room_proto_converter.h" |
26 | 27 |
|
27 | 28 | namespace livekit { |
@@ -433,29 +434,45 @@ void CaptureSource::setOnFinishedCallback(FinishedCallback callback) { |
433 | 434 | on_finished_ = std::move(callback); |
434 | 435 | } |
435 | 436 |
|
436 | | -void CaptureSource::start() { |
437 | | - proto::FfiRequest req; |
438 | | - req.mutable_start_capture()->set_capture_handle(handle_.get()); |
| 437 | +bool CaptureSource::start() { |
| 438 | + try { |
| 439 | + proto::FfiRequest req; |
| 440 | + req.mutable_start_capture()->set_capture_handle(handle_.get()); |
439 | 441 |
|
440 | | - const proto::FfiResponse resp = FfiClient::instance().sendRequest(req); |
441 | | - if (!resp.has_start_capture()) { |
442 | | - throw CaptureSourceError("FfiResponse missing start_capture"); |
443 | | - } |
444 | | - if (resp.start_capture().has_error()) { |
445 | | - throw CaptureSourceError(resp.start_capture().error()); |
| 442 | + const proto::FfiResponse resp = FfiClient::instance().sendRequest(req); |
| 443 | + if (!resp.has_start_capture()) { |
| 444 | + LK_LOG_WARN("Capture start request returned no start_capture response"); |
| 445 | + return false; |
| 446 | + } |
| 447 | + if (resp.start_capture().has_error()) { |
| 448 | + LK_LOG_WARN("Capture start request failed: {}", resp.start_capture().error()); |
| 449 | + return false; |
| 450 | + } |
| 451 | + return true; |
| 452 | + } catch (const std::exception& e) { |
| 453 | + LK_LOG_WARN("Capture start request failed: {}", e.what()); |
| 454 | + return false; |
446 | 455 | } |
447 | 456 | } |
448 | 457 |
|
449 | | -void CaptureSource::stop() { |
450 | | - proto::FfiRequest req; |
451 | | - req.mutable_stop_capture()->set_capture_handle(handle_.get()); |
| 458 | +bool CaptureSource::stop() { |
| 459 | + try { |
| 460 | + proto::FfiRequest req; |
| 461 | + req.mutable_stop_capture()->set_capture_handle(handle_.get()); |
452 | 462 |
|
453 | | - const proto::FfiResponse resp = FfiClient::instance().sendRequest(req); |
454 | | - if (!resp.has_stop_capture()) { |
455 | | - throw CaptureSourceError("FfiResponse missing stop_capture"); |
456 | | - } |
457 | | - if (resp.stop_capture().has_error()) { |
458 | | - throw CaptureSourceError(resp.stop_capture().error()); |
| 463 | + const proto::FfiResponse resp = FfiClient::instance().sendRequest(req); |
| 464 | + if (!resp.has_stop_capture()) { |
| 465 | + LK_LOG_WARN("Capture stop request returned no stop_capture response"); |
| 466 | + return false; |
| 467 | + } |
| 468 | + if (resp.stop_capture().has_error()) { |
| 469 | + LK_LOG_WARN("Capture stop request failed: {}", resp.stop_capture().error()); |
| 470 | + return false; |
| 471 | + } |
| 472 | + return true; |
| 473 | + } catch (const std::exception& e) { |
| 474 | + LK_LOG_WARN("Capture stop request failed: {}", e.what()); |
| 475 | + return false; |
459 | 476 | } |
460 | 477 | } |
461 | 478 |
|
|
0 commit comments