WebRtcVoiceEngine: Use AudioDecoderFactory to generate recv codecs.

Reland of https://codereview.webrtc.org/2072753002/ which broke
chromium due to how their build was setup. This issue should now be
resolved.

Changed WebRtcVoiceEngine to present receive codecs from the formats
provided by its decoder factory. Added supported formats to
BuiltinAudioDecoderFactory. Added helper functions for creating some
simple decoder factories for mocking.

Created a PayloadTypeMapper for assigning payload types to formats. I
think we'll eventually want to use this further up, or possibly in
both the audio and video sides. It would be best if the engines didn't
have to talk payload types at all, but it might be more difficult to
get around when payload types depend on each-other, like the RTX
codecs for video.

BUG=webrtc:5805
TBR=ivoc@webrtc.org

Review-Url: https://codereview.webrtc.org/2250683002
Cr-Commit-Position: refs/heads/master@{#13793}
This commit is contained in:
ossu
2016-08-17 02:45:41 -07:00
committed by Commit bot
parent a93d5ac019
commit c54071d8ab
12 changed files with 511 additions and 32 deletions

View File

@ -130,7 +130,31 @@ NamedDecoderConstructor decoder_constructors[] = {
class BuiltinAudioDecoderFactory : public AudioDecoderFactory {
public:
std::vector<SdpAudioFormat> GetSupportedFormats() override {
FATAL() << "Not implemented yet!";
static std::vector<SdpAudioFormat> formats = {
#ifdef WEBRTC_CODEC_OPUS
{ "opus", 48000, 2, {
{"minptime", "10" },
{"useinbandfec", "1" }
}
},
#endif
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
{ "isac", 16000, 1 },
#endif
#if (defined(WEBRTC_CODEC_ISAC))
{ "isac", 32000, 1 },
#endif
#ifdef WEBRTC_CODEC_G722
{ "G722", 8000, 1 },
#endif
#ifdef WEBRTC_CODEC_ILBC
{ "iLBC", 8000, 1 },
#endif
{ "PCMU", 8000, 1 },
{ "PCMA", 8000, 1 }
};
return formats;
}
std::unique_ptr<AudioDecoder> MakeAudioDecoder(

View File

@ -14,6 +14,7 @@
#include <vector>
#include "testing/gmock/include/gmock/gmock.h"
#include "webrtc/base/scoped_ref_ptr.h"
#include "webrtc/modules/audio_coding/codecs/audio_decoder_factory.h"
namespace webrtc {
@ -30,6 +31,45 @@ class MockAudioDecoderFactory : public AudioDecoderFactory {
MOCK_METHOD2(MakeAudioDecoderMock,
void(const SdpAudioFormat& format,
std::unique_ptr<AudioDecoder>* return_value));
// Creates a MockAudioDecoderFactory with no formats and that may not be
// invoked to create a codec - useful for initializing a voice engine, for
// example.
static rtc::scoped_refptr<webrtc::MockAudioDecoderFactory>
CreateUnusedFactory() {
using testing::_;
using testing::AnyNumber;
using testing::Return;
rtc::scoped_refptr<webrtc::MockAudioDecoderFactory> factory =
new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>;
ON_CALL(*factory.get(), GetSupportedFormats())
.WillByDefault(Return(std::vector<webrtc::SdpAudioFormat>()));
EXPECT_CALL(*factory.get(), GetSupportedFormats()).Times(AnyNumber());
EXPECT_CALL(*factory.get(), MakeAudioDecoderMock(_, _)).Times(0);
return factory;
}
// Creates a MockAudioDecoderFactory with no formats that may be invoked to
// create a codec any number of times. It will, though, return nullptr on each
// call, since it supports no codecs.
static rtc::scoped_refptr<webrtc::MockAudioDecoderFactory>
CreateEmptyFactory() {
using testing::_;
using testing::AnyNumber;
using testing::Return;
using testing::SetArgPointee;
rtc::scoped_refptr<webrtc::MockAudioDecoderFactory> factory =
new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>;
ON_CALL(*factory.get(), GetSupportedFormats())
.WillByDefault(Return(std::vector<webrtc::SdpAudioFormat>()));
EXPECT_CALL(*factory.get(), GetSupportedFormats()).Times(AnyNumber());
ON_CALL(*factory.get(), MakeAudioDecoderMock(_, _))
.WillByDefault(SetArgPointee<1>(nullptr));
EXPECT_CALL(*factory.get(), MakeAudioDecoderMock(_, _)).Times(AnyNumber());
return factory;
}
};
} // namespace webrtc