Skip to content

Commit cb18121

Browse files
Add an unpacker tool for audioproc debug files.
- It only unpacks audio data at the moment. - Also switch to Chrome's protoc.gypi for protobuf targets. This reduces the complexity of our targets. Review URL: http://webrtc-codereview.appspot.com/241009 git-svn-id: http://webrtc.googlecode.com/svn/trunk@817 4adac7df-926f-26a2-2b94-8c16560cd09d
1 parent fc9bcef commit cb18121

File tree

5 files changed

+261
-128
lines changed

5 files changed

+261
-128
lines changed

src/build/protoc.gypi

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
# It was necessary to copy this file to WebRTC, because the path to
6+
# build/common.gypi is different for the standalone and Chromium builds. Gyp
7+
# doesn't permit conditional inclusion or variable expansion in include paths.
8+
# http://code.google.com/p/gyp/wiki/InputFormatReference#Including_Other_Files
9+
10+
# This file is meant to be included into a target to provide a rule
11+
# to invoke protoc in a consistent manner.
12+
#
13+
# To use this, create a gyp target with the following form:
14+
# {
15+
# 'target_name': 'my_proto_lib',
16+
# 'type': 'static_library',
17+
# 'sources': [
18+
# 'foo.proto',
19+
# 'bar.proto',
20+
# ],
21+
# 'variables': {
22+
# # Optional, see below: 'proto_in_dir': '.'
23+
# 'proto_out_dir': 'dir/for/my_proto_lib'
24+
# },
25+
# 'includes': ['path/to/this/gypi/file'],
26+
# }
27+
# If necessary, you may add normal .cc files to the sources list or other gyp
28+
# dependencies. The proto headers are guaranteed to be generated before any
29+
# source files, even within this target, are compiled.
30+
#
31+
# The 'proto_in_dir' variable must be the relative path to the
32+
# directory containing the .proto files. If left out, it defaults to '.'.
33+
#
34+
# The 'proto_out_dir' variable specifies the path suffix that output
35+
# files are generated under. Targets that gyp-depend on my_proto_lib
36+
# will be able to include the resulting proto headers with an include
37+
# like:
38+
# #include "dir/for/my_proto_lib/foo.pb.h"
39+
#
40+
# Implementation notes:
41+
# A proto_out_dir of foo/bar produces
42+
# <(SHARED_INTERMEDIATE_DIR)/protoc_out/foo/bar/{file1,file2}.pb.{cc,h}
43+
# <(SHARED_INTERMEDIATE_DIR)/pyproto/foo/bar/{file1,file2}_pb2.py
44+
45+
{
46+
'variables': {
47+
'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
48+
'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)',
49+
'py_dir': '<(PRODUCT_DIR)/pyproto/<(proto_out_dir)',
50+
'proto_in_dir%': '.',
51+
},
52+
'rules': [
53+
{
54+
'rule_name': 'genproto',
55+
'extension': 'proto',
56+
'inputs': [
57+
'<(protoc)',
58+
],
59+
'outputs': [
60+
'<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py',
61+
'<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc',
62+
'<(cc_dir)/<(RULE_INPUT_ROOT).pb.h',
63+
],
64+
'action': [
65+
'<(protoc)',
66+
'--proto_path=<(proto_in_dir)',
67+
# Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires
68+
# --proto_path is a strict prefix of the path given as an argument.
69+
'<(proto_in_dir)/<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)',
70+
'--cpp_out=<(cc_dir)',
71+
'--python_out=<(py_dir)',
72+
],
73+
'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)',
74+
'process_outputs_as_sources': 1,
75+
},
76+
],
77+
'dependencies': [
78+
'<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host',
79+
'<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite',
80+
],
81+
'include_dirs': [
82+
'<(SHARED_INTERMEDIATE_DIR)/protoc_out',
83+
],
84+
'direct_dependent_settings': {
85+
'include_dirs': [
86+
'<(SHARED_INTERMEDIATE_DIR)/protoc_out',
87+
]
88+
},
89+
'export_dependent_settings': [
90+
# The generated headers reference headers within protobuf_lite,
91+
# so dependencies must be able to find those headers too.
92+
'<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite',
93+
],
94+
# This target exports a hard dependency because it generates header
95+
# files.
96+
'hard_dependency': 1,
97+
}

