Skip to content

Commit eed71b6

Browse files
committed
(M)JPG HTTP output support
1 parent ecd7e32 commit eed71b6

10 files changed

Lines changed: 90 additions & 298 deletions

File tree

generated/meson.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ embed_files = [
3232
{'infile': '../embed/min/skins/default.css', 'variable': 'skin_default_css', 'outfile': 'skin_default.css.h'},
3333
{'infile': '../embed/min/skins/dev.css', 'variable': 'skin_dev_css', 'outfile': 'skin_dev.css.h'},
3434
{'infile': '../embed/skins/video-js.css', 'variable': 'skin_videojs_css', 'outfile': 'skin_videojs.css.h'},
35-
{'infile': '../src/output/noffmpeg.jpg', 'variable': 'noffmpeg', 'outfile': 'noffmpeg.h'},
36-
{'infile': '../src/output/noh264.jpg', 'variable': 'noh264', 'outfile': 'noh264.h'},
3735
]
3836

3937
embed_tgts = []

lib/util.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,24 @@ namespace Util{
316316
rndSrc.close();
317317
}
318318

319+
/// Secure random alphanumeric string generator
320+
/// Uses getRandomBytes internally
321+
std::string getRandomAlphanumeric(size_t len){
322+
std::string ret(len, 'X');
323+
getRandomBytes((void*)ret.data(), len);
324+
for (size_t i = 0; i < len; ++i){
325+
uint8_t v = (ret[i] % 62);
326+
if (v < 10){
327+
ret[i] = v + '0';
328+
}else if (v < 36){
329+
ret[i] = v - 10 + 'A';
330+
}else{
331+
ret[i] = v - 10 - 26 + 'a';
332+
}
333+
}
334+
return ret;
335+
}
336+
319337
/// 64-bits version of ftell
320338
uint64_t ftell(FILE *stream){
321339
/// \TODO Windows implementation (e.g. _ftelli64 ?)

lib/util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace Util{
2121
int64_t expBackoffMs(const size_t currIter, const size_t maxIter, const int64_t maxWait);
2222

2323
void getRandomBytes(void * dest, size_t len);
24+
std::string getRandomAlphanumeric(size_t len);
2425

2526
uint64_t ftell(FILE *stream);
2627
uint64_t fseek(FILE *stream, uint64_t offset, int whence);

meson_options.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ option('DEBUG', description: 'Default debug level. Recommended value for develop
2121
option('NOGA', description: 'Disables Google Analytics entirely in the LSP', type: 'boolean', value: false)
2222
option('LOAD_BALANCE', description: 'Build the load balancer (WIP)', type: 'boolean', value: false)
2323
option('WITH_AV', description: 'Build a generic libav-based input (not distributable!)', type: 'boolean', value: false)
24-
option('WITH_JPG', description: 'Build JPG thumbnailer output support (WIP)', type: 'boolean', value: false)
2524
option('WITH_SANITY', description: 'Enable MistOutSanityCheck output for testing purposes', type: 'boolean', value: false)
2625
option('LSP_MINIFY', description: 'Try to minify LSP JS via java closure-compiler, generally not needed unless changing JS code as a minified version is part of the repository already', type: 'boolean', value: false)
2726
option('LOCAL_GENERATORS', description: 'Attempts to find a locally-installed version of sourcery and make_html, instead of compiling it', type: 'boolean', value: false)

src/input/input_ebml.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,16 @@ namespace Mist{
381381
trueCodec = "JPEG";
382382
trueType = "video";
383383
}
384+
if (codec == "V_MS/VFW/FOURCC"){
385+
tmpElem = E.findChild(EBML::EID_CODECPRIVATE);
386+
if (tmpElem){
387+
std::string bitmapheader = tmpElem.getValStringUntrimmed();
388+
if (bitmapheader.substr(16, 4) == "MJPG"){
389+
trueCodec = "JPEG";
390+
trueType = "video";
391+
}
392+
}
393+
}
384394
if (codec == "A_PCM/FLOAT/IEEE"){
385395
trueCodec = "FLOAT";
386396
trueType = "audio";

src/output/meson.build

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ outputs = [
2222
{'name' : 'SDP', 'format' : 'sdp', 'extra': ['http']},
2323
{'name' : 'HTTP', 'format' : 'http_internal', 'extra': ['http','embed']},
2424
{'name' : 'JSONLine', 'format' : 'jsonline'},
25+
{'name' : 'JPG', 'format' : 'jpg', 'extra': ['http']},
2526
]
2627

2728
if usessl
@@ -39,10 +40,6 @@ if have_srt
3940
outputs += {'name' : 'TSSRT', 'format' : 'tssrt', 'extra': ['ts', 'debased', 'with_srt']}
4041
endif
4142

42-
if get_option('WITH_JPG')
43-
outputs += {'name' : 'JPG', 'format' : 'jpg', 'extra': ['http','embed']}
44-
endif
45-
4643
if get_option('WITH_SANITY')
4744
outputs += {'name' : 'SanityCheck', 'format' : 'sanitycheck'}
4845
endif

src/output/output_ebml.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ namespace Mist{
119119
cfg->addOption("target", opt);
120120
}
121121

122-
bool OutEBML::isRecording(){return config->getString("target").size();}
123-
124122
/// Calculates the size of a Cluster (contents only) and returns it.
125123
/// Bases the calculation on the currently selected tracks and the given start/end time for the
126124
/// cluster.

src/output/output_ebml.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ namespace Mist{
1919
}
2020

2121
private:
22-
bool isRecording();
2322
std::string doctype;
2423
void sendElemTrackEntry(size_t idx);
2524
size_t sizeElemTrackEntry(size_t idx);

0 commit comments

Comments
 (0)