parent
13448b19c0
commit
07e4e01c94
@ -0,0 +1,60 @@
|
|||||||
|
|
||||||
|
#include "miniwebcam.h"
|
||||||
|
#include "inmemorytar.h"
|
||||||
|
#include "inmemoryfile.h"
|
||||||
|
|
||||||
|
InMemoryTar::InMemoryTar() {
|
||||||
|
struct archive *a;
|
||||||
|
struct archive_entry *entry;
|
||||||
|
size_t tar_size = _binary_assets_tar_end - _binary_assets_tar_start;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
debug ("");
|
||||||
|
|
||||||
|
a = archive_read_new();
|
||||||
|
archive_read_support_format_tar(a);
|
||||||
|
if (a == NULL) ErrorExit("error on archive new", -1);
|
||||||
|
|
||||||
|
r = archive_read_open_memory(a, _binary_assets_tar_start, tar_size);
|
||||||
|
if (r != ARCHIVE_OK) ErrorExit("bindary asset could not been found in memory", -1);
|
||||||
|
|
||||||
|
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
|
||||||
|
debug ("found file %s\n", archive_entry_pathname(entry));
|
||||||
|
InMemoryFile *imf = new InMemoryFile();
|
||||||
|
size_t size = archive_entry_size(entry);
|
||||||
|
imf->filename = archive_entry_pathname(entry);
|
||||||
|
imf->Allocate(size);
|
||||||
|
archive_read_data(a, imf->mem, size);
|
||||||
|
files.push_back(imf);
|
||||||
|
}
|
||||||
|
archive_read_free(a);
|
||||||
|
};
|
||||||
|
|
||||||
|
InMemoryTar::~InMemoryTar() {
|
||||||
|
std::list<InMemoryFile*>::iterator f;
|
||||||
|
|
||||||
|
f = files.begin();
|
||||||
|
while (f != files.end()) {
|
||||||
|
InMemoryFile *imf = *f;
|
||||||
|
delete imf;
|
||||||
|
f = files.begin();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// @brief
|
||||||
|
/// @param file
|
||||||
|
/// @param imf - do not free the pointer!!!!
|
||||||
|
/// @return
|
||||||
|
int InMemoryTar::FindFile(std::string file, InMemoryFile **imf) {
|
||||||
|
std::list<InMemoryFile*>::iterator f;
|
||||||
|
|
||||||
|
for (f = files.begin(); f != files.end(); f++) {
|
||||||
|
if (file.compare ((*f)->filename) == 0) {
|
||||||
|
*imf = *f;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
#ifndef _INMEMORYTAR_H_
|
||||||
|
#define _INMEMORYTAR_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <list>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <archive.h>
|
||||||
|
#include <archive_entry.h>
|
||||||
|
|
||||||
|
#include "inmemoryfile.h"
|
||||||
|
|
||||||
|
// Symbole vom Linker/objcopy
|
||||||
|
extern unsigned char _binary_assets_tar_start[];
|
||||||
|
extern unsigned char _binary_assets_tar_end[];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* this class will always read the assets_tar structure
|
||||||
|
*/
|
||||||
|
class InMemoryTar {
|
||||||
|
private:
|
||||||
|
std::list<InMemoryFile*> files;
|
||||||
|
protected:
|
||||||
|
public:
|
||||||
|
InMemoryTar();
|
||||||
|
~InMemoryTar();
|
||||||
|
|
||||||
|
int FindFile(std::string file, InMemoryFile **imf);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>MiniWebCam</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<img id="myimage1" src="snapshot.jpg"></img>
|
||||||
|
<br>
|
||||||
|
<img id="myimage2" src="snapshot-float.jpg"></img>
|
||||||
|
</body>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
function reloadImage() {
|
||||||
|
const img1 = document.getElementById('myimage1');
|
||||||
|
let src1 = img1.src.split('?')[0];
|
||||||
|
src1 = src1 + '?' + new Date().getTime();
|
||||||
|
img1.src = src1;
|
||||||
|
|
||||||
|
const img2 = document.getElementById('myimage2');
|
||||||
|
let src2 = img2.src.split('?')[0];
|
||||||
|
src2 = src2 + '?' + new Date().getTime();
|
||||||
|
img2.src = src2;
|
||||||
|
}
|
||||||
|
|
||||||
|
setInterval(reloadImage, 250);
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</html>
|
||||||
Loading…
Reference in new issue