src/modules/audio_processing/apm_tests.gypi

+23-58
Original file line numberDiff line numberDiff line change
@@ -7,94 +7,59 @@
77
# be found in the AUTHORS file in the root of the source tree.
88

99
{
10-
'variables': {
11-
'protoc_out_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out',
12-
'protoc_out_relpath': 'webrtc/audio_processing',
13-
},
1410
'targets': [
1511
{
1612
'target_name': 'audioproc_unittest',
1713
'type': 'executable',
1814
'conditions': [
1915
['prefer_fixed_point==1', {
20-
'defines': ['WEBRTC_APM_UNIT_TEST_FIXED_PROFILE'],
16+
'defines': [ 'WEBRTC_APM_UNIT_TEST_FIXED_PROFILE' ],
2117
}, {
22-
'defines': ['WEBRTC_APM_UNIT_TEST_FLOAT_PROFILE'],
18+
'defines': [ 'WEBRTC_APM_UNIT_TEST_FLOAT_PROFILE' ],
2319
}],
2420
],
2521
'dependencies': [
26-
'audioproc_unittest_proto',
2722
'audio_processing',
23+
'audioproc_unittest_proto',
2824
'<(webrtc_root)/common_audio/common_audio.gyp:spl',
2925
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
3026
'<(webrtc_root)/../test/test.gyp:test_support',
3127
'<(webrtc_root)/../testing/gtest.gyp:gtest',
32-
'<(webrtc_root)/../third_party/protobuf/protobuf.gyp:protobuf_lite',
33-
],
34-
'include_dirs': [
35-
'<(webrtc_root)/../testing/gtest/include',
36-
'<(protoc_out_dir)',
37-
],
38-
'sources': [
39-
'test/unit_test.cc',
40-
'<(protoc_out_dir)/<(protoc_out_relpath)/unittest.pb.cc',
41-
'<(protoc_out_dir)/<(protoc_out_relpath)/unittest.pb.h',
4228
],
29+
'sources': [ 'test/unit_test.cc', ],
4330
},
4431
{
45-
# Protobuf compiler / generate rule for audioproc_unittest
4632
'target_name': 'audioproc_unittest_proto',
47-
'type': 'none',
33+
'type': 'static_library',
34+
'sources': [ 'test/unittest.proto', ],
4835
'variables': {
49-
'proto_relpath':
50-
'<(webrtc_root)/modules/audio_processing/test',
36+
'proto_in_dir': 'test',
37+
# Workaround to protect against gyp's pathname relativization when this
38+
# file is included by modules.gyp.
39+
'proto_out_protected': 'webrtc/audio_processing',
40+
'proto_out_dir': '<(proto_out_protected)',
5141
},
52-
'sources': [
53-
'<(proto_relpath)/unittest.proto',
54-
],
55-
'rules': [
56-
{
57-
'rule_name': 'genproto',
58-
'extension': 'proto',
59-
'inputs': [
60-
'<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
61-
],
62-
'outputs': [
63-
'<(protoc_out_dir)/<(protoc_out_relpath)/<(RULE_INPUT_ROOT).pb.cc',
64-
'<(protoc_out_dir)/<(RULE_INPUT_ROOT).pb.h',
65-
],
66-
'action': [
67-
'<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
68-
'--proto_path=<(proto_relpath)',
69-
'<(proto_relpath)/<(RULE_INPUT_NAME)',
70-
'--cpp_out=<(protoc_out_dir)/<(protoc_out_relpath)',
71-
],
72-
'message': 'Generating C++ code from <(RULE_INPUT_PATH)',
73-
},
74-
],
75-
'dependencies': [
76-
'<(webrtc_root)/../third_party/protobuf/protobuf.gyp:protoc#host',
77-
],
78-
# This target exports a hard dependency because it generates header
79-
# files.
80-
'hard_dependency': 1,
42+
'includes': [ '../../../build/protoc.gypi', ],
8143
},
8244
{
83-
'target_name': 'audioproc_process_test',
45+
'target_name': 'audioproc',
8446
'type': 'executable',
8547
'dependencies': [
8648
'audio_processing',
49+
'audioproc_debug_proto',
8750
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
8851
'<(webrtc_root)/../testing/gtest.gyp:gtest',
89-
'<(webrtc_root)/../third_party/protobuf/protobuf.gyp:protobuf_lite',
90-
],
91-
'include_dirs': [
92-
'<(webrtc_root)/../testing/gtest/include',
93-
'<(protoc_out_dir)',
9452
],
95-
'sources': [
96-
'test/process_test.cc',
53+
'sources': [ 'test/process_test.cc', ],
54+
},
55+
{
56+
'target_name': 'unpack',
57+
'type': 'executable',
58+
'dependencies': [
59+
'audioproc_debug_proto',
60+
'<(webrtc_root)/../third_party/google-gflags/google-gflags.gyp:google-gflags',
9761
],
62+
'sources': [ 'test/unpack.cc', ],
9863
},
9964
],
10065
}

src/modules/audio_processing/audio_processing.gypi

+14-62
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,21 @@
77
# be found in the AUTHORS file in the root of the source tree.
88

99
{
10-
'variables': {
11-
'protoc_out_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out',
12-
'protoc_out_relpath': 'webrtc/audio_processing',
13-
},
1410
'targets': [
1511
{
1612
'target_name': 'audio_processing',
1713
'type': '<(library)',
1814
'conditions': [
1915
['prefer_fixed_point==1', {
20-
'dependencies': ['ns_fix'],
21-
'defines': ['WEBRTC_NS_FIXED'],
16+
'dependencies': [ 'ns_fix' ],
17+
'defines': [ 'WEBRTC_NS_FIXED' ],
2218
}, {
23-
'dependencies': ['ns'],
24-
'defines': ['WEBRTC_NS_FLOAT'],
25-
}],
26-
['build_with_chromium==1', {
27-
'dependencies': [
28-
'<(webrtc_root)/../protobuf/protobuf.gyp:protobuf_lite',
29-
],
30-
}, {
31-
'dependencies': [
32-
'<(webrtc_root)/../third_party/protobuf/protobuf.gyp:protobuf_lite',
33-
],
19+
'dependencies': [ 'ns' ],
20+
'defines': [ 'WEBRTC_NS_FLOAT' ],
3421
}],
3522
],
3623
'dependencies': [
37-
'debug_proto',
24+
'audioproc_debug_proto',
3825
'aec',
3926
'aecm',
4027
'agc',
@@ -45,7 +32,6 @@
4532
'include_dirs': [
4633
'interface',
4734
'../interface',
48-
'<(protoc_out_dir)',
4935
],
5036
'direct_dependent_settings': {
5137
'include_dirs': [
@@ -77,54 +63,20 @@
7763
'processing_component.h',
7864
'voice_detection_impl.cc',
7965
'voice_detection_impl.h',
80-
'<(protoc_out_dir)/<(protoc_out_relpath)/debug.pb.cc',
81-
'<(protoc_out_dir)/<(protoc_out_relpath)/debug.pb.h',
8266
],
8367
},
8468
{
85-
# Protobuf compiler / generate rule for audio_processing
86-
'target_name': 'debug_proto',
87-
'type': 'none',
69+
'target_name': 'audioproc_debug_proto',
70+
'type': 'static_library',
71+
'sources': [ 'debug.proto', ],
8872
'variables': {
89-
'proto_relpath': '<(webrtc_root)/modules/audio_processing',
73+
'proto_in_dir': '.',
74+
# Workaround to protect against gyp's pathname relativization when this
75+
# file is included by modules.gyp.
76+
'proto_out_protected': 'webrtc/audio_processing',
77+
'proto_out_dir': '<(proto_out_protected)',
9078
},
91-
'sources': [
92-
'<(proto_relpath)/debug.proto',
93-
],
94-
'rules': [
95-
{
96-
'rule_name': 'genproto',
97-
'extension': 'proto',
98-
'inputs': [
99-
'<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
100-
],
101-
'outputs': [
102-
'<(protoc_out_dir)/<(protoc_out_relpath)/<(RULE_INPUT_ROOT).pb.cc',
103-
'<(protoc_out_dir)/<(protoc_out_relpath)/<(RULE_INPUT_ROOT).pb.h',
104-
],
105-
'action': [
106-
'<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
107-
'--proto_path=<(proto_relpath)',
108-
'<(proto_relpath)/<(RULE_INPUT_NAME)',
109-
'--cpp_out=<(protoc_out_dir)/<(protoc_out_relpath)',
110-
],
111-
'message': 'Generating C++ code from <(RULE_INPUT_PATH)',
112-
},
113-
],
114-
'conditions': [
115-
['build_with_chromium==1', {
116-
'dependencies': [
117-
'<(webrtc_root)/../protobuf/protobuf.gyp:protoc#host',
118-
],
119-
}, {
120-
'dependencies': [
121-
'<(webrtc_root)/../third_party/protobuf/protobuf.gyp:protoc#host',
122-
],
123-
}],
124-
],
125-
# This target exports a hard dependency because it generates header
126-
# files.
127-
'hard_dependency': 1,
79+
'includes': [ '../../../build/protoc.gypi', ],
12880
},
12981
],
13082
}

src/modules/audio_processing/test/process_test.cc

+9-8
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ bool ReadMessageFromFile(FILE* file,
4444
::google::protobuf::MessageLite* msg) {
4545
// The "wire format" for the size is little-endian.
4646
// Assume process_test is running on a little-endian machine.
47-
int32_t size;
47+
int32_t size = 0;
4848
if (fread(&size, sizeof(int32_t), 1, file) != 1) {
4949
return false;
5050
}
@@ -116,11 +116,12 @@ void usage() {
116116
printf(" --vad_out_file FILE\n");
117117
printf("\n");
118118
printf("Modifiers:\n");
119-
printf(" --noasm Disable SSE optimization.\n");
120-
printf(" --perf Measure performance.\n");
121-
printf(" --quiet Suppress text output.\n");
122-
printf(" --no_progress Suppress progress.\n");
123-
printf(" --version Print version information and exit.\n");
119+
printf(" --noasm Disable SSE optimization.\n");
120+
printf(" --perf Measure performance.\n");
121+
printf(" --quiet Suppress text output.\n");
122+
printf(" --no_progress Suppress progress.\n");
123+
printf(" --debug_file FILE Dump a debug recording.\n");
124+
printf(" --version Print version information and exit.\n");
124125
}
125126

126127
// void function for gtest.
@@ -359,9 +360,9 @@ void void_main(int argc, char* argv[]) {
359360
printf("%s\n", version);
360361
return;
361362

362-
} else if (strcmp(argv[i], "--debug_recording") == 0) {
363+
} else if (strcmp(argv[i], "--debug_file") == 0) {
363364
i++;
364-
ASSERT_LT(i, argc) << "Specify filename after --debug_recording";
365+
ASSERT_LT(i, argc) << "Specify filename after --debug_file";
365366
ASSERT_EQ(apm->kNoError, apm->StartDebugRecording(argv[i]));
366367
} else {
367368
FAIL() << "Unrecognized argument " << argv[i];

0 commit comments

Comments
 (0)