Skip to content

Commit

Permalink
Major patch
Browse files Browse the repository at this point in the history
 - Screen capturing rewrite
   o Using FFmpeg
   o OSX screen capturing via avfoundation
   o Windows screen capturing via gdi
   o WEBP image encoding
   o Separate OSX builds for 10.7 and 10.8+ as avfoundation can't hide the cursor before 10.8
 - Upgrade to JUCE 6
 - Logging improvements
 - Separate installers for server and plugin
   o Check for a running server on windows to avoid silently failing updates
   o Allow downgrade and force override on Windows
 - OSX permissions: Check needed permissions at server startup
  • Loading branch information
apohl79 committed Aug 28, 2020
1 parent e206a8a commit 81e2f00
Show file tree
Hide file tree
Showing 50 changed files with 7,193 additions and 7,264 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
JuceLibraryCode
Builds
package/build/*
package/AudioGridder.iss
package/AudioGridder*.iss
package/VERSION
package/archiveWin.bat

20 changes: 11 additions & 9 deletions Common/Source/ImageDiff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ namespace e47 {

namespace ImageDiff {

bool operator==(const PixelARGB& lhs, const PixelARGB& rhs) { return lhs.getNativeARGB() == rhs.getNativeARGB(); }
static bool operator==(const PixelARGB& lhs, const PixelARGB& rhs) {
return lhs.getNativeARGB() == rhs.getNativeARGB();
}

bool operator!=(const PixelARGB& lhs, const PixelARGB& rhs) { return !(lhs == rhs); }
static bool operator!=(const PixelARGB& lhs, const PixelARGB& rhs) { return !(lhs == rhs); }

using PerPixelFn = std::function<void(const PixelARGB& px)>;

uint64_t getDelta(const uint8_t* imgFrom, const uint8_t* imgTo, uint8_t* imgDelta, int width, int height,
PerPixelFn fn = nullptr) {
inline uint64_t getDelta(const uint8_t* imgFrom, const uint8_t* imgTo, uint8_t* imgDelta, int width, int height,
PerPixelFn fn = nullptr) {
uint64_t count = 0;
auto* pxFrom = reinterpret_cast<const PixelARGB*>(imgFrom);
auto* pxTo = reinterpret_cast<const PixelARGB*>(imgTo);
Expand All @@ -44,7 +46,7 @@ uint64_t getDelta(const uint8_t* imgFrom, const uint8_t* imgTo, uint8_t* imgDelt
return count;
}

uint64_t getDelta(const Image& imgFrom, const Image& imgTo, const Image& imgDelta, PerPixelFn fn = nullptr) {
inline uint64_t getDelta(const Image& imgFrom, const Image& imgTo, const Image& imgDelta, PerPixelFn fn = nullptr) {
if (imgFrom.getBounds() == imgTo.getBounds() && imgDelta.getBounds() == imgTo.getBounds()) {
int width = imgTo.getWidth();
int height = imgTo.getHeight();
Expand All @@ -56,7 +58,7 @@ uint64_t getDelta(const Image& imgFrom, const Image& imgTo, const Image& imgDelt
return 0;
}

uint64_t applyDelta(uint8_t* imgDst, const uint8_t* imgDelta, int width, int height) {
inline uint64_t applyDelta(uint8_t* imgDst, const uint8_t* imgDelta, int width, int height) {
uint64_t count = 0;
auto* pxDst = reinterpret_cast<PixelARGB*>(imgDst);
auto* pxDelta = reinterpret_cast<const PixelARGB*>(imgDelta);
Expand All @@ -72,7 +74,7 @@ uint64_t applyDelta(uint8_t* imgDst, const uint8_t* imgDelta, int width, int hei
return count;
}

uint64_t applyDelta(Image& imgDst, const Image& imgDelta) {
inline uint64_t applyDelta(Image& imgDst, const Image& imgDelta) {
if (imgDelta.getBounds() == imgDst.getBounds()) {
int width = imgDelta.getWidth();
int height = imgDelta.getHeight();
Expand All @@ -88,7 +90,7 @@ inline float getBrightness(const PixelARGB& px) {
return col.getFloatRed() / 3 + col.getFloatGreen() / 3 + col.getFloatBlue() / 3;
}

float getBrightness(const uint8_t* img, int width, int height) {
inline float getBrightness(const uint8_t* img, int width, int height) {
auto* px = reinterpret_cast<const PixelARGB*>(img);
float brightness = 0;
for (int y = 0; y < height; y++) {
Expand All @@ -100,7 +102,7 @@ float getBrightness(const uint8_t* img, int width, int height) {
return brightness;
}

float getBrightness(const Image& img) {
inline float getBrightness(const Image& img) {
int width = img.getWidth();
int height = img.getHeight();
const Image::BitmapData bd(img, 0, 0, width, height);
Expand Down
20 changes: 11 additions & 9 deletions Common/Source/Message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ class AudioMessage {
return false;
}
}
const uint8* midiData;
MidiHeader midiHdr;
MidiBuffer::Iterator midiIt(midi);
while (midiIt.getNextEvent(midiData, midiHdr.size, midiHdr.sampleNumber)) {
for (auto midiIt = midi.begin(); midiIt != midi.end(); midiIt++) {
midiHdr.size = (*midiIt).numBytes;
midiHdr.sampleNumber = (*midiIt).samplePosition;
if (!send(socket, reinterpret_cast<const char*>(&midiHdr), sizeof(midiHdr))) {
return false;
}
if (!send(socket, reinterpret_cast<const char*>(midiData), midiHdr.size)) {
if (!send(socket, reinterpret_cast<const char*>((*midiIt).data), midiHdr.size)) {
return false;
}
}
Expand Down Expand Up @@ -212,14 +212,14 @@ class AudioMessage {
return false;
}
}
const uint8* midiData;
MidiHeader midiHdr;
MidiBuffer::Iterator midiIt(midi);
while (midiIt.getNextEvent(midiData, midiHdr.size, midiHdr.sampleNumber)) {
for (auto midiIt = midi.begin(); midiIt != midi.end(); midiIt++) {
midiHdr.size = (*midiIt).numBytes;
midiHdr.sampleNumber = (*midiIt).samplePosition;
if (!send(socket, reinterpret_cast<const char*>(&midiHdr), sizeof(midiHdr))) {
return false;
}
if (!send(socket, reinterpret_cast<const char*>(midiData), midiHdr.size)) {
if (!send(socket, reinterpret_cast<const char*>((*midiIt).data), midiHdr.size)) {
return false;
}
}
Expand Down Expand Up @@ -529,17 +529,19 @@ class ScreenCapture : public Payload {
struct hdr_t {
int width;
int height;
double scale;
size_t size;
};
hdr_t* hdr;
char* data;

ScreenCapture() : Payload(Type) { realign(); }

void setImage(int width, int height, const void* p, size_t size) {
void setImage(int width, int height, double scale, const void* p, size_t size) {
setSize(as<int>(sizeof(hdr_t) + size));
hdr->width = width;
hdr->height = height;
hdr->scale = scale;
hdr->size = size;
if (nullptr != p) {
memcpy(data, p, size);
Expand Down
30 changes: 27 additions & 3 deletions Common/Source/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@

#endif

#define setLogTagStatic(t) auto getLogTag = [] { return LogTag::getTaggedStr(t, "static"); };

namespace e47 {

class LogTag {
public:
LogTag(const String& name) : m_name(name) {}

String getStrWithLeadingZero(int n, int digits = 2) const {
static String getStrWithLeadingZero(int n, int digits = 2) {
String s = "";
while (--digits > 0) {
if (n < pow(10, digits)) {
Expand All @@ -55,17 +57,25 @@ class LogTag {
return s;
}

String getLogTag() const {
static String getTimeStr() {
auto now = Time::getCurrentTime();
auto H = getStrWithLeadingZero(now.getHours());
auto M = getStrWithLeadingZero(now.getMinutes());
auto S = getStrWithLeadingZero(now.getSeconds());
auto m = getStrWithLeadingZero(now.getMilliseconds(), 3);
String ret = "";
ret << H << ":" << M << ":" << S << "." << m;
return ret;
}

static String getTaggedStr(const String& name, const String& ptr) {
String tag = "";
tag << H << ":" << M << ":" << S << "." << m << "|" << m_name << "|" << (uint64)this;
tag << getTimeStr() << "|" << name << "|" << ptr;
return tag;
}

String getLogTag() const { return getTaggedStr(m_name, String((uint64)this)); }

private:
String m_name;
};
Expand Down Expand Up @@ -164,6 +174,20 @@ class ServerString {
int m_id;
};

inline void callOnMessageThread(std::function<void()> fn) {
std::mutex mtx;
std::condition_variable cv;
bool done = false;
MessageManager::callAsync([&] {
std::lock_guard<std::mutex> lock(mtx);
fn();
done = true;
cv.notify_one();
});
std::unique_lock<std::mutex> lock(mtx);
cv.wait(lock, [&done] { return done; });
}

} // namespace e47

#endif /* Utils_hpp */
Loading

0 comments on commit 81e2f00

Please sign in to comment.