Browse Source

调试

worker
unknown 8 years ago
parent
commit
838ce86a13
  1. 9
      AudioDecoder.h
  2. 11
      MonaClient.cpp
  3. 10
      NetStream.h
  4. 16
      js/MonaClient.js
  5. 26
      js/index.html

9
AudioDecoder.h

@ -37,7 +37,7 @@ class AudioDecoder
u8 *outputBuffer;
#ifdef USE_AAC
faacDecHandle faacHandle;
faacDecConfigurationPtr faacConfiguration;
//faacDecConfigurationPtr faacConfiguration;
#endif
#ifdef USE_SPEEX
i16 *audioOutput;
@ -60,9 +60,10 @@ class AudioDecoder
#endif
#ifdef USE_AAC
faacHandle = faacDecOpen();
faacConfiguration = faacDecGetCurrentConfiguration(faacHandle);
//faacConfiguration = faacDecGetCurrentConfiguration(faacHandle);
emscripten_log(0, "aac init! %d", faacHandle);
#endif
emscripten_log(0, "audio init! %d", this);
}
~AudioDecoder()
{emscripten_log(0, "audio decoder release\n");
@ -127,12 +128,12 @@ class AudioDecoder
if (input.readB<1, u8>())
{
faacDecFrameInfo frame_info;
//emscripten_log(0, "%d", data.length());
auto pcm_data = faacDecDecode(faacHandle, &frame_info, (unsigned char *)input.point(), input.length());
if (frame_info.error > 0)
{
emscripten_log(1, "%s\n", NeAACDecGetErrorMessage(frame_info.error));
emscripten_log(1, "!!%s\n", NeAACDecGetErrorMessage(frame_info.error));
}
else
{

11
MonaClient.cpp

@ -191,14 +191,17 @@ void MonaClient::OnWsMessage(val evt)
{
case 1:
{
MemoryStream ms(data.substr(1));
netStreams[0]->decodeAudio(ms.readUInt32B(), ms);
if(netStreams[0]->audioDecoder){
emscripten_log(0, "netStream audioDecoder! %d", netStreams[0]->audioDecoder);
MemoryStream ms(data.substr(1));
netStreams[0]->decodeAudio(ms.readUInt32B(), ms);
}
}
break;
case 2:
{
MemoryStream ms(data.substr(1));
netStreams[0]->decodeVideo(ms.readUInt32B(), ms);
MemoryStream ms(data.substr(1));
netStreams[0]->decodeVideo(ms.readUInt32B(), ms);
}
break;
default:

10
NetStream.h

@ -1,10 +1,10 @@
#pragma once
class NetStream
{
private:
public:
AudioDecoder* audioDecoder;
VideoDecoder* videoDecoder;
public:
MonaClient *mc;
bool isFirstVideoReceived = true;
//mp4AudioSpecificConfig* config;
@ -30,9 +30,7 @@ public:
~NetStream()
{
emscripten_log(0, "netStream deleted! %d", id);
EM_ASM_({
clearTimeout($0)
}, videoTimeoutId);
EM_ASM_({clearTimeout($0)}, videoTimeoutId);
if(videoDecoder)delete videoDecoder;
if(audioDecoder)delete audioDecoder;
if (jsThis) delete jsThis;
@ -138,7 +136,7 @@ public:
}
bool decodeAudio(clock_t _timestamp, MemoryStream & data) {
if(audioDecoder == nullptr)return false;
unsigned char flag = 0;
data.readB<1>(flag);
auto audioType = flag >> 4;

16
js/MonaClient.js
File diff suppressed because it is too large
View File

26
js/index.html

@ -22,28 +22,20 @@
var txt = "";
var testFunctions = []
testFunctions.push(function() {
testFunctions.push(function(n) {
test()
setTimeout(testFunctions[1], 2000, n)
})
testFunctions.push(function() {
play('user1')
testFunctions.push(function(n) {
play(n)
setTimeout(testFunctions[2], 8000, n == 'user1' ? 'user2' : 'user1')
})
testFunctions.push(function() {
testFunctions.push(function(n) {
mc.close()
setTimeout(testFunctions[0], 1000, n)
})
testFunctions.push(function() {
test()
})
testFunctions.push(function() {
play('user2')
})
testFunctions.push(function() {
mc.close()
})
setInterval(function() {
testFunctions[0]()
testFunctions.push(testFunctions.shift())
}, 5000)
setTimeout(testFunctions[0], 1000, 'user1')
function handleErr(msg, url, l) {
txt = "There was an error on this page.\n\n";

Loading…
Cancel
Save