Continuing to rewrite custom calls.
Added new helper for getting regular input. Rewrote remaining input handling for custom calls. Added a --choose_defaults flag which makes it possible to default on everything (e.g. with the flag, choosing custom call will accept all defaults and go directly to the call). The next patch will add support for overriding arbitrary choices using flags. That is the point I want to arrive at and this patch paves the way for that. Fortunately it gets rid of some repetitive and bug-prone code on the way. BUG= Review URL: https://webrtc-codereview.appspot.com/858005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2878 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -17,39 +17,16 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
static const int kNoDefault = 0;
|
|
||||||
|
|
||||||
ChoiceBuilder::ChoiceBuilder(const Choices& choices)
|
ChoiceBuilder::ChoiceBuilder(const Choices& choices)
|
||||||
: choices_(choices), default_choice_(kNoDefault), input_source_(stdin) {
|
: choices_(choices),
|
||||||
|
input_helper_(new IntegerWithinRangeValidator(1, choices.size())) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int ChoiceBuilder::Choose() {
|
int ChoiceBuilder::Choose() {
|
||||||
if (!title_.empty()) {
|
std::string input = input_helper_
|
||||||
printf("\n%s\n", title_.c_str());
|
.WithTitle(MakeTitleWithOptions())
|
||||||
}
|
.AskForInput();
|
||||||
|
return atoi(input.c_str());
|
||||||
Choices::const_iterator iterator = choices_.begin();
|
|
||||||
for (int number = 1; iterator != choices_.end(); ++iterator, ++number)
|
|
||||||
printf(" %d. %s\n", number, (*iterator).c_str());
|
|
||||||
|
|
||||||
if (default_choice_ != kNoDefault)
|
|
||||||
printf(" Hit enter for default (%s):\n", default_choice_text_.c_str());
|
|
||||||
printf("# ");
|
|
||||||
char input[8];
|
|
||||||
if (!fgets(input, 8, input_source_))
|
|
||||||
input[0] = '0'; // Make the selection fail
|
|
||||||
int selection;
|
|
||||||
if (input[0] == '\n')
|
|
||||||
selection = default_choice_;
|
|
||||||
else
|
|
||||||
selection = atoi(input);
|
|
||||||
|
|
||||||
if (selection < 1 || selection > static_cast<int>(choices_.size())) {
|
|
||||||
printf("Please select one of the given options.\n");
|
|
||||||
return Choose();
|
|
||||||
}
|
|
||||||
|
|
||||||
return selection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ChoiceBuilder& ChoiceBuilder::WithDefault(const std::string& default_choice) {
|
ChoiceBuilder& ChoiceBuilder::WithDefault(const std::string& default_choice) {
|
||||||
@ -58,13 +35,16 @@ ChoiceBuilder& ChoiceBuilder::WithDefault(const std::string& default_choice) {
|
|||||||
assert(iterator != choices_.end() && "No such choice.");
|
assert(iterator != choices_.end() && "No such choice.");
|
||||||
|
|
||||||
// Store the value as the choice number, e.g. its index + 1.
|
// Store the value as the choice number, e.g. its index + 1.
|
||||||
default_choice_ = (iterator - choices_.begin()) + 1;
|
int choice_index = (iterator - choices_.begin()) + 1;
|
||||||
default_choice_text_ = default_choice;
|
char number[16];
|
||||||
|
sprintf(number, "%d", choice_index);
|
||||||
|
|
||||||
|
input_helper_.WithDefault(number);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChoiceBuilder& ChoiceBuilder::WithInputSource(FILE* input_source) {
|
ChoiceBuilder& ChoiceBuilder::WithInputSource(FILE* input_source) {
|
||||||
input_source_ = input_source;
|
input_helper_.WithInputSource(input_source);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,6 +53,17 @@ ChoiceBuilder& ChoiceBuilder::WithTitle(const std::string& title) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ChoiceBuilder::MakeTitleWithOptions() {
|
||||||
|
std::string title_with_options = title_;
|
||||||
|
Choices::const_iterator iterator = choices_.begin();
|
||||||
|
for (int number = 1; iterator != choices_.end(); ++iterator, ++number) {
|
||||||
|
char buffer[128];
|
||||||
|
sprintf(buffer, "\n %d. %s", number, (*iterator).c_str());
|
||||||
|
title_with_options += buffer;
|
||||||
|
}
|
||||||
|
return title_with_options;
|
||||||
|
}
|
||||||
|
|
||||||
Choices SplitChoices(const std::string& raw_choices) {
|
Choices SplitChoices(const std::string& raw_choices) {
|
||||||
Choices result;
|
Choices result;
|
||||||
size_t current_pos = 0;
|
size_t current_pos = 0;
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "video_engine/test/auto_test/primitives/input_helpers.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
typedef std::vector<std::string> Choices;
|
typedef std::vector<std::string> Choices;
|
||||||
@ -52,13 +54,12 @@ class ChoiceBuilder {
|
|||||||
// Prints the choice list and requests input from the input source. Returns
|
// Prints the choice list and requests input from the input source. Returns
|
||||||
// the choice number (choices start at 1).
|
// the choice number (choices start at 1).
|
||||||
int Choose();
|
int Choose();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string MakeTitleWithOptions();
|
||||||
|
|
||||||
Choices choices_;
|
Choices choices_;
|
||||||
int default_choice_;
|
InputBuilder input_helper_;
|
||||||
std::string default_choice_text_;
|
|
||||||
std::string title_;
|
std::string title_;
|
||||||
FILE* input_source_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convenience function that creates a choice builder given a string where
|
// Convenience function that creates a choice builder given a string where
|
||||||
|
@ -12,21 +12,7 @@
|
|||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "video_engine/test/auto_test/primitives/choice_helpers.h"
|
#include "video_engine/test/auto_test/primitives/choice_helpers.h"
|
||||||
|
#include "video_engine/test/auto_test/primitives/fake_stdin.h"
|
||||||
namespace {
|
|
||||||
|
|
||||||
FILE* FakeStdin(const std::string& input) {
|
|
||||||
FILE* fake_stdin = tmpfile();
|
|
||||||
|
|
||||||
EXPECT_EQ(input.size(),
|
|
||||||
fwrite(input.c_str(), sizeof(char), input.size(), fake_stdin));
|
|
||||||
rewind(fake_stdin);
|
|
||||||
|
|
||||||
return fake_stdin;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
25
src/video_engine/test/auto_test/primitives/fake_stdin.cc
Normal file
25
src/video_engine/test/auto_test/primitives/fake_stdin.cc
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
* tree. An additional intellectual property rights grant can be found
|
||||||
|
* in the file PATENTS. All contributing project authors may
|
||||||
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "video_engine/test/auto_test/primitives/fake_stdin.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
FILE* FakeStdin(const std::string& input) {
|
||||||
|
FILE* fake_stdin = tmpfile();
|
||||||
|
|
||||||
|
EXPECT_EQ(input.size(),
|
||||||
|
fwrite(input.c_str(), sizeof(char), input.size(), fake_stdin));
|
||||||
|
rewind(fake_stdin);
|
||||||
|
|
||||||
|
return fake_stdin;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace webrtc
|
25
src/video_engine/test/auto_test/primitives/fake_stdin.h
Normal file
25
src/video_engine/test/auto_test/primitives/fake_stdin.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
* tree. An additional intellectual property rights grant can be found
|
||||||
|
* in the file PATENTS. All contributing project authors may
|
||||||
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
#ifndef FAKE_STDIN_H_
|
||||||
|
#define FAKE_STDIN_H_
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
// Creates a fake stdin-like FILE* for unit test usage.
|
||||||
|
FILE* FakeStdin(const std::string& input);
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
|
#endif // FAKE_STDIN_H_
|
99
src/video_engine/test/auto_test/primitives/input_helpers.cc
Normal file
99
src/video_engine/test/auto_test/primitives/input_helpers.cc
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
* tree. An additional intellectual property rights grant can be found
|
||||||
|
* in the file PATENTS. All contributing project authors may
|
||||||
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "video_engine/test/auto_test/primitives/input_helpers.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "gflags/gflags.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
DEFINE_bool(choose_defaults, false,
|
||||||
|
"Make the default choice at every choice when running a custom call.");
|
||||||
|
|
||||||
|
class AcceptAllNonEmptyValidator : public InputValidator {
|
||||||
|
public:
|
||||||
|
bool InputOk(const std::string& value) const {
|
||||||
|
return value.length() > 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
InputBuilder::InputBuilder(const InputValidator* input_validator)
|
||||||
|
: input_source_(stdin), input_validator_(input_validator),
|
||||||
|
default_value_("") {
|
||||||
|
}
|
||||||
|
|
||||||
|
InputBuilder::~InputBuilder() {
|
||||||
|
delete input_validator_;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string InputBuilder::AskForInput() const {
|
||||||
|
if (FLAGS_choose_defaults && !default_value_.empty())
|
||||||
|
return default_value_;
|
||||||
|
if (!title_.empty())
|
||||||
|
printf("\n%s\n", title_.c_str());
|
||||||
|
|
||||||
|
if (!default_value_.empty())
|
||||||
|
printf("Hit enter for default (%s):\n", default_value_.c_str());
|
||||||
|
|
||||||
|
printf("# ");
|
||||||
|
char raw_input[128];
|
||||||
|
if (!fgets(raw_input, 128, input_source_)) {
|
||||||
|
// If we get here the user probably hit CTRL+D.
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string input = raw_input;
|
||||||
|
input = input.substr(0, input.size() - 1); // Strip last \n.
|
||||||
|
|
||||||
|
if (input.empty() && !default_value_.empty())
|
||||||
|
return default_value_;
|
||||||
|
|
||||||
|
if (!input_validator_->InputOk(input)) {
|
||||||
|
printf("Invalid input. Please try again.\n");
|
||||||
|
return AskForInput();
|
||||||
|
}
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
InputBuilder& InputBuilder::WithInputSource(FILE* input_source) {
|
||||||
|
input_source_ = input_source;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
InputBuilder& InputBuilder::WithInputValidator(
|
||||||
|
const InputValidator* input_validator) {
|
||||||
|
// If there's a default value, it must be accepted by the input validator.
|
||||||
|
assert(default_value_.empty() || input_validator->InputOk(default_value_));
|
||||||
|
delete input_validator_;
|
||||||
|
input_validator_ = input_validator;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
InputBuilder& InputBuilder::WithDefault(const std::string& default_value) {
|
||||||
|
assert(input_validator_->InputOk(default_value));
|
||||||
|
default_value_ = default_value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
InputBuilder& InputBuilder::WithTitle(const std::string& title) {
|
||||||
|
title_ = title;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
InputBuilder TypedInput() {
|
||||||
|
return InputBuilder(new AcceptAllNonEmptyValidator());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace webrtc
|
82
src/video_engine/test/auto_test/primitives/input_helpers.h
Normal file
82
src/video_engine/test/auto_test/primitives/input_helpers.h
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
* tree. An additional intellectual property rights grant can be found
|
||||||
|
* in the file PATENTS. All contributing project authors may
|
||||||
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_PRIMITIVES_
|
||||||
|
#define WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_PRIMITIVES_
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
class InputValidator {
|
||||||
|
public:
|
||||||
|
virtual ~InputValidator() {}
|
||||||
|
|
||||||
|
virtual bool InputOk(const std::string& value) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class InputBuilder {
|
||||||
|
public:
|
||||||
|
// The input builder takes ownership of the validator.
|
||||||
|
explicit InputBuilder(const InputValidator* input_validator);
|
||||||
|
~InputBuilder();
|
||||||
|
|
||||||
|
// Ask the user for input, reads input from the input source and returns
|
||||||
|
// the answer. This method will keep asking the user until a correct answer
|
||||||
|
// is returned and is thereby guaranteed to return a response that is
|
||||||
|
// acceptable to the input validator.
|
||||||
|
std::string AskForInput() const;
|
||||||
|
|
||||||
|
// Replaces the input source where we ask for input. Default is stdin.
|
||||||
|
InputBuilder& WithInputSource(FILE* input_source);
|
||||||
|
|
||||||
|
// Sets the input validator. The input builder takes ownership. If a default
|
||||||
|
// value has been set, it must be acceptable to this validator.
|
||||||
|
InputBuilder& WithInputValidator(const InputValidator* input_validator);
|
||||||
|
// Sets a default value if the user doesn't want to give input. This value
|
||||||
|
// must be acceptable to the input validator.
|
||||||
|
InputBuilder& WithDefault(const std::string& default_value);
|
||||||
|
// Prints a title before querying the user.
|
||||||
|
InputBuilder& WithTitle(const std::string& title);
|
||||||
|
|
||||||
|
private:
|
||||||
|
FILE* input_source_;
|
||||||
|
const InputValidator* input_validator_;
|
||||||
|
std::string default_value_;
|
||||||
|
std::string title_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Ensures input is an integer between low and high (inclusive).
|
||||||
|
class IntegerWithinRangeValidator : public InputValidator {
|
||||||
|
public:
|
||||||
|
IntegerWithinRangeValidator(int low, int high)
|
||||||
|
: low_(low), high_(high) {}
|
||||||
|
|
||||||
|
bool InputOk(const std::string& input) const {
|
||||||
|
int value = atoi(input.c_str());
|
||||||
|
// Note: atoi returns 0 on failure.
|
||||||
|
if (value == 0 && input.length() > 0 && input[0] != '0')
|
||||||
|
return false; // Probably bad input.
|
||||||
|
return value >= low_ && value <= high_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int low_;
|
||||||
|
int high_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convenience method for creating an input builder.
|
||||||
|
InputBuilder TypedInput();
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
|
#endif // WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_PRIMITIVES_
|
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
* tree. An additional intellectual property rights grant can be found
|
||||||
|
* in the file PATENTS. All contributing project authors may
|
||||||
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
#include "video_engine/test/auto_test/primitives/fake_stdin.h"
|
||||||
|
#include "video_engine/test/auto_test/primitives/input_helpers.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
class InputHelpersTest: public testing::Test {
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(InputHelpersTest, AcceptsAnyInputExceptEmptyByDefault) {
|
||||||
|
FILE* fake_stdin = FakeStdin("\n\nWhatever\n");
|
||||||
|
std::string result = TypedInput().WithInputSource(fake_stdin).AskForInput();
|
||||||
|
EXPECT_EQ("Whatever", result);
|
||||||
|
fclose(fake_stdin);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(InputHelpersTest, ReturnsDefaultOnEmptyInputIfDefaultSet) {
|
||||||
|
FILE* fake_stdin = FakeStdin("\n\nWhatever\n");
|
||||||
|
std::string result = TypedInput()
|
||||||
|
.WithInputSource(fake_stdin)
|
||||||
|
.WithDefault("MyDefault")
|
||||||
|
.AskForInput();
|
||||||
|
EXPECT_EQ("MyDefault", result);
|
||||||
|
fclose(fake_stdin);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(InputHelpersTest, CanSetTitle) {
|
||||||
|
FILE* fake_stdin = FakeStdin("\n\nWhatever\n");
|
||||||
|
std::string result = TypedInput()
|
||||||
|
.WithInputSource(fake_stdin)
|
||||||
|
.WithTitle("Make a choice!")
|
||||||
|
.AskForInput();
|
||||||
|
EXPECT_EQ("Whatever", result);
|
||||||
|
fclose(fake_stdin);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(InputHelpersTest, ObeysInputValidator) {
|
||||||
|
class ValidatorWhichOnlyAcceptsFooBar : public InputValidator {
|
||||||
|
public:
|
||||||
|
bool InputOk(const std::string& input) const {
|
||||||
|
return input == "FooBar";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
FILE* fake_stdin = FakeStdin("\nFoo\nBar\nFoo Bar\nFooBar\n");
|
||||||
|
std::string result = TypedInput()
|
||||||
|
.WithInputSource(fake_stdin)
|
||||||
|
.WithInputValidator(new ValidatorWhichOnlyAcceptsFooBar())
|
||||||
|
.AskForInput();
|
||||||
|
EXPECT_EQ("FooBar", result);
|
||||||
|
fclose(fake_stdin);
|
||||||
|
}
|
||||||
|
};
|
@ -8,30 +8,34 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <climits>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "video_engine/test/auto_test/interface/vie_autotest.h"
|
#include "video_engine/test/auto_test/interface/vie_autotest.h"
|
||||||
#include "video_engine/test/auto_test/interface/vie_autotest_defines.h"
|
#include "video_engine/test/auto_test/interface/vie_autotest_defines.h"
|
||||||
#include "video_engine/test/auto_test/primitives/choice_helpers.h"
|
#include "video_engine/test/auto_test/primitives/choice_helpers.h"
|
||||||
|
#include "video_engine/test/auto_test/primitives/input_helpers.h"
|
||||||
|
|
||||||
#define VCM_RED_PAYLOAD_TYPE 96
|
#define VCM_RED_PAYLOAD_TYPE 96
|
||||||
#define VCM_ULPFEC_PAYLOAD_TYPE 97
|
#define VCM_ULPFEC_PAYLOAD_TYPE 97
|
||||||
#define DEFAULT_SEND_IP "127.0.0.1"
|
#define DEFAULT_SEND_IP "127.0.0.1"
|
||||||
#define DEFAULT_VIDEO_PORT 11111
|
#define DEFAULT_VIDEO_PORT "11111"
|
||||||
#define DEFAULT_VIDEO_CODEC "VP8"
|
#define DEFAULT_VIDEO_CODEC "VP8"
|
||||||
#define DEFAULT_VIDEO_CODEC_WIDTH 640
|
#define DEFAULT_VIDEO_CODEC_WIDTH "640"
|
||||||
#define DEFAULT_VIDEO_CODEC_HEIGHT 480
|
#define DEFAULT_VIDEO_CODEC_HEIGHT "480"
|
||||||
#define DEFAULT_VIDEO_CODEC_BITRATE 300
|
#define DEFAULT_VIDEO_CODEC_BITRATE "300"
|
||||||
#define DEFAULT_VIDEO_CODEC_MIN_BITRATE 100
|
#define DEFAULT_VIDEO_CODEC_MIN_BITRATE "100"
|
||||||
#define DEFAULT_VIDEO_CODEC_MAX_BITRATE 1000
|
#define DEFAULT_VIDEO_CODEC_MAX_BITRATE "1000"
|
||||||
#define DEFAULT_AUDIO_PORT 11113
|
#define DEFAULT_AUDIO_PORT "11113"
|
||||||
#define DEFAULT_AUDIO_CODEC "ISAC"
|
#define DEFAULT_AUDIO_CODEC "ISAC"
|
||||||
#define DEFAULT_INCOMING_FILE_NAME "IncomingFile.avi"
|
#define DEFAULT_INCOMING_FILE_NAME "IncomingFile.avi"
|
||||||
#define DEFAULT_OUTGOING_FILE_NAME "OutgoingFile.avi"
|
#define DEFAULT_OUTGOING_FILE_NAME "OutgoingFile.avi"
|
||||||
#define DEFAULT_VIDEO_CODEC_MAX_FRAMERATE 30
|
#define DEFAULT_VIDEO_CODEC_MAX_FRAMERATE "30"
|
||||||
#define DEFAULT_VIDEO_PROTECTION_METHOD "None"
|
#define DEFAULT_VIDEO_PROTECTION_METHOD "None"
|
||||||
#define DEFAULT_TEMPORAL_LAYER 0
|
#define DEFAULT_TEMPORAL_LAYER "0"
|
||||||
|
|
||||||
enum StatisticsType {
|
enum StatisticsType {
|
||||||
kSendStatistic,
|
kSendStatistic,
|
||||||
@ -46,6 +50,7 @@ enum VideoProtectionMethod {
|
|||||||
};
|
};
|
||||||
|
|
||||||
using webrtc::FromChoices;
|
using webrtc::FromChoices;
|
||||||
|
using webrtc::TypedInput;
|
||||||
|
|
||||||
class ViEAutotestFileObserver : public webrtc::ViEFileObserver {
|
class ViEAutotestFileObserver : public webrtc::ViEFileObserver {
|
||||||
public:
|
public:
|
||||||
@ -92,18 +97,18 @@ class ViEAutotestDecoderObserver : public webrtc::ViEDecoderObserver {
|
|||||||
bool GetVideoDevice(webrtc::ViEBase* vie_base,
|
bool GetVideoDevice(webrtc::ViEBase* vie_base,
|
||||||
webrtc::ViECapture* vie_capture,
|
webrtc::ViECapture* vie_capture,
|
||||||
char* capture_device_name, char* capture_device_unique_id);
|
char* capture_device_name, char* capture_device_unique_id);
|
||||||
bool GetIPAddress(char* IP);
|
std::string GetIPAddress();
|
||||||
bool ValidateIP(std::string i_str);
|
bool ValidateIP(std::string i_str);
|
||||||
|
|
||||||
// The following are Print to stdout functions.
|
// The following are Print to stdout functions.
|
||||||
void PrintCallInformation(char* IP,
|
void PrintCallInformation(const char* IP,
|
||||||
char* video_capture_device_name,
|
const char* video_capture_device_name,
|
||||||
char* video_capture_unique_id,
|
const char* video_capture_unique_id,
|
||||||
webrtc::VideoCodec video_codec,
|
webrtc::VideoCodec video_codec,
|
||||||
int video_tx_port,
|
int video_tx_port,
|
||||||
int video_rx_port,
|
int video_rx_port,
|
||||||
char* audio_capture_device_name,
|
const char* audio_capture_device_name,
|
||||||
char* audio_playbackDeviceName,
|
const char* audio_playbackDeviceName,
|
||||||
webrtc::CodecInst audio_codec,
|
webrtc::CodecInst audio_codec,
|
||||||
int audio_tx_port,
|
int audio_tx_port,
|
||||||
int audio_rx_port,
|
int audio_rx_port,
|
||||||
@ -125,24 +130,16 @@ void PrintVideoStreamInformation(webrtc::ViECodec* vie_codec,
|
|||||||
void PrintVideoCodec(webrtc::VideoCodec video_codec);
|
void PrintVideoCodec(webrtc::VideoCodec video_codec);
|
||||||
|
|
||||||
// The following are video functions.
|
// The following are video functions.
|
||||||
// TODO(amyfong): change to pointers as input arguments
|
void GetVideoPorts(int* tx_port, int* rx_port);
|
||||||
// instead of references
|
void SetVideoCodecType(webrtc::ViECodec* vie_codec,
|
||||||
bool SetVideoPorts(int* tx_port, int* rx_port);
|
|
||||||
bool SetVideoCodecType(webrtc::ViECodec* vie_codec,
|
|
||||||
webrtc::VideoCodec* video_codec);
|
webrtc::VideoCodec* video_codec);
|
||||||
bool SetVideoCodecResolution(webrtc::ViECodec* vie_codec,
|
void SetVideoCodecResolution(webrtc::VideoCodec* video_codec);
|
||||||
webrtc::VideoCodec* video_codec);
|
void SetVideoCodecSize(webrtc::VideoCodec* video_codec);
|
||||||
bool SetVideoCodecSize(webrtc::ViECodec* vie_codec,
|
void SetVideoCodecBitrate(webrtc::VideoCodec* video_codec);
|
||||||
webrtc::VideoCodec* video_codec);
|
void SetVideoCodecMinBitrate(webrtc::VideoCodec* video_codec);
|
||||||
bool SetVideoCodecBitrate(webrtc::ViECodec* vie_codec,
|
void SetVideoCodecMaxBitrate(webrtc::VideoCodec* video_codec);
|
||||||
webrtc::VideoCodec* video_codec);
|
void SetVideoCodecMaxFramerate(webrtc::VideoCodec* video_codec);
|
||||||
bool SetVideoCodecMinBitrate(webrtc::ViECodec* vie_codec,
|
void SetVideoCodecTemporalLayer(webrtc::VideoCodec* video_codec);
|
||||||
webrtc::VideoCodec* video_codec);
|
|
||||||
bool SetVideoCodecMaxBitrate(webrtc::ViECodec* vie_codec,
|
|
||||||
webrtc::VideoCodec* video_codec);
|
|
||||||
bool SetVideoCodecMaxFramerate(webrtc::ViECodec* vie_codec,
|
|
||||||
webrtc::VideoCodec* video_codec);
|
|
||||||
bool SetVideoCodecTemporalLayer(webrtc::VideoCodec* video_codec);
|
|
||||||
VideoProtectionMethod GetVideoProtection();
|
VideoProtectionMethod GetVideoProtection();
|
||||||
bool SetVideoProtection(webrtc::ViECodec* vie_codec,
|
bool SetVideoProtection(webrtc::ViECodec* vie_codec,
|
||||||
webrtc::ViERTP_RTCP* vie_rtp_rtcp,
|
webrtc::ViERTP_RTCP* vie_rtp_rtcp,
|
||||||
@ -158,7 +155,7 @@ bool GetAudioDevices(webrtc::VoEBase* voe_base,
|
|||||||
bool GetAudioDevices(webrtc::VoEBase* voe_base,
|
bool GetAudioDevices(webrtc::VoEBase* voe_base,
|
||||||
webrtc::VoEHardware* voe_hardware,
|
webrtc::VoEHardware* voe_hardware,
|
||||||
int& recording_device_index, int& playback_device_index);
|
int& recording_device_index, int& playback_device_index);
|
||||||
bool GetAudioPorts(int* tx_port, int* rx_port);
|
void GetAudioPorts(int* tx_port, int* rx_port);
|
||||||
bool GetAudioCodec(webrtc::VoECodec* voe_codec,
|
bool GetAudioCodec(webrtc::VoECodec* voe_codec,
|
||||||
webrtc::CodecInst& audio_codec);
|
webrtc::CodecInst& audio_codec);
|
||||||
|
|
||||||
@ -244,8 +241,7 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
__LINE__);
|
__LINE__);
|
||||||
|
|
||||||
bool start_call = false;
|
bool start_call = false;
|
||||||
const unsigned int kMaxIPLength = 16;
|
std::string ip_address;
|
||||||
char ip_address[kMaxIPLength] = "";
|
|
||||||
const unsigned int KMaxUniqueIdLength = 256;
|
const unsigned int KMaxUniqueIdLength = 256;
|
||||||
char unique_id[KMaxUniqueIdLength] = "";
|
char unique_id[KMaxUniqueIdLength] = "";
|
||||||
char device_name[KMaxUniqueIdLength] = "";
|
char device_name[KMaxUniqueIdLength] = "";
|
||||||
@ -267,8 +263,7 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
|
|
||||||
while (!start_call) {
|
while (!start_call) {
|
||||||
// Get the IP address to use from call.
|
// Get the IP address to use from call.
|
||||||
memset(ip_address, 0, kMaxIPLength);
|
ip_address = GetIPAddress();
|
||||||
GetIPAddress(ip_address);
|
|
||||||
|
|
||||||
// Get the video device to use for call.
|
// Get the video device to use for call.
|
||||||
memset(device_name, 0, KMaxUniqueIdLength);
|
memset(device_name, 0, KMaxUniqueIdLength);
|
||||||
@ -279,16 +274,16 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
// Get and set the video ports for the call.
|
// Get and set the video ports for the call.
|
||||||
video_tx_port = 0;
|
video_tx_port = 0;
|
||||||
video_rx_port = 0;
|
video_rx_port = 0;
|
||||||
SetVideoPorts(&video_tx_port, &video_rx_port);
|
GetVideoPorts(&video_tx_port, &video_rx_port);
|
||||||
|
|
||||||
// Get and set the video codec parameters for the call.
|
// Get and set the video codec parameters for the call.
|
||||||
memset(&video_send_codec, 0, sizeof(webrtc::VideoCodec));
|
memset(&video_send_codec, 0, sizeof(webrtc::VideoCodec));
|
||||||
SetVideoCodecType(vie_codec, &video_send_codec);
|
SetVideoCodecType(vie_codec, &video_send_codec);
|
||||||
SetVideoCodecSize(vie_codec, &video_send_codec);
|
SetVideoCodecSize(&video_send_codec);
|
||||||
SetVideoCodecBitrate(vie_codec, &video_send_codec);
|
SetVideoCodecBitrate(&video_send_codec);
|
||||||
SetVideoCodecMinBitrate(vie_codec, &video_send_codec);
|
SetVideoCodecMinBitrate(&video_send_codec);
|
||||||
SetVideoCodecMaxBitrate(vie_codec, &video_send_codec);
|
SetVideoCodecMaxBitrate(&video_send_codec);
|
||||||
SetVideoCodecMaxFramerate(vie_codec, &video_send_codec);
|
SetVideoCodecMaxFramerate(&video_send_codec);
|
||||||
SetVideoCodecTemporalLayer(&video_send_codec);
|
SetVideoCodecTemporalLayer(&video_send_codec);
|
||||||
remb = GetBitrateSignaling();
|
remb = GetBitrateSignaling();
|
||||||
|
|
||||||
@ -312,8 +307,8 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
GetAudioCodec(voe_codec, audio_codec);
|
GetAudioCodec(voe_codec, audio_codec);
|
||||||
|
|
||||||
// Now ready to start the call. Check user wants to continue.
|
// Now ready to start the call. Check user wants to continue.
|
||||||
PrintCallInformation(ip_address, device_name, unique_id, video_send_codec,
|
PrintCallInformation(ip_address.c_str(), device_name, unique_id,
|
||||||
video_tx_port, video_rx_port,
|
video_send_codec, video_tx_port, video_rx_port,
|
||||||
audio_capture_device_name, audio_playbackDeviceName,
|
audio_capture_device_name, audio_playbackDeviceName,
|
||||||
audio_codec, audio_tx_port, audio_rx_port,
|
audio_codec, audio_tx_port, audio_rx_port,
|
||||||
protection_method);
|
protection_method);
|
||||||
@ -332,7 +327,7 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
// Configure audio channel first.
|
// Configure audio channel first.
|
||||||
audio_channel = voe_base->CreateChannel();
|
audio_channel = voe_base->CreateChannel();
|
||||||
error = voe_base->SetSendDestination(audio_channel, audio_tx_port,
|
error = voe_base->SetSendDestination(audio_channel, audio_tx_port,
|
||||||
ip_address);
|
ip_address.c_str());
|
||||||
number_of_errors += ViETest::TestError(error == 0,
|
number_of_errors += ViETest::TestError(error == 0,
|
||||||
"ERROR: %s at line %d",
|
"ERROR: %s at line %d",
|
||||||
__FUNCTION__, __LINE__);
|
__FUNCTION__, __LINE__);
|
||||||
@ -451,7 +446,7 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
number_of_errors += ViETest::TestError(error == 0,
|
number_of_errors += ViETest::TestError(error == 0,
|
||||||
"ERROR: %s at line %d",
|
"ERROR: %s at line %d",
|
||||||
__FUNCTION__, __LINE__);
|
__FUNCTION__, __LINE__);
|
||||||
error = vie_network->SetSendDestination(video_channel, ip_address,
|
error = vie_network->SetSendDestination(video_channel, ip_address.c_str(),
|
||||||
video_tx_port);
|
video_tx_port);
|
||||||
number_of_errors += ViETest::TestError(error == 0,
|
number_of_errors += ViETest::TestError(error == 0,
|
||||||
"ERROR: %s at line %d",
|
"ERROR: %s at line %d",
|
||||||
@ -527,7 +522,7 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
int selection = FromChoices(
|
int selection = FromChoices(
|
||||||
"Stop the call\n"
|
"Stop the call\n"
|
||||||
"Modify the call\n").WithDefault("Stop the call").Choose();
|
"Modify the call\n").Choose();
|
||||||
|
|
||||||
int file_selection = 0;
|
int file_selection = 0;
|
||||||
|
|
||||||
@ -560,13 +555,13 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
case 2:
|
case 2:
|
||||||
// Change video codec.
|
// Change video codec.
|
||||||
SetVideoCodecType(vie_codec, &video_send_codec);
|
SetVideoCodecType(vie_codec, &video_send_codec);
|
||||||
SetVideoCodecSize(vie_codec, &video_send_codec);
|
SetVideoCodecSize(&video_send_codec);
|
||||||
SetVideoCodecBitrate(vie_codec, &video_send_codec);
|
SetVideoCodecBitrate(&video_send_codec);
|
||||||
SetVideoCodecMinBitrate(vie_codec, &video_send_codec);
|
SetVideoCodecMinBitrate(&video_send_codec);
|
||||||
SetVideoCodecMaxBitrate(vie_codec, &video_send_codec);
|
SetVideoCodecMaxBitrate(&video_send_codec);
|
||||||
SetVideoCodecMaxFramerate(vie_codec, &video_send_codec);
|
SetVideoCodecMaxFramerate(&video_send_codec);
|
||||||
SetVideoCodecTemporalLayer(&video_send_codec);
|
SetVideoCodecTemporalLayer(&video_send_codec);
|
||||||
PrintCallInformation(ip_address, device_name,
|
PrintCallInformation(ip_address.c_str(), device_name,
|
||||||
unique_id, video_send_codec,
|
unique_id, video_send_codec,
|
||||||
video_tx_port, video_rx_port,
|
video_tx_port, video_rx_port,
|
||||||
audio_capture_device_name,
|
audio_capture_device_name,
|
||||||
@ -583,8 +578,8 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
// Change Video codec size by common resolution.
|
// Change Video codec size by common resolution.
|
||||||
SetVideoCodecResolution(vie_codec, &video_send_codec);
|
SetVideoCodecResolution(&video_send_codec);
|
||||||
PrintCallInformation(ip_address, device_name,
|
PrintCallInformation(ip_address.c_str(), device_name,
|
||||||
unique_id, video_send_codec,
|
unique_id, video_send_codec,
|
||||||
video_tx_port, video_rx_port,
|
video_tx_port, video_rx_port,
|
||||||
audio_capture_device_name,
|
audio_capture_device_name,
|
||||||
@ -601,8 +596,8 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
// Change video codec by size height and width.
|
// Change video codec by size height and width.
|
||||||
SetVideoCodecSize(vie_codec, &video_send_codec);
|
SetVideoCodecSize(&video_send_codec);
|
||||||
PrintCallInformation(ip_address, device_name,
|
PrintCallInformation(ip_address.c_str(), device_name,
|
||||||
unique_id, video_send_codec,
|
unique_id, video_send_codec,
|
||||||
video_tx_port, video_rx_port,
|
video_tx_port, video_rx_port,
|
||||||
audio_capture_device_name,
|
audio_capture_device_name,
|
||||||
@ -809,7 +804,7 @@ int ViEAutoTest::ViECustomCall() {
|
|||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
// Print Call information..
|
// Print Call information..
|
||||||
PrintCallInformation(ip_address, device_name,
|
PrintCallInformation(ip_address.c_str(), device_name,
|
||||||
unique_id, video_send_codec,
|
unique_id, video_send_codec,
|
||||||
video_tx_port, video_rx_port,
|
video_tx_port, video_rx_port,
|
||||||
audio_capture_device_name,
|
audio_capture_device_name,
|
||||||
@ -1123,148 +1118,55 @@ bool GetAudioDevices(webrtc::VoEBase* voe_base,
|
|||||||
|
|
||||||
// General helper functions.
|
// General helper functions.
|
||||||
|
|
||||||
bool GetIPAddress(char* i_ip) {
|
std::string GetIPAddress() {
|
||||||
char o_ip[16] = DEFAULT_SEND_IP;
|
class IpValidator : public webrtc::InputValidator {
|
||||||
std::string str;
|
public:
|
||||||
|
bool InputOk(const std::string& input) const {
|
||||||
while (1) {
|
// Just check quickly that it's on the form x.y.z.w
|
||||||
std::cout << std::endl;
|
return std::count(input.begin(), input.end(), '.') == 3;
|
||||||
std::cout << "Enter destination IP. Press enter for default ("
|
|
||||||
<< o_ip << "): ";
|
|
||||||
std::getline(std::cin, str);
|
|
||||||
|
|
||||||
if (str.compare("") == 0) {
|
|
||||||
// use default value;
|
|
||||||
strcpy(i_ip, o_ip);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (ValidateIP(str) == false) {
|
};
|
||||||
std::cout << "Invalid entry. Try again." << std::endl;
|
return TypedInput()
|
||||||
continue;
|
.WithDefault(DEFAULT_SEND_IP)
|
||||||
}
|
.WithTitle("Enter destination IP.")
|
||||||
// Done, copy std::string to c_string and return.
|
.WithInputValidator(new IpValidator())
|
||||||
strcpy(i_ip, str.c_str());
|
.AskForInput();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ValidateIP(std::string i_str) {
|
|
||||||
if (0 == i_str.compare("")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Video settings functions.
|
// Video settings functions.
|
||||||
|
|
||||||
bool SetVideoPorts(int* tx_port, int* rx_port) {
|
void GetVideoPorts(int* tx_port, int* rx_port) {
|
||||||
std::string str;
|
std::string tx_input = TypedInput()
|
||||||
int port = 0;
|
.WithTitle("Enter video send port.")
|
||||||
|
.WithDefault(DEFAULT_VIDEO_PORT)
|
||||||
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536))
|
||||||
|
.AskForInput();
|
||||||
|
*tx_port = atoi(tx_input.c_str());
|
||||||
|
|
||||||
// Set to default values.
|
std::string rx_input = TypedInput()
|
||||||
*tx_port = DEFAULT_VIDEO_PORT;
|
.WithTitle("Enter video receive port.")
|
||||||
*rx_port = DEFAULT_VIDEO_PORT;
|
.WithDefault(DEFAULT_VIDEO_PORT)
|
||||||
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536))
|
||||||
while (1) {
|
.AskForInput();
|
||||||
std::cout << "Enter video send port. Press enter for default ("
|
*rx_port = atoi(rx_input.c_str());
|
||||||
<< *tx_port << "): ";
|
|
||||||
std::getline(std::cin, str);
|
|
||||||
port = atoi(str.c_str());
|
|
||||||
|
|
||||||
if (port == 0) {
|
|
||||||
// Default value.
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
// User selection.
|
|
||||||
if (port <= 0 || port > 63556) {
|
|
||||||
// Invalid selection.
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
*tx_port = port;
|
|
||||||
break; // Move on to rx_port.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
std::cout << "Enter video receive port. Press enter for default ("
|
|
||||||
<< *rx_port << "): ";
|
|
||||||
std::getline(std::cin, str);
|
|
||||||
port = atoi(str.c_str());
|
|
||||||
|
|
||||||
if (port == 0) {
|
|
||||||
// Default value
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
// User selection.
|
|
||||||
if (port <= 0 || port > 63556) {
|
|
||||||
// Invalid selection.
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
*rx_port = port;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert(false);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audio settings functions.
|
// Audio settings functions.
|
||||||
|
|
||||||
bool GetAudioPorts(int* tx_port, int* rx_port) {
|
void GetAudioPorts(int* tx_port, int* rx_port) {
|
||||||
int port = 0;
|
std::string tx_input = TypedInput()
|
||||||
std::string str;
|
.WithTitle("Enter audio send port.")
|
||||||
|
.WithDefault(DEFAULT_AUDIO_PORT)
|
||||||
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536))
|
||||||
|
.AskForInput();
|
||||||
|
*tx_port = atoi(tx_input.c_str());
|
||||||
|
|
||||||
// set to default values.
|
std::string rx_input = TypedInput()
|
||||||
*tx_port = DEFAULT_AUDIO_PORT;
|
.WithTitle("Enter audio receive port.")
|
||||||
*rx_port = DEFAULT_AUDIO_PORT;
|
.WithDefault(DEFAULT_AUDIO_PORT)
|
||||||
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536))
|
||||||
while (1) {
|
.AskForInput();
|
||||||
std::cout << "Enter audio send port. Press enter for default ("
|
*rx_port = atoi(rx_input.c_str());
|
||||||
<< *tx_port << "): ";
|
|
||||||
std::getline(std::cin, str);
|
|
||||||
port = atoi(str.c_str());
|
|
||||||
|
|
||||||
if (port == 0) {
|
|
||||||
// Default value.
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
// User selection.
|
|
||||||
if (port <= 0 || port > 63556) {
|
|
||||||
// Invalid selection.
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
*tx_port = port;
|
|
||||||
break; // Move on to rx_port.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
std::cout << "Enter audio receive port. Press enter for default ("
|
|
||||||
<< *rx_port << "): ";
|
|
||||||
std::getline(std::cin, str);
|
|
||||||
port = atoi(str.c_str());
|
|
||||||
|
|
||||||
if (port == 0) {
|
|
||||||
// Default value.
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
// User selection.
|
|
||||||
if (port <= 0 || port > 63556) {
|
|
||||||
// Invalid selection.
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
*rx_port = port;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert(false);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetAudioCodec(webrtc::VoECodec* voe_codec,
|
bool GetAudioCodec(webrtc::VoECodec* voe_codec,
|
||||||
@ -1305,12 +1207,12 @@ bool GetAudioCodec(webrtc::VoECodec* voe_codec,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintCallInformation(char* IP, char* video_capture_device_name,
|
void PrintCallInformation(const char* IP, const char* video_capture_device_name,
|
||||||
char* video_capture_unique_id,
|
const char* video_capture_unique_id,
|
||||||
webrtc::VideoCodec video_codec,
|
webrtc::VideoCodec video_codec,
|
||||||
int video_tx_port, int video_rx_port,
|
int video_tx_port, int video_rx_port,
|
||||||
char* audio_capture_device_name,
|
const char* audio_capture_device_name,
|
||||||
char* audio_playbackDeviceName,
|
const char* audio_playbackDeviceName,
|
||||||
webrtc::CodecInst audio_codec,
|
webrtc::CodecInst audio_codec,
|
||||||
int audio_tx_port, int audio_rx_port,
|
int audio_tx_port, int audio_rx_port,
|
||||||
int protection_method) {
|
int protection_method) {
|
||||||
@ -1343,7 +1245,7 @@ void PrintCallInformation(char* IP, char* video_capture_device_name,
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetVideoCodecType(webrtc::ViECodec* vie_codec,
|
void SetVideoCodecType(webrtc::ViECodec* vie_codec,
|
||||||
webrtc::VideoCodec* video_codec) {
|
webrtc::VideoCodec* video_codec) {
|
||||||
int error = 0;
|
int error = 0;
|
||||||
int number_of_errors = 0;
|
int number_of_errors = 0;
|
||||||
@ -1375,14 +1277,12 @@ bool SetVideoCodecType(webrtc::ViECodec* vie_codec,
|
|||||||
video_codec->width = 176;
|
video_codec->width = 176;
|
||||||
video_codec->height = 144;
|
video_codec->height = 144;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetVideoCodecResolution(webrtc::ViECodec* vie_codec,
|
void SetVideoCodecResolution(webrtc::VideoCodec* video_codec) {
|
||||||
webrtc::VideoCodec* video_codec) {
|
|
||||||
if (video_codec->codecType != webrtc::kVideoCodecVP8) {
|
if (video_codec->codecType != webrtc::kVideoCodecVP8) {
|
||||||
printf("Can only change codec size if it's VP8\n");
|
printf("Can only change codec size if it's VP8\n");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int choice = FromChoices(
|
int choice = FromChoices(
|
||||||
@ -1441,113 +1341,78 @@ bool SetVideoCodecResolution(webrtc::ViECodec* vie_codec,
|
|||||||
video_codec->height = 768;
|
video_codec->height = 768;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetVideoCodecSize(webrtc::ViECodec* vie_codec,
|
void SetVideoCodecSize(webrtc::VideoCodec* video_codec) {
|
||||||
webrtc::VideoCodec* video_codec) {
|
|
||||||
if (video_codec->codecType != webrtc::kVideoCodecVP8) {
|
if (video_codec->codecType != webrtc::kVideoCodecVP8) {
|
||||||
printf("Can only change codec size if it's VP8\n");
|
printf("Can only change codec size if it's VP8\n");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string str;
|
std::string input = TypedInput()
|
||||||
video_codec->width = DEFAULT_VIDEO_CODEC_WIDTH;
|
.WithDefault(DEFAULT_VIDEO_CODEC_WIDTH)
|
||||||
video_codec->height = DEFAULT_VIDEO_CODEC_HEIGHT;
|
.WithTitle("Choose video width.")
|
||||||
std::cout << "Choose video width. Press enter for default ("
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||||
<< DEFAULT_VIDEO_CODEC_WIDTH << "): ";
|
.AskForInput();
|
||||||
std::getline(std::cin, str);
|
video_codec->width = atoi(input.c_str());
|
||||||
int size_selection = atoi(str.c_str());
|
|
||||||
if (size_selection != 0) {
|
input = TypedInput()
|
||||||
video_codec->width = size_selection;
|
.WithDefault(DEFAULT_VIDEO_CODEC_HEIGHT)
|
||||||
}
|
.WithTitle("Choose video height.")
|
||||||
std::cout << "Choose video height. Press enter for default ("
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||||
<< DEFAULT_VIDEO_CODEC_HEIGHT << "): ";
|
.AskForInput();
|
||||||
std::getline(std::cin, str);
|
video_codec->height = atoi(input.c_str());
|
||||||
size_selection = atoi(str.c_str());
|
|
||||||
if (size_selection != 0) {
|
|
||||||
video_codec->height = size_selection;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetVideoCodecBitrate(webrtc::ViECodec* vie_codec,
|
void SetVideoCodecBitrate(webrtc::VideoCodec* video_codec) {
|
||||||
webrtc::VideoCodec* video_codec) {
|
std::string input = TypedInput()
|
||||||
std::string str;
|
.WithDefault(DEFAULT_VIDEO_CODEC_BITRATE)
|
||||||
std::cout << std::endl;
|
.WithTitle("Choose start rate (in kbps).")
|
||||||
std::cout << "Choose start rate (in kbps). Press enter for default ("
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||||
<< DEFAULT_VIDEO_CODEC_BITRATE << "): ";
|
.AskForInput();
|
||||||
std::getline(std::cin, str);
|
|
||||||
int start_rate = atoi(str.c_str());
|
video_codec->startBitrate = atoi(input.c_str());
|
||||||
video_codec->startBitrate = DEFAULT_VIDEO_CODEC_BITRATE;
|
|
||||||
if (start_rate != 0) {
|
|
||||||
video_codec->startBitrate = start_rate;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetVideoCodecMaxBitrate(webrtc::ViECodec* vie_codec,
|
void SetVideoCodecMaxBitrate(webrtc::VideoCodec* video_codec) {
|
||||||
webrtc::VideoCodec* video_codec) {
|
std::string input = TypedInput()
|
||||||
std::string str;
|
.WithDefault(DEFAULT_VIDEO_CODEC_MAX_BITRATE)
|
||||||
std::cout << std::endl;
|
.WithTitle("Choose max bitrate (in kbps).")
|
||||||
std::cout << "Choose max bitrate (in kbps). Press enter for default ("
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||||
<< DEFAULT_VIDEO_CODEC_MAX_BITRATE << "): ";
|
.AskForInput();
|
||||||
std::getline(std::cin, str);
|
|
||||||
int max_rate = atoi(str.c_str());
|
video_codec->maxBitrate = atoi(input.c_str());
|
||||||
video_codec->maxBitrate = DEFAULT_VIDEO_CODEC_MAX_BITRATE;
|
|
||||||
if (max_rate != 0) {
|
|
||||||
video_codec->maxBitrate = max_rate;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetVideoCodecMinBitrate(webrtc::ViECodec* vie_codec,
|
void SetVideoCodecMinBitrate(webrtc::VideoCodec* video_codec) {
|
||||||
webrtc::VideoCodec* video_codec) {
|
std::string input = TypedInput()
|
||||||
std::string str;
|
.WithDefault(DEFAULT_VIDEO_CODEC_MIN_BITRATE)
|
||||||
std::cout << std::endl;
|
.WithTitle("Choose min bitrate (in kbps).")
|
||||||
std::cout << "Choose min bitrate (in fps). Press enter for default ("
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||||
<< DEFAULT_VIDEO_CODEC_MIN_BITRATE << "): ";
|
.AskForInput();
|
||||||
std::getline(std::cin, str);
|
|
||||||
char min_bit_rate = atoi(str.c_str());
|
video_codec->minBitrate = atoi(input.c_str());
|
||||||
video_codec->minBitrate = DEFAULT_VIDEO_CODEC_MIN_BITRATE;
|
|
||||||
if (min_bit_rate != 0) {
|
|
||||||
video_codec->minBitrate = min_bit_rate;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetVideoCodecMaxFramerate(webrtc::ViECodec* vie_codec,
|
void SetVideoCodecMaxFramerate(webrtc::VideoCodec* video_codec) {
|
||||||
webrtc::VideoCodec* video_codec) {
|
std::string input = TypedInput()
|
||||||
std::string str;
|
.WithDefault(DEFAULT_VIDEO_CODEC_MAX_FRAMERATE)
|
||||||
std::cout << std::endl;
|
.WithTitle("Choose max framerate (in fps).")
|
||||||
std::cout << "Choose max framerate (in fps). Press enter for default ("
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||||
<< DEFAULT_VIDEO_CODEC_MAX_FRAMERATE << "): ";
|
.AskForInput();
|
||||||
std::getline(std::cin, str);
|
video_codec->maxFramerate = atoi(input.c_str());
|
||||||
char max_frame_rate = atoi(str.c_str());
|
|
||||||
video_codec->maxFramerate = DEFAULT_VIDEO_CODEC_MAX_FRAMERATE;
|
|
||||||
if (max_frame_rate != 0) {
|
|
||||||
video_codec->maxFramerate = max_frame_rate;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetVideoCodecTemporalLayer(webrtc::VideoCodec* video_codec) {
|
void SetVideoCodecTemporalLayer(webrtc::VideoCodec* video_codec) {
|
||||||
if (video_codec->codecType == webrtc::kVideoCodecVP8) {
|
if (video_codec->codecType != webrtc::kVideoCodecVP8)
|
||||||
std::string str;
|
return;
|
||||||
std::cout << std::endl;
|
|
||||||
std::cout << "Choose number of temporal layers (1 to 4). "
|
std::string input = TypedInput()
|
||||||
<< "Press enter for default ("
|
.WithDefault(DEFAULT_TEMPORAL_LAYER)
|
||||||
<< DEFAULT_TEMPORAL_LAYER << "): ";
|
.WithTitle("Choose number of temporal layers (0 to 4).")
|
||||||
std::getline(std::cin, str);
|
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(0, 4))
|
||||||
char num_temporal_layers = atoi(str.c_str());
|
.AskForInput();
|
||||||
video_codec->codecSpecific.VP8.numberOfTemporalLayers =
|
video_codec->codecSpecific.VP8.numberOfTemporalLayers = atoi(input.c_str());
|
||||||
DEFAULT_TEMPORAL_LAYER;
|
|
||||||
if (num_temporal_layers != 0) {
|
|
||||||
video_codec->codecSpecific.VP8.numberOfTemporalLayers =
|
|
||||||
num_temporal_layers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetVideoProtection only prints the prompt to get a number
|
// GetVideoProtection only prints the prompt to get a number
|
||||||
|
@ -62,11 +62,16 @@
|
|||||||
'primitives/choice_helpers_unittest.cc',
|
'primitives/choice_helpers_unittest.cc',
|
||||||
'primitives/codec_primitives.cc',
|
'primitives/codec_primitives.cc',
|
||||||
'primitives/codec_primitives.h',
|
'primitives/codec_primitives.h',
|
||||||
|
'primitives/fake_stdin.h',
|
||||||
|
'primitives/fake_stdin.cc',
|
||||||
'primitives/framedrop_primitives.h',
|
'primitives/framedrop_primitives.h',
|
||||||
'primitives/framedrop_primitives.cc',
|
'primitives/framedrop_primitives.cc',
|
||||||
'primitives/framedrop_primitives_unittest.cc',
|
'primitives/framedrop_primitives_unittest.cc',
|
||||||
'primitives/general_primitives.cc',
|
'primitives/general_primitives.cc',
|
||||||
'primitives/general_primitives.h',
|
'primitives/general_primitives.h',
|
||||||
|
'primitives/input_helpers.cc',
|
||||||
|
'primitives/input_helpers.h',
|
||||||
|
'primitives/input_helpers_unittest.cc',
|
||||||
|
|
||||||
# Platform independent
|
# Platform independent
|
||||||
'source/vie_autotest.cc',
|
'source/vie_autotest.cc',
|
||||||
|
Reference in New Issue
Block a user