Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to output log to files #32

Merged
merged 2 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ This section describes required fields for the json configuration file.
- **width**: The width of the input video
- **fps**: The frames per second (FPS) of the input video
- **file_path**: The file path of the input video in [YUV](https://en.wikipedia.org/wiki/YUV) format
- **logging**:
- **enabled**: If set to `true`, the client will write log to the file specified
- **log_output_path**: The out path of the log file

***Note: one and only one of `video_source.webcam.enabled` and `video_source.video_file.enabled` has to be `true`. I.e., `video_source.webcam.enabled` XOR `video_source.video_file.enabled`***

Expand Down
8 changes: 8 additions & 0 deletions api/alphacc_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ bool ParseAlphaCCConfig(const std::string& file_path) {
RETURN_ON_FAIL(GetString(third, "file_path", &config->audio_output_path));
}

second.clear();
third.clear();
RETURN_ON_FAIL(GetValue(top, "logging", &second));
RETURN_ON_FAIL(GetBool(second, "enabled", &config->save_log_to_file));
if (config->save_log_to_file) {
RETURN_ON_FAIL(GetString(second, "log_output_path", &config->log_output_path));
}

return true;
}

Expand Down
3 changes: 3 additions & 0 deletions api/alphacc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ struct AlphaCCConfig {
int video_output_height = 0;
int video_output_width = 0;
int video_output_fps = 0;

bool save_log_to_file;
std::string log_output_path;
};

// Get alphaCC global configurations
Expand Down
4 changes: 4 additions & 0 deletions examples/peerconnection/serverless/corpus/receiver.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@
"fps": 10,
"file_path": "outvideo.yuv"
}
},
"logging": {
"enabled": true,
"log_output_path": "webrtc.log"
}
}
3 changes: 3 additions & 0 deletions examples/peerconnection/serverless/corpus/sender.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@
},
"save_to_file": {
"enabled": false
},
"logging": {
"enabled": false
}
}
6 changes: 6 additions & 0 deletions examples/peerconnection/serverless/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ int main(int argc, char* argv[]) {
new rtc::RefCountedObject<Conductor>(&client, &wnd));

auto config = webrtc::GetAlphaCCConfig();

if (config->save_log_to_file) {
rtc::LogMessage::SetIfLogToFile(true);
rtc::LogMessage::SetLogFileName(config->log_output_path);
}

if (config->is_receiver) {
client.StartListen(config->listening_ip, config->listening_port);
}
Expand Down