From 307d3dbdeed71d42edf38d3828081b11a5a416fb Mon Sep 17 00:00:00 2001 From: "henrikg@webrtc.org" Date: Thu, 11 Sep 2014 09:48:30 +0000 Subject: [PATCH] Revert 7114 "Expose VideoEncoders with webrtc/video_encoder.h." Speculative revert, seems to be reason for flaky Win FYI bot compile break. > Expose VideoEncoders with webrtc/video_encoder.h. > > Exposes VideoEncoders as part of the public API and provides a factory > method for creating them. > > BUG=3070 > R=mflodman@webrtc.org, stefan@webrtc.org > > Review URL: https://webrtc-codereview.appspot.com/21929004 TBR=pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/19329004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7151 4adac7df-926f-26a2-2b94-8c16560cd09d --- talk/media/webrtc/webrtcvideoengine2.cc | 5 +- .../common_video/interface/i420_video_frame.h | 146 +++++++++++- webrtc/common_video/interface/video_image.h | 59 ++++- .../codecs/interface/video_codec_interface.h | 103 +++++++- .../test/mock/mock_packet_manipulator.h | 2 +- .../test/configurable_frame_size_encoder.cc | 4 +- webrtc/test/configurable_frame_size_encoder.h | 2 +- webrtc/test/fake_encoder.cc | 2 - webrtc/test/fake_encoder.h | 3 +- webrtc/video/call.cc | 10 - webrtc/video/end_to_end_tests.cc | 9 +- webrtc/video/full_stack.cc | 4 +- webrtc/video/loopback.cc | 2 +- webrtc/video_encoder.h | 70 ------ webrtc/video_frame.h | 219 ------------------ 15 files changed, 317 insertions(+), 323 deletions(-) delete mode 100644 webrtc/video_encoder.h delete mode 100644 webrtc/video_frame.h diff --git a/talk/media/webrtc/webrtcvideoengine2.cc b/talk/media/webrtc/webrtcvideoengine2.cc index d53305e8a5..44c1bf8ad6 100644 --- a/talk/media/webrtc/webrtcvideoengine2.cc +++ b/talk/media/webrtc/webrtcvideoengine2.cc @@ -42,7 +42,8 @@ #include "webrtc/base/logging.h" #include "webrtc/base/stringutils.h" #include "webrtc/call.h" -#include "webrtc/video_encoder.h" +// TODO(pbos): Move codecs out of modules (webrtc:3070). +#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" #define UNIMPLEMENTED \ LOG(LS_ERROR) << "Call to unimplemented function " << __FUNCTION__; \ @@ -199,7 +200,7 @@ webrtc::VideoEncoder* WebRtcVideoEncoderFactory2::CreateVideoEncoder( const VideoOptions& options) { assert(SupportsCodec(codec)); if (_stricmp(codec.name.c_str(), kVp8CodecName) == 0) { - return webrtc::VideoEncoder::Create(webrtc::VideoEncoder::kVp8); + return webrtc::VP8Encoder::Create(); } // This shouldn't happen, we should be able to create encoders for all codecs // we support. diff --git a/webrtc/common_video/interface/i420_video_frame.h b/webrtc/common_video/interface/i420_video_frame.h index ba23c87a8f..5f7a572bda 100644 --- a/webrtc/common_video/interface/i420_video_frame.h +++ b/webrtc/common_video/interface/i420_video_frame.h @@ -11,7 +11,149 @@ #ifndef COMMON_VIDEO_INTERFACE_I420_VIDEO_FRAME_H #define COMMON_VIDEO_INTERFACE_I420_VIDEO_FRAME_H -// TODO(pbos): Remove this file and include webrtc/video_frame.h instead. -#include "webrtc/video_frame.h" +// I420VideoFrame class +// +// Storing and handling of YUV (I420) video frames. + +#include + +#include "webrtc/common_video/plane.h" +#include "webrtc/system_wrappers/interface/scoped_refptr.h" +#include "webrtc/typedefs.h" + +/* + * I420VideoFrame includes support for a reference counted impl. + */ + +namespace webrtc { + +enum PlaneType { + kYPlane = 0, + kUPlane = 1, + kVPlane = 2, + kNumOfPlanes = 3 +}; + +class I420VideoFrame { + public: + I420VideoFrame(); + virtual ~I420VideoFrame(); + // Infrastructure for refCount implementation. + // Implements dummy functions for reference counting so that non reference + // counted instantiation can be done. These functions should not be called + // when creating the frame with new I420VideoFrame(). + // Note: do not pass a I420VideoFrame created with new I420VideoFrame() or + // equivalent to a scoped_refptr or memory leak will occur. + virtual int32_t AddRef() {assert(false); return -1;} + virtual int32_t Release() {assert(false); return -1;} + + // CreateEmptyFrame: Sets frame dimensions and allocates buffers based + // on set dimensions - height and plane stride. + // If required size is bigger than the allocated one, new buffers of adequate + // size will be allocated. + // Return value: 0 on success, -1 on error. + virtual int CreateEmptyFrame(int width, int height, + int stride_y, int stride_u, int stride_v); + + // CreateFrame: Sets the frame's members and buffers. If required size is + // bigger than allocated one, new buffers of adequate size will be allocated. + // Return value: 0 on success, -1 on error. + virtual int CreateFrame(int size_y, const uint8_t* buffer_y, + int size_u, const uint8_t* buffer_u, + int size_v, const uint8_t* buffer_v, + int width, int height, + int stride_y, int stride_u, int stride_v); + + // Copy frame: If required size is bigger than allocated one, new buffers of + // adequate size will be allocated. + // Return value: 0 on success, -1 on error. + virtual int CopyFrame(const I420VideoFrame& videoFrame); + + // Make a copy of |this|. The caller owns the returned frame. + // Return value: a new frame on success, NULL on error. + virtual I420VideoFrame* CloneFrame() const; + + // Swap Frame. + virtual void SwapFrame(I420VideoFrame* videoFrame); + + // Get pointer to buffer per plane. + virtual uint8_t* buffer(PlaneType type); + // Overloading with const. + virtual const uint8_t* buffer(PlaneType type) const; + + // Get allocated size per plane. + virtual int allocated_size(PlaneType type) const; + + // Get allocated stride per plane. + virtual int stride(PlaneType type) const; + + // Set frame width. + virtual int set_width(int width); + + // Set frame height. + virtual int set_height(int height); + + // Get frame width. + virtual int width() const {return width_;} + + // Get frame height. + virtual int height() const {return height_;} + + // Set frame timestamp (90kHz). + virtual void set_timestamp(uint32_t timestamp) {timestamp_ = timestamp;} + + // Get frame timestamp (90kHz). + virtual uint32_t timestamp() const {return timestamp_;} + + // Set capture ntp time in miliseconds. + virtual void set_ntp_time_ms(int64_t ntp_time_ms) { + ntp_time_ms_ = ntp_time_ms; + } + + // Get capture ntp time in miliseconds. + virtual int64_t ntp_time_ms() const {return ntp_time_ms_;} + + // Set render time in miliseconds. + virtual void set_render_time_ms(int64_t render_time_ms) {render_time_ms_ = + render_time_ms;} + + // Get render time in miliseconds. + virtual int64_t render_time_ms() const {return render_time_ms_;} + + // Return true if underlying plane buffers are of zero size, false if not. + virtual bool IsZeroSize() const; + + // Reset underlying plane buffers sizes to 0. This function doesn't + // clear memory. + virtual void ResetSize(); + + // Return the handle of the underlying video frame. This is used when the + // frame is backed by a texture. The object should be destroyed when it is no + // longer in use, so the underlying resource can be freed. + virtual void* native_handle() const; + + protected: + // Verifies legality of parameters. + // Return value: 0 on success, -1 on error. + virtual int CheckDimensions(int width, int height, + int stride_y, int stride_u, int stride_v); + + private: + // Get the pointer to a specific plane. + const Plane* GetPlane(PlaneType type) const; + // Overloading with non-const. + Plane* GetPlane(PlaneType type); + + Plane y_plane_; + Plane u_plane_; + Plane v_plane_; + int width_; + int height_; + uint32_t timestamp_; + int64_t ntp_time_ms_; + int64_t render_time_ms_; +}; // I420VideoFrame + +} // namespace webrtc #endif // COMMON_VIDEO_INTERFACE_I420_VIDEO_FRAME_H diff --git a/webrtc/common_video/interface/video_image.h b/webrtc/common_video/interface/video_image.h index 4cbf23f1a1..c8df436b3c 100644 --- a/webrtc/common_video/interface/video_image.h +++ b/webrtc/common_video/interface/video_image.h @@ -11,7 +11,62 @@ #ifndef COMMON_VIDEO_INTERFACE_VIDEO_IMAGE_H #define COMMON_VIDEO_INTERFACE_VIDEO_IMAGE_H -// TODO(pbos): Remove this file and include webrtc/video_frame.h instead. -#include "webrtc/video_frame.h" +#include +#include "webrtc/typedefs.h" + +namespace webrtc +{ + +enum VideoFrameType +{ + kKeyFrame = 0, + kDeltaFrame = 1, + kGoldenFrame = 2, + kAltRefFrame = 3, + kSkipFrame = 4 +}; + +class EncodedImage +{ +public: + EncodedImage() + : _encodedWidth(0), + _encodedHeight(0), + _timeStamp(0), + capture_time_ms_(0), + _frameType(kDeltaFrame), + _buffer(NULL), + _length(0), + _size(0), + _completeFrame(false) {} + + EncodedImage(uint8_t* buffer, + uint32_t length, + uint32_t size) + : _encodedWidth(0), + _encodedHeight(0), + _timeStamp(0), + ntp_time_ms_(0), + capture_time_ms_(0), + _frameType(kDeltaFrame), + _buffer(buffer), + _length(length), + _size(size), + _completeFrame(false) {} + + uint32_t _encodedWidth; + uint32_t _encodedHeight; + uint32_t _timeStamp; + // NTP time of the capture time in local timebase in milliseconds. + int64_t ntp_time_ms_; + int64_t capture_time_ms_; + VideoFrameType _frameType; + uint8_t* _buffer; + uint32_t _length; + uint32_t _size; + bool _completeFrame; +}; + +} // namespace webrtc #endif // COMMON_VIDEO_INTERFACE_VIDEO_IMAGE_H diff --git a/webrtc/modules/video_coding/codecs/interface/video_codec_interface.h b/webrtc/modules/video_coding/codecs/interface/video_codec_interface.h index 82bcd26ded..e6b1d0978d 100644 --- a/webrtc/modules/video_coding/codecs/interface/video_codec_interface.h +++ b/webrtc/modules/video_coding/codecs/interface/video_codec_interface.h @@ -15,10 +15,11 @@ #include "webrtc/common_types.h" #include "webrtc/common_video/interface/i420_video_frame.h" +#include "webrtc/common_video/interface/video_image.h" #include "webrtc/modules/interface/module_common_types.h" #include "webrtc/modules/video_coding/codecs/interface/video_error_codes.h" + #include "webrtc/typedefs.h" -#include "webrtc/video_encoder.h" namespace webrtc { @@ -62,6 +63,106 @@ struct CodecSpecificInfo CodecSpecificInfoUnion codecSpecific; }; +class EncodedImageCallback +{ +public: + virtual ~EncodedImageCallback() {}; + + // Callback function which is called when an image has been encoded. + // + // Input: + // - encodedImage : The encoded image + // + // Return value : > 0, signals to the caller that one or more future frames + // should be dropped to keep bit rate or frame rate. + // = 0, if OK. + // < 0, on error. + virtual int32_t + Encoded(EncodedImage& encodedImage, + const CodecSpecificInfo* codecSpecificInfo = NULL, + const RTPFragmentationHeader* fragmentation = NULL) = 0; +}; + +class VideoEncoder +{ +public: + virtual ~VideoEncoder() {}; + + // Initialize the encoder with the information from the VideoCodec. + // + // Input: + // - codecSettings : Codec settings + // - numberOfCores : Number of cores available for the encoder + // - maxPayloadSize : The maximum size each payload is allowed + // to have. Usually MTU - overhead. + // + // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. + virtual int32_t InitEncode(const VideoCodec* codecSettings, int32_t numberOfCores, uint32_t maxPayloadSize) = 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: + // - inputImage : Image to be encoded + // - codecSpecificInfo : Pointer to codec specific data + // - frame_types : The frame type to encode + // + // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 + // otherwise. + virtual int32_t Encode( + const I420VideoFrame& inputImage, + const CodecSpecificInfo* codecSpecificInfo, + const std::vector* frame_types) = 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; + + // Inform the encoder about the packet loss and round trip time on the + // network used to decide the best pattern and signaling. + // + // - packetLoss : Fraction lost (loss rate in percent = + // 100 * packetLoss / 255) + // - rtt : Round-trip time in milliseconds + // + // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. + virtual int32_t SetChannelParameters(uint32_t packetLoss, int rtt) = 0; + + // Inform the encoder about the new target bit rate. + // + // - newBitRate : 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 newBitRate, uint32_t frameRate) = 0; + + // Use this function to enable or disable periodic key frames. Can be useful for codecs + // which have other ways of stopping error propagation. + // + // - enable : Enable or disable periodic key frames + // + // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. + virtual int32_t SetPeriodicKeyFrames(bool enable) { return WEBRTC_VIDEO_CODEC_ERROR; } + + // Codec configuration data to send out-of-band, i.e. in SIP call setup + // + // - buffer : Buffer pointer to where the configuration data + // should be stored + // - size : The size of the buffer in bytes + // + // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. + virtual int32_t CodecConfigParameters(uint8_t* /*buffer*/, int32_t /*size*/) { return WEBRTC_VIDEO_CODEC_ERROR; } +}; + class DecodedImageCallback { public: diff --git a/webrtc/modules/video_coding/codecs/test/mock/mock_packet_manipulator.h b/webrtc/modules/video_coding/codecs/test/mock/mock_packet_manipulator.h index 1e2c9b8fb6..75fe63fe5a 100644 --- a/webrtc/modules/video_coding/codecs/test/mock/mock_packet_manipulator.h +++ b/webrtc/modules/video_coding/codecs/test/mock/mock_packet_manipulator.h @@ -16,8 +16,8 @@ #include #include "testing/gmock/include/gmock/gmock.h" +#include "webrtc/common_video/interface/video_image.h" #include "webrtc/typedefs.h" -#include "webrtc/video_frame.h" namespace webrtc { namespace test { diff --git a/webrtc/test/configurable_frame_size_encoder.cc b/webrtc/test/configurable_frame_size_encoder.cc index d3ed784ca9..b246da3575 100644 --- a/webrtc/test/configurable_frame_size_encoder.cc +++ b/webrtc/test/configurable_frame_size_encoder.cc @@ -12,10 +12,8 @@ #include -#include "testing/gtest/include/gtest/gtest.h" - #include "webrtc/common_video/interface/video_image.h" -#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" +#include "testing/gtest/include/gtest/gtest.h" namespace webrtc { namespace test { diff --git a/webrtc/test/configurable_frame_size_encoder.h b/webrtc/test/configurable_frame_size_encoder.h index 4120bc6c83..f29038fac7 100644 --- a/webrtc/test/configurable_frame_size_encoder.h +++ b/webrtc/test/configurable_frame_size_encoder.h @@ -14,7 +14,7 @@ #include #include "webrtc/system_wrappers/interface/scoped_ptr.h" -#include "webrtc/video_encoder.h" +#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" namespace webrtc { namespace test { diff --git a/webrtc/test/fake_encoder.cc b/webrtc/test/fake_encoder.cc index 9551c8204e..ecd3dd8710 100644 --- a/webrtc/test/fake_encoder.cc +++ b/webrtc/test/fake_encoder.cc @@ -12,8 +12,6 @@ #include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" - namespace webrtc { namespace test { diff --git a/webrtc/test/fake_encoder.h b/webrtc/test/fake_encoder.h index 50b86520e1..3c6f73502d 100644 --- a/webrtc/test/fake_encoder.h +++ b/webrtc/test/fake_encoder.h @@ -13,9 +13,8 @@ #include -#include "webrtc/common_types.h" +#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" #include "webrtc/system_wrappers/interface/clock.h" -#include "webrtc/video_encoder.h" namespace webrtc { namespace test { diff --git a/webrtc/video/call.cc b/webrtc/video/call.cc index b4adafd75b..8b71acfddf 100644 --- a/webrtc/video/call.cc +++ b/webrtc/video/call.cc @@ -18,7 +18,6 @@ #include "webrtc/common.h" #include "webrtc/config.h" #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" -#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" #include "webrtc/system_wrappers/interface/scoped_ptr.h" @@ -42,15 +41,6 @@ bool RtpExtension::IsSupported(const std::string& name) { name == webrtc::RtpExtension::kAbsSendTime; } -VideoEncoder* VideoEncoder::Create(VideoEncoder::EncoderType codec_type) { - switch (codec_type) { - case kVp8: - return VP8Encoder::Create(); - } - assert(false); - return NULL; -} - namespace internal { class CpuOveruseObserverProxy : public webrtc::CpuOveruseObserver { diff --git a/webrtc/video/end_to_end_tests.cc b/webrtc/video/end_to_end_tests.cc index a83eddce7f..114ab65b23 100644 --- a/webrtc/video/end_to_end_tests.cc +++ b/webrtc/video/end_to_end_tests.cc @@ -19,6 +19,7 @@ #include "webrtc/call.h" #include "webrtc/frame_callback.h" #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" +#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/event_wrapper.h" #include "webrtc/system_wrappers/interface/scoped_ptr.h" @@ -36,7 +37,6 @@ #include "webrtc/test/testsupport/fileutils.h" #include "webrtc/test/testsupport/perf_test.h" #include "webrtc/video/transport_adapter.h" -#include "webrtc/video_encoder.h" // Disabled on Android since all tests currently fail (webrtc:3770). #ifndef WEBRTC_ANDROID @@ -645,8 +645,7 @@ TEST_F(EndToEndTest, UsesFrameCallbacks) { receiver_transport.SetReceiver(sender_call_->Receiver()); CreateSendConfig(1); - scoped_ptr encoder( - VideoEncoder::Create(VideoEncoder::kVp8)); + scoped_ptr encoder(VP8Encoder::Create()); send_config_.encoder_settings.encoder = encoder.get(); send_config_.encoder_settings.payload_name = "VP8"; ASSERT_EQ(1u, video_streams_.size()) << "Test setup error."; @@ -975,9 +974,9 @@ TEST_F(EndToEndTest, SendsAndReceivesMultipleStreams) { VideoOutputObserver* observers[kNumStreams]; test::FrameGeneratorCapturer* frame_generators[kNumStreams]; - scoped_ptr encoders[kNumStreams]; + scoped_ptr encoders[kNumStreams]; for (size_t i = 0; i < kNumStreams; ++i) - encoders[i].reset(VideoEncoder::Create(VideoEncoder::kVp8)); + encoders[i].reset(VP8Encoder::Create()); for (size_t i = 0; i < kNumStreams; ++i) { uint32_t ssrc = codec_settings[i].ssrc; diff --git a/webrtc/video/full_stack.cc b/webrtc/video/full_stack.cc index 54abd1fff0..b00eb0edac 100644 --- a/webrtc/video/full_stack.cc +++ b/webrtc/video/full_stack.cc @@ -17,6 +17,7 @@ #include "webrtc/call.h" #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" +#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" #include "webrtc/system_wrappers/interface/clock.h" #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/event_wrapper.h" @@ -390,8 +391,7 @@ void FullStackTest::RunTest(const FullStackTestParams& params) { CreateSendConfig(1); - scoped_ptr encoder( - VideoEncoder::Create(VideoEncoder::kVp8)); + scoped_ptr encoder(VP8Encoder::Create()); send_config_.encoder_settings.encoder = encoder.get(); send_config_.encoder_settings.payload_name = "VP8"; send_config_.encoder_settings.payload_type = 124; diff --git a/webrtc/video/loopback.cc b/webrtc/video/loopback.cc index 29a3c7823c..4ec738824f 100644 --- a/webrtc/video/loopback.cc +++ b/webrtc/video/loopback.cc @@ -120,7 +120,7 @@ void Loopback() { send_config.local_renderer = local_preview.get(); scoped_ptr encoder; if (flags::Codec() == "VP8") { - encoder.reset(VideoEncoder::Create(VideoEncoder::kVp8)); + encoder.reset(VP8Encoder::Create()); } else { // Codec not supported. assert(false && "Codec not supported!"); diff --git a/webrtc/video_encoder.h b/webrtc/video_encoder.h deleted file mode 100644 index 6d57d9264b..0000000000 --- a/webrtc/video_encoder.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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_VIDEO_ENCODER_H_ -#define WEBRTC_VIDEO_ENCODER_H_ - -#include - -#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; -struct VideoCodec; - -class EncodedImageCallback { - public: - virtual ~EncodedImageCallback() {} - - // Callback function which is called when an image has been encoded. - // TODO(pbos): Make encoded_image const or pointer. Remove default arguments. - virtual int32_t Encoded( - EncodedImage& encoded_image, - const CodecSpecificInfo* codec_specific_info = NULL, - const RTPFragmentationHeader* fragmentation = NULL) = 0; -}; - -class VideoEncoder { - public: - enum EncoderType { - kVp8, - }; - - static VideoEncoder* Create(EncoderType codec_type); - - virtual ~VideoEncoder() {} - - virtual int32_t InitEncode(const VideoCodec* codec_settings, - int32_t number_of_cores, - uint32_t max_payload_size) = 0; - virtual int32_t RegisterEncodeCompleteCallback( - EncodedImageCallback* callback) = 0; - virtual int32_t Release() = 0; - - - virtual int32_t Encode(const I420VideoFrame& frame, - const CodecSpecificInfo* codec_specific_info, - const std::vector* frame_types) = 0; - - virtual int32_t SetChannelParameters(uint32_t packet_loss, int rtt) = 0; - virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) = 0; - - virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; } - virtual int32_t CodecConfigParameters(uint8_t* /*buffer*/, int32_t /*size*/) { - return -1; - } -}; - -} // namespace webrtc -#endif // WEBRTC_VIDEO_ENCODER_H_ diff --git a/webrtc/video_frame.h b/webrtc/video_frame.h deleted file mode 100644 index f76b9af373..0000000000 --- a/webrtc/video_frame.h +++ /dev/null @@ -1,219 +0,0 @@ -/* - * 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_VIDEO_FRAME_H_ -#define WEBRTC_VIDEO_FRAME_H_ - -#include - -#include "webrtc/common_video/plane.h" -// TODO(pbos): Remove scoped_refptr include (and AddRef/Release if they're not -// used). -#include "webrtc/system_wrappers/interface/scoped_refptr.h" -#include "webrtc/typedefs.h" - -namespace webrtc { - -enum PlaneType { - kYPlane = 0, - kUPlane = 1, - kVPlane = 2, - kNumOfPlanes = 3 -}; - -class I420VideoFrame { - public: - I420VideoFrame(); - virtual ~I420VideoFrame(); - // Infrastructure for refCount implementation. - // Implements dummy functions for reference counting so that non reference - // counted instantiation can be done. These functions should not be called - // when creating the frame with new I420VideoFrame(). - // Note: do not pass a I420VideoFrame created with new I420VideoFrame() or - // equivalent to a scoped_refptr or memory leak will occur. - virtual int32_t AddRef() { - assert(false); - return -1; - } - virtual int32_t Release() { - assert(false); - return -1; - } - - // CreateEmptyFrame: Sets frame dimensions and allocates buffers based - // on set dimensions - height and plane stride. - // If required size is bigger than the allocated one, new buffers of adequate - // size will be allocated. - // Return value: 0 on success, -1 on error. - virtual int CreateEmptyFrame(int width, - int height, - int stride_y, - int stride_u, - int stride_v); - - // CreateFrame: Sets the frame's members and buffers. If required size is - // bigger than allocated one, new buffers of adequate size will be allocated. - // Return value: 0 on success, -1 on error. - virtual int CreateFrame(int size_y, - const uint8_t* buffer_y, - int size_u, - const uint8_t* buffer_u, - int size_v, - const uint8_t* buffer_v, - int width, - int height, - int stride_y, - int stride_u, - int stride_v); - - // Copy frame: If required size is bigger than allocated one, new buffers of - // adequate size will be allocated. - // Return value: 0 on success, -1 on error. - virtual int CopyFrame(const I420VideoFrame& videoFrame); - - // Make a copy of |this|. The caller owns the returned frame. - // Return value: a new frame on success, NULL on error. - virtual I420VideoFrame* CloneFrame() const; - - // Swap Frame. - virtual void SwapFrame(I420VideoFrame* videoFrame); - - // Get pointer to buffer per plane. - virtual uint8_t* buffer(PlaneType type); - // Overloading with const. - virtual const uint8_t* buffer(PlaneType type) const; - - // Get allocated size per plane. - virtual int allocated_size(PlaneType type) const; - - // Get allocated stride per plane. - virtual int stride(PlaneType type) const; - - // Set frame width. - virtual int set_width(int width); - - // Set frame height. - virtual int set_height(int height); - - // Get frame width. - virtual int width() const { return width_; } - - // Get frame height. - virtual int height() const { return height_; } - - // Set frame timestamp (90kHz). - virtual void set_timestamp(uint32_t timestamp) { timestamp_ = timestamp; } - - // Get frame timestamp (90kHz). - virtual uint32_t timestamp() const { return timestamp_; } - - // Set capture ntp time in miliseconds. - virtual void set_ntp_time_ms(int64_t ntp_time_ms) { - ntp_time_ms_ = ntp_time_ms; - } - - // Get capture ntp time in miliseconds. - virtual int64_t ntp_time_ms() const { return ntp_time_ms_; } - - // Set render time in miliseconds. - virtual void set_render_time_ms(int64_t render_time_ms) { - render_time_ms_ = render_time_ms; - } - - // Get render time in miliseconds. - virtual int64_t render_time_ms() const { return render_time_ms_; } - - // Return true if underlying plane buffers are of zero size, false if not. - virtual bool IsZeroSize() const; - - // Reset underlying plane buffers sizes to 0. This function doesn't - // clear memory. - virtual void ResetSize(); - - // Return the handle of the underlying video frame. This is used when the - // frame is backed by a texture. The object should be destroyed when it is no - // longer in use, so the underlying resource can be freed. - virtual void* native_handle() const; - - protected: - // Verifies legality of parameters. - // Return value: 0 on success, -1 on error. - virtual int CheckDimensions(int width, - int height, - int stride_y, - int stride_u, - int stride_v); - - private: - // Get the pointer to a specific plane. - const Plane* GetPlane(PlaneType type) const; - // Overloading with non-const. - Plane* GetPlane(PlaneType type); - - Plane y_plane_; - Plane u_plane_; - Plane v_plane_; - int width_; - int height_; - uint32_t timestamp_; - int64_t ntp_time_ms_; - int64_t render_time_ms_; -}; - -enum VideoFrameType { - kKeyFrame = 0, - kDeltaFrame = 1, - kGoldenFrame = 2, - kAltRefFrame = 3, - kSkipFrame = 4 -}; - -// TODO(pbos): Rename EncodedFrame and reformat this class' members. -class EncodedImage { - public: - EncodedImage() - : _encodedWidth(0), - _encodedHeight(0), - _timeStamp(0), - capture_time_ms_(0), - _frameType(kDeltaFrame), - _buffer(NULL), - _length(0), - _size(0), - _completeFrame(false) {} - - EncodedImage(uint8_t* buffer, uint32_t length, uint32_t size) - : _encodedWidth(0), - _encodedHeight(0), - _timeStamp(0), - ntp_time_ms_(0), - capture_time_ms_(0), - _frameType(kDeltaFrame), - _buffer(buffer), - _length(length), - _size(size), - _completeFrame(false) {} - - uint32_t _encodedWidth; - uint32_t _encodedHeight; - uint32_t _timeStamp; - // NTP time of the capture time in local timebase in milliseconds. - int64_t ntp_time_ms_; - int64_t capture_time_ms_; - VideoFrameType _frameType; - uint8_t* _buffer; - uint32_t _length; - uint32_t _size; - bool _completeFrame; -}; - -} // namespace webrtc -#endif // WEBRTC_VIDEO_FRAME_H_ -