mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Reland of Move video_encoder.h and video_decoder.h to /api and create GN targets for them (patchset #1 id:1 of https://codereview.webrtc.org/2794033002/ )
Reason for revert: Reland with temporary deprecated API to not break chromium and google3. Original issue's description: > Revert of Move video_encoder.h and video_decoder.h to /api and create GN targets for them (patchset #8 id:140001 of https://codereview.webrtc.org/2780943003/ ) > > Reason for revert: > Suspect of breaking Chrome FYI bots. > > See > https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/23065 > https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Builder > > Example logs: > ../../content/renderer/media/gpu/rtc_video_encoder_unittest.cc:18:46: fatal error: third_party/webrtc/video_encoder.h: No such file or directory > #include "third_party/webrtc/video_encoder.h" > ^ > > Original issue's description: > > Move video_encoder.h and video_decoder.h to /api and create GN targets for them > > > > BUG=webrtc:5881 > > # Because PRESUBMIT ignores LINT blacklist for moved files and these > > # headers have some not easy to resolve issues. > > NOPRESUBMIT=True > > > > Review-Url: https://codereview.webrtc.org/2780943003 > > Cr-Commit-Position: refs/heads/master@{#17511} > > Committed:c42f540570
> > TBR=solenberg@webrtc.org,sprang@webrtc.org,ilnik@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:5881 > > Review-Url: https://codereview.webrtc.org/2794033002 > Cr-Commit-Position: refs/heads/master@{#17514} > Committed:716d7ac5c1
TBR=solenberg@webrtc.org,sprang@webrtc.org,guidou@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5881 Review-Url: https://codereview.webrtc.org/2795163002 Cr-Commit-Position: refs/heads/master@{#17537}
This commit is contained in:
parent
d8ce1e172e
commit
d60d06a9f9
31 changed files with 378 additions and 305 deletions
|
@ -16,6 +16,8 @@ import sys
|
||||||
# Files and directories that are *skipped* by cpplint in the presubmit script.
|
# Files and directories that are *skipped* by cpplint in the presubmit script.
|
||||||
CPPLINT_BLACKLIST = [
|
CPPLINT_BLACKLIST = [
|
||||||
'tools-webrtc',
|
'tools-webrtc',
|
||||||
|
'webrtc/api/video_codecs/video_decoder.h',
|
||||||
|
'webrtc/api/video_codecs/video_encoder.h',
|
||||||
'webrtc/base',
|
'webrtc/base',
|
||||||
'webrtc/examples/objc',
|
'webrtc/examples/objc',
|
||||||
'webrtc/media',
|
'webrtc/media',
|
||||||
|
@ -38,8 +40,6 @@ CPPLINT_BLACKLIST = [
|
||||||
'webrtc/call.h',
|
'webrtc/call.h',
|
||||||
'webrtc/common_types.h',
|
'webrtc/common_types.h',
|
||||||
'webrtc/common_types.cc',
|
'webrtc/common_types.cc',
|
||||||
'webrtc/video_decoder.h',
|
|
||||||
'webrtc/video_encoder.h',
|
|
||||||
'webrtc/video_send_stream.h',
|
'webrtc/video_send_stream.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,6 @@ include_rules = [
|
||||||
"+webrtc/config.h",
|
"+webrtc/config.h",
|
||||||
"+webrtc/transport.h",
|
"+webrtc/transport.h",
|
||||||
"+webrtc/typedefs.h",
|
"+webrtc/typedefs.h",
|
||||||
"+webrtc/video_decoder.h",
|
|
||||||
"+webrtc/video_encoder.h",
|
|
||||||
"+webrtc/video_frame.h",
|
"+webrtc/video_frame.h",
|
||||||
"+webrtc/video_receive_stream.h",
|
"+webrtc/video_receive_stream.h",
|
||||||
"+webrtc/video_send_stream.h",
|
"+webrtc/video_send_stream.h",
|
||||||
|
|
28
webrtc/api/video_codecs/BUILD.gn
Normal file
28
webrtc/api/video_codecs/BUILD.gn
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# Copyright (c) 2017 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.
|
||||||
|
|
||||||
|
import("../../webrtc.gni")
|
||||||
|
if (is_android) {
|
||||||
|
import("//build/config/android/config.gni")
|
||||||
|
import("//build/config/android/rules.gni")
|
||||||
|
}
|
||||||
|
|
||||||
|
rtc_source_set("video_codecs_api") {
|
||||||
|
sources = [
|
||||||
|
"video_decoder.h",
|
||||||
|
"video_encoder.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
deps = [
|
||||||
|
# TODO(ilnik): Add dependency on webrtc/video_frame.h when it will have it's
|
||||||
|
# own build target.
|
||||||
|
|
||||||
|
"../..:webrtc_common",
|
||||||
|
"../../base:rtc_base_approved",
|
||||||
|
]
|
||||||
|
}
|
86
webrtc/api/video_codecs/video_decoder.h
Normal file
86
webrtc/api/video_codecs/video_decoder.h
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2014 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_API_VIDEO_CODECS_VIDEO_DECODER_H_
|
||||||
|
#define WEBRTC_API_VIDEO_CODECS_VIDEO_DECODER_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "webrtc/common_types.h"
|
||||||
|
#include "webrtc/typedefs.h"
|
||||||
|
#include "webrtc/video_frame.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
class RTPFragmentationHeader;
|
||||||
|
// TODO(pbos): Expose these through a public (root) header or change these APIs.
|
||||||
|
struct CodecSpecificInfo;
|
||||||
|
class VideoCodec;
|
||||||
|
|
||||||
|
class DecodedImageCallback {
|
||||||
|
public:
|
||||||
|
virtual ~DecodedImageCallback() {}
|
||||||
|
|
||||||
|
virtual int32_t Decoded(VideoFrame& decodedImage) = 0;
|
||||||
|
// Provides an alternative interface that allows the decoder to specify the
|
||||||
|
// decode time excluding waiting time for any previous pending frame to
|
||||||
|
// return. This is necessary for breaking positive feedback in the delay
|
||||||
|
// estimation when the decoder has a single output buffer.
|
||||||
|
virtual int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) {
|
||||||
|
// The default implementation ignores custom decode time value.
|
||||||
|
return Decoded(decodedImage);
|
||||||
|
}
|
||||||
|
// TODO(sakal): Remove other implementations when upstream projects have been
|
||||||
|
// updated.
|
||||||
|
virtual void Decoded(VideoFrame& decodedImage,
|
||||||
|
rtc::Optional<int32_t> decode_time_ms,
|
||||||
|
rtc::Optional<uint8_t> qp) {
|
||||||
|
Decoded(decodedImage,
|
||||||
|
decode_time_ms ? static_cast<int32_t>(*decode_time_ms) : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId) { return -1; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class VideoDecoder {
|
||||||
|
public:
|
||||||
|
virtual ~VideoDecoder() {}
|
||||||
|
|
||||||
|
virtual int32_t InitDecode(const VideoCodec* codec_settings,
|
||||||
|
int32_t number_of_cores) = 0;
|
||||||
|
|
||||||
|
virtual int32_t Decode(const EncodedImage& input_image,
|
||||||
|
bool missing_frames,
|
||||||
|
const RTPFragmentationHeader* fragmentation,
|
||||||
|
const CodecSpecificInfo* codec_specific_info = NULL,
|
||||||
|
int64_t render_time_ms = -1) = 0;
|
||||||
|
|
||||||
|
virtual int32_t RegisterDecodeCompleteCallback(
|
||||||
|
DecodedImageCallback* callback) = 0;
|
||||||
|
|
||||||
|
virtual int32_t Release() = 0;
|
||||||
|
|
||||||
|
// Returns true if the decoder prefer to decode frames late.
|
||||||
|
// That is, it can not decode infinite number of frames before the decoded
|
||||||
|
// frame is consumed.
|
||||||
|
virtual bool PrefersLateDecoding() const { return true; }
|
||||||
|
|
||||||
|
virtual const char* ImplementationName() const { return "unknown"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
|
#endif // WEBRTC_API_VIDEO_CODECS_VIDEO_DECODER_H_
|
192
webrtc/api/video_codecs/video_encoder.h
Normal file
192
webrtc/api/video_codecs/video_encoder.h
Normal file
|
@ -0,0 +1,192 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2014 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_API_VIDEO_CODECS_VIDEO_ENCODER_H_
|
||||||
|
#define WEBRTC_API_VIDEO_CODECS_VIDEO_ENCODER_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "webrtc/base/checks.h"
|
||||||
|
#include "webrtc/common_types.h"
|
||||||
|
#include "webrtc/typedefs.h"
|
||||||
|
#include "webrtc/video_frame.h"
|
||||||
|
#include "webrtc/base/optional.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
class RTPFragmentationHeader;
|
||||||
|
// TODO(pbos): Expose these through a public (root) header or change these APIs.
|
||||||
|
struct CodecSpecificInfo;
|
||||||
|
class VideoCodec;
|
||||||
|
|
||||||
|
class EncodedImageCallback {
|
||||||
|
public:
|
||||||
|
virtual ~EncodedImageCallback() {}
|
||||||
|
|
||||||
|
struct Result {
|
||||||
|
enum Error {
|
||||||
|
OK,
|
||||||
|
|
||||||
|
// Failed to send the packet.
|
||||||
|
ERROR_SEND_FAILED,
|
||||||
|
};
|
||||||
|
|
||||||
|
Result(Error error) : error(error) {}
|
||||||
|
Result(Error error, uint32_t frame_id) : error(error), frame_id(frame_id) {}
|
||||||
|
|
||||||
|
Error error;
|
||||||
|
|
||||||
|
// Frame ID assigned to the frame. The frame ID should be the same as the ID
|
||||||
|
// seen by the receiver for this frame. RTP timestamp of the frame is used
|
||||||
|
// as frame ID when RTP is used to send video. Must be used only when
|
||||||
|
// error=OK.
|
||||||
|
uint32_t frame_id = 0;
|
||||||
|
|
||||||
|
// Tells the encoder that the next frame is should be dropped.
|
||||||
|
bool drop_next_frame = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Callback function which is called when an image has been encoded.
|
||||||
|
virtual Result OnEncodedImage(
|
||||||
|
const EncodedImage& encoded_image,
|
||||||
|
const CodecSpecificInfo* codec_specific_info,
|
||||||
|
const RTPFragmentationHeader* fragmentation) = 0;
|
||||||
|
|
||||||
|
virtual void OnDroppedFrame() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class VideoEncoder {
|
||||||
|
public:
|
||||||
|
enum EncoderType {
|
||||||
|
kH264,
|
||||||
|
kVp8,
|
||||||
|
kVp9,
|
||||||
|
kUnsupportedCodec,
|
||||||
|
};
|
||||||
|
struct QpThresholds {
|
||||||
|
QpThresholds(int l, int h) : low(l), high(h) {}
|
||||||
|
QpThresholds() : low(-1), high(-1) {}
|
||||||
|
int low;
|
||||||
|
int high;
|
||||||
|
};
|
||||||
|
struct ScalingSettings {
|
||||||
|
ScalingSettings(bool on, int low, int high)
|
||||||
|
: enabled(on),
|
||||||
|
thresholds(rtc::Optional<QpThresholds>(QpThresholds(low, high))) {}
|
||||||
|
explicit ScalingSettings(bool on) : enabled(on) {}
|
||||||
|
const bool enabled;
|
||||||
|
const rtc::Optional<QpThresholds> thresholds;
|
||||||
|
};
|
||||||
|
static VideoEncoder* Create(EncoderType codec_type);
|
||||||
|
// Returns true if this type of encoder can be created using
|
||||||
|
// VideoEncoder::Create.
|
||||||
|
static bool IsSupportedSoftware(EncoderType codec_type);
|
||||||
|
static EncoderType CodecToEncoderType(VideoCodecType codec_type);
|
||||||
|
|
||||||
|
static VideoCodecVP8 GetDefaultVp8Settings();
|
||||||
|
static VideoCodecVP9 GetDefaultVp9Settings();
|
||||||
|
static VideoCodecH264 GetDefaultH264Settings();
|
||||||
|
|
||||||
|
virtual ~VideoEncoder() {}
|
||||||
|
|
||||||
|
// Initialize the encoder with the information from the codecSettings
|
||||||
|
//
|
||||||
|
// Input:
|
||||||
|
// - codec_settings : Codec settings
|
||||||
|
// - number_of_cores : Number of cores available for the encoder
|
||||||
|
// - max_payload_size : The maximum size each payload is allowed
|
||||||
|
// to have. Usually MTU - overhead.
|
||||||
|
//
|
||||||
|
// Return value : Set bit rate if OK
|
||||||
|
// <0 - Errors:
|
||||||
|
// WEBRTC_VIDEO_CODEC_ERR_PARAMETER
|
||||||
|
// WEBRTC_VIDEO_CODEC_ERR_SIZE
|
||||||
|
// WEBRTC_VIDEO_CODEC_LEVEL_EXCEEDED
|
||||||
|
// WEBRTC_VIDEO_CODEC_MEMORY
|
||||||
|
// WEBRTC_VIDEO_CODEC_ERROR
|
||||||
|
virtual int32_t InitEncode(const VideoCodec* codec_settings,
|
||||||
|
int32_t number_of_cores,
|
||||||
|
size_t max_payload_size) = 0;
|
||||||
|
|
||||||
|
// Register an encode complete callback object.
|
||||||
|
//
|
||||||
|
// Input:
|
||||||
|
// - callback : Callback object which handles encoded images.
|
||||||
|
//
|
||||||
|
// Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise.
|
||||||
|
virtual int32_t RegisterEncodeCompleteCallback(
|
||||||
|
EncodedImageCallback* callback) = 0;
|
||||||
|
|
||||||
|
// Free encoder memory.
|
||||||
|
// Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise.
|
||||||
|
virtual int32_t Release() = 0;
|
||||||
|
|
||||||
|
// Encode an I420 image (as a part of a video stream). The encoded image
|
||||||
|
// will be returned to the user through the encode complete callback.
|
||||||
|
//
|
||||||
|
// Input:
|
||||||
|
// - frame : Image to be encoded
|
||||||
|
// - frame_types : Frame type to be generated by the encoder.
|
||||||
|
//
|
||||||
|
// Return value : WEBRTC_VIDEO_CODEC_OK if OK
|
||||||
|
// <0 - Errors:
|
||||||
|
// WEBRTC_VIDEO_CODEC_ERR_PARAMETER
|
||||||
|
// WEBRTC_VIDEO_CODEC_MEMORY
|
||||||
|
// WEBRTC_VIDEO_CODEC_ERROR
|
||||||
|
// WEBRTC_VIDEO_CODEC_TIMEOUT
|
||||||
|
virtual int32_t Encode(const VideoFrame& frame,
|
||||||
|
const CodecSpecificInfo* codec_specific_info,
|
||||||
|
const std::vector<FrameType>* frame_types) = 0;
|
||||||
|
|
||||||
|
// Inform the encoder of the new packet loss rate and the round-trip time of
|
||||||
|
// the network.
|
||||||
|
//
|
||||||
|
// Input:
|
||||||
|
// - packet_loss : Fraction lost
|
||||||
|
// (loss rate in percent = 100 * packetLoss / 255)
|
||||||
|
// - rtt : Round-trip time in milliseconds
|
||||||
|
// Return value : WEBRTC_VIDEO_CODEC_OK if OK
|
||||||
|
// <0 - Errors: WEBRTC_VIDEO_CODEC_ERROR
|
||||||
|
virtual int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) = 0;
|
||||||
|
|
||||||
|
// Inform the encoder about the new target bit rate.
|
||||||
|
//
|
||||||
|
// Input:
|
||||||
|
// - bitrate : New target bit rate
|
||||||
|
// - framerate : The target frame rate
|
||||||
|
//
|
||||||
|
// Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise.
|
||||||
|
virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) {
|
||||||
|
RTC_NOTREACHED() << "SetRate(uint32_t, uint32_t) is deprecated.";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default fallback: Just use the sum of bitrates as the single target rate.
|
||||||
|
// TODO(sprang): Remove this default implementation when we remove SetRates().
|
||||||
|
virtual int32_t SetRateAllocation(const BitrateAllocation& allocation,
|
||||||
|
uint32_t framerate) {
|
||||||
|
return SetRates(allocation.get_sum_kbps(), framerate);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Any encoder implementation wishing to use the WebRTC provided
|
||||||
|
// quality scaler must implement this method.
|
||||||
|
virtual ScalingSettings GetScalingSettings() const {
|
||||||
|
return ScalingSettings(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; }
|
||||||
|
virtual bool SupportsNativeHandle() const { return false; }
|
||||||
|
virtual const char* ImplementationName() const { return "unknown"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
#endif // WEBRTC_API_VIDEO_CODECS_VIDEO_ENCODER_H_
|
|
@ -226,6 +226,7 @@ rtc_static_library("rtc_media") {
|
||||||
"../api:video_frame_api",
|
"../api:video_frame_api",
|
||||||
"../api/audio_codecs:audio_codecs_api",
|
"../api/audio_codecs:audio_codecs_api",
|
||||||
"../api/audio_codecs:builtin_audio_decoder_factory",
|
"../api/audio_codecs:builtin_audio_decoder_factory",
|
||||||
|
"../api/video_codecs:video_codecs_api",
|
||||||
"../base:rtc_base",
|
"../base:rtc_base",
|
||||||
"../base:rtc_base_approved",
|
"../base:rtc_base_approved",
|
||||||
"../call",
|
"../call",
|
||||||
|
@ -305,6 +306,7 @@ if (rtc_include_tests) {
|
||||||
"..:webrtc_common",
|
"..:webrtc_common",
|
||||||
"../api:call_api",
|
"../api:call_api",
|
||||||
"../api:video_frame_api",
|
"../api:video_frame_api",
|
||||||
|
"../api/video_codecs:video_codecs_api",
|
||||||
"../base:rtc_base",
|
"../base:rtc_base",
|
||||||
"../base:rtc_base_approved",
|
"../base:rtc_base_approved",
|
||||||
"../base:rtc_base_tests_main",
|
"../base:rtc_base_tests_main",
|
||||||
|
@ -438,6 +440,7 @@ if (rtc_include_tests) {
|
||||||
":rtc_unittest_main",
|
":rtc_unittest_main",
|
||||||
"../api:video_frame_api",
|
"../api:video_frame_api",
|
||||||
"../api/audio_codecs:builtin_audio_decoder_factory",
|
"../api/audio_codecs:builtin_audio_decoder_factory",
|
||||||
|
"../api/video_codecs:video_codecs_api",
|
||||||
"../audio",
|
"../audio",
|
||||||
"../base:rtc_base",
|
"../base:rtc_base",
|
||||||
"../base:rtc_base_approved",
|
"../base:rtc_base_approved",
|
||||||
|
|
|
@ -14,7 +14,10 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "webrtc/api/video_codecs/video_decoder.h"
|
||||||
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||||
#include "webrtc/base/basictypes.h"
|
#include "webrtc/base/basictypes.h"
|
||||||
#include "webrtc/base/criticalsection.h"
|
#include "webrtc/base/criticalsection.h"
|
||||||
#include "webrtc/base/gunit.h"
|
#include "webrtc/base/gunit.h"
|
||||||
|
@ -24,8 +27,6 @@
|
||||||
#include "webrtc/media/engine/webrtcvideodecoderfactory.h"
|
#include "webrtc/media/engine/webrtcvideodecoderfactory.h"
|
||||||
#include "webrtc/media/engine/webrtcvideoencoderfactory.h"
|
#include "webrtc/media/engine/webrtcvideoencoderfactory.h"
|
||||||
#include "webrtc/modules/video_coding/include/video_error_codes.h"
|
#include "webrtc/modules/video_coding/include/video_error_codes.h"
|
||||||
#include "webrtc/video_decoder.h"
|
|
||||||
#include "webrtc/video_encoder.h"
|
|
||||||
|
|
||||||
namespace cricket {
|
namespace cricket {
|
||||||
static const int kEventTimeoutMs = 10000;
|
static const int kEventTimeoutMs = 10000;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "webrtc/video_decoder.h"
|
#include "webrtc/api/video_codecs/video_decoder.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
* 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 "webrtc/video_decoder.h"
|
#include "webrtc/api/video_codecs/video_decoder.h"
|
||||||
|
|
||||||
#include "webrtc/base/checks.h"
|
#include "webrtc/base/checks.h"
|
||||||
#include "webrtc/media/engine/videodecodersoftwarefallbackwrapper.h"
|
#include "webrtc/media/engine/videodecodersoftwarefallbackwrapper.h"
|
||||||
#include "webrtc/modules/video_coding/include/video_error_codes.h"
|
#include "webrtc/modules/video_coding/include/video_error_codes.h"
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||||
#include "webrtc/media/base/codec.h"
|
#include "webrtc/media/base/codec.h"
|
||||||
#include "webrtc/video_encoder.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "webrtc/api/video/i420_buffer.h"
|
#include "webrtc/api/video/i420_buffer.h"
|
||||||
|
#include "webrtc/api/video_codecs/video_decoder.h"
|
||||||
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||||
#include "webrtc/base/copyonwritebuffer.h"
|
#include "webrtc/base/copyonwritebuffer.h"
|
||||||
#include "webrtc/base/logging.h"
|
#include "webrtc/base/logging.h"
|
||||||
#include "webrtc/base/stringutils.h"
|
#include "webrtc/base/stringutils.h"
|
||||||
|
@ -35,8 +37,6 @@
|
||||||
#include "webrtc/media/engine/webrtcvoiceengine.h"
|
#include "webrtc/media/engine/webrtcvoiceengine.h"
|
||||||
#include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
|
#include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
|
||||||
#include "webrtc/system_wrappers/include/field_trial.h"
|
#include "webrtc/system_wrappers/include/field_trial.h"
|
||||||
#include "webrtc/video_decoder.h"
|
|
||||||
#include "webrtc/video_encoder.h"
|
|
||||||
|
|
||||||
using DegradationPreference = webrtc::VideoSendStream::DegradationPreference;
|
using DegradationPreference = webrtc::VideoSendStream::DegradationPreference;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||||
#include "webrtc/base/arraysize.h"
|
#include "webrtc/base/arraysize.h"
|
||||||
#include "webrtc/base/gunit.h"
|
#include "webrtc/base/gunit.h"
|
||||||
#include "webrtc/base/stringutils.h"
|
#include "webrtc/base/stringutils.h"
|
||||||
|
@ -30,7 +31,6 @@
|
||||||
#include "webrtc/media/engine/webrtcvideoengine2.h"
|
#include "webrtc/media/engine/webrtcvideoengine2.h"
|
||||||
#include "webrtc/media/engine/webrtcvoiceengine.h"
|
#include "webrtc/media/engine/webrtcvoiceengine.h"
|
||||||
#include "webrtc/test/field_trial.h"
|
#include "webrtc/test/field_trial.h"
|
||||||
#include "webrtc/video_encoder.h"
|
|
||||||
|
|
||||||
using webrtc::RtpExtension;
|
using webrtc::RtpExtension;
|
||||||
|
|
||||||
|
@ -3803,7 +3803,6 @@ TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) {
|
||||||
// The first unsignalled SSRC received will create a default receive stream.
|
// The first unsignalled SSRC received will create a default receive stream.
|
||||||
// Any different unsignalled SSRC received will replace the default.
|
// Any different unsignalled SSRC received will replace the default.
|
||||||
TEST_F(WebRtcVideoChannel2Test, ReceiveDifferentUnsignaledSsrc) {
|
TEST_F(WebRtcVideoChannel2Test, ReceiveDifferentUnsignaledSsrc) {
|
||||||
|
|
||||||
// Allow receiving VP8, VP9, H264 (if enabled).
|
// Allow receiving VP8, VP9, H264 (if enabled).
|
||||||
cricket::VideoRecvParameters parameters;
|
cricket::VideoRecvParameters parameters;
|
||||||
parameters.codecs.push_back(GetEngineCodec("VP8"));
|
parameters.codecs.push_back(GetEngineCodec("VP8"));
|
||||||
|
|
|
@ -129,6 +129,7 @@ rtc_static_library("video_coding_utility") {
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
"../..:webrtc_common",
|
"../..:webrtc_common",
|
||||||
|
"../../api/video_codecs:video_codecs_api",
|
||||||
"../../base:rtc_base_approved",
|
"../../base:rtc_base_approved",
|
||||||
"../../base:rtc_numerics",
|
"../../base:rtc_numerics",
|
||||||
"../../base:rtc_task_queue",
|
"../../base:rtc_task_queue",
|
||||||
|
@ -224,6 +225,7 @@ rtc_static_library("webrtc_vp8") {
|
||||||
deps = [
|
deps = [
|
||||||
":video_coding_utility",
|
":video_coding_utility",
|
||||||
"../..:webrtc_common",
|
"../..:webrtc_common",
|
||||||
|
"../../api/video_codecs:video_codecs_api",
|
||||||
"../../base:rtc_base_approved",
|
"../../base:rtc_base_approved",
|
||||||
"../../common_video",
|
"../../common_video",
|
||||||
"../../system_wrappers",
|
"../../system_wrappers",
|
||||||
|
@ -322,6 +324,7 @@ if (rtc_include_tests) {
|
||||||
":video_coding_utility",
|
":video_coding_utility",
|
||||||
":webrtc_vp8",
|
":webrtc_vp8",
|
||||||
"../..:webrtc_common",
|
"../..:webrtc_common",
|
||||||
|
"../../api/video_codecs:video_codecs_api",
|
||||||
"../../base:rtc_base_approved",
|
"../../base:rtc_base_approved",
|
||||||
"../../common_video:common_video",
|
"../../common_video:common_video",
|
||||||
"../../system_wrappers:system_wrappers",
|
"../../system_wrappers:system_wrappers",
|
||||||
|
@ -528,6 +531,7 @@ if (rtc_include_tests) {
|
||||||
":webrtc_vp9",
|
":webrtc_vp9",
|
||||||
"../..:webrtc_common",
|
"../..:webrtc_common",
|
||||||
"../../api:video_frame_api",
|
"../../api:video_frame_api",
|
||||||
|
"../../api/video_codecs:video_codecs_api",
|
||||||
"../../base:rtc_base",
|
"../../base:rtc_base",
|
||||||
"../../base:rtc_base_approved",
|
"../../base:rtc_base_approved",
|
||||||
"../../base:rtc_task_queue",
|
"../../base:rtc_task_queue",
|
||||||
|
|
|
@ -13,12 +13,12 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "webrtc/api/video_codecs/video_decoder.h"
|
||||||
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||||
#include "webrtc/base/criticalsection.h"
|
#include "webrtc/base/criticalsection.h"
|
||||||
#include "webrtc/base/event.h"
|
#include "webrtc/base/event.h"
|
||||||
#include "webrtc/base/thread_annotations.h"
|
#include "webrtc/base/thread_annotations.h"
|
||||||
#include "webrtc/test/gtest.h"
|
#include "webrtc/test/gtest.h"
|
||||||
#include "webrtc/video_decoder.h"
|
|
||||||
#include "webrtc/video_encoder.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||||
#include "webrtc/base/constructormagic.h"
|
#include "webrtc/base/constructormagic.h"
|
||||||
#include "webrtc/common_video/include/video_bitrate_allocator.h"
|
#include "webrtc/common_video/include/video_bitrate_allocator.h"
|
||||||
#include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
|
#include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
|
||||||
#include "webrtc/video_encoder.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,12 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "webrtc/api/video/video_frame.h"
|
#include "webrtc/api/video/video_frame.h"
|
||||||
|
#include "webrtc/api/video_codecs/video_decoder.h"
|
||||||
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||||
#include "webrtc/common_types.h"
|
#include "webrtc/common_types.h"
|
||||||
#include "webrtc/modules/include/module_common_types.h"
|
#include "webrtc/modules/include/module_common_types.h"
|
||||||
#include "webrtc/modules/video_coding/include/video_error_codes.h"
|
#include "webrtc/modules/video_coding/include/video_error_codes.h"
|
||||||
#include "webrtc/typedefs.h"
|
#include "webrtc/typedefs.h"
|
||||||
#include "webrtc/video_decoder.h"
|
|
||||||
#include "webrtc/video_encoder.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "webrtc/common_types.h"
|
#include "webrtc/common_types.h"
|
||||||
#include "webrtc/video_encoder.h"
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||||
#include "webrtc/base/optional.h"
|
#include "webrtc/base/optional.h"
|
||||||
#include "webrtc/base/sequenced_task_checker.h"
|
#include "webrtc/base/sequenced_task_checker.h"
|
||||||
#include "webrtc/modules/video_coding/utility/moving_average.h"
|
#include "webrtc/modules/video_coding/utility/moving_average.h"
|
||||||
|
|
|
@ -8,12 +8,12 @@
|
||||||
* 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 "webrtc/api/video_codecs/video_encoder.h"
|
||||||
#include "webrtc/common_video/include/video_bitrate_allocator.h"
|
#include "webrtc/common_video/include/video_bitrate_allocator.h"
|
||||||
#include "webrtc/common_types.h"
|
#include "webrtc/common_types.h"
|
||||||
#include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
|
#include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
|
||||||
#include "webrtc/modules/video_coding/include/video_codec_initializer.h"
|
#include "webrtc/modules/video_coding/include/video_codec_initializer.h"
|
||||||
#include "webrtc/test/gtest.h"
|
#include "webrtc/test/gtest.h"
|
||||||
#include "webrtc/video_encoder.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,7 @@ rtc_static_library("libjingle_peerconnection") {
|
||||||
":rtc_pc",
|
":rtc_pc",
|
||||||
"../api:call_api",
|
"../api:call_api",
|
||||||
"../api:rtc_stats_api",
|
"../api:rtc_stats_api",
|
||||||
|
"../api/video_codecs:video_codecs_api",
|
||||||
"../call",
|
"../call",
|
||||||
"../media",
|
"../media",
|
||||||
"../stats",
|
"../stats",
|
||||||
|
|
|
@ -13,15 +13,15 @@
|
||||||
#include "webrtc/sdk/android/src/jni/androidmediaencoder_jni.h"
|
#include "webrtc/sdk/android/src/jni/androidmediaencoder_jni.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "third_party/libyuv/include/libyuv/convert.h"
|
#include "third_party/libyuv/include/libyuv/convert.h"
|
||||||
#include "third_party/libyuv/include/libyuv/convert_from.h"
|
#include "third_party/libyuv/include/libyuv/convert_from.h"
|
||||||
#include "third_party/libyuv/include/libyuv/video_common.h"
|
#include "third_party/libyuv/include/libyuv/video_common.h"
|
||||||
#include "webrtc/sdk/android/src/jni/androidmediacodeccommon.h"
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||||
#include "webrtc/sdk/android/src/jni/classreferenceholder.h"
|
|
||||||
#include "webrtc/sdk/android/src/jni/native_handle_impl.h"
|
|
||||||
#include "webrtc/base/bind.h"
|
#include "webrtc/base/bind.h"
|
||||||
#include "webrtc/base/checks.h"
|
#include "webrtc/base/checks.h"
|
||||||
#include "webrtc/base/logging.h"
|
#include "webrtc/base/logging.h"
|
||||||
|
@ -38,9 +38,11 @@
|
||||||
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
||||||
#include "webrtc/modules/video_coding/utility/quality_scaler.h"
|
#include "webrtc/modules/video_coding/utility/quality_scaler.h"
|
||||||
#include "webrtc/modules/video_coding/utility/vp8_header_parser.h"
|
#include "webrtc/modules/video_coding/utility/vp8_header_parser.h"
|
||||||
|
#include "webrtc/sdk/android/src/jni/androidmediacodeccommon.h"
|
||||||
|
#include "webrtc/sdk/android/src/jni/classreferenceholder.h"
|
||||||
|
#include "webrtc/sdk/android/src/jni/native_handle_impl.h"
|
||||||
#include "webrtc/system_wrappers/include/field_trial.h"
|
#include "webrtc/system_wrappers/include/field_trial.h"
|
||||||
#include "webrtc/system_wrappers/include/logcat_trace_context.h"
|
#include "webrtc/system_wrappers/include/logcat_trace_context.h"
|
||||||
#include "webrtc/video_encoder.h"
|
|
||||||
|
|
||||||
using rtc::Bind;
|
using rtc::Bind;
|
||||||
using rtc::Thread;
|
using rtc::Thread;
|
||||||
|
@ -123,7 +125,7 @@ class MediaCodecVideoEncoder : public webrtc::VideoEncoder {
|
||||||
private:
|
private:
|
||||||
class EncodeTask : public rtc::QueuedTask {
|
class EncodeTask : public rtc::QueuedTask {
|
||||||
public:
|
public:
|
||||||
EncodeTask(rtc::WeakPtr<MediaCodecVideoEncoder> encoder);
|
explicit EncodeTask(rtc::WeakPtr<MediaCodecVideoEncoder> encoder);
|
||||||
bool Run() override;
|
bool Run() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -519,8 +521,9 @@ int32_t MediaCodecVideoEncoder::InitEncodeInternal(int width,
|
||||||
ScopedLocalRefFrame local_ref_frame(jni);
|
ScopedLocalRefFrame local_ref_frame(jni);
|
||||||
|
|
||||||
const VideoCodecType codec_type = GetCodecType();
|
const VideoCodecType codec_type = GetCodecType();
|
||||||
ALOGD << "InitEncodeInternal Type: " << (int)codec_type << ", " << width
|
ALOGD << "InitEncodeInternal Type: " << static_cast<int>(codec_type) << ", "
|
||||||
<< " x " << height << ". Bitrate: " << kbps << " kbps. Fps: " << fps;
|
<< width << " x " << height << ". Bitrate: " << kbps
|
||||||
|
<< " kbps. Fps: " << fps;
|
||||||
if (kbps == 0) {
|
if (kbps == 0) {
|
||||||
kbps = last_set_bitrate_kbps_;
|
kbps = last_set_bitrate_kbps_;
|
||||||
}
|
}
|
||||||
|
@ -550,9 +553,10 @@ int32_t MediaCodecVideoEncoder::InitEncodeInternal(int width,
|
||||||
input_frame_infos_.clear();
|
input_frame_infos_.clear();
|
||||||
drop_next_input_frame_ = false;
|
drop_next_input_frame_ = false;
|
||||||
use_surface_ = use_surface;
|
use_surface_ = use_surface;
|
||||||
picture_id_ = static_cast<uint16_t>(rand()) & 0x7FFF;
|
// TODO(ilnik): Use rand_r() instead to avoid LINT warnings below.
|
||||||
|
picture_id_ = static_cast<uint16_t>(rand()) & 0x7FFF; // NOLINT
|
||||||
gof_.SetGofInfoVP9(webrtc::TemporalStructureMode::kTemporalStructureMode1);
|
gof_.SetGofInfoVP9(webrtc::TemporalStructureMode::kTemporalStructureMode1);
|
||||||
tl0_pic_idx_ = static_cast<uint8_t>(rand());
|
tl0_pic_idx_ = static_cast<uint8_t>(rand()); // NOLINT
|
||||||
gof_idx_ = 0;
|
gof_idx_ = 0;
|
||||||
last_frame_received_ms_ = -1;
|
last_frame_received_ms_ = -1;
|
||||||
frames_received_since_last_key_ = kMinKeyFrameInterval;
|
frames_received_since_last_key_ = kMinKeyFrameInterval;
|
||||||
|
@ -676,7 +680,7 @@ int32_t MediaCodecVideoEncoder::Encode(
|
||||||
}
|
}
|
||||||
if (frames_encoded_ < kMaxEncodedLogFrames) {
|
if (frames_encoded_ < kMaxEncodedLogFrames) {
|
||||||
ALOGD << "Encoder frame in # " << (frames_received_ - 1)
|
ALOGD << "Encoder frame in # " << (frames_received_ - 1)
|
||||||
<< ". TS: " << (int)(current_timestamp_us_ / 1000)
|
<< ". TS: " << static_cast<int>(current_timestamp_us_ / 1000)
|
||||||
<< ". Q: " << input_frame_infos_.size() << ". Fps: " << last_set_fps_
|
<< ". Q: " << input_frame_infos_.size() << ". Fps: " << last_set_fps_
|
||||||
<< ". Kbps: " << last_set_bitrate_kbps_;
|
<< ". Kbps: " << last_set_bitrate_kbps_;
|
||||||
}
|
}
|
||||||
|
@ -696,7 +700,7 @@ int32_t MediaCodecVideoEncoder::Encode(
|
||||||
if (input_frame_infos_.size() > MAX_ENCODER_Q_SIZE) {
|
if (input_frame_infos_.size() > MAX_ENCODER_Q_SIZE) {
|
||||||
ALOGD << "Already " << input_frame_infos_.size()
|
ALOGD << "Already " << input_frame_infos_.size()
|
||||||
<< " frames in the queue, dropping"
|
<< " frames in the queue, dropping"
|
||||||
<< ". TS: " << (int)(current_timestamp_us_ / 1000)
|
<< ". TS: " << static_cast<int>(current_timestamp_us_ / 1000)
|
||||||
<< ". Fps: " << last_set_fps_
|
<< ". Fps: " << last_set_fps_
|
||||||
<< ". Consecutive drops: " << consecutive_full_queue_frame_drops_;
|
<< ". Consecutive drops: " << consecutive_full_queue_frame_drops_;
|
||||||
current_timestamp_us_ += rtc::kNumMicrosecsPerSec / last_set_fps_;
|
current_timestamp_us_ += rtc::kNumMicrosecsPerSec / last_set_fps_;
|
||||||
|
@ -1139,14 +1143,13 @@ bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) {
|
||||||
frame_encoding_time_ms = rtc::TimeMillis() - encoding_start_time_ms;
|
frame_encoding_time_ms = rtc::TimeMillis() - encoding_start_time_ms;
|
||||||
}
|
}
|
||||||
if (frames_encoded_ < kMaxEncodedLogFrames) {
|
if (frames_encoded_ < kMaxEncodedLogFrames) {
|
||||||
int current_latency =
|
int current_latency = static_cast<int>(last_input_timestamp_ms_ -
|
||||||
(int)(last_input_timestamp_ms_ - last_output_timestamp_ms_);
|
last_output_timestamp_ms_);
|
||||||
ALOGD << "Encoder frame out # " << frames_encoded_ <<
|
ALOGD << "Encoder frame out # " << frames_encoded_
|
||||||
". Key: " << key_frame <<
|
<< ". Key: " << key_frame << ". Size: " << payload_size
|
||||||
". Size: " << payload_size <<
|
<< ". TS: " << static_cast<int>(last_output_timestamp_ms_)
|
||||||
". TS: " << (int)last_output_timestamp_ms_ <<
|
<< ". Latency: " << current_latency
|
||||||
". Latency: " << current_latency <<
|
<< ". EncTime: " << frame_encoding_time_ms;
|
||||||
". EncTime: " << frame_encoding_time_ms;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate and print encoding statistics - every 3 seconds.
|
// Calculate and print encoding statistics - every 3 seconds.
|
||||||
|
|
|
@ -403,6 +403,7 @@ rtc_source_set("test_common") {
|
||||||
":test_support",
|
":test_support",
|
||||||
":video_test_common",
|
":video_test_common",
|
||||||
"..:webrtc_common",
|
"..:webrtc_common",
|
||||||
|
"../api/video_codecs:video_codecs_api",
|
||||||
"../audio",
|
"../audio",
|
||||||
"../base:rtc_base_approved",
|
"../base:rtc_base_approved",
|
||||||
"../call",
|
"../call",
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "webrtc/video_encoder.h"
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
|
@ -14,12 +14,12 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||||
#include "webrtc/base/criticalsection.h"
|
#include "webrtc/base/criticalsection.h"
|
||||||
#include "webrtc/base/sequenced_task_checker.h"
|
#include "webrtc/base/sequenced_task_checker.h"
|
||||||
#include "webrtc/base/task_queue.h"
|
#include "webrtc/base/task_queue.h"
|
||||||
#include "webrtc/common_types.h"
|
#include "webrtc/common_types.h"
|
||||||
#include "webrtc/system_wrappers/include/clock.h"
|
#include "webrtc/system_wrappers/include/clock.h"
|
||||||
#include "webrtc/video_encoder.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
|
@ -58,6 +58,7 @@ rtc_static_library("video") {
|
||||||
deps = [
|
deps = [
|
||||||
"..:webrtc_common",
|
"..:webrtc_common",
|
||||||
"../api:transport_api",
|
"../api:transport_api",
|
||||||
|
"../api/video_codecs:video_codecs_api",
|
||||||
"../base:rtc_base_approved",
|
"../base:rtc_base_approved",
|
||||||
"../base:rtc_numerics",
|
"../base:rtc_numerics",
|
||||||
"../base:rtc_task_queue",
|
"../base:rtc_task_queue",
|
||||||
|
@ -168,6 +169,7 @@ if (rtc_include_tests) {
|
||||||
"replay.cc",
|
"replay.cc",
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
|
"../api/video_codecs:video_codecs_api",
|
||||||
"../system_wrappers:metrics_default",
|
"../system_wrappers:metrics_default",
|
||||||
"../test:field_trial",
|
"../test:field_trial",
|
||||||
"../test:run_test",
|
"../test:run_test",
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||||
#include "webrtc/base/checks.h"
|
#include "webrtc/base/checks.h"
|
||||||
#include "webrtc/base/event.h"
|
#include "webrtc/base/event.h"
|
||||||
#include "webrtc/base/file.h"
|
#include "webrtc/base/file.h"
|
||||||
|
@ -54,7 +55,6 @@
|
||||||
#include "webrtc/test/testsupport/fileutils.h"
|
#include "webrtc/test/testsupport/fileutils.h"
|
||||||
#include "webrtc/test/testsupport/perf_test.h"
|
#include "webrtc/test/testsupport/perf_test.h"
|
||||||
#include "webrtc/video/transport_adapter.h"
|
#include "webrtc/video/transport_adapter.h"
|
||||||
#include "webrtc/video_encoder.h"
|
|
||||||
|
|
||||||
#if defined(MEMORY_SANITIZER)
|
#if defined(MEMORY_SANITIZER)
|
||||||
// Flaky under MemorySanitizer, see
|
// Flaky under MemorySanitizer, see
|
||||||
|
|
|
@ -13,12 +13,12 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||||
#include "webrtc/base/constructormagic.h"
|
#include "webrtc/base/constructormagic.h"
|
||||||
#include "webrtc/base/criticalsection.h"
|
#include "webrtc/base/criticalsection.h"
|
||||||
#include "webrtc/base/thread_annotations.h"
|
#include "webrtc/base/thread_annotations.h"
|
||||||
#include "webrtc/common_types.h"
|
#include "webrtc/common_types.h"
|
||||||
#include "webrtc/config.h"
|
#include "webrtc/config.h"
|
||||||
#include "webrtc/video_encoder.h"
|
|
||||||
#include "webrtc/system_wrappers/include/atomic32.h"
|
#include "webrtc/system_wrappers/include/atomic32.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "gflags/gflags.h"
|
#include "gflags/gflags.h"
|
||||||
|
#include "webrtc/api/video_codecs/video_decoder.h"
|
||||||
#include "webrtc/base/checks.h"
|
#include "webrtc/base/checks.h"
|
||||||
#include "webrtc/call/call.h"
|
#include "webrtc/call/call.h"
|
||||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||||
|
@ -32,7 +33,6 @@
|
||||||
#include "webrtc/test/video_capturer.h"
|
#include "webrtc/test/video_capturer.h"
|
||||||
#include "webrtc/test/video_renderer.h"
|
#include "webrtc/test/video_renderer.h"
|
||||||
#include "webrtc/typedefs.h"
|
#include "webrtc/typedefs.h"
|
||||||
#include "webrtc/video_decoder.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace flags {
|
namespace flags {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "webrtc/test/gtest.h"
|
#include "webrtc/test/gtest.h"
|
||||||
#include "webrtc/test/gmock.h"
|
#include "webrtc/test/gmock.h"
|
||||||
|
|
||||||
|
#include "webrtc/api/video_codecs/video_decoder.h"
|
||||||
#include "webrtc/base/criticalsection.h"
|
#include "webrtc/base/criticalsection.h"
|
||||||
#include "webrtc/base/event.h"
|
#include "webrtc/base/event.h"
|
||||||
#include "webrtc/media/base/fakevideorenderer.h"
|
#include "webrtc/media/base/fakevideorenderer.h"
|
||||||
|
@ -24,7 +25,6 @@
|
||||||
#include "webrtc/system_wrappers/include/clock.h"
|
#include "webrtc/system_wrappers/include/clock.h"
|
||||||
#include "webrtc/system_wrappers/include/sleep.h"
|
#include "webrtc/system_wrappers/include/sleep.h"
|
||||||
#include "webrtc/test/field_trial.h"
|
#include "webrtc/test/field_trial.h"
|
||||||
#include "webrtc/video_decoder.h"
|
|
||||||
|
|
||||||
using testing::_;
|
using testing::_;
|
||||||
using testing::Invoke;
|
using testing::Invoke;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "webrtc/api/video/video_rotation.h"
|
#include "webrtc/api/video/video_rotation.h"
|
||||||
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||||
#include "webrtc/base/criticalsection.h"
|
#include "webrtc/base/criticalsection.h"
|
||||||
#include "webrtc/base/event.h"
|
#include "webrtc/base/event.h"
|
||||||
#include "webrtc/base/sequenced_task_checker.h"
|
#include "webrtc/base/sequenced_task_checker.h"
|
||||||
|
@ -31,7 +32,6 @@
|
||||||
#include "webrtc/system_wrappers/include/atomic32.h"
|
#include "webrtc/system_wrappers/include/atomic32.h"
|
||||||
#include "webrtc/typedefs.h"
|
#include "webrtc/typedefs.h"
|
||||||
#include "webrtc/video/overuse_frame_detector.h"
|
#include "webrtc/video/overuse_frame_detector.h"
|
||||||
#include "webrtc/video_encoder.h"
|
|
||||||
#include "webrtc/video_send_stream.h"
|
#include "webrtc/video_send_stream.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
|
* DEPRECATED: use api/video_codecs/video_decoder.h instead.
|
||||||
|
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license
|
* 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
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
@ -11,76 +12,6 @@
|
||||||
#ifndef WEBRTC_VIDEO_DECODER_H_
|
#ifndef WEBRTC_VIDEO_DECODER_H_
|
||||||
#define WEBRTC_VIDEO_DECODER_H_
|
#define WEBRTC_VIDEO_DECODER_H_
|
||||||
|
|
||||||
#include <memory>
|
#include "webrtc/api/video_codecs/video_decoder.h"
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "webrtc/common_types.h"
|
|
||||||
#include "webrtc/typedefs.h"
|
|
||||||
#include "webrtc/video_frame.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
|
|
||||||
class RTPFragmentationHeader;
|
|
||||||
// TODO(pbos): Expose these through a public (root) header or change these APIs.
|
|
||||||
struct CodecSpecificInfo;
|
|
||||||
class VideoCodec;
|
|
||||||
|
|
||||||
class DecodedImageCallback {
|
|
||||||
public:
|
|
||||||
virtual ~DecodedImageCallback() {}
|
|
||||||
|
|
||||||
virtual int32_t Decoded(VideoFrame& decodedImage) = 0;
|
|
||||||
// Provides an alternative interface that allows the decoder to specify the
|
|
||||||
// decode time excluding waiting time for any previous pending frame to
|
|
||||||
// return. This is necessary for breaking positive feedback in the delay
|
|
||||||
// estimation when the decoder has a single output buffer.
|
|
||||||
virtual int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) {
|
|
||||||
// The default implementation ignores custom decode time value.
|
|
||||||
return Decoded(decodedImage);
|
|
||||||
}
|
|
||||||
// TODO(sakal): Remove other implementations when upstream projects have been
|
|
||||||
// updated.
|
|
||||||
virtual void Decoded(VideoFrame& decodedImage,
|
|
||||||
rtc::Optional<int32_t> decode_time_ms,
|
|
||||||
rtc::Optional<uint8_t> qp) {
|
|
||||||
Decoded(decodedImage,
|
|
||||||
decode_time_ms ? static_cast<int32_t>(*decode_time_ms) : -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId) { return -1; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class VideoDecoder {
|
|
||||||
public:
|
|
||||||
virtual ~VideoDecoder() {}
|
|
||||||
|
|
||||||
virtual int32_t InitDecode(const VideoCodec* codec_settings,
|
|
||||||
int32_t number_of_cores) = 0;
|
|
||||||
|
|
||||||
virtual int32_t Decode(const EncodedImage& input_image,
|
|
||||||
bool missing_frames,
|
|
||||||
const RTPFragmentationHeader* fragmentation,
|
|
||||||
const CodecSpecificInfo* codec_specific_info = NULL,
|
|
||||||
int64_t render_time_ms = -1) = 0;
|
|
||||||
|
|
||||||
virtual int32_t RegisterDecodeCompleteCallback(
|
|
||||||
DecodedImageCallback* callback) = 0;
|
|
||||||
|
|
||||||
virtual int32_t Release() = 0;
|
|
||||||
|
|
||||||
// Returns true if the decoder prefer to decode frames late.
|
|
||||||
// That is, it can not decode infinite number of frames before the decoded
|
|
||||||
// frame is consumed.
|
|
||||||
virtual bool PrefersLateDecoding() const { return true; }
|
|
||||||
|
|
||||||
virtual const char* ImplementationName() const { return "unknown"; }
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace webrtc
|
|
||||||
|
|
||||||
#endif // WEBRTC_VIDEO_DECODER_H_
|
#endif // WEBRTC_VIDEO_DECODER_H_
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
|
* DEPRECATED: use api/video_codecs/video_encoder.h instead.
|
||||||
|
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license
|
* 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
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
@ -11,182 +12,6 @@
|
||||||
#ifndef WEBRTC_VIDEO_ENCODER_H_
|
#ifndef WEBRTC_VIDEO_ENCODER_H_
|
||||||
#define WEBRTC_VIDEO_ENCODER_H_
|
#define WEBRTC_VIDEO_ENCODER_H_
|
||||||
|
|
||||||
#include <memory>
|
#include "webrtc/api/video_codecs/video_encoder.h"
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "webrtc/base/checks.h"
|
|
||||||
#include "webrtc/common_types.h"
|
|
||||||
#include "webrtc/typedefs.h"
|
|
||||||
#include "webrtc/video_frame.h"
|
|
||||||
#include "webrtc/base/optional.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
|
|
||||||
class RTPFragmentationHeader;
|
|
||||||
// TODO(pbos): Expose these through a public (root) header or change these APIs.
|
|
||||||
struct CodecSpecificInfo;
|
|
||||||
class VideoCodec;
|
|
||||||
|
|
||||||
class EncodedImageCallback {
|
|
||||||
public:
|
|
||||||
virtual ~EncodedImageCallback() {}
|
|
||||||
|
|
||||||
struct Result {
|
|
||||||
enum Error {
|
|
||||||
OK,
|
|
||||||
|
|
||||||
// Failed to send the packet.
|
|
||||||
ERROR_SEND_FAILED,
|
|
||||||
};
|
|
||||||
|
|
||||||
Result(Error error) : error(error) {}
|
|
||||||
Result(Error error, uint32_t frame_id) : error(error), frame_id(frame_id) {}
|
|
||||||
|
|
||||||
Error error;
|
|
||||||
|
|
||||||
// Frame ID assigned to the frame. The frame ID should be the same as the ID
|
|
||||||
// seen by the receiver for this frame. RTP timestamp of the frame is used
|
|
||||||
// as frame ID when RTP is used to send video. Must be used only when
|
|
||||||
// error=OK.
|
|
||||||
uint32_t frame_id = 0;
|
|
||||||
|
|
||||||
// Tells the encoder that the next frame is should be dropped.
|
|
||||||
bool drop_next_frame = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Callback function which is called when an image has been encoded.
|
|
||||||
virtual Result OnEncodedImage(
|
|
||||||
const EncodedImage& encoded_image,
|
|
||||||
const CodecSpecificInfo* codec_specific_info,
|
|
||||||
const RTPFragmentationHeader* fragmentation) = 0;
|
|
||||||
|
|
||||||
virtual void OnDroppedFrame() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class VideoEncoder {
|
|
||||||
public:
|
|
||||||
enum EncoderType {
|
|
||||||
kH264,
|
|
||||||
kVp8,
|
|
||||||
kVp9,
|
|
||||||
kUnsupportedCodec,
|
|
||||||
};
|
|
||||||
struct QpThresholds {
|
|
||||||
QpThresholds(int l, int h) : low(l), high(h) {}
|
|
||||||
QpThresholds() : low(-1), high(-1) {}
|
|
||||||
int low;
|
|
||||||
int high;
|
|
||||||
};
|
|
||||||
struct ScalingSettings {
|
|
||||||
ScalingSettings(bool on, int low, int high)
|
|
||||||
: enabled(on),
|
|
||||||
thresholds(rtc::Optional<QpThresholds>(QpThresholds(low, high))) {}
|
|
||||||
explicit ScalingSettings(bool on) : enabled(on) {}
|
|
||||||
const bool enabled;
|
|
||||||
const rtc::Optional<QpThresholds> thresholds;
|
|
||||||
};
|
|
||||||
static VideoEncoder* Create(EncoderType codec_type);
|
|
||||||
// Returns true if this type of encoder can be created using
|
|
||||||
// VideoEncoder::Create.
|
|
||||||
static bool IsSupportedSoftware(EncoderType codec_type);
|
|
||||||
static EncoderType CodecToEncoderType(VideoCodecType codec_type);
|
|
||||||
|
|
||||||
static VideoCodecVP8 GetDefaultVp8Settings();
|
|
||||||
static VideoCodecVP9 GetDefaultVp9Settings();
|
|
||||||
static VideoCodecH264 GetDefaultH264Settings();
|
|
||||||
|
|
||||||
virtual ~VideoEncoder() {}
|
|
||||||
|
|
||||||
// Initialize the encoder with the information from the codecSettings
|
|
||||||
//
|
|
||||||
// Input:
|
|
||||||
// - codec_settings : Codec settings
|
|
||||||
// - number_of_cores : Number of cores available for the encoder
|
|
||||||
// - max_payload_size : The maximum size each payload is allowed
|
|
||||||
// to have. Usually MTU - overhead.
|
|
||||||
//
|
|
||||||
// Return value : Set bit rate if OK
|
|
||||||
// <0 - Errors:
|
|
||||||
// WEBRTC_VIDEO_CODEC_ERR_PARAMETER
|
|
||||||
// WEBRTC_VIDEO_CODEC_ERR_SIZE
|
|
||||||
// WEBRTC_VIDEO_CODEC_LEVEL_EXCEEDED
|
|
||||||
// WEBRTC_VIDEO_CODEC_MEMORY
|
|
||||||
// WEBRTC_VIDEO_CODEC_ERROR
|
|
||||||
virtual int32_t InitEncode(const VideoCodec* codec_settings,
|
|
||||||
int32_t number_of_cores,
|
|
||||||
size_t max_payload_size) = 0;
|
|
||||||
|
|
||||||
// Register an encode complete callback object.
|
|
||||||
//
|
|
||||||
// Input:
|
|
||||||
// - callback : Callback object which handles encoded images.
|
|
||||||
//
|
|
||||||
// Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise.
|
|
||||||
virtual int32_t RegisterEncodeCompleteCallback(
|
|
||||||
EncodedImageCallback* callback) = 0;
|
|
||||||
|
|
||||||
// Free encoder memory.
|
|
||||||
// Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise.
|
|
||||||
virtual int32_t Release() = 0;
|
|
||||||
|
|
||||||
// Encode an I420 image (as a part of a video stream). The encoded image
|
|
||||||
// will be returned to the user through the encode complete callback.
|
|
||||||
//
|
|
||||||
// Input:
|
|
||||||
// - frame : Image to be encoded
|
|
||||||
// - frame_types : Frame type to be generated by the encoder.
|
|
||||||
//
|
|
||||||
// Return value : WEBRTC_VIDEO_CODEC_OK if OK
|
|
||||||
// <0 - Errors:
|
|
||||||
// WEBRTC_VIDEO_CODEC_ERR_PARAMETER
|
|
||||||
// WEBRTC_VIDEO_CODEC_MEMORY
|
|
||||||
// WEBRTC_VIDEO_CODEC_ERROR
|
|
||||||
// WEBRTC_VIDEO_CODEC_TIMEOUT
|
|
||||||
virtual int32_t Encode(const VideoFrame& frame,
|
|
||||||
const CodecSpecificInfo* codec_specific_info,
|
|
||||||
const std::vector<FrameType>* frame_types) = 0;
|
|
||||||
|
|
||||||
// Inform the encoder of the new packet loss rate and the round-trip time of
|
|
||||||
// the network.
|
|
||||||
//
|
|
||||||
// Input:
|
|
||||||
// - packet_loss : Fraction lost
|
|
||||||
// (loss rate in percent = 100 * packetLoss / 255)
|
|
||||||
// - rtt : Round-trip time in milliseconds
|
|
||||||
// Return value : WEBRTC_VIDEO_CODEC_OK if OK
|
|
||||||
// <0 - Errors: WEBRTC_VIDEO_CODEC_ERROR
|
|
||||||
virtual int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) = 0;
|
|
||||||
|
|
||||||
// Inform the encoder about the new target bit rate.
|
|
||||||
//
|
|
||||||
// Input:
|
|
||||||
// - bitrate : New target bit rate
|
|
||||||
// - framerate : The target frame rate
|
|
||||||
//
|
|
||||||
// Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise.
|
|
||||||
virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) {
|
|
||||||
RTC_NOTREACHED() << "SetRate(uint32_t, uint32_t) is deprecated.";
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default fallback: Just use the sum of bitrates as the single target rate.
|
|
||||||
// TODO(sprang): Remove this default implementation when we remove SetRates().
|
|
||||||
virtual int32_t SetRateAllocation(const BitrateAllocation& allocation,
|
|
||||||
uint32_t framerate) {
|
|
||||||
return SetRates(allocation.get_sum_kbps(), framerate);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Any encoder implementation wishing to use the WebRTC provided
|
|
||||||
// quality scaler must implement this method.
|
|
||||||
virtual ScalingSettings GetScalingSettings() const {
|
|
||||||
return ScalingSettings(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; }
|
|
||||||
virtual bool SupportsNativeHandle() const { return false; }
|
|
||||||
virtual const char* ImplementationName() const { return "unknown"; }
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace webrtc
|
|
||||||
#endif // WEBRTC_VIDEO_ENCODER_H_
|
#endif // WEBRTC_VIDEO_ENCODER_H_
|
||||||
|
|
Loading…
Reference in a new issue