This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
199 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "BlobMessage.hpp" | ||
|
||
#include <cstring> | ||
|
||
namespace scin { namespace osc { | ||
|
||
BlobMessage::BlobMessage(): m_size(0) {} | ||
|
||
BlobMessage::~BlobMessage() { | ||
if (m_message) { | ||
lo_message_free(m_message); | ||
m_message = nullptr; | ||
} | ||
} | ||
|
||
bool BlobMessage::extract(lo_blob blob) { | ||
m_size = lo_blob_datasize(blob); | ||
if (m_size == 0) { | ||
return false; | ||
} | ||
m_bytes.reset(new uint8_t[m_size]); | ||
std::memcpy(m_bytes.get(), lo_blob_dataptr(blob), m_size); | ||
m_message = lo_message_deserialise(m_bytes.get(), m_size, nullptr); | ||
if (!m_message) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
} // namespace osc | ||
} // namespace scin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef SRC_OSC_BLOB_MESSAGE_HPP_ | ||
#define SRC_OSC_BLOB_MESSAGE_HPP_ | ||
|
||
#include "lo/lo.h" | ||
|
||
#include <memory> | ||
|
||
namespace scin { namespace osc { | ||
/*! Can extract a copy of a message from a OSC blob lo_blob data structure. | ||
*/ | ||
class BlobMessage { | ||
public: | ||
BlobMessage(); | ||
~BlobMessage(); | ||
|
||
bool extract(lo_blob blob); | ||
|
||
lo_message message() { return m_message; } | ||
const char* path() const { return reinterpret_cast<const char*>(m_bytes.get()); } | ||
|
||
private: | ||
std::unique_ptr<uint8_t[]> m_bytes; | ||
uint32_t m_size; | ||
lo_message m_message; | ||
}; | ||
|
||
} // namespace osc | ||
} // namespace scin | ||
|
||
#endif // SRC_OSC_BLOB_MESSAGE_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.