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:
parent
81ebe38acb
commit
ad6612b1f8
@ -17,39 +17,16 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
static const int kNoDefault = 0;
|
||||
|
||||
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() {
|
||||
if (!title_.empty()) {
|
||||
printf("\n%s\n", title_.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;
|
||||
std::string input = input_helper_
|
||||
.WithTitle(MakeTitleWithOptions())
|
||||
.AskForInput();
|
||||
return atoi(input.c_str());
|
||||
}
|
||||
|
||||
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.");
|
||||
|
||||
// Store the value as the choice number, e.g. its index + 1.
|
||||
default_choice_ = (iterator - choices_.begin()) + 1;
|
||||
default_choice_text_ = default_choice;
|
||||
int choice_index = (iterator - choices_.begin()) + 1;
|
||||
char number[16];
|
||||
sprintf(number, "%d", choice_index);
|
||||
|
||||
input_helper_.WithDefault(number);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ChoiceBuilder& ChoiceBuilder::WithInputSource(FILE* input_source) {
|
||||
input_source_ = input_source;
|
||||
input_helper_.WithInputSource(input_source);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -73,6 +53,17 @@ ChoiceBuilder& ChoiceBuilder::WithTitle(const std::string& title) {
|
||||
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 result;
|
||||
size_t current_pos = 0;
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "video_engine/test/auto_test/primitives/input_helpers.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
typedef std::vector<std::string> Choices;
|
||||
@ -52,13 +54,12 @@ class ChoiceBuilder {
|
||||
// Prints the choice list and requests input from the input source. Returns
|
||||
// the choice number (choices start at 1).
|
||||
int Choose();
|
||||
|
||||
private:
|
||||
std::string MakeTitleWithOptions();
|
||||
|
||||
Choices choices_;
|
||||
int default_choice_;
|
||||
std::string default_choice_text_;
|
||||
InputBuilder input_helper_;
|
||||
std::string title_;
|
||||
FILE* input_source_;
|
||||
};
|
||||
|
||||
// Convenience function that creates a choice builder given a string where
|
||||
|
@ -12,21 +12,7 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "video_engine/test/auto_test/primitives/choice_helpers.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
|
||||
|
||||
#include "video_engine/test/auto_test/primitives/fake_stdin.h"
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <climits>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#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/primitives/choice_helpers.h"
|
||||
#include "video_engine/test/auto_test/primitives/input_helpers.h"
|
||||
|
||||
#define VCM_RED_PAYLOAD_TYPE 96
|
||||
#define VCM_ULPFEC_PAYLOAD_TYPE 97
|
||||
#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_WIDTH 640
|
||||
#define DEFAULT_VIDEO_CODEC_HEIGHT 480
|
||||
#define DEFAULT_VIDEO_CODEC_BITRATE 300
|
||||
#define DEFAULT_VIDEO_CODEC_MIN_BITRATE 100
|
||||
#define DEFAULT_VIDEO_CODEC_MAX_BITRATE 1000
|
||||
#define DEFAULT_AUDIO_PORT 11113
|
||||
#define DEFAULT_VIDEO_CODEC_WIDTH "640"
|
||||
#define DEFAULT_VIDEO_CODEC_HEIGHT "480"
|
||||
#define DEFAULT_VIDEO_CODEC_BITRATE "300"
|
||||
#define DEFAULT_VIDEO_CODEC_MIN_BITRATE "100"
|
||||
#define DEFAULT_VIDEO_CODEC_MAX_BITRATE "1000"
|
||||
#define DEFAULT_AUDIO_PORT "11113"
|
||||
#define DEFAULT_AUDIO_CODEC "ISAC"
|
||||
#define DEFAULT_INCOMING_FILE_NAME "IncomingFile.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_TEMPORAL_LAYER 0
|
||||
#define DEFAULT_TEMPORAL_LAYER "0"
|
||||
|
||||
enum StatisticsType {
|
||||
kSendStatistic,
|
||||
@ -46,6 +50,7 @@ enum VideoProtectionMethod {
|
||||
};
|
||||
|
||||
using webrtc::FromChoices;
|
||||
using webrtc::TypedInput;
|
||||
|
||||
class ViEAutotestFileObserver : public webrtc::ViEFileObserver {
|
||||
public:
|
||||
@ -92,18 +97,18 @@ class ViEAutotestDecoderObserver : public webrtc::ViEDecoderObserver {
|
||||
bool GetVideoDevice(webrtc::ViEBase* vie_base,
|
||||
webrtc::ViECapture* vie_capture,
|
||||
char* capture_device_name, char* capture_device_unique_id);
|
||||
bool GetIPAddress(char* IP);
|
||||
std::string GetIPAddress();
|
||||
bool ValidateIP(std::string i_str);
|
||||
|
||||
// The following are Print to stdout functions.
|
||||
void PrintCallInformation(char* IP,
|
||||
char* video_capture_device_name,
|
||||
char* video_capture_unique_id,
|
||||
void PrintCallInformation(const char* IP,
|
||||
const char* video_capture_device_name,
|
||||
const char* video_capture_unique_id,
|
||||
webrtc::VideoCodec video_codec,
|
||||
int video_tx_port,
|
||||
int video_rx_port,
|
||||
char* audio_capture_device_name,
|
||||
char* audio_playbackDeviceName,
|
||||
const char* audio_capture_device_name,
|
||||
const char* audio_playbackDeviceName,
|
||||
webrtc::CodecInst audio_codec,
|
||||
int audio_tx_port,
|
||||
int audio_rx_port,
|
||||
@ -125,24 +130,16 @@ void PrintVideoStreamInformation(webrtc::ViECodec* vie_codec,
|
||||
void PrintVideoCodec(webrtc::VideoCodec video_codec);
|
||||
|
||||
// The following are video functions.
|
||||
// TODO(amyfong): change to pointers as input arguments
|
||||
// instead of references
|
||||
bool SetVideoPorts(int* tx_port, int* rx_port);
|
||||
bool SetVideoCodecType(webrtc::ViECodec* vie_codec,
|
||||
void GetVideoPorts(int* tx_port, int* rx_port);
|
||||
void SetVideoCodecType(webrtc::ViECodec* vie_codec,
|
||||
webrtc::VideoCodec* video_codec);
|
||||
bool SetVideoCodecResolution(webrtc::ViECodec* vie_codec,
|
||||
webrtc::VideoCodec* video_codec);
|
||||
bool SetVideoCodecSize(webrtc::ViECodec* vie_codec,
|
||||
webrtc::VideoCodec* video_codec);
|
||||
bool SetVideoCodecBitrate(webrtc::ViECodec* vie_codec,
|
||||
webrtc::VideoCodec* video_codec);
|
||||
bool SetVideoCodecMinBitrate(webrtc::ViECodec* vie_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);
|
||||
void SetVideoCodecResolution(webrtc::VideoCodec* video_codec);
|
||||
void SetVideoCodecSize(webrtc::VideoCodec* video_codec);
|
||||
void SetVideoCodecBitrate(webrtc::VideoCodec* video_codec);
|
||||
void SetVideoCodecMinBitrate(webrtc::VideoCodec* video_codec);
|
||||
void SetVideoCodecMaxBitrate(webrtc::VideoCodec* video_codec);
|
||||
void SetVideoCodecMaxFramerate(webrtc::VideoCodec* video_codec);
|
||||
void SetVideoCodecTemporalLayer(webrtc::VideoCodec* video_codec);
|
||||
VideoProtectionMethod GetVideoProtection();
|
||||
bool SetVideoProtection(webrtc::ViECodec* vie_codec,
|
||||
webrtc::ViERTP_RTCP* vie_rtp_rtcp,
|
||||
@ -158,7 +155,7 @@ bool GetAudioDevices(webrtc::VoEBase* voe_base,
|
||||
bool GetAudioDevices(webrtc::VoEBase* voe_base,
|
||||
webrtc::VoEHardware* voe_hardware,
|
||||
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,
|
||||
webrtc::CodecInst& audio_codec);
|
||||
|
||||
@ -244,8 +241,7 @@ int ViEAutoTest::ViECustomCall() {
|
||||
__LINE__);
|
||||
|
||||
bool start_call = false;
|
||||
const unsigned int kMaxIPLength = 16;
|
||||
char ip_address[kMaxIPLength] = "";
|
||||
std::string ip_address;
|
||||
const unsigned int KMaxUniqueIdLength = 256;
|
||||
char unique_id[KMaxUniqueIdLength] = "";
|
||||
char device_name[KMaxUniqueIdLength] = "";
|
||||
@ -267,8 +263,7 @@ int ViEAutoTest::ViECustomCall() {
|
||||
|
||||
while (!start_call) {
|
||||
// Get the IP address to use from call.
|
||||
memset(ip_address, 0, kMaxIPLength);
|
||||
GetIPAddress(ip_address);
|
||||
ip_address = GetIPAddress();
|
||||
|
||||
// Get the video device to use for call.
|
||||
memset(device_name, 0, KMaxUniqueIdLength);
|
||||
@ -279,16 +274,16 @@ int ViEAutoTest::ViECustomCall() {
|
||||
// Get and set the video ports for the call.
|
||||
video_tx_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.
|
||||
memset(&video_send_codec, 0, sizeof(webrtc::VideoCodec));
|
||||
SetVideoCodecType(vie_codec, &video_send_codec);
|
||||
SetVideoCodecSize(vie_codec, &video_send_codec);
|
||||
SetVideoCodecBitrate(vie_codec, &video_send_codec);
|
||||
SetVideoCodecMinBitrate(vie_codec, &video_send_codec);
|
||||
SetVideoCodecMaxBitrate(vie_codec, &video_send_codec);
|
||||
SetVideoCodecMaxFramerate(vie_codec, &video_send_codec);
|
||||
SetVideoCodecSize(&video_send_codec);
|
||||
SetVideoCodecBitrate(&video_send_codec);
|
||||
SetVideoCodecMinBitrate(&video_send_codec);
|
||||
SetVideoCodecMaxBitrate(&video_send_codec);
|
||||
SetVideoCodecMaxFramerate(&video_send_codec);
|
||||
SetVideoCodecTemporalLayer(&video_send_codec);
|
||||
remb = GetBitrateSignaling();
|
||||
|
||||
@ -312,8 +307,8 @@ int ViEAutoTest::ViECustomCall() {
|
||||
GetAudioCodec(voe_codec, audio_codec);
|
||||
|
||||
// Now ready to start the call. Check user wants to continue.
|
||||
PrintCallInformation(ip_address, device_name, unique_id, video_send_codec,
|
||||
video_tx_port, video_rx_port,
|
||||
PrintCallInformation(ip_address.c_str(), device_name, unique_id,
|
||||
video_send_codec, video_tx_port, video_rx_port,
|
||||
audio_capture_device_name, audio_playbackDeviceName,
|
||||
audio_codec, audio_tx_port, audio_rx_port,
|
||||
protection_method);
|
||||
@ -332,7 +327,7 @@ int ViEAutoTest::ViECustomCall() {
|
||||
// Configure audio channel first.
|
||||
audio_channel = voe_base->CreateChannel();
|
||||
error = voe_base->SetSendDestination(audio_channel, audio_tx_port,
|
||||
ip_address);
|
||||
ip_address.c_str());
|
||||
number_of_errors += ViETest::TestError(error == 0,
|
||||
"ERROR: %s at line %d",
|
||||
__FUNCTION__, __LINE__);
|
||||
@ -451,7 +446,7 @@ int ViEAutoTest::ViECustomCall() {
|
||||
number_of_errors += ViETest::TestError(error == 0,
|
||||
"ERROR: %s at line %d",
|
||||
__FUNCTION__, __LINE__);
|
||||
error = vie_network->SetSendDestination(video_channel, ip_address,
|
||||
error = vie_network->SetSendDestination(video_channel, ip_address.c_str(),
|
||||
video_tx_port);
|
||||
number_of_errors += ViETest::TestError(error == 0,
|
||||
"ERROR: %s at line %d",
|
||||
@ -527,7 +522,7 @@ int ViEAutoTest::ViECustomCall() {
|
||||
printf("\n");
|
||||
int selection = FromChoices(
|
||||
"Stop the call\n"
|
||||
"Modify the call\n").WithDefault("Stop the call").Choose();
|
||||
"Modify the call\n").Choose();
|
||||
|
||||
int file_selection = 0;
|
||||
|
||||
@ -560,13 +555,13 @@ int ViEAutoTest::ViECustomCall() {
|
||||
case 2:
|
||||
// Change video codec.
|
||||
SetVideoCodecType(vie_codec, &video_send_codec);
|
||||
SetVideoCodecSize(vie_codec, &video_send_codec);
|
||||
SetVideoCodecBitrate(vie_codec, &video_send_codec);
|
||||
SetVideoCodecMinBitrate(vie_codec, &video_send_codec);
|
||||
SetVideoCodecMaxBitrate(vie_codec, &video_send_codec);
|
||||
SetVideoCodecMaxFramerate(vie_codec, &video_send_codec);
|
||||
SetVideoCodecSize(&video_send_codec);
|
||||
SetVideoCodecBitrate(&video_send_codec);
|
||||
SetVideoCodecMinBitrate(&video_send_codec);
|
||||
SetVideoCodecMaxBitrate(&video_send_codec);
|
||||
SetVideoCodecMaxFramerate(&video_send_codec);
|
||||
SetVideoCodecTemporalLayer(&video_send_codec);
|
||||
PrintCallInformation(ip_address, device_name,
|
||||
PrintCallInformation(ip_address.c_str(), device_name,
|
||||
unique_id, video_send_codec,
|
||||
video_tx_port, video_rx_port,
|
||||
audio_capture_device_name,
|
||||
@ -583,8 +578,8 @@ int ViEAutoTest::ViECustomCall() {
|
||||
break;
|
||||
case 3:
|
||||
// Change Video codec size by common resolution.
|
||||
SetVideoCodecResolution(vie_codec, &video_send_codec);
|
||||
PrintCallInformation(ip_address, device_name,
|
||||
SetVideoCodecResolution(&video_send_codec);
|
||||
PrintCallInformation(ip_address.c_str(), device_name,
|
||||
unique_id, video_send_codec,
|
||||
video_tx_port, video_rx_port,
|
||||
audio_capture_device_name,
|
||||
@ -601,8 +596,8 @@ int ViEAutoTest::ViECustomCall() {
|
||||
break;
|
||||
case 4:
|
||||
// Change video codec by size height and width.
|
||||
SetVideoCodecSize(vie_codec, &video_send_codec);
|
||||
PrintCallInformation(ip_address, device_name,
|
||||
SetVideoCodecSize(&video_send_codec);
|
||||
PrintCallInformation(ip_address.c_str(), device_name,
|
||||
unique_id, video_send_codec,
|
||||
video_tx_port, video_rx_port,
|
||||
audio_capture_device_name,
|
||||
@ -809,7 +804,7 @@ int ViEAutoTest::ViECustomCall() {
|
||||
break;
|
||||
case 12:
|
||||
// Print Call information..
|
||||
PrintCallInformation(ip_address, device_name,
|
||||
PrintCallInformation(ip_address.c_str(), device_name,
|
||||
unique_id, video_send_codec,
|
||||
video_tx_port, video_rx_port,
|
||||
audio_capture_device_name,
|
||||
@ -1123,148 +1118,55 @@ bool GetAudioDevices(webrtc::VoEBase* voe_base,
|
||||
|
||||
// General helper functions.
|
||||
|
||||
bool GetIPAddress(char* i_ip) {
|
||||
char o_ip[16] = DEFAULT_SEND_IP;
|
||||
std::string str;
|
||||
|
||||
while (1) {
|
||||
std::cout << std::endl;
|
||||
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;
|
||||
std::string GetIPAddress() {
|
||||
class IpValidator : public webrtc::InputValidator {
|
||||
public:
|
||||
bool InputOk(const std::string& input) const {
|
||||
// Just check quickly that it's on the form x.y.z.w
|
||||
return std::count(input.begin(), input.end(), '.') == 3;
|
||||
}
|
||||
if (ValidateIP(str) == false) {
|
||||
std::cout << "Invalid entry. Try again." << std::endl;
|
||||
continue;
|
||||
}
|
||||
// Done, copy std::string to c_string and return.
|
||||
strcpy(i_ip, str.c_str());
|
||||
return true;
|
||||
}
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ValidateIP(std::string i_str) {
|
||||
if (0 == i_str.compare("")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
return TypedInput()
|
||||
.WithDefault(DEFAULT_SEND_IP)
|
||||
.WithTitle("Enter destination IP.")
|
||||
.WithInputValidator(new IpValidator())
|
||||
.AskForInput();
|
||||
}
|
||||
|
||||
// Video settings functions.
|
||||
|
||||
bool SetVideoPorts(int* tx_port, int* rx_port) {
|
||||
std::string str;
|
||||
int port = 0;
|
||||
void GetVideoPorts(int* tx_port, int* rx_port) {
|
||||
std::string tx_input = TypedInput()
|
||||
.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.
|
||||
*tx_port = DEFAULT_VIDEO_PORT;
|
||||
*rx_port = DEFAULT_VIDEO_PORT;
|
||||
|
||||
while (1) {
|
||||
std::cout << "Enter video send port. Press enter for default ("
|
||||
<< *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;
|
||||
std::string rx_input = TypedInput()
|
||||
.WithTitle("Enter video receive port.")
|
||||
.WithDefault(DEFAULT_VIDEO_PORT)
|
||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536))
|
||||
.AskForInput();
|
||||
*rx_port = atoi(rx_input.c_str());
|
||||
}
|
||||
|
||||
// Audio settings functions.
|
||||
|
||||
bool GetAudioPorts(int* tx_port, int* rx_port) {
|
||||
int port = 0;
|
||||
std::string str;
|
||||
void GetAudioPorts(int* tx_port, int* rx_port) {
|
||||
std::string tx_input = TypedInput()
|
||||
.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.
|
||||
*tx_port = DEFAULT_AUDIO_PORT;
|
||||
*rx_port = DEFAULT_AUDIO_PORT;
|
||||
|
||||
while (1) {
|
||||
std::cout << "Enter audio send port. Press enter for default ("
|
||||
<< *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;
|
||||
std::string rx_input = TypedInput()
|
||||
.WithTitle("Enter audio receive port.")
|
||||
.WithDefault(DEFAULT_AUDIO_PORT)
|
||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536))
|
||||
.AskForInput();
|
||||
*rx_port = atoi(rx_input.c_str());
|
||||
}
|
||||
|
||||
bool GetAudioCodec(webrtc::VoECodec* voe_codec,
|
||||
@ -1305,12 +1207,12 @@ bool GetAudioCodec(webrtc::VoECodec* voe_codec,
|
||||
return true;
|
||||
}
|
||||
|
||||
void PrintCallInformation(char* IP, char* video_capture_device_name,
|
||||
char* video_capture_unique_id,
|
||||
void PrintCallInformation(const char* IP, const char* video_capture_device_name,
|
||||
const char* video_capture_unique_id,
|
||||
webrtc::VideoCodec video_codec,
|
||||
int video_tx_port, int video_rx_port,
|
||||
char* audio_capture_device_name,
|
||||
char* audio_playbackDeviceName,
|
||||
const char* audio_capture_device_name,
|
||||
const char* audio_playbackDeviceName,
|
||||
webrtc::CodecInst audio_codec,
|
||||
int audio_tx_port, int audio_rx_port,
|
||||
int protection_method) {
|
||||
@ -1343,7 +1245,7 @@ void PrintCallInformation(char* IP, char* video_capture_device_name,
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
bool SetVideoCodecType(webrtc::ViECodec* vie_codec,
|
||||
void SetVideoCodecType(webrtc::ViECodec* vie_codec,
|
||||
webrtc::VideoCodec* video_codec) {
|
||||
int error = 0;
|
||||
int number_of_errors = 0;
|
||||
@ -1375,14 +1277,12 @@ bool SetVideoCodecType(webrtc::ViECodec* vie_codec,
|
||||
video_codec->width = 176;
|
||||
video_codec->height = 144;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetVideoCodecResolution(webrtc::ViECodec* vie_codec,
|
||||
webrtc::VideoCodec* video_codec) {
|
||||
void SetVideoCodecResolution(webrtc::VideoCodec* video_codec) {
|
||||
if (video_codec->codecType != webrtc::kVideoCodecVP8) {
|
||||
printf("Can only change codec size if it's VP8\n");
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
int choice = FromChoices(
|
||||
@ -1441,113 +1341,78 @@ bool SetVideoCodecResolution(webrtc::ViECodec* vie_codec,
|
||||
video_codec->height = 768;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetVideoCodecSize(webrtc::ViECodec* vie_codec,
|
||||
webrtc::VideoCodec* video_codec) {
|
||||
void SetVideoCodecSize(webrtc::VideoCodec* video_codec) {
|
||||
if (video_codec->codecType != webrtc::kVideoCodecVP8) {
|
||||
printf("Can only change codec size if it's VP8\n");
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
std::string str;
|
||||
video_codec->width = DEFAULT_VIDEO_CODEC_WIDTH;
|
||||
video_codec->height = DEFAULT_VIDEO_CODEC_HEIGHT;
|
||||
std::cout << "Choose video width. Press enter for default ("
|
||||
<< DEFAULT_VIDEO_CODEC_WIDTH << "): ";
|
||||
std::getline(std::cin, str);
|
||||
int size_selection = atoi(str.c_str());
|
||||
if (size_selection != 0) {
|
||||
video_codec->width = size_selection;
|
||||
}
|
||||
std::cout << "Choose video height. Press enter for default ("
|
||||
<< DEFAULT_VIDEO_CODEC_HEIGHT << "): ";
|
||||
std::getline(std::cin, str);
|
||||
size_selection = atoi(str.c_str());
|
||||
if (size_selection != 0) {
|
||||
video_codec->height = size_selection;
|
||||
}
|
||||
return true;
|
||||
std::string input = TypedInput()
|
||||
.WithDefault(DEFAULT_VIDEO_CODEC_WIDTH)
|
||||
.WithTitle("Choose video width.")
|
||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||
.AskForInput();
|
||||
video_codec->width = atoi(input.c_str());
|
||||
|
||||
input = TypedInput()
|
||||
.WithDefault(DEFAULT_VIDEO_CODEC_HEIGHT)
|
||||
.WithTitle("Choose video height.")
|
||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||
.AskForInput();
|
||||
video_codec->height = atoi(input.c_str());
|
||||
}
|
||||
|
||||
bool SetVideoCodecBitrate(webrtc::ViECodec* vie_codec,
|
||||
webrtc::VideoCodec* video_codec) {
|
||||
std::string str;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Choose start rate (in kbps). Press enter for default ("
|
||||
<< DEFAULT_VIDEO_CODEC_BITRATE << "): ";
|
||||
std::getline(std::cin, str);
|
||||
int start_rate = atoi(str.c_str());
|
||||
video_codec->startBitrate = DEFAULT_VIDEO_CODEC_BITRATE;
|
||||
if (start_rate != 0) {
|
||||
video_codec->startBitrate = start_rate;
|
||||
}
|
||||
return true;
|
||||
void SetVideoCodecBitrate(webrtc::VideoCodec* video_codec) {
|
||||
std::string input = TypedInput()
|
||||
.WithDefault(DEFAULT_VIDEO_CODEC_BITRATE)
|
||||
.WithTitle("Choose start rate (in kbps).")
|
||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||
.AskForInput();
|
||||
|
||||
video_codec->startBitrate = atoi(input.c_str());
|
||||
}
|
||||
|
||||
bool SetVideoCodecMaxBitrate(webrtc::ViECodec* vie_codec,
|
||||
webrtc::VideoCodec* video_codec) {
|
||||
std::string str;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Choose max bitrate (in kbps). Press enter for default ("
|
||||
<< DEFAULT_VIDEO_CODEC_MAX_BITRATE << "): ";
|
||||
std::getline(std::cin, str);
|
||||
int max_rate = atoi(str.c_str());
|
||||
video_codec->maxBitrate = DEFAULT_VIDEO_CODEC_MAX_BITRATE;
|
||||
if (max_rate != 0) {
|
||||
video_codec->maxBitrate = max_rate;
|
||||
}
|
||||
return true;
|
||||
void SetVideoCodecMaxBitrate(webrtc::VideoCodec* video_codec) {
|
||||
std::string input = TypedInput()
|
||||
.WithDefault(DEFAULT_VIDEO_CODEC_MAX_BITRATE)
|
||||
.WithTitle("Choose max bitrate (in kbps).")
|
||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||
.AskForInput();
|
||||
|
||||
video_codec->maxBitrate = atoi(input.c_str());
|
||||
}
|
||||
|
||||
bool SetVideoCodecMinBitrate(webrtc::ViECodec* vie_codec,
|
||||
webrtc::VideoCodec* video_codec) {
|
||||
std::string str;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Choose min bitrate (in fps). Press enter for default ("
|
||||
<< DEFAULT_VIDEO_CODEC_MIN_BITRATE << "): ";
|
||||
std::getline(std::cin, str);
|
||||
char min_bit_rate = atoi(str.c_str());
|
||||
video_codec->minBitrate = DEFAULT_VIDEO_CODEC_MIN_BITRATE;
|
||||
if (min_bit_rate != 0) {
|
||||
video_codec->minBitrate = min_bit_rate;
|
||||
}
|
||||
return true;
|
||||
void SetVideoCodecMinBitrate(webrtc::VideoCodec* video_codec) {
|
||||
std::string input = TypedInput()
|
||||
.WithDefault(DEFAULT_VIDEO_CODEC_MIN_BITRATE)
|
||||
.WithTitle("Choose min bitrate (in kbps).")
|
||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||
.AskForInput();
|
||||
|
||||
video_codec->minBitrate = atoi(input.c_str());
|
||||
}
|
||||
|
||||
bool SetVideoCodecMaxFramerate(webrtc::ViECodec* vie_codec,
|
||||
webrtc::VideoCodec* video_codec) {
|
||||
std::string str;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Choose max framerate (in fps). Press enter for default ("
|
||||
<< DEFAULT_VIDEO_CODEC_MAX_FRAMERATE << "): ";
|
||||
std::getline(std::cin, 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;
|
||||
void SetVideoCodecMaxFramerate(webrtc::VideoCodec* video_codec) {
|
||||
std::string input = TypedInput()
|
||||
.WithDefault(DEFAULT_VIDEO_CODEC_MAX_FRAMERATE)
|
||||
.WithTitle("Choose max framerate (in fps).")
|
||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX))
|
||||
.AskForInput();
|
||||
video_codec->maxFramerate = atoi(input.c_str());
|
||||
}
|
||||
|
||||
bool SetVideoCodecTemporalLayer(webrtc::VideoCodec* video_codec) {
|
||||
if (video_codec->codecType == webrtc::kVideoCodecVP8) {
|
||||
std::string str;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Choose number of temporal layers (1 to 4). "
|
||||
<< "Press enter for default ("
|
||||
<< DEFAULT_TEMPORAL_LAYER << "): ";
|
||||
std::getline(std::cin, str);
|
||||
char num_temporal_layers = atoi(str.c_str());
|
||||
video_codec->codecSpecific.VP8.numberOfTemporalLayers =
|
||||
DEFAULT_TEMPORAL_LAYER;
|
||||
if (num_temporal_layers != 0) {
|
||||
video_codec->codecSpecific.VP8.numberOfTemporalLayers =
|
||||
num_temporal_layers;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
void SetVideoCodecTemporalLayer(webrtc::VideoCodec* video_codec) {
|
||||
if (video_codec->codecType != webrtc::kVideoCodecVP8)
|
||||
return;
|
||||
|
||||
std::string input = TypedInput()
|
||||
.WithDefault(DEFAULT_TEMPORAL_LAYER)
|
||||
.WithTitle("Choose number of temporal layers (0 to 4).")
|
||||
.WithInputValidator(new webrtc::IntegerWithinRangeValidator(0, 4))
|
||||
.AskForInput();
|
||||
video_codec->codecSpecific.VP8.numberOfTemporalLayers = atoi(input.c_str());
|
||||
}
|
||||
|
||||
// GetVideoProtection only prints the prompt to get a number
|
||||
|
@ -62,11 +62,16 @@
|
||||
'primitives/choice_helpers_unittest.cc',
|
||||
'primitives/codec_primitives.cc',
|
||||
'primitives/codec_primitives.h',
|
||||
'primitives/fake_stdin.h',
|
||||
'primitives/fake_stdin.cc',
|
||||
'primitives/framedrop_primitives.h',
|
||||
'primitives/framedrop_primitives.cc',
|
||||
'primitives/framedrop_primitives_unittest.cc',
|
||||
'primitives/general_primitives.cc',
|
||||
'primitives/general_primitives.h',
|
||||
'primitives/input_helpers.cc',
|
||||
'primitives/input_helpers.h',
|
||||
'primitives/input_helpers_unittest.cc',
|
||||
|
||||
# Platform independent
|
||||
'source/vie_autotest.cc',
|
||||
|
Loading…
x
Reference in New Issue
Block a user