2013-12-10 10:05:17 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 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 "webrtc/test/configurable_frame_size_encoder.h"
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2015-11-16 13:52:24 -08:00
|
|
|
#include "webrtc/common_video/include/video_image.h"
|
2015-11-18 22:00:21 +01:00
|
|
|
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
2016-09-30 22:29:43 -07:00
|
|
|
#include "webrtc/test/gtest.h"
|
2014-09-17 09:02:25 +00:00
|
|
|
|
2013-12-10 10:05:17 +00:00
|
|
|
namespace webrtc {
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
|
|
ConfigurableFrameSizeEncoder::ConfigurableFrameSizeEncoder(
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t max_frame_size)
|
2013-12-10 10:05:17 +00:00
|
|
|
: callback_(NULL),
|
|
|
|
|
max_frame_size_(max_frame_size),
|
|
|
|
|
current_frame_size_(max_frame_size),
|
|
|
|
|
buffer_(new uint8_t[max_frame_size]) {
|
|
|
|
|
memset(buffer_.get(), 0, max_frame_size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConfigurableFrameSizeEncoder::~ConfigurableFrameSizeEncoder() {}
|
|
|
|
|
|
|
|
|
|
int32_t ConfigurableFrameSizeEncoder::InitEncode(
|
|
|
|
|
const VideoCodec* codec_settings,
|
|
|
|
|
int32_t number_of_cores,
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t max_payload_size) {
|
2013-12-10 10:05:17 +00:00
|
|
|
return WEBRTC_VIDEO_CODEC_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t ConfigurableFrameSizeEncoder::Encode(
|
2015-05-29 17:21:40 -07:00
|
|
|
const VideoFrame& inputImage,
|
2013-12-10 10:05:17 +00:00
|
|
|
const CodecSpecificInfo* codecSpecificInfo,
|
2015-10-19 02:39:06 -07:00
|
|
|
const std::vector<FrameType>* frame_types) {
|
2013-12-10 10:05:17 +00:00
|
|
|
EncodedImage encodedImage(
|
|
|
|
|
buffer_.get(), current_frame_size_, max_frame_size_);
|
|
|
|
|
encodedImage._completeFrame = true;
|
|
|
|
|
encodedImage._encodedHeight = inputImage.height();
|
|
|
|
|
encodedImage._encodedWidth = inputImage.width();
|
2015-10-23 15:58:18 +02:00
|
|
|
encodedImage._frameType = kVideoFrameKey;
|
2013-12-10 10:05:17 +00:00
|
|
|
encodedImage._timeStamp = inputImage.timestamp();
|
|
|
|
|
encodedImage.capture_time_ms_ = inputImage.render_time_ms();
|
|
|
|
|
RTPFragmentationHeader* fragmentation = NULL;
|
2014-02-18 08:40:33 +00:00
|
|
|
CodecSpecificInfo specific;
|
|
|
|
|
memset(&specific, 0, sizeof(specific));
|
2016-11-04 11:39:29 -07:00
|
|
|
callback_->OnEncodedImage(encodedImage, &specific, fragmentation);
|
2013-12-10 10:05:17 +00:00
|
|
|
|
|
|
|
|
return WEBRTC_VIDEO_CODEC_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t ConfigurableFrameSizeEncoder::RegisterEncodeCompleteCallback(
|
|
|
|
|
EncodedImageCallback* callback) {
|
|
|
|
|
callback_ = callback;
|
|
|
|
|
return WEBRTC_VIDEO_CODEC_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t ConfigurableFrameSizeEncoder::Release() {
|
|
|
|
|
return WEBRTC_VIDEO_CODEC_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t ConfigurableFrameSizeEncoder::SetChannelParameters(uint32_t packet_loss,
|
2015-01-12 21:51:21 +00:00
|
|
|
int64_t rtt) {
|
2013-12-10 10:05:17 +00:00
|
|
|
return WEBRTC_VIDEO_CODEC_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-10 08:30:33 -08:00
|
|
|
int32_t ConfigurableFrameSizeEncoder::SetRates(uint32_t new_bit_rate,
|
|
|
|
|
uint32_t frame_rate) {
|
2013-12-10 10:05:17 +00:00
|
|
|
return WEBRTC_VIDEO_CODEC_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t ConfigurableFrameSizeEncoder::SetPeriodicKeyFrames(bool enable) {
|
|
|
|
|
return WEBRTC_VIDEO_CODEC_OK;
|
|
|
|
|
}
|
|
|
|
|
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
int32_t ConfigurableFrameSizeEncoder::SetFrameSize(size_t size) {
|
2016-11-10 08:30:33 -08:00
|
|
|
assert(size <= max_frame_size_);
|
2013-12-10 10:05:17 +00:00
|
|
|
current_frame_size_ = size;
|
|
|
|
|
return WEBRTC_VIDEO_CODEC_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace webrtc
|