mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-19 08:37:54 +01:00

This is a reland of4e64e60589
This CL lands all code except the code that activates the change, see media/engine/webrtc_video_engine.cc Once downstream projects are fixed, there will be a one-line change to activate the change to distinguish between send and receive video codecs. Original change's description: > Reland "Reland "Distinguish between send and receive video codecs"" > > This is a reland of77eb338ae4
> > Original change's description: > > Reland "Distinguish between send and receive video codecs" > > > > This reverts commitf2d6fe62f2
. > > > > Reason for revert: Downstream test updated. > > > > Original change's description: > > > Revert "Reland "Distinguish between send and receive video codecs"" > > > > > > This reverts commit26e6afe93f
. > > > > > > Reason for revert: Breaks another downstream test. > > > > > > Original change's description: > > > > Reland "Distinguish between send and receive video codecs" > > > > > > > > This reverts commitf22af3cca7
. > > > > > > > > Reason for revert: Downstream tests have been updated. > > > > > > > > Original change's description: > > > > > Revert "Distinguish between send and receive video codecs" > > > > > > > > > > This reverts commit18314bd8d2
. > > > > > > > > > > Reason for revert: Breaks downstream test. > > > > > > > > > > Original change's description: > > > > > > Distinguish between send and receive video codecs > > > > > > > > > > > > Even though send and receive codecs are the same, > > > > > > they might have different support in HW. > > > > > > Distinguish between send and receive codecs to be able to keep > > > > > > track of which codecs have HW support. > > > > > > > > > > > > Bug: chromium:1029737 > > > > > > Change-Id: I16a80da44c5061ca42f2aabda76e6bf0b879bf7b > > > > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161306 > > > > > > Reviewed-by: Anders Carlsson <andersc@webrtc.org> > > > > > > Reviewed-by: Steve Anton <steveanton@webrtc.org> > > > > > > Commit-Queue: Johannes Kron <kron@webrtc.org> > > > > > > Cr-Commit-Position: refs/heads/master@{#30041} > > > > > > > > > > TBR=steveanton@webrtc.org,andersc@webrtc.org,kron@webrtc.org > > > > > > > > > > Change-Id: I7e5807460006db613e9b3b369ec6036b88f164fd > > > > > No-Presubmit: true > > > > > No-Tree-Checks: true > > > > > No-Try: true > > > > > Bug: chromium:1029737 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161662 > > > > > Reviewed-by: Johannes Kron <kron@webrtc.org> > > > > > Commit-Queue: Johannes Kron <kron@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#30042} > > > > > > > > TBR=steveanton@webrtc.org,andersc@webrtc.org,kron@webrtc.org > > > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > > > Bug: chromium:1029737 > > > > Change-Id: Ia70b11376b43888e2495ef21838c2d2e3c68d735 > > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161734 > > > > Reviewed-by: Johannes Kron <kron@webrtc.org> > > > > Reviewed-by: Steve Anton <steveanton@webrtc.org> > > > > Reviewed-by: Anders Carlsson <andersc@webrtc.org> > > > > Commit-Queue: Johannes Kron <kron@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#30078} > > > > > > TBR=steveanton@webrtc.org,andersc@webrtc.org,kron@webrtc.org > > > > > > Change-Id: Ia4971b898c9209a3736a916a1c2c48d392dfdad6 > > > No-Presubmit: true > > > No-Tree-Checks: true > > > No-Try: true > > > Bug: chromium:1029737 > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/162140 > > > Reviewed-by: Johannes Kron <kron@webrtc.org> > > > Commit-Queue: Johannes Kron <kron@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#30079} > > > > TBR=steveanton@webrtc.org,andersc@webrtc.org,kron@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: chromium:1029737 > > Change-Id: If2c3c5b5e7d86cb852a1f20f02b6ceae62b2e0c8 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/162186 > > Reviewed-by: Johannes Kron <kron@webrtc.org> > > Reviewed-by: Anders Carlsson <andersc@webrtc.org> > > Reviewed-by: Steve Anton <steveanton@webrtc.org> > > Commit-Queue: Johannes Kron <kron@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#30097} > > Bug: chromium:1029737 > Change-Id: I5912822df8169fbb3097c0f440f7924527fa950b > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/162483 > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Reviewed-by: Anders Carlsson <andersc@webrtc.org> > Commit-Queue: Johannes Kron <kron@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30120} Bug: chromium:1029737 Change-Id: Id4f1c6f6f0cf7b96fe93dd22d14310d286af31f3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/165682 Reviewed-by: Steve Anton <steveanton@webrtc.org> Reviewed-by: Anders Carlsson <andersc@webrtc.org> Commit-Queue: Johannes Kron <kron@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30219}
174 lines
5.6 KiB
C++
174 lines
5.6 KiB
C++
/*
|
|
* Copyright (c) 2004 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 MEDIA_BASE_MEDIA_ENGINE_H_
|
|
#define MEDIA_BASE_MEDIA_ENGINE_H_
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "api/audio_codecs/audio_decoder_factory.h"
|
|
#include "api/audio_codecs/audio_encoder_factory.h"
|
|
#include "api/crypto/crypto_options.h"
|
|
#include "api/rtp_parameters.h"
|
|
#include "api/video/video_bitrate_allocator_factory.h"
|
|
#include "call/audio_state.h"
|
|
#include "media/base/codec.h"
|
|
#include "media/base/media_channel.h"
|
|
#include "media/base/video_common.h"
|
|
#include "rtc_base/system/file_wrapper.h"
|
|
|
|
namespace webrtc {
|
|
class AudioDeviceModule;
|
|
class AudioMixer;
|
|
class AudioProcessing;
|
|
class Call;
|
|
} // namespace webrtc
|
|
|
|
namespace cricket {
|
|
|
|
webrtc::RTCError CheckRtpParametersValues(
|
|
const webrtc::RtpParameters& new_parameters);
|
|
|
|
webrtc::RTCError CheckRtpParametersInvalidModificationAndValues(
|
|
const webrtc::RtpParameters& old_parameters,
|
|
const webrtc::RtpParameters& new_parameters);
|
|
|
|
struct RtpCapabilities {
|
|
RtpCapabilities();
|
|
~RtpCapabilities();
|
|
std::vector<webrtc::RtpExtension> header_extensions;
|
|
};
|
|
|
|
class VoiceEngineInterface {
|
|
public:
|
|
VoiceEngineInterface() = default;
|
|
virtual ~VoiceEngineInterface() = default;
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(VoiceEngineInterface);
|
|
|
|
// Initialization
|
|
// Starts the engine.
|
|
virtual void Init() = 0;
|
|
|
|
// TODO(solenberg): Remove once VoE API refactoring is done.
|
|
virtual rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const = 0;
|
|
|
|
// MediaChannel creation
|
|
// Creates a voice media channel. Returns NULL on failure.
|
|
virtual VoiceMediaChannel* CreateMediaChannel(
|
|
webrtc::Call* call,
|
|
const MediaConfig& config,
|
|
const AudioOptions& options,
|
|
const webrtc::CryptoOptions& crypto_options) = 0;
|
|
|
|
virtual const std::vector<AudioCodec>& send_codecs() const = 0;
|
|
virtual const std::vector<AudioCodec>& recv_codecs() const = 0;
|
|
virtual RtpCapabilities GetCapabilities() const = 0;
|
|
|
|
// Starts AEC dump using existing file, a maximum file size in bytes can be
|
|
// specified. Logging is stopped just before the size limit is exceeded.
|
|
// If max_size_bytes is set to a value <= 0, no limit will be used.
|
|
virtual bool StartAecDump(webrtc::FileWrapper file,
|
|
int64_t max_size_bytes) = 0;
|
|
|
|
// Stops recording AEC dump.
|
|
virtual void StopAecDump() = 0;
|
|
};
|
|
|
|
class VideoEngineInterface {
|
|
public:
|
|
VideoEngineInterface() = default;
|
|
virtual ~VideoEngineInterface() = default;
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(VideoEngineInterface);
|
|
|
|
// Creates a video media channel, paired with the specified voice channel.
|
|
// Returns NULL on failure.
|
|
virtual VideoMediaChannel* CreateMediaChannel(
|
|
webrtc::Call* call,
|
|
const MediaConfig& config,
|
|
const VideoOptions& options,
|
|
const webrtc::CryptoOptions& crypto_options,
|
|
webrtc::VideoBitrateAllocatorFactory*
|
|
video_bitrate_allocator_factory) = 0;
|
|
|
|
virtual std::vector<VideoCodec> send_codecs() const = 0;
|
|
virtual std::vector<VideoCodec> recv_codecs() const = 0;
|
|
|
|
virtual RtpCapabilities GetCapabilities() const = 0;
|
|
};
|
|
|
|
// MediaEngineInterface is an abstraction of a media engine which can be
|
|
// subclassed to support different media componentry backends.
|
|
// It supports voice and video operations in the same class to facilitate
|
|
// proper synchronization between both media types.
|
|
class MediaEngineInterface {
|
|
public:
|
|
virtual ~MediaEngineInterface() {}
|
|
|
|
// Initialization
|
|
// Starts the engine.
|
|
virtual bool Init() = 0;
|
|
virtual VoiceEngineInterface& voice() = 0;
|
|
virtual VideoEngineInterface& video() = 0;
|
|
virtual const VoiceEngineInterface& voice() const = 0;
|
|
virtual const VideoEngineInterface& video() const = 0;
|
|
};
|
|
|
|
// CompositeMediaEngine constructs a MediaEngine from separate
|
|
// voice and video engine classes.
|
|
class CompositeMediaEngine : public MediaEngineInterface {
|
|
public:
|
|
CompositeMediaEngine(std::unique_ptr<VoiceEngineInterface> audio_engine,
|
|
std::unique_ptr<VideoEngineInterface> video_engine);
|
|
~CompositeMediaEngine() override;
|
|
bool Init() override;
|
|
|
|
VoiceEngineInterface& voice() override;
|
|
VideoEngineInterface& video() override;
|
|
const VoiceEngineInterface& voice() const override;
|
|
const VideoEngineInterface& video() const override;
|
|
|
|
private:
|
|
std::unique_ptr<VoiceEngineInterface> voice_engine_;
|
|
std::unique_ptr<VideoEngineInterface> video_engine_;
|
|
};
|
|
|
|
enum DataChannelType {
|
|
DCT_NONE = 0,
|
|
DCT_RTP = 1,
|
|
DCT_SCTP = 2,
|
|
|
|
// Data channel transport over media transport.
|
|
DCT_MEDIA_TRANSPORT = 3,
|
|
|
|
// Data channel transport over datagram transport (with no fallback). This is
|
|
// the same behavior as data channel transport over media transport, and is
|
|
// usable without DTLS.
|
|
DCT_DATA_CHANNEL_TRANSPORT = 4,
|
|
|
|
// Data channel transport over datagram transport (with SCTP negotiation
|
|
// semantics and a fallback to SCTP). Only usable with DTLS.
|
|
DCT_DATA_CHANNEL_TRANSPORT_SCTP = 5,
|
|
};
|
|
|
|
class DataEngineInterface {
|
|
public:
|
|
virtual ~DataEngineInterface() {}
|
|
virtual DataMediaChannel* CreateChannel(const MediaConfig& config) = 0;
|
|
virtual const std::vector<DataCodec>& data_codecs() = 0;
|
|
};
|
|
|
|
webrtc::RtpParameters CreateRtpParametersWithOneEncoding();
|
|
webrtc::RtpParameters CreateRtpParametersWithEncodings(StreamParams sp);
|
|
|
|
} // namespace cricket
|
|
|
|
#endif // MEDIA_BASE_MEDIA_ENGINE_H_
|