File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525// / LIVEKIT_URL, LIVEKIT_RECEIVER_TOKEN, LIVEKIT_SENDER_IDENTITY
2626
2727#include < atomic>
28- #include < cassert>
2928#include < chrono>
3029#include < csignal>
3130#include < cstdlib>
3231#include < iostream>
32+ #include < stdexcept>
3333#include < thread>
3434
3535#include " livekit/livekit.h"
@@ -84,7 +84,9 @@ int main(int argc, char* argv[]) {
8484 }
8585
8686 auto lp = room->localParticipant ().lock ();
87- assert (lp);
87+ if (!lp) {
88+ throw std::runtime_error (" [receiver] local participant is null" );
89+ }
8890
8991 std::cout << " [info] [receiver] Connected as identity='" << lp->identity () << " ' room='" << room->roomInfo ().name
9092 << " '; subscribing to sender identity='" << sender_identity << " '\n " ;
Original file line number Diff line number Diff line change 2424// / LIVEKIT_URL, LIVEKIT_SENDER_TOKEN
2525
2626#include < atomic>
27- #include < cassert>
2827#include < chrono>
2928#include < csignal>
3029#include < cstdlib>
3130#include < iomanip>
3231#include < iostream>
3332#include < sstream>
33+ #include < stdexcept>
3434#include < thread>
3535
3636#include " livekit/livekit.h"
@@ -89,7 +89,9 @@ int main(int argc, char* argv[]) {
8989 std::shared_ptr<VideoSource> video_source;
9090 {
9191 auto lp = room->localParticipant ().lock ();
92- assert (lp);
92+ if (!lp) {
93+ throw std::runtime_error (" [sender] local participant is null" );
94+ }
9395
9496 std::cout << " [info] [sender] Connected as identity='" << lp->identity () << " ' room='" << room->roomInfo ().name
9597 << " ' — pass this identity to HelloLivekitReceiver\n " ;
Original file line number Diff line number Diff line change 1919// / identity is `ping`.
2020
2121#include < atomic>
22- #include < cassert>
2322#include < csignal>
2423#include < cstdint>
2524#include < exception>
2625#include < iostream>
2726#include < memory>
2827#include < mutex>
2928#include < optional>
29+ #include < stdexcept>
3030#include < string>
3131#include < thread>
3232#include < unordered_map>
@@ -101,7 +101,9 @@ int main(int argc, char* argv[]) {
101101 std::shared_ptr<LocalDataTrack> ping_track;
102102 {
103103 auto local_participant = room->localParticipant ().lock ();
104- assert (local_participant);
104+ if (!local_participant) {
105+ throw std::runtime_error (" [ping] local participant is null" );
106+ }
105107
106108 std::cout << " [info] ping connected as identity='" << local_participant->identity () << " ' room='"
107109 << room->roomInfo ().name << " '\n " ;
Original file line number Diff line number Diff line change 1818// / on the "pong" data track. Use a token whose identity is `pong`.
1919
2020#include < atomic>
21- #include < cassert>
2221#include < csignal>
2322#include < cstdint>
2423#include < exception>
2524#include < iostream>
2625#include < memory>
2726#include < optional>
27+ #include < stdexcept>
2828#include < string>
2929#include < thread>
3030#include < vector>
@@ -81,7 +81,9 @@ int main(int argc, char* argv[]) {
8181 {
8282 // limit the scope of the local participant
8383 auto local_participant = room->localParticipant ().lock ();
84- assert (local_participant);
84+ if (!local_participant) {
85+ throw std::runtime_error (" [pong] local participant is null" );
86+ }
8587
8688 std::cout << " [info] pong connected as identity='" << local_participant->identity () << " ' room='"
8789 << room->roomInfo ().name << " '\n " ;
You can’t perform that action at this time.
0 commit comments