diff --git a/webrtc/video_engine/internal/video_send_stream.cc b/webrtc/video_engine/internal/video_send_stream.cc index c81825871c..adcf818b40 100644 --- a/webrtc/video_engine/internal/video_send_stream.cc +++ b/webrtc/video_engine/internal/video_send_stream.cc @@ -24,7 +24,8 @@ namespace webrtc { namespace internal { VideoSendStream::VideoSendStream( - newapi::Transport* transport, webrtc::VideoEngine* video_engine, + newapi::Transport* transport, + webrtc::VideoEngine* video_engine, const newapi::VideoSendStreamConfig& send_stream_config) : transport_(transport), config_(send_stream_config) { @@ -74,7 +75,9 @@ VideoSendStream::~VideoSendStream() { } void VideoSendStream::PutFrame(const I420VideoFrame& frame, - int32_t delta_capture_time) { + uint32_t time_since_capture_ms) { + // TODO(pbos): frame_copy should happen after the VideoProcessingModule has + // resized the frame. I420VideoFrame frame_copy; frame_copy.CopyFrame(frame); @@ -95,7 +98,7 @@ void VideoSendStream::PutFrame(const I420VideoFrame& frame, vf.width = frame.width(); vf.height = frame.height(); - external_capture_->IncomingFrameI420(vf, frame.timestamp()); + external_capture_->IncomingFrameI420(vf, frame.render_time_ms()); if (config_.local_renderer != NULL) { config_.local_renderer->RenderFrame(frame, 0); @@ -105,11 +108,13 @@ void VideoSendStream::PutFrame(const I420VideoFrame& frame, newapi::VideoSendStreamInput* VideoSendStream::Input() { return this; } void VideoSendStream::StartSend() { - if (video_engine_base_->StartSend(channel_) != 0) abort(); + if (video_engine_base_->StartSend(channel_) != 0) + abort(); } void VideoSendStream::StopSend() { - if (video_engine_base_->StopSend(channel_) != 0) abort(); + if (video_engine_base_->StopSend(channel_) != 0) + abort(); } void VideoSendStream::GetSendStatistics( @@ -118,7 +123,8 @@ void VideoSendStream::GetSendStatistics( } bool VideoSendStream::SetTargetBitrate( - int min_bitrate, int max_bitrate, + int min_bitrate, + int max_bitrate, const std::vector& streams) { return false; } @@ -127,7 +133,8 @@ void VideoSendStream::GetSendCodec(VideoCodec* send_codec) { *send_codec = config_.codec; } -int VideoSendStream::SendPacket(int /*channel*/, const void* packet, +int VideoSendStream::SendPacket(int /*channel*/, + const void* packet, int length) { // TODO(pbos): Lock these methods and the destructor so it can't be processing // a packet when the destructor has been called. @@ -135,7 +142,8 @@ int VideoSendStream::SendPacket(int /*channel*/, const void* packet, return transport_->SendRTP(packet, static_cast(length)) ? 0 : -1; } -int VideoSendStream::SendRTCPPacket(int /*channel*/, const void* packet, +int VideoSendStream::SendRTCPPacket(int /*channel*/, + const void* packet, int length) { assert(length >= 0); return transport_->SendRTCP(packet, static_cast(length)) ? 0 : -1; diff --git a/webrtc/video_engine/internal/video_send_stream.h b/webrtc/video_engine/internal/video_send_stream.h index ef398b6a93..45d89f4b27 100644 --- a/webrtc/video_engine/internal/video_send_stream.h +++ b/webrtc/video_engine/internal/video_send_stream.h @@ -38,8 +38,8 @@ class VideoSendStream : public newapi::VideoSendStream, virtual ~VideoSendStream(); - virtual void PutFrame(const I420VideoFrame& frame, int32_t delta_capture_time) - OVERRIDE; + virtual void PutFrame(const I420VideoFrame& frame, + uint32_t time_since_capture_ms) OVERRIDE; virtual newapi::VideoSendStreamInput* Input() OVERRIDE; diff --git a/webrtc/video_engine/new_include/video_send_stream.h b/webrtc/video_engine/new_include/video_send_stream.h index 5db53901ff..04d953c01b 100644 --- a/webrtc/video_engine/new_include/video_send_stream.h +++ b/webrtc/video_engine/new_include/video_send_stream.h @@ -46,7 +46,7 @@ class VideoSendStreamInput { // TODO(mflodman) Replace time_since_capture_ms when I420VideoFrame uses NTP // time. virtual void PutFrame(const I420VideoFrame& video_frame, - int time_since_capture_ms) = 0; + uint32_t time_since_capture_ms) = 0; protected: virtual ~VideoSendStreamInput() {} diff --git a/webrtc/video_engine/test/common/frame_generator.cc b/webrtc/video_engine/test/common/frame_generator.cc new file mode 100644 index 0000000000..bfe248aeb8 --- /dev/null +++ b/webrtc/video_engine/test/common/frame_generator.cc @@ -0,0 +1,84 @@ +/* + * 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/video_engine/test/common/frame_generator.h" + +#include +#include + +#include "webrtc/system_wrappers/interface/clock.h" + +namespace webrtc { +namespace test { + +FrameGenerator* FrameGenerator::Create(size_t width, + size_t height, + Clock* clock) { + return new ChromaFrameGenerator(width, height, clock); +} + +void FrameGenerator::InsertFrame(newapi::VideoSendStreamInput* input) { + int64_t time_before = clock_->TimeInMilliseconds(); + frame_.set_render_time_ms(time_before); + + GenerateNextFrame(); + + int64_t time_after = clock_->TimeInMilliseconds(); + input->PutFrame(frame_, static_cast(time_after - time_before)); +} + +FrameGenerator::FrameGenerator(size_t width, size_t height, Clock* clock) + : width_(width), height_(height), clock_(clock) { + // Generate frame by constructor arguments + assert(width > 0); + assert(height > 0); + frame_.CreateEmptyFrame(static_cast(width), static_cast(height), + width, (width + 1) / 2, (width + 1) / 2); +} + +BlackFrameGenerator::BlackFrameGenerator(size_t width, + size_t height, + Clock* clock) + : FrameGenerator(width, height, clock) { + memset(frame_.buffer(kYPlane), 0x00, frame_.allocated_size(kYPlane)); + memset(frame_.buffer(kUPlane), 0x80, frame_.allocated_size(kUPlane)); + memset(frame_.buffer(kVPlane), 0x80, frame_.allocated_size(kVPlane)); +} + +void BlackFrameGenerator::GenerateNextFrame() {} + +WhiteFrameGenerator::WhiteFrameGenerator(size_t width, + size_t height, + Clock* clock) + : FrameGenerator(width, height, clock) { + memset(frame_.buffer(kYPlane), 0xFF, frame_.allocated_size(kYPlane)); + memset(frame_.buffer(kUPlane), 0x80, frame_.allocated_size(kUPlane)); + memset(frame_.buffer(kVPlane), 0x80, frame_.allocated_size(kVPlane)); +} + +void WhiteFrameGenerator::GenerateNextFrame() {} + +ChromaFrameGenerator::ChromaFrameGenerator(size_t width, + size_t height, + Clock* clock) + : FrameGenerator(width, height, clock) { + memset(frame_.buffer(kYPlane), 0x80, frame_.allocated_size(kYPlane)); +} + +void ChromaFrameGenerator::GenerateNextFrame() { + double angle = static_cast(frame_.render_time_ms()) / 1000.0; + uint8_t u = fabs(sin(angle)) * 0xFF; + uint8_t v = fabs(cos(angle)) * 0xFF; + + memset(frame_.buffer(kUPlane), u, frame_.allocated_size(kUPlane)); + memset(frame_.buffer(kVPlane), v, frame_.allocated_size(kVPlane)); +} +} // test +} // webrtc diff --git a/webrtc/video_engine/test/common/frame_generator.h b/webrtc/video_engine/test/common/frame_generator.h new file mode 100644 index 0000000000..6dca1744a7 --- /dev/null +++ b/webrtc/video_engine/test/common/frame_generator.h @@ -0,0 +1,67 @@ +/* + * 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. + */ +#ifndef WEBRTC_VIDEO_ENGINE_TEST_COMMON_FRAME_GENERATOR_H_ +#define WEBRTC_VIDEO_ENGINE_TEST_COMMON_FRAME_GENERATOR_H_ + +#include "webrtc/common_video/interface/i420_video_frame.h" +#include "webrtc/typedefs.h" +#include "webrtc/video_engine/new_include/video_send_stream.h" + +namespace webrtc { + +class Clock; + +namespace test { + +// A set of classes that generate sequences of I420VideoFrames for testing +// without using the webcam. +class FrameGenerator { + public: + static FrameGenerator* Create(size_t width, size_t height, Clock* clock); + virtual ~FrameGenerator() {} + + void InsertFrame(newapi::VideoSendStreamInput* input); + + protected: + FrameGenerator(size_t width, size_t height, Clock* clock); + virtual void GenerateNextFrame() = 0; + + size_t width_, height_; + I420VideoFrame frame_; + Clock* clock_; +}; + +class BlackFrameGenerator : public FrameGenerator { + public: + BlackFrameGenerator(size_t width, size_t height, Clock* clock); + + private: + virtual void GenerateNextFrame() OVERRIDE; +}; + +class WhiteFrameGenerator : public FrameGenerator { + public: + WhiteFrameGenerator(size_t width, size_t height, Clock* clock); + + private: + virtual void GenerateNextFrame() OVERRIDE; +}; + +class ChromaFrameGenerator : public FrameGenerator { + public: + ChromaFrameGenerator(size_t width, size_t height, Clock* clock); + + private: + virtual void GenerateNextFrame() OVERRIDE; +}; +} // test +} // webrtc + +#endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_FRAME_GENERATOR_H_ diff --git a/webrtc/video_engine/test/common/video_renderer.h b/webrtc/video_engine/test/common/video_renderer.h index 6865d5aba7..b312fbe341 100644 --- a/webrtc/video_engine/test/common/video_renderer.h +++ b/webrtc/video_engine/test/common/video_renderer.h @@ -21,6 +21,8 @@ class VideoRenderer : public newapi::VideoRenderer { size_t width, size_t height); virtual ~VideoRenderer() {} + protected: + VideoRenderer() {} }; } // test } // webrtc diff --git a/webrtc/video_engine/test/tests.gypi b/webrtc/video_engine/test/tests.gypi index a9b17c943a..662de69313 100644 --- a/webrtc/video_engine/test/tests.gypi +++ b/webrtc/video_engine/test/tests.gypi @@ -29,6 +29,8 @@ 'sources': [ 'common/flags.cc', 'common/flags.h', + 'common/frame_generator.cc', + 'common/frame_generator.h', 'common/generate_ssrcs.h', 'common/vcm_capturer.h', 'common/vcm_capturer.cc',