MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / receiveDataMaster

Function receiveDataMaster

src/server/NymphCastServer.cpp:626–660  ·  view source on GitHub ↗

--- RECEIVE DATA MASTER --- Receives data chunks for playback. uint8 receiveDataMaster(blob data)

Source from the content-addressed store, hash-verified

624// Receives data chunks for playback.
625// uint8 receiveDataMaster(blob data)
626NymphMessage* receiveDataMaster(int session, NymphMessage* msg, void* data) {
627 NymphMessage* returnMsg = msg->getReplyMessage();
628
629 // Extract data blob and add it to the buffer.
630 NymphType* mediaData = msg->parameters()[0];
631 bool done = msg->parameters()[1]->getBool();
632 int64_t when = msg->parameters()[2]->getInt64();
633
634 // Write string into buffer.
635 DataBuffer::write(mediaData->getChar(), mediaData->string_length());
636
637 if (!ffplay.playbackActive()) {
638 // Start the player when the delay in 'when' has been reached.
639 std::condition_variable cv;
640 std::mutex cv_m;
641 std::unique_lock<std::mutex> lk(cv_m);
642 //std::chrono::system_clock::time_point then = std::chrono::system_clock::from_time_t(when);
643 std::chrono::microseconds dur(when);
644 std::chrono::time_point<std::chrono::system_clock> then(dur);
645 //while (cv.wait_until(lk, then) != std::cv_status::timeout) { }
646 while (cv.wait_for(lk, dur) != std::cv_status::timeout) { }
647
648 // Start player.
649 ffplay.playTrack();
650 }
651
652 if (done) {
653 DataBuffer::setEof(done);
654 }
655
656 msg->discard();
657
658 returnMsg->setResultValue(new NymphType((uint8_t) 0));
659 return returnMsg;
660}
661
662
663// Client disconnects from server.

Callers

nothing calls this directly

Calls 2

playbackActiveMethod · 0.45
playTrackMethod · 0.45

Tested by

no test coverage detected