From 283599ea687e81855d78abffcbf641edb3bf02fb Mon Sep 17 00:00:00 2001 From: deva Date: Wed, 26 Oct 2005 14:09:13 +0000 Subject: *** empty log message *** --- src/camera.cc | 5 +++++ src/camera.h | 2 ++ src/decoder.cc | 7 +++++++ src/decoder.h | 3 +++ src/encoder.cc | 1 + src/encoder.h | 2 +- src/frame.h | 2 ++ src/liblame_wrapper.cc | 44 +++++++++++++++++++++++++++++--------------- src/mainwindow.cc | 2 ++ src/package.h | 1 + src/server.cc | 3 ++- 11 files changed, 55 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/camera.cc b/src/camera.cc index 85ef404..26a52a4 100644 --- a/src/camera.cc +++ b/src/camera.cc @@ -174,4 +174,9 @@ void Camera::resize(int w, int h, bool s) player->resize(w,h,s); } +void Camera::setMute(bool mute) +{ + decoder->setMute(mute); +} + #endif/* USE_GUI */ diff --git a/src/camera.h b/src/camera.h index beb1260..a0b849a 100644 --- a/src/camera.h +++ b/src/camera.h @@ -78,6 +78,8 @@ public: // Indirect call to player->resize void resize(int width, int height, bool showtext); + void setMute(bool mute); + private: // Info object passed to all sub objects. Info *info; diff --git a/src/decoder.cc b/src/decoder.cc index dea0ae4..0d56aca 100644 --- a/src/decoder.cc +++ b/src/decoder.cc @@ -77,6 +77,8 @@ Decoder::Decoder(Info *ginfo, pthread_mutex_init (&shot_mutex, NULL); shot = NULL; + + mute = false; } Decoder::~Decoder() @@ -160,6 +162,7 @@ void Decoder::decode() eframe->shoot = local_shoot; eframe->freeze = local_freeze; eframe->record = local_record; + eframe->mute = mute; encode_queue->push(eframe); @@ -275,5 +278,9 @@ void Decoder::getScreenshot(Frame *frame, unsigned char *rgb) dv_decoder_free(decoder); } +void Decoder::setMute(bool m) +{ + mute = m; +} #endif /*USE_GUI*/ diff --git a/src/decoder.h b/src/decoder.h index ba78d49..20878c7 100644 --- a/src/decoder.h +++ b/src/decoder.h @@ -67,8 +67,11 @@ public: void shoot(unsigned char *rgb); void start(); void stop(n_savestate save); + void setMute(bool mute); private: + volatile bool mute; + void getScreenshot(Frame *frame, unsigned char *rgb); pthread_mutex_t shot_mutex; diff --git a/src/encoder.cc b/src/encoder.cc index 9563d89..c46ca33 100644 --- a/src/encoder.cc +++ b/src/encoder.cc @@ -123,6 +123,7 @@ void Encoder::encode() h.header.h_data.snapshot = frame->shoot; h.header.h_data.record = frame->record; h.header.h_data.savestate = savestate;//NO_CHANGE; + h.header.h_data.mute = frame->mute; // if(freeze_request != freeze_value) freeze_value = freeze_request; // if(shoot_request != shoot_value) shoot_value = shoot_request; diff --git a/src/encoder.h b/src/encoder.h index a8ffcc5..0fada07 100644 --- a/src/encoder.h +++ b/src/encoder.h @@ -89,7 +89,7 @@ public: private: Info *info; - + int port; char ip[32]; char cpr[32]; diff --git a/src/frame.h b/src/frame.h index 6859116..988f460 100644 --- a/src/frame.h +++ b/src/frame.h @@ -43,6 +43,8 @@ public: unsigned int bitrate; + bool mute; + bool shoot; int freeze; // 1 is freeze, -1 is unfreeze bool record; diff --git a/src/liblame_wrapper.cc b/src/liblame_wrapper.cc index b29acf9..5603d6f 100644 --- a/src/liblame_wrapper.cc +++ b/src/liblame_wrapper.cc @@ -118,26 +118,40 @@ Frame *LibLAMEWrapper::close(Frame *oldframe) return frame; } +#include +static unsigned int sin_cnt = 0; Frame *LibLAMEWrapper::encode(Frame *dvframe) { + if(dvframe->mute) { + // Overwrite audiobuffer with dummy data + double volume = 1000; // Min:= 0 - Max := 32000 + double frequency = 440; // in Hz + + for(int cnt = 0; cnt < SAMPLES; cnt++) { + sin_cnt++; + double sin_val = (((double)sin_cnt / (double)OUTPUT_SAMPLE_RATE) * (double)M_PI) * frequency; + audio_buffer[0][cnt] = audio_buffer[1][cnt] = (short int)(sin(sin_val) * volume); + } - if(!decoder) { - decoder = dv_decoder_new(FALSE/*this value is unused*/, FALSE, FALSE); - decoder->quality = DV_QUALITY_BEST; - - dv_parse_header(decoder, dvframe->data); - - decoder->system = e_dv_system_625_50; // PAL lines, PAL framerate - decoder->sampling = e_dv_sample_422; // 4 bytes y, 2 bytes u, 2 bytes v - decoder->std = e_dv_std_iec_61834; - decoder->num_dif_seqs = 12; + // memset(audio_buffer[0], 0, sizeof(audio_buffer[0])); + // memset(audio_buffer[1], 0, sizeof(audio_buffer[1])); + } else { + // Decode audio from dv frame + if(!decoder) { + decoder = dv_decoder_new(FALSE/*this value is unused*/, FALSE, FALSE); + decoder->quality = DV_QUALITY_BEST; + + dv_parse_header(decoder, dvframe->data); + + decoder->system = e_dv_system_625_50; // PAL lines, PAL framerate + decoder->sampling = e_dv_sample_422; // 4 bytes y, 2 bytes u, 2 bytes v + decoder->std = e_dv_std_iec_61834; + decoder->num_dif_seqs = 12; + } + // Decode audio using libdv + dv_decode_full_audio( decoder, dvframe->data, audio_buffer ); } - /** - * Decode audio using libdv - */ - dv_decode_full_audio( decoder, dvframe->data, audio_buffer ); - /** * input pcm data, output (maybe) mp3 frames. * This routine handles all buffering, resampling and filtering for you. diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 555d3ab..87088b2 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -554,6 +554,8 @@ void MainWindow::mute_clicked() muted = !muted; if(muted) btn_mute->setPixmap(*img_unmute); else btn_mute->setPixmap(*img_mute); + + camera->setMute(muted); } #endif /*USE_GUI*/ diff --git a/src/package.h b/src/package.h index 725ff59..a16557a 100644 --- a/src/package.h +++ b/src/package.h @@ -49,6 +49,7 @@ typedef struct { bool freeze; bool snapshot; n_savestate savestate; + bool mute; } h_data; struct { int fisk; diff --git a/src/server.cc b/src/server.cc index cd12db8..fc06a1d 100644 --- a/src/server.cc +++ b/src/server.cc @@ -76,7 +76,6 @@ void newConnection(Socket *socket, Info *info) Network network = Network(socket, info); while(int ret = network.recvPackage(&h, frame->data, frame->size)) { - status.checkPoint(); if(ret == -1) { @@ -84,6 +83,8 @@ void newConnection(Socket *socket, Info *info) break; } + frame->mute = h.header.h_data.mute; + if(!hasCpr) { sprintf(cpr, h.header.h_data.cpr); hasCpr = true; -- cgit v1.2.3