Skip to content

Commit

Permalink
Try mp4
Browse files Browse the repository at this point in the history
  • Loading branch information
easafe committed Jan 19, 2025
1 parent f587992 commit bac30ef
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/Client/Common/Dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,6 @@ export async function subscribe_(registration) {

export function isMediaTypeSupported_(mt) {
return MediaRecorder.isTypeSupported(mt);
}
}


2 changes: 1 addition & 1 deletion src/Client/Common/Dom.purs
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,5 @@ acceptedAudioCodec = do
isIt ← EU.runEffectFn1 isMediaTypeSupported_ appleShit
if isIt then pure appleShit else pure webm
where
appleShit = "audio/aac"
appleShit = "video/mp4;codecs=avc1"
webm = "audio/webm"
4 changes: 2 additions & 2 deletions src/Client/Im/Record.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let mediaRecorder,
chunks = [];

function st(options, handler) {
return function(stream) {
return function (stream) {
mediaRecorder = new MediaRecorder(stream, options);
mediaRecorder.start();

Expand All @@ -23,7 +23,7 @@ function st(options, handler) {
}

export function start_(constraints, options, handler) {
navigator.mediaDevices.getUserMedia(constraints).then(st(options, handler), e => console.log(e));
navigator.mediaDevices.getUserMedia(constraints).then(st(options, handler), e => alert(e)).catch(a => alert(a));
}

export function stop_() {
Expand Down
19 changes: 14 additions & 5 deletions src/Server/File.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
import imageType from 'image-type';

//webm and aac for audio files
//webm and mp4 for audio files
function webm(buffer) {
return buffer[0] === 26 &&
buffer[1] === 69 &&
buffer[2] === 223 &&
buffer[3] === 163 ? 'webm' : '';
}

function aac(buffer) {
console.log(buffer[0], buffer[1]);
return buffer[0] === 255 && (buffer[1] === 241 || buffer[1] === 249) ? 'aac' : '';
//apple shit
function mp4(buffer) {
console.log(buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], buffer[8]);
return buffer[0] === 102 &&
buffer[1] === 116 &&
buffer[2] === 121 &&
buffer[3] === 112 &&
buffer[4] === 112 &&
(buffer[5] === 105 || buffer[5] === 77) &&
(buffer[6] === 115 || buffer[6] === 83) &&
(buffer[7] === 111 || buffer[7] === 78) &&
(buffer[8] === 109 || buffer[8] === 86) ? 'mp4' : '';
}

export function realFileExtension_(buffer) {
return async function () {
let r = await imageType(buffer);
return r.ext || webm(buffer) || aac(buffer) || '';
return r.ext || webm(buffer) || mp4(buffer) || '';
}
}
2 changes: 1 addition & 1 deletion src/Shared/Resource.purs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Data.Set as DS
import Environment (production)

allowedMediaTypes HashMap String String
allowedMediaTypes = DH.fromFoldable <<< DA.zip [ "data:image/png;base64", "data:image/jpeg;base64", "data:image/tiff;base64", "data:image/bmp;base64", "data:image/gif;base64", "data:audio/webm;base64" ] $ DS.toUnfoldable allowedExtensions
allowedMediaTypes = DH.fromFoldable <<< DA.zip [ "data:image/png;base64", "data:image/jpeg;base64", "data:image/tiff;base64", "data:image/bmp;base64", "data:image/gif;base64", "data:audio/webm;base64", "data:video/mp4;base64" ] $ DS.toUnfoldable allowedExtensions

allowedExtensions Set String
allowedExtensions = DS.fromFoldable [ ".png", ".jpg", ".tiff", ".bmp", ".gif", ".webm" ]
Expand Down

0 comments on commit bac30ef

Please sign in to comment